Rev 8 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8 | Rev 9 | ||
---|---|---|---|
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | /* |
3 | /* |
4 | * ViaThinkSoft LogViewer |
4 | * ViaThinkSoft LogViewer |
5 | * Copyright 2018-2019 Daniel Marschall, ViaThinkSoft |
5 | * Copyright 2018-2022 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 | * |
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
12 | * |
12 | * |
13 | * Unless required by applicable law or agreed to in writing, software |
13 | * Unless required by applicable law or agreed to in writing, software |
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | * See the License for the specific language governing permissions and |
16 | * See the License for the specific language governing permissions and |
17 | * limitations under the License. |
17 | * limitations under the License. |
18 | */ |
18 | */ |
19 | 19 | ||
20 | if (!isset($_REQUEST['cmd'])) _err('cmd is missing'); |
20 | if (!isset($_REQUEST['cmd'])) _err('cmd is missing'); |
21 | 21 | ||
22 | $hostname = trim(file_get_contents('/etc/hostname')); |
22 | $hostname = trim(file_get_contents('/etc/hostname')); |
23 | 23 | ||
24 | if (file_exists(__DIR__."/config_$hostname.inc.php")) { |
24 | if (file_exists(__DIR__."/config_$hostname.inc.php")) { |
25 | require_once __DIR__."/config_$hostname.inc.php"; |
25 | require_once __DIR__."/config_$hostname.inc.php"; |
26 | } else { |
26 | } else { |
27 | require_once __DIR__.'/config.inc.php'; |
27 | require_once __DIR__.'/config.inc.php'; |
28 | } |
28 | } |
29 | 29 | ||
30 | if (file_exists(__DIR__."/db_$hostname.inc.php")) { |
30 | if (file_exists(__DIR__."/db_$hostname.inc.php")) { |
31 | require_once __DIR__."/db_$hostname.inc.php"; |
31 | require_once __DIR__."/db_$hostname.inc.php"; |
32 | } else { |
32 | } else { |
33 | require_once __DIR__.'/db.inc.php'; |
33 | require_once __DIR__.'/db.inc.php'; |
34 | } |
34 | } |
35 | 35 | ||
36 | if (file_exists(__DIR__."/auth_$hostname.inc.php")) { |
36 | if (file_exists(__DIR__."/auth_$hostname.inc.php")) { |
37 | require_once __DIR__."/auth_$hostname.inc.php"; |
37 | require_once __DIR__."/auth_$hostname.inc.php"; |
38 | } else { |
38 | } else { |
39 | require_once __DIR__.'/auth.inc.php'; |
39 | require_once __DIR__.'/auth.inc.php'; |
40 | } |
40 | } |
41 | 41 | ||
42 | try { |
42 | try { |
43 | logviewer_check_access(); |
43 | logviewer_check_access(); |
44 | } catch (Exception $e) { |
44 | } catch (Exception $e) { |
45 | _err($e->getMessage()); |
45 | _err($e->getMessage()); |
46 | } |
46 | } |
47 | 47 | ||
48 | # Please keep this code synchronized with index.php |
48 | # Please keep this code synchronized with index.php |
49 | $add_filters = logviewer_additional_filter(); |
49 | $add_filters = logviewer_additional_filter(); |
50 | $hardcoded_filters = empty($add_filters) ? '' : "and ($add_filters)"; |
50 | $hardcoded_filters = empty($add_filters) ? '' : "and ($add_filters)"; |
51 | $hardcoded_filters .= " and (letzter >= DATE_SUB(NOW(),INTERVAL ".MAXYEARS." YEAR))"; |
51 | $hardcoded_filters .= " and (letzter >= DATE_SUB(NOW(),INTERVAL ".MAXYEARS." YEAR))"; |
52 | # Please keep this code synchronized with index.php |
52 | # Please keep this code synchronized with index.php |
53 | 53 | ||
54 | if ($_REQUEST['cmd'] == 'solve') { |
54 | if ($_REQUEST['cmd'] == 'solve') { |
55 | if (!is_numeric($_REQUEST['id'])) _err('Invalid solve id'); |
55 | if (!is_numeric($_REQUEST['id'])) _err('Invalid solve id'); |
56 | 56 | ||
57 | try { |
57 | try { |
58 | if (file_exists(__DIR__."/db_$hostname.inc.php")) { |
58 | if (file_exists(__DIR__."/db_$hostname.inc.php")) { |
59 | require_once __DIR__."/db_$hostname.inc.php"; |
59 | require_once __DIR__."/db_$hostname.inc.php"; |
60 | } else { |
60 | } else { |
61 | require_once __DIR__.'/db.inc.php'; |
61 | require_once __DIR__.'/db.inc.php'; |
62 | } |
62 | } |
63 | 63 | ||
64 | if (!logviewer_allow_solvemark()) _err('No permission to mark entries as solved!'); |
64 | if (!logviewer_allow_solvemark()) _err('No permission to mark entries as solved!'); |
65 | } catch (Exception $e) { |
65 | } catch (Exception $e) { |
66 | _err($e->getMessage()); |
66 | _err($e->getMessage()); |
67 | } |
67 | } |
68 | 68 | ||
69 | $res = @db_query('select id from vts_fehlerlog where (id = '.$_REQUEST['id'].') '.$hardcoded_filters); |
69 | $res = @db_query('select id from vts_fehlerlog where (id = '.$_REQUEST['id'].') '.$hardcoded_filters); |
70 | if (!$res) _err('mysql query failed'); |
70 | if (!$res) _err('mysql query failed'); |
71 | if (db_num_rows($res) == 0) _err('Row not found or no permission given.'); |
71 | if (db_num_rows($res) == 0) _err('Row not found or no permission given.'); |
72 | 72 | ||
73 | $res = @db_query('update vts_fehlerlog set anzahlsolved = anzahl where (id = '.$_REQUEST['id'].') '.$hardcoded_filters); |
73 | $res = @db_query('update vts_fehlerlog set anzahlsolved = anzahl where (id = '.$_REQUEST['id'].') '.$hardcoded_filters); |
74 | if (!$res) _err('mysql query failed'); |
74 | if (!$res) _err('mysql query failed'); |
75 | 75 | ||
76 | $out = array(); |
76 | $out = array(); |
77 | $out['success'] = true; |
77 | $out['success'] = true; |
78 | $out['id'] = $_REQUEST['id']; // give OK to hide the line |
78 | $out['id'] = $_REQUEST['id']; // give OK to hide the line |
79 | header('Content-Type: application/json'); |
79 | header('Content-Type: application/json'); |
80 | die(json_encode($out)); |
80 | die(json_encode($out)); |
81 | } else { |
81 | } else { |
82 | _err('unknown cmd'); |
82 | _err('unknown cmd'); |
83 | } |
83 | } |
84 | 84 | ||
85 | # --- |
85 | # --- |
86 | 86 | ||
87 | function _err($msg) { |
87 | function _err($msg) { |
88 | $out = array(); |
88 | $out = array(); |
89 | $out['success'] = false; |
89 | $out['success'] = false; |
90 | $out['error'] = $msg; |
90 | $out['error'] = $msg; |
91 | header('Content-Type: application/json'); |
91 | header('Content-Type: application/json'); |
92 | die(json_encode($out)); |
92 | die(json_encode($out)); |
93 | } |
93 | } |
94 | 94 |