Subversion Repositories logviewer

Rev

Rev 9 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9 Rev 12
Line 1... Line 1...
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * ViaThinkSoft LogViewer
4
 * ViaThinkSoft LogViewer
5
 * Copyright 2018-2022 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2018-2023 Daniel Marschall, ViaThinkSoft
6
 *
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
9
 * You may obtain a copy of the License at
10
 *
10
 *
Line 51... Line 51...
51
$add_filters = logviewer_additional_filter();
51
$add_filters = logviewer_additional_filter();
52
$hardcoded_filters = empty($add_filters) ? '' : "and ($add_filters)";
52
$hardcoded_filters = empty($add_filters) ? '' : " and ($add_filters)";
53
$hardcoded_filters .= " and (letzter >= DATE_SUB(NOW(),INTERVAL ".MAXYEARS." YEAR))";
53
$hardcoded_filters .= " and (letzter >= DATE_SUB(NOW(),INTERVAL ".MAXYEARS." YEAR))";
54
# Please keep this code synchronized with ajax_cmd.php
54
# Please keep this code synchronized with ajax_cmd.php
55
 
55
 
56
if (isset($_REQUEST['solveall']) && logviewer_allow_solvemark()) {
-
 
57
        db_query("update vts_fehlerlog set anzahlsolved = anzahl where text like '%".db_real_escape_string($_REQUEST['solveall'])."%'");
-
 
58
        header('location:?sort='.urlencode($sort)); // avoid F5
-
 
59
        die();
-
 
60
}
-
 
61
 
-
 
62
$filter_add = '';
56
$filter_add = '';
63
if (isset($_REQUEST['filter'])) {
57
if (isset($_REQUEST['filter'])) {
64
        $ary = explode(' ', $_REQUEST['filter']);
58
        $ary = explode(' ', $_REQUEST['filter']);
65
        foreach ($ary as $a) {
59
        foreach ($ary as $a) {
66
                $a = trim($a);
60
                $a = trim($a);
Line 75... Line 69...
75
 
69
 
76
                $filter_add .= " and text $negate like '".db_real_escape_string('%'.$a.'%')."' ";
70
                $filter_add .= " and text $negate like '".db_real_escape_string('%'.$a.'%')."' ";
77
        }
71
        }
78
}
72
}
79
 
73
 
-
 
74
$where = "(anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters;
-
 
75
 
-
 
76
if (isset($_REQUEST['solveall']) && logviewer_allow_solvemark()) {
-
 
77
        db_query("update vts_fehlerlog set anzahlsolved = anzahl where $where");
-
 
78
        header('location:?sort='.urlencode($sort)); // avoid F5
-
 
79
        die();
-
 
80
}
-
 
81
 
80
?>
82
?>
81
<html>
83
<html>
82
 
84
 
83
<head>
85
<head>
84
        <title>ViaThinkSoft LogViewer</title>
86
        <title>ViaThinkSoft LogViewer</title>
Line 94... Line 96...
94
<input type="hidden" name="sort" value="<?php echo htmlentities($sort); ?>">
96
<input type="hidden" name="sort" value="<?php echo htmlentities($sort); ?>">
95
<p>Filter: <input style="width:300px" type="text" name="filter" value="<?php echo htmlentities(isset($_REQUEST['filter']) ? $_REQUEST['filter'] : ''); ?>"> <input type="submit" value="Filter"><?php
97
<p>Filter: <input style="width:300px" type="text" name="filter" value="<?php echo htmlentities(isset($_REQUEST['filter']) ? $_REQUEST['filter'] : ''); ?>"> <input type="submit" value="Filter"><?php
96
if (isset($_REQUEST['filter'])) {
98
if (isset($_REQUEST['filter'])) {
97
        echo ' <a href="?sort='.htmlentities($sort).'">Clear filter</a>';
99
        echo ' <a href="?sort='.htmlentities($sort).'">Clear filter</a>';
98
        if (logviewer_allow_solvemark()) {
100
        if (logviewer_allow_solvemark()) {
99
                echo ' | <a href="?sort='.htmlentities($sort).'&solveall='.urlencode($_REQUEST['filter']).'" onclick="return confirm(\'Are you sure?\');">Solve all</a>';
101
                echo ' | <a href="?sort='.htmlentities($sort).'&solveall=1&filter='.urlencode($_REQUEST['filter']).'" onclick="return confirm(\'Are you sure?\');">Solve all</a>';
100
        }
102
        }
101
}
103
}
102
?></p>
104
?></p>
103
<p><font size="-3">Search terms divided with whitespace. Prepend hyphen to exclude a search term. Only field "Message" will be searched.</font></p>
105
<p><font size="-3">Search terms divided with whitespace. Prepend hyphen to exclude a search term. Only field "Message" will be searched.</font></p>
104
</form>
106
</form>
Line 135... Line 137...
135
        echo '<a href="?sort=random'.((isset($_REQUEST['filter'])) ? '&filter='.urlencode($_REQUEST['filter']) : '').'">Random order</a>';
137
        echo '<a href="?sort=random'.((isset($_REQUEST['filter'])) ? '&filter='.urlencode($_REQUEST['filter']) : '').'">Random order</a>';
136
}
138
}
137
 
139
 
138
?> (<span id="count"><?php
140
?> (<span id="count"><?php
139
 
141
 
140
$res = db_query("select count(*) as cnt from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters.";");
142
$res = db_query("select count(*) as cnt from vts_fehlerlog where $where;");
141
$row = db_fetch_object($res);
143
$row = db_fetch_object($res);
142
echo $row->cnt;
144
echo $row->cnt;
143
 
145
 
144
?></span>)</div>
146
?></span>)</div>
145
 
147
 
Line 171... Line 173...
171
<?php
173
<?php
172
 
174
 
173
$odd = true;
175
$odd = true;
174
 
176
 
175
if ($sort == 'letzter') {
177
if ($sort == 'letzter') {
176
        $res = db_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by letzter desc, anzahl desc, id asc limit ".COUNT);
178
        $res = db_query("select * from vts_fehlerlog where $where order by letzter desc, anzahl desc, id asc limit ".COUNT);
177
} else if ($sort == 'anzahl') {
179
} else if ($sort == 'anzahl') {
178
        $res = db_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by anzahl desc, letzter desc, id asc limit ".COUNT);
180
        $res = db_query("select * from vts_fehlerlog where $where order by anzahl desc, letzter desc, id asc limit ".COUNT);
179
} else if ($sort == 'random') {
181
} else if ($sort == 'random') {
180
        $res = db_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by RAND() limit ".COUNT);
182
        $res = db_query("select * from vts_fehlerlog where $where order by RAND() limit ".COUNT);
181
}
183
}
182
while ($row = db_fetch_object($res)) {
184
while ($row = db_fetch_object($res)) {
183
        $text = htmlentities($row->text);
185
        $text = htmlentities($row->text);
184
        $text = preg_replace('@ ([^ ]{2,}) on line@ismU', ' <a href="?sort='.urlencode($sort).'&filter=\1">\1</a> on line', $text); // TODO: urlencode \1
186
        $text = preg_replace('@ ([^ ]{2,}) on line@ismU', ' <a href="?sort='.urlencode($sort).'&filter=\1">\1</a> on line', $text); // TODO: urlencode \1
185
        $text = preg_replace('@(at|in) ([^ ]{2,}):(\d+)@ismU', '\1 <a href="?sort='.urlencode($sort).'&filter=\2">\2</a>:\3', $text); // TODO: urlencode \2
187
        $text = preg_replace('@(at|in) ([^ ]{2,}):(\d+)@ismU', '\1 <a href="?sort='.urlencode($sort).'&filter=\2">\2</a>:\3', $text); // TODO: urlencode \2