[r1281]: branches / 2.5.4RC1 / cgi-bin / yabb2 / Admin / ErrorLog.pm Maximize Restore History

Download this file

ErrorLog.pm    358 lines (339 with data), 12.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
###############################################################################
# ErrorLog.pm #
# $Date: 9.16.13 $ #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBB 2.5.41 #
# Packaged: September 1, 2013 #
# Distributed by: http://www.yabbforum.com #
# =========================================================================== #
# Copyright (c) 2000-2013 YaBB (www.yabbforum.com) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
###############################################################################
use CGI::Carp qw(fatalsToBrowser);
our $VERSION = '2.5.41';
$errorlogpmver = 'YaBB 2.5.4 RC1 $Revision: 1281 $';
if ( $action eq 'detailedversion' ) { return 1; }
sub ErrorLog {
is_admin_or_gmod();
$yytitle = "$errorlog{'1'}";
$errorcount = 0;
fopen( ERRORFILE, "$vardir/errorlog.txt" );
@errors = <ERRORFILE>;
fclose(ERRORFILE);
$errorcount = @errors;
$date2 = $date;
for my $i ( 0 .. ( $errorcount - 1 ) ) {
my @tmpArray = split /\|/xsm, $errors[$i];
$date1 = $tmpArray[1];
calcdifference();
$date_ref = $result;
$tmplist[$i] = qq~$date_ref\|$errors[$i]~;
}
$sortmode = $INFO{'sort'};
$sortorder = $INFO{'order'};
if ( $sortmode eq q{} ) {
$sortmode = 'time';
}
if ( $sortorder eq q{} ) {
$sortorder = 'reverse';
}
my @sortlist = ();
my $field = '0'; # 0-based field defaults to the datecmp value
my $type = '0'; # 0=numeric; 1=text
my $case = '1'; # 0=case sensitive; 1=ignore case
my $dir = '0'; # 0=increasing; 1=decreasing
if ( $sortmode eq 'time' ) {
$field = '1';
$type = '0';
$case = '1';
$dir = '0';
}
elsif ( $sortmode eq 'users' ) {
$field = '8';
$type = '1';
$case = '1';
$dir = '0';
}
elsif ( $sortmode eq 'ip' ) {
$field = '3';
$type = '0';
$case = '0';
$dir = '0';
}
@sortlist =
map { $_->[0] }
sort { YaBBsort( $field, $type, $case, $dir ) }
map { [ $_, split /\|/xsm ] } @tmplist;
if ( $INFO{'order'} eq 'reverse' ) {
@sortlist = reverse @sortlist;
}
else {
if ( $sortmode eq 'time' ) {
$order_time = ';order=reverse';
}
elsif ( $sortmode eq 'users' ) {
$order_users = ';order=reverse';
}
elsif ( $sortmode eq 'ip' ) {
$order_ip = ';order=reverse';
}
}
if ( $sortmode ne q{} ) {
$sortmode = ';sort=' . $INFO{'sort'};
}
if ( $sortorder ne q{} ) {
$sortorder = ';order=' . $INFO{'order'};
}
$yymain .= qq~\
<script src="$yyhtml_root/ubbc.js" type="text/javascript"></script>
<script type="text/javascript">
<!-- Begin
function changeBox(cbox) {
box = eval(cbox);
box.checked = !box.checked;
}
function checkAll() {
for (var i = 0; i < document.errorlog_form.elements.length; i++) {
if(document.errorlog_form.elements[i].name != "subfield" && document.errorlog_form.elements[i].name != "msgfield") {
document.errorlog_form.elements[i].checked = true;
}
}
}
function uncheckAll() {
for (var i = 0; i < document.errorlog_form.elements.length; i++) {
if(document.errorlog_form.elements[i].name != "subfield" && document.errorlog_form.elements[i].name != "msgfield") {
document.errorlog_form.elements[i].checked = false;
}
}
}
//-->
</script>
<form name="errorlog_form" action="$adminurl?action=deleteerror;$sortmode$sortorder" method="post" onsubmit="return submitproc()">
<input type="hidden" name="button" value="4" />
<div class="bordercolor rightboxdiv">
<table class="cs_thin pad_4px" style="margin-bottom:.5em">
<col style="width:5%" />
<col style="width:10%" />
<col style="width:15%" />
<col style="width:65%" />
<col style="width:5%" />
<tr>
<td class="titlebg" colspan="5">$admin_img{'xx'} <b>$yytitle</b></td>
</tr><tr>
<td class="windowbg2 padd_8_12px" colspan="5">$errorlog{'18'}</td>
</tr><tr>
<td class="catbg center"><b>$errorlog{'21'}</b></td>
<td class="catbg center">
<a href="$adminurl?action=errorlog$startmode;sort=time$order_time"><b>$errorlog{'5'}</b></a>
</td>
<td class="catbg center">
<a href="$adminurl?action=errorlog$startmode;sort=users$order_users"><b>$errorlog{'11'}</b></a> ( <a href="$adminurl?action=errorlog$startmode;sort=ip$order_ip"><b>$errorlog{'6'}</b></a> )
</td>
<td class="catbg center"><b>$errorlog{'7'} / $errorlog{'8'}</b></td>
<td class="catbg center"><b>$errorlog{'13'}</b></td>
</tr>~;
$numshown = 0;
$actualnum = 0;
while ( $numshown <= $errorcount ) {
my ( $tmp_user, $username, $numb, $ids, $all ) = q{};
$numshown++;
my (
$tmp_datecmp, $tmp_id, $tmp_date,
$tmp_userip, $tmp_error, $tmp_action,
$tmp_topic_number, $tmp_board, $tmp_username,
$tmp_password
) = split /\|/xsm, $sortlist[$b];
if ( !$tmp_id ) { next; }
FormatUserName($tmp_username);
if ( !$tmp_username ) {
$tmp_user = 'Guest';
}
else {
$tmp_user = $tmp_username;
}
$userlist{$tmp_user} = $userlist{$tmp_user} + 1;
$tmp_date = timeformat($tmp_date);
LoadUser($tmp_user);
my $ipBlock = ( $use_guardian && $use_htaccess ) ? qq~<br /><a href="$adminurl?action=guardian_block;ip=$tmp_userip;return=errorlog" onclick="return confirm('$admin_txt{'ipblock_confirm'}$tmp_userip');">$admin_txt{'ipblock'}</a>~ : q{};
my $lookupIP =
($ipLookup)
? qq~<a href="$scripturl?action=iplookup;ip=$tmp_userip">$tmp_userip</a>~
: qq~$tmp_userip~;
if ( $tmp_user eq "$useraccount{$tmp_user}" ) {
if ( $userprofile{$tmp_user}->[1] ) {
$username =
qq~<a href="$scripturl?action=viewprofile;username=$useraccount{$tmp_user}" target="_blank">$userprofile{$tmp_user}->[1]</a>~;
}
else {
$username .= qq~$useraccount{$tmp_user}~;
}
$username .=
qq~<br />$lookupIP - <a href="$adminurl?action=ipban_err;ban=$tmp_userip;lev=p;return=errorlog" onclick="return confirm('$admin_txt{'ipban_confirm'}$tmp_userip');">$admin_txt{'725f'}</a>$ipBlock~;
}
else {
$username =
qq~$tmp_user<br />$lookupIP - <a href="$adminurl?action=ipban_err;ban=$tmp_userip;lev=p;return=errorlog" onclick="return confirm('$admin_txt{'ipban_confirm'}$tmp_userip');">$admin_txt{'725f'}</a>$ipBlock~;
}
if ( $tmp_topic_number eq q{} ) {
$numb = "&amp;action=$tmp_action";
}
else {
$numb = "&amp;action=$tmp_action&amp;num=$tmp_topic_number";
}
if ( $tmp_board eq q{} ) {
$ids = '?board=';
}
else {
$ids = "?board=$tmp_board";
}
if ( $tmp_action eq q{} && $tmp_board eq q{} ) {
$all = "$boardurl/$yyexec.$yyext";
}
else {
$all = "$boardurl/$yyexec.$yyext$ids$numb";
}
if ( $tmp_error eq $admin_txt{'39'} || $tmp_error eq $admin_txt{'40'} )
{
$tmp_error =
$tmp_error . qq~ - (<span class="red">$tmp_password</span>)~;
}
$b++;
$addel =
qq~ <td class="windowbg center"><input type="checkbox" name="error$tmp_id" value="$tmp_id" class="windowbg" style="border: 0px;" /></td>~;
$actualnum++;
$print_errorlog .= qq~<tr>
<td class="windowbg center">$actualnum</td>
<td class="windowbg">$tmp_date</td>
<td class="windowbg2 center">$username</td>
<td class="windowbg center">
<div class="small" style="height:5em; overflow:auto">$tmp_error<br /><br /><a href="$all">$all</a></div>
</td>
$addel
</tr>~;
}
if ( !($actualnum) ) {
$print_errorlog = qq~<tr>
<td class="windowbg2 center" colspan="5">$errorlog{'19'}</td>
</tr>~;
}
$yymain .= qq~
$print_errorlog
~;
@userlist = reverse sort { $userlist{$a} <=> $userlist{$b} } keys %userlist;
foreach my $member (@userlist) {
$errmember .= qq~$member ($userlist{$member}), ~;
}
$errmember =~ s/, \Z//sm;
$yymain .= qq~ <tr>
<td class="windowbg2 padd_8_12px" colspan="5"><b>$errorlog{'26'}</b> $errmember</td>
</tr><tr>
<td class="windowbg right" colspan="4">&nbsp;~;
if ( $errorcount > 0 ) {
$yymain .=
qq~<label for="checkall"><b>$admin_txt{'737'}</b></label>&nbsp;~;
}
$yymain .= q~
</td>
<td class="windowbg center">&nbsp;~;
if ( $errorcount > 0 ) {
$yymain .=
q~<input type="checkbox" name="checkall" id="checkall" class="windowbg" style="border: 0px;" onclick="if (this.checked) checkAll(); else uncheckAll();" />~;
}
$yymain .= q~
</td>
</tr>
</table>
</div>~;
if ( $errorcount > 0 ) {
$yymain .= qq~
<div class="bordercolor rightboxdiv">
<table class="cs_thin pad_4px">
<tr>
<th class="titlebg">$admin_img{'prefimg'} $errorlog{'14'}</th>
</tr><tr>
<td class="catbg center">
<input type="submit" value="$errorlog{'14'}" onclick="return confirm('$errorlog{'15'}')" class="button" />
</td>
</tr>
</table>
</div>~;
}
$yymain .= q~
</form>
~;
$action_area = 'errorlog';
AdminTemplate();
return;
}
sub CleanErrorLog {
is_admin_or_gmod();
if ( -e ("$vardir/errorlog.txt") ) {
unlink "$vardir/errorlog.txt" or croak qq~$!~;
}
$yySetLocation = qq~$adminurl?action=errorlog~;
redirectexit();
return;
}
sub DeleteError {
is_admin_or_gmod();
my ( $sortmode, $sortorder );
chomp $FORM{'button'};
if ( $FORM{'button'} ne '4' ) { fatal_error('no_access'); }
fopen( FILE, "$vardir/errorlog.txt" );
@errors = <FILE>;
fclose(FILE);
unlink "$vardir/errorlog.txt";
fopen( FILE, ">>$vardir/errorlog.txt" );
foreach my $line (@errors) {
chomp $line;
my (
$tmp_id, $tmp_date, $tmp_username,
$tmp_error, $tmp_board, $tmp_action
) = split /\|/xsm, $line;
if ( !exists $FORM{"error$tmp_id"} ) {
print {FILE} $line . "\n" or croak "$croak{'print'} FILE";
}
}
fclose(FILE);
$yySetLocation = qq~$adminurl?action=errorlog~;
redirectexit();
return;
}
# Moved here from Subs.pm since it was only used here
sub YaBBsort {
my $field = ( shift || 0 ) + 1; # 0-based field
my $type = shift || 0; # 0=numeric; 1=text
my $case = shift || 0; # 0=case sensitive; 1=ignore case
my $dir = shift || 0; # 0=increasing; 1=decreasing
if ( $type == 0 ) {
if ( $dir == 0 ) {
$a->[$field] <=> $b->[$field];
}
else {
$b->[$field] <=> $a->[$field];
}
}
else {
if ( $case == 0 ) {
if ( $dir == 0 ) {
$a->[$field] cmp $b->[$field];
}
else {
$b->[$field] cmp $a->[$field];
}
}
else {
if ( $dir == 0 ) {
uc $a->[$field] cmp uc $b->[$field];
}
else {
uc $b->[$field] cmp uc $a->[$field];
}
}
}
return 1;
}
1;