Subversion Repositories logviewer

Rev

Rev 4 | Rev 8 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4 Rev 6
Line 37... Line 37...
37
        logviewer_check_access();
37
        logviewer_check_access();
38
} catch (Exception $e) {
38
} catch (Exception $e) {
39
        die('<h1>ViaThinkSoft LogViewer - Error</h1><p>'.$e->getMessage().'</p>');
39
        die('<h1>ViaThinkSoft LogViewer - Error</h1><p>'.$e->getMessage().'</p>');
40
}
40
}
41
 
41
 
-
 
42
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : '';
-
 
43
if ($sort == '') $sort = 'anzahl';
-
 
44
if (($sort != 'anzahl') && ($sort != 'letzter') && ($sort != 'random')) die('Sort falsch');
-
 
45
 
42
# Please keep this code synchronized with ajax_cmd.php
46
# Please keep this code synchronized with ajax_cmd.php
43
$add_filters = logviewer_additional_filter();
47
$add_filters = logviewer_additional_filter();
44
$hardcoded_filters = empty($add_filters) ? '' : "and ($add_filters)";
48
$hardcoded_filters = empty($add_filters) ? '' : "and ($add_filters)";
45
$hardcoded_filters .= " and (letzter >= DATE_SUB(NOW(),INTERVAL ".MAXYEARS." YEAR))";
49
$hardcoded_filters .= " and (letzter >= DATE_SUB(NOW(),INTERVAL ".MAXYEARS." YEAR))";
46
# Please keep this code synchronized with ajax_cmd.php
50
# Please keep this code synchronized with ajax_cmd.php
47
 
51
 
48
if (isset($_REQUEST['solveall']) && logviewer_allow_solvemark()) {
52
if (isset($_REQUEST['solveall']) && logviewer_allow_solvemark()) {
49
        mysql_query("update vts_fehlerlog set anzahlsolved = anzahl where text like '%".mysql_real_escape_string($_REQUEST['solveall'])."%'");
53
        db_query("update vts_fehlerlog set anzahlsolved = anzahl where text like '%".db_real_escape_string($_REQUEST['solveall'])."%'");
50
        header('location:?sort='.urlencode($sort)); // avoid F5
54
        header('location:?sort='.urlencode($sort)); // avoid F5
51
        die();
55
        die();
52
}
56
}
53
 
57
 
54
$filter_add = '';
58
$filter_add = '';
Line 63... Line 67...
63
                        $a = substr($a, 1); // remove "-"
67
                        $a = substr($a, 1); // remove "-"
64
                } else {
68
                } else {
65
                        $negate = " ";
69
                        $negate = " ";
66
                }
70
                }
67
 
71
 
68
                $filter_add .= " and text $negate like '".mysql_real_escape_string('%'.$a.'%')."' ";
72
                $filter_add .= " and text $negate like '".db_real_escape_string('%'.$a.'%')."' ";
69
        }
73
        }
70
}
74
}
71
 
75
 
72
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : '';
-
 
73
if ($sort == '') $sort = 'anzahl';
-
 
74
if (($sort != 'anzahl') && ($sort != 'letzter') && ($sort != 'random')) die('Sort falsch');
-
 
75
 
-
 
76
?>
76
?>
77
<html>
77
<html>
78
 
78
 
79
<head>
79
<head>
80
        <title>ViaThinkSoft LogViewer</title>
80
        <title>ViaThinkSoft LogViewer</title>
Line 131... Line 131...
131
        echo '<a href="?sort=random'.((isset($_REQUEST['filter'])) ? '&filter='.urlencode($_REQUEST['filter']) : '').'">Random order</a>';
131
        echo '<a href="?sort=random'.((isset($_REQUEST['filter'])) ? '&filter='.urlencode($_REQUEST['filter']) : '').'">Random order</a>';
132
}
132
}
133
 
133
 
134
?> (<span id="count"><?php
134
?> (<span id="count"><?php
135
 
135
 
136
$res = mysql_query("select count(*) as cnt from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters.";");
136
$res = db_query("select count(*) as cnt from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters.";");
137
$row = mysql_fetch_array($res);
137
$row = db_fetch_object($res);
138
echo $row['cnt'];
138
echo $row->cnt;
139
 
139
 
140
?></span>)</div>
140
?></span>)</div>
141
 
141
 
142
<table border="1" width="100%">
142
<table border="1" width="100%">
143
<thead>
143
<thead>
Line 167... Line 167...
167
<?php
167
<?php
168
 
168
 
169
$odd = true;
169
$odd = true;
170
 
170
 
171
if ($sort == 'letzter') {
171
if ($sort == 'letzter') {
172
        $res = mysql_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by letzter desc, anzahl desc, id asc limit ".COUNT);
172
        $res = db_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by letzter desc, anzahl desc, id asc limit ".COUNT);
173
} else if ($sort == 'anzahl') {
173
} else if ($sort == 'anzahl') {
174
        $res = mysql_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by anzahl desc, letzter desc, id asc limit ".COUNT);
174
        $res = db_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by anzahl desc, letzter desc, id asc limit ".COUNT);
175
} else if ($sort == 'random') {
175
} else if ($sort == 'random') {
176
        $res = mysql_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by RAND() limit ".COUNT);
176
        $res = db_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by RAND() limit ".COUNT);
177
}
177
}
178
while ($row = mysql_fetch_array($res)) {
178
while ($row = db_fetch_object($res)) {
179
        $text = htmlentities($row['text']);
179
        $text = htmlentities($row->text);
180
        $text = preg_replace('@ ([^ ]{2,}) on line@ismU', ' <a href="?sort='.urlencode($sort).'&filter=\1">\1</a> on line', $text); // TODO: urlencode \1
180
        $text = preg_replace('@ ([^ ]{2,}) on line@ismU', ' <a href="?sort='.urlencode($sort).'&filter=\1">\1</a> on line', $text); // TODO: urlencode \1
181
        $text = preg_replace('@(at|in) ([^ ]{2,}):(\d+)@ismU', '\1 <a href="?sort='.urlencode($sort).'&filter=\2">\2</a>:\3', $text); // TODO: urlencode \2
181
        $text = preg_replace('@(at|in) ([^ ]{2,}):(\d+)@ismU', '\1 <a href="?sort='.urlencode($sort).'&filter=\2">\2</a>:\3', $text); // TODO: urlencode \2
182
 
182
 
183
        $anzahl = htmlentities($row['anzahl']);
183
        $anzahl = htmlentities($row->anzahl);
184
        if ($row['anzahlsolved'] != 0) $anzahl .= '<br>('.$row['anzahlsolved'].')';
184
        if ($row->anzahlsolved != 0) $anzahl .= '<br>('.$row->anzahlsolved.')';
185
 
185
 
186
        $class = $odd ? 'tr_odd' : 'tr_even';
186
        $class = $odd ? 'tr_odd' : 'tr_even';
187
        $odd = !$odd;
187
        $odd = !$odd;
188
 
188
 
189
        echo '<tr id="line'.$row['id'].'" class="'.$class.'">';
189
        echo '<tr id="line'.$row->id.'" class="'.$class.'">';
190
        if (SOURCE_STYLE == 0) {
190
        if (SOURCE_STYLE == 0) {
191
                // nothing
191
                // nothing
192
        } else if (SOURCE_STYLE == 1) {
192
        } else if (SOURCE_STYLE == 1) {
193
                echo '<td>'.htmlentities($row['logfile']).'</td>';
193
                echo '<td>'.htmlentities($row->logfile).'</td>';
194
                echo '<td>'.htmlentities($row['modul']).'</td>';
194
                echo '<td>'.htmlentities($row->modul).'</td>';
195
        } else {
195
        } else {
196
                $user = preg_match('@/home/(.+)/@sU', $row['logfile'], $m) ? $m[1] : ((strpos($row['logfile'], '/root/') === 0) ? 'root' : '');
196
                $user = preg_match('@/home/(.+)/@sU', $row->logfile, $m) ? $m[1] : ((strpos($row->logfile, '/root/') === 0) ? 'root' : '');
197
                echo '<td>'.htmlentities($user).'</td>';
197
                echo '<td>'.htmlentities($user).'</td>';
198
        }
198
        }
199
        if (logviewer_allow_solvemark()) echo '<td><a href="javascript:_solve('.$row['id'].')">Solved</a></td>';
199
        if (logviewer_allow_solvemark()) echo '<td><a href="javascript:_solve('.$row->id.')">Solved</a></td>';
200
        echo '<td>'.$anzahl.'</td>';
200
        echo '<td>'.$anzahl.'</td>';
201
        echo '<td>'.htmlentities($row['letzter']).'</td>';
201
        echo '<td>'.htmlentities($row->letzter).'</td>';
202
        echo '<td>'.$text.'</td>';
202
        echo '<td>'.$text.'</td>';
203
        echo '</tr>';
203
        echo '</tr>';
204
        flush();
204
        flush();
205
}
205
}
206
?>
206
?>