/trunk/INSTALL |
---|
0,0 → 1,12 |
1. Import logviewer.sql into your MySQL database |
2. Add MySQL login information to db.inc.php |
3. Either edit auth.inc.php if you have a authentification/permission infrastructure, or create a simple .htaccess/.htpasswd protection. |
4. Add backend/insert_logs into crontab, letting it run every 10 minutes, e.g. following entry in /etc/crontab |
*/10 * * * * root /.../logviewer/backend/insert_logs > /dev/null |
5. Modify config.inc.php |
/trunk/LICENSE |
---|
0,0 → 1,202 |
Apache License |
Version 2.0, January 2004 |
http://www.apache.org/licenses/ |
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
1. Definitions. |
"License" shall mean the terms and conditions for use, reproduction, |
and distribution as defined by Sections 1 through 9 of this document. |
"Licensor" shall mean the copyright owner or entity authorized by |
the copyright owner that is granting the License. |
"Legal Entity" shall mean the union of the acting entity and all |
other entities that control, are controlled by, or are under common |
control with that entity. For the purposes of this definition, |
"control" means (i) the power, direct or indirect, to cause the |
direction or management of such entity, whether by contract or |
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
outstanding shares, or (iii) beneficial ownership of such entity. |
"You" (or "Your") shall mean an individual or Legal Entity |
exercising permissions granted by this License. |
"Source" form shall mean the preferred form for making modifications, |
including but not limited to software source code, documentation |
source, and configuration files. |
"Object" form shall mean any form resulting from mechanical |
transformation or translation of a Source form, including but |
not limited to compiled object code, generated documentation, |
and conversions to other media types. |
"Work" shall mean the work of authorship, whether in Source or |
Object form, made available under the License, as indicated by a |
copyright notice that is included in or attached to the work |
(an example is provided in the Appendix below). |
"Derivative Works" shall mean any work, whether in Source or Object |
form, that is based on (or derived from) the Work and for which the |
editorial revisions, annotations, elaborations, or other modifications |
represent, as a whole, an original work of authorship. For the purposes |
of this License, Derivative Works shall not include works that remain |
separable from, or merely link (or bind by name) to the interfaces of, |
the Work and Derivative Works thereof. |
"Contribution" shall mean any work of authorship, including |
the original version of the Work and any modifications or additions |
to that Work or Derivative Works thereof, that is intentionally |
submitted to Licensor for inclusion in the Work by the copyright owner |
or by an individual or Legal Entity authorized to submit on behalf of |
the copyright owner. For the purposes of this definition, "submitted" |
means any form of electronic, verbal, or written communication sent |
to the Licensor or its representatives, including but not limited to |
communication on electronic mailing lists, source code control systems, |
and issue tracking systems that are managed by, or on behalf of, the |
Licensor for the purpose of discussing and improving the Work, but |
excluding communication that is conspicuously marked or otherwise |
designated in writing by the copyright owner as "Not a Contribution." |
"Contributor" shall mean Licensor and any individual or Legal Entity |
on behalf of whom a Contribution has been received by Licensor and |
subsequently incorporated within the Work. |
2. Grant of Copyright License. Subject to the terms and conditions of |
this License, each Contributor hereby grants to You a perpetual, |
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
copyright license to reproduce, prepare Derivative Works of, |
publicly display, publicly perform, sublicense, and distribute the |
Work and such Derivative Works in Source or Object form. |
3. Grant of Patent License. Subject to the terms and conditions of |
this License, each Contributor hereby grants to You a perpetual, |
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
(except as stated in this section) patent license to make, have made, |
use, offer to sell, sell, import, and otherwise transfer the Work, |
where such license applies only to those patent claims licensable |
by such Contributor that are necessarily infringed by their |
Contribution(s) alone or by combination of their Contribution(s) |
with the Work to which such Contribution(s) was submitted. If You |
institute patent litigation against any entity (including a |
cross-claim or counterclaim in a lawsuit) alleging that the Work |
or a Contribution incorporated within the Work constitutes direct |
or contributory patent infringement, then any patent licenses |
granted to You under this License for that Work shall terminate |
as of the date such litigation is filed. |
4. Redistribution. You may reproduce and distribute copies of the |
Work or Derivative Works thereof in any medium, with or without |
modifications, and in Source or Object form, provided that You |
meet the following conditions: |
(a) You must give any other recipients of the Work or |
Derivative Works a copy of this License; and |
(b) You must cause any modified files to carry prominent notices |
stating that You changed the files; and |
(c) You must retain, in the Source form of any Derivative Works |
that You distribute, all copyright, patent, trademark, and |
attribution notices from the Source form of the Work, |
excluding those notices that do not pertain to any part of |
the Derivative Works; and |
(d) If the Work includes a "NOTICE" text file as part of its |
distribution, then any Derivative Works that You distribute must |
include a readable copy of the attribution notices contained |
within such NOTICE file, excluding those notices that do not |
pertain to any part of the Derivative Works, in at least one |
of the following places: within a NOTICE text file distributed |
as part of the Derivative Works; within the Source form or |
documentation, if provided along with the Derivative Works; or, |
within a display generated by the Derivative Works, if and |
wherever such third-party notices normally appear. The contents |
of the NOTICE file are for informational purposes only and |
do not modify the License. You may add Your own attribution |
notices within Derivative Works that You distribute, alongside |
or as an addendum to the NOTICE text from the Work, provided |
that such additional attribution notices cannot be construed |
as modifying the License. |
You may add Your own copyright statement to Your modifications and |
may provide additional or different license terms and conditions |
for use, reproduction, or distribution of Your modifications, or |
for any such Derivative Works as a whole, provided Your use, |
reproduction, and distribution of the Work otherwise complies with |
the conditions stated in this License. |
5. Submission of Contributions. Unless You explicitly state otherwise, |
any Contribution intentionally submitted for inclusion in the Work |
by You to the Licensor shall be under the terms and conditions of |
this License, without any additional terms or conditions. |
Notwithstanding the above, nothing herein shall supersede or modify |
the terms of any separate license agreement you may have executed |
with Licensor regarding such Contributions. |
6. Trademarks. This License does not grant permission to use the trade |
names, trademarks, service marks, or product names of the Licensor, |
except as required for reasonable and customary use in describing the |
origin of the Work and reproducing the content of the NOTICE file. |
7. Disclaimer of Warranty. Unless required by applicable law or |
agreed to in writing, Licensor provides the Work (and each |
Contributor provides its Contributions) on an "AS IS" BASIS, |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
implied, including, without limitation, any warranties or conditions |
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
PARTICULAR PURPOSE. You are solely responsible for determining the |
appropriateness of using or redistributing the Work and assume any |
risks associated with Your exercise of permissions under this License. |
8. Limitation of Liability. In no event and under no legal theory, |
whether in tort (including negligence), contract, or otherwise, |
unless required by applicable law (such as deliberate and grossly |
negligent acts) or agreed to in writing, shall any Contributor be |
liable to You for damages, including any direct, indirect, special, |
incidental, or consequential damages of any character arising as a |
result of this License or out of the use or inability to use the |
Work (including but not limited to damages for loss of goodwill, |
work stoppage, computer failure or malfunction, or any and all |
other commercial damages or losses), even if such Contributor |
has been advised of the possibility of such damages. |
9. Accepting Warranty or Additional Liability. While redistributing |
the Work or Derivative Works thereof, You may choose to offer, |
and charge a fee for, acceptance of support, warranty, indemnity, |
or other liability obligations and/or rights consistent with this |
License. However, in accepting such obligations, You may act only |
on Your own behalf and on Your sole responsibility, not on behalf |
of any other Contributor, and only if You agree to indemnify, |
defend, and hold each Contributor harmless for any liability |
incurred by, or claims asserted against, such Contributor by reason |
of your accepting any such warranty or additional liability. |
END OF TERMS AND CONDITIONS |
APPENDIX: How to apply the Apache License to your work. |
To apply the Apache License to your work, attach the following |
boilerplate notice, with the fields enclosed by brackets "[]" |
replaced with your own identifying information. (Don't include |
the brackets!) The text should be enclosed in the appropriate |
comment syntax for the file format. We also recommend that a |
file or class name and description of purpose be included on the |
same "printed page" as the copyright notice for easier |
identification within third-party archives. |
Copyright 2018 Daniel Marschall, ViaThinkSoft |
Licensed under the Apache License, Version 2.0 (the "License"); |
you may not use this file except in compliance with the License. |
You may obtain a copy of the License at |
http://www.apache.org/licenses/LICENSE-2.0 |
Unless required by applicable law or agreed to in writing, software |
distributed under the License is distributed on an "AS IS" BASIS, |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
See the License for the specific language governing permissions and |
limitations under the License. |
/trunk/README.md |
---|
0,0 → 1,18 |
# LogViewer |
**(English)** |
LogViewer is a small tool for Linux that reads out log files (usually from PHP) and saves them in a MySQL database. |
There, the errors are categorized and summarized according to the time and number of occurrences. |
The errors can be sorted and filtered via a web interface. Since the goal is to correct the problems, the error can be hidden with one click. It will then only be displayed if it appears again anyway. |
**(German)** |
LogViewer ist ein kleines Tool für Linux, das Logdateien (üblicherweise von PHP) ausliest und in eine MySQL-Datenbank speichert. |
Dort werden die Fehler kategorisiert und nach Eintrittszeitpunkt und Anzahl zusammengefasst. |
Über ein Webinterface können die Fehler sortiert und gefiltert werden. Da es das Ziel ist, die Fehler zu korrigieren, kann mit einem Klick der Fehler ausgeblendet werden. Er wird dann nur noch eingeblendet, wenn er trotzdem nocheinmal auftritt. |
Property changes: |
Added: svn:mime-type |
+text/markdown |
\ No newline at end of property |
/trunk/TODO |
---|
0,0 → 1,23 |
in loginbereich integrieren (und loggen wer das problem beseitigt hat) |
ein problem für immer ausblenden (anzahlsolved = 9999999999) |
erstes vorkommen in DB loggen |
filtern nach datum |
auto-solve items which are older than X years |
"show more" link at the bottom of the page, to load more |
also, when items are deleted, reload new items at the bottom of the page |
bei modul genau zeigen, von welchem logfile es reinkam! |
Idea: undo functionality |
wie kann man PHP stacktraces gescheit einfügen, sodass die zeilen zusammenhängend bleiben? |
implement PDO |
bug: when a logfile has multiple same lines, e.g. because an error happened 5 times in the same second, then the line is only logged once. but the count should be 5. |
/trunk/ajax.js |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/javascript |
Property changes: |
Added: svn:mime-type |
+application/javascript |
\ No newline at end of property |
/trunk/ajax_cmd.php |
---|
0,0 → 1,93 |
<?php |
/* |
* ViaThinkSoft LogViewer |
* Copyright 2018-2022 Daniel Marschall, ViaThinkSoft |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
if (!isset($_REQUEST['cmd'])) _err('cmd is missing'); |
$hostname = trim(file_get_contents('/etc/hostname')); |
if (file_exists(__DIR__."/config_$hostname.inc.php")) { |
require_once __DIR__."/config_$hostname.inc.php"; |
} else { |
require_once __DIR__.'/config.inc.php'; |
} |
if (file_exists(__DIR__."/db_$hostname.inc.php")) { |
require_once __DIR__."/db_$hostname.inc.php"; |
} else { |
require_once __DIR__.'/db.inc.php'; |
} |
if (file_exists(__DIR__."/auth_$hostname.inc.php")) { |
require_once __DIR__."/auth_$hostname.inc.php"; |
} else { |
require_once __DIR__.'/auth.inc.php'; |
} |
try { |
logviewer_check_access(); |
} catch (Exception $e) { |
_err($e->getMessage()); |
} |
# Please keep this code synchronized with index.php |
$add_filters = logviewer_additional_filter(); |
$hardcoded_filters = empty($add_filters) ? '' : "and ($add_filters)"; |
$hardcoded_filters .= " and (letzter >= DATE_SUB(NOW(),INTERVAL ".MAXYEARS." YEAR))"; |
# Please keep this code synchronized with index.php |
if ($_REQUEST['cmd'] == 'solve') { |
if (!is_numeric($_REQUEST['id'])) _err('Invalid solve id'); |
try { |
if (file_exists(__DIR__."/db_$hostname.inc.php")) { |
require_once __DIR__."/db_$hostname.inc.php"; |
} else { |
require_once __DIR__.'/db.inc.php'; |
} |
if (!logviewer_allow_solvemark()) _err('No permission to mark entries as solved!'); |
} catch (Exception $e) { |
_err($e->getMessage()); |
} |
$res = @db_query('select id from vts_fehlerlog where (id = '.$_REQUEST['id'].') '.$hardcoded_filters); |
if (!$res) _err('mysql query failed'); |
if (db_num_rows($res) == 0) _err('Row not found or no permission given.'); |
$res = @db_query('update vts_fehlerlog set anzahlsolved = anzahl where (id = '.$_REQUEST['id'].') '.$hardcoded_filters); |
if (!$res) _err('mysql query failed'); |
$out = array(); |
$out['success'] = true; |
$out['id'] = $_REQUEST['id']; // give OK to hide the line |
header('Content-Type: application/json'); |
die(json_encode($out)); |
} else { |
_err('unknown cmd'); |
} |
# --- |
function _err($msg) { |
$out = array(); |
$out['success'] = false; |
$out['error'] = $msg; |
header('Content-Type: application/json'); |
die(json_encode($out)); |
} |
/trunk/auth.inc.php |
---|
0,0 → 1,41 |
<?php |
/* |
* ViaThinkSoft LogViewer |
* Copyright 2018-2022 Daniel Marschall, ViaThinkSoft |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
// Please reply this code with your actual implementation |
function logviewer_check_access()/*: void*/ { |
// Here you can add some code for general access. If you don't want the user to access LogViewer, throw an Exception here. |
// if (check_login()) { |
// throw new Exception("Please login first"); |
// } |
} |
function logviewer_allow_solvemark(): bool { |
return true; // allow |
} |
function logviewer_additional_filter(): string { |
$filter = ''; // no filter |
// Example: |
// $filter = '`text` like '%/home/foobar/%' |
return $filter; |
} |
/trunk/backend/.htaccess |
---|
0,0 → 1,3 |
Order Deny,Allow |
Deny From All |
/trunk/backend/insert_logs.sh |
---|
0,0 → 1,223 |
#!/usr/bin/php |
<?php |
/* |
* ViaThinkSoft LogViewer |
* Copyright 2018-2023 Daniel Marschall, ViaThinkSoft |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
if (php_sapi_name() !== 'cli') { |
die("Error: This script can only be called from command line.\n"); |
} |
$hostname = trim(file_get_contents('/etc/hostname')); |
if (file_exists(__DIR__."/../config_$hostname.inc.php")) { |
require_once __DIR__."/../config_$hostname.inc.php"; |
} else { |
require_once __DIR__.'/../config.inc.php'; |
} |
if (file_exists(__DIR__."/../db_$hostname.inc.php")) { |
require_once __DIR__."/../db_$hostname.inc.php"; |
} else { |
require_once __DIR__.'/../db.inc.php'; |
} |
$files = array(); |
foreach (apache_log_locations as $tpl) $files = array_merge($files, glob($tpl)); |
usort($files, function($a,$b) { return filemtime($a) - filemtime($b); }); |
$phpfiles = array(); |
foreach (php_log_locations as $tpl) $phpfiles = array_merge($phpfiles, glob($tpl)); |
usort($phpfiles, function($a,$b) { return filemtime($a) - filemtime($b); }); |
$file_nr = 0; |
$file_max = count($files) + count($phpfiles); |
$TMP_FILE = __DIR__ . '/.insertlogs.cache'; |
if (file_exists($TMP_FILE)) { |
$cont = file_get_contents($TMP_FILE); |
$cache = unserialize($cont); |
} else { |
$cache = array(); |
} |
// Apache Log Files |
foreach ($files as $file) { |
$file_nr++; |
if (isset($cache[$file]) && ($cache[$file] == md5_file($file))) continue; |
if (time()-filemtime($file) > MAX_DAYS_LOGFILE * 3600) continue; |
if (substr($file,-3,3) === '.gz') { |
if (IGNORE_GZ) continue; |
$cont = file_get_contents($file); |
$cont = gzdecode($cont); |
if ($cont === false) continue; |
$lines = explode("\n", $cont); |
} else { |
$lines = file($file); |
} |
$line_no = 0; |
$line_max = count($lines); |
$logfile = removeLogrotateSuffix($file); |
foreach ($lines as $line) { |
$line_no++; |
$line = trim($line); |
if (preg_match('@^\[(.*)\] \[(.*)\] \[(.*)\] \[(.*)\] (.*)$@ismU', $line, $m)) { |
// [Sun Aug 13 15:54:16.054530 2017] [fcgid:warn] [pid 28401] [client 104.236.113.44:52188] mod_fcgid: stderr: PHP Notice: Undefined offset: 11 in /home/d |
$time = $m[1]; |
$modul = $m[2]; |
$text = $m[5]; |
$time = trim(substr($time, 4, 6)).' '.substr($time, -4).' '.substr($time, 11, 8); |
$time_mysql = date('Y-m-d H:i:s', strtotime($time)); |
} else if (preg_match('@^(.+)\|(.+)\|(.+)\|(.+)$@ismU', $line, $m)) { |
// 5.6 | /daten/homes/daniel-marschall/hosts/dracenmarx/public_html/wiki/vendor/oyejorge/less.php/lib:91 | ini | Ini mbstring.internal_encoding is deprecated. |
// A special implementation of PHP codefixer (showing the full path) . TODO: release |
$time = filemtime($file); |
$modul = 'php_codefixer'; |
$text = 'PHP Codefixer: ' . trim($m[4]) . ' in ' . trim($m[2]); |
$time_mysql = date('Y-m-d H:i:s', $time); |
} else { |
continue; |
} |
if (strlen($modul) > 30) { |
echo "Attention: Truncate modul: $modul\n"; |
$modul = substr($modul, 0, 512); |
} |
if (strlen($text) > 512) { |
echo "Attention: Truncate text in file $file: $text\n"; |
$text = substr($text, 0, 512); |
} |
$res = mysql_query("select * from vts_fehlerlog where modul = '".mysql_real_escape_string($modul)."' and logfile = '".mysql_real_escape_string($logfile)."' and text = '".mysql_real_escape_string($text)."';"); |
#echo mysql_error(); |
if (mysql_num_rows($res) > 0) { |
mysql_query("update vts_fehlerlog set anzahl = anzahl + 1, letzter = '$time_mysql' " . |
"where modul = '".mysql_real_escape_string($modul)."' and logfile = '".mysql_real_escape_string($logfile)."' and text = '".mysql_real_escape_string($text)."' and letzter < '".$time_mysql."';"); |
#echo mysql_error(); |
} else { |
mysql_query("insert into vts_fehlerlog (modul, text, anzahl, letzter, logfile) " . |
"values ('".mysql_real_escape_string($modul)."', '".mysql_real_escape_string($text)."', 1, '".$time_mysql."', '".mysql_real_escape_string($logfile)."');"); |
#echo mysql_error(); |
} |
echo "file $file_nr/$file_max (line $line_no/$line_max) \r"; |
} |
$cache[$file] = md5_file($file); |
} |
// PHP Log files |
foreach ($phpfiles as $file) { |
$file_nr++; |
if (isset($cache[$file]) && ($cache[$file] == md5_file($file))) continue; |
if (time()-filemtime($file) > MAX_DAYS_LOGFILE * 3600) continue; |
if (substr($file,-3,3) === '.gz') { |
if (IGNORE_GZ) continue; |
$cont = file_get_contents($file); |
$cont = gzdecode($cont); |
if ($cont === false) continue; |
} else { |
$cont = file_get_contents($file); |
} |
$cont = str_replace("\r", "", $cont); |
$cont = str_replace("\n ", " ", $cont); |
$lines = explode("\n", $cont); |
$line_no = 0; |
$line_max = count($lines); |
$logfile = removeLogrotateSuffix($file); |
foreach ($lines as $line) { |
$line_no++; |
$line = trim($line); |
echo "file $file_nr/$file_max (line $line_no/$line_max) \r"; |
if (preg_match('@^\[(.*)\] ((.*)(\n ){0,1})$@ismU', $line, $m)) { |
# [19-Aug-2017 23:00:54 europe/berlin] PHP Notice: Undefined variable: ssl in /home/viathinksoft/public_html/serverinfo/index.php on line 364 |
$time = $m[1]; |
$modul = ''; |
$text = $m[2]; |
$time = trim(substr($time, 0, 20)); |
$time_mysql = date('Y-m-d H:i:s', strtotime($time)); |
} else { |
continue; |
} |
if (strpos($text, '{"reqId":"') !== false) { |
// For some reason, owncloud or nextcloud seems to write to php_error.log and not in data/nextcloud.log ?? But only sometimes ?? |
// TODO: Should we try to parse this JSON log message? |
// [12-Sep-2023 15:01:24 UTC] {"reqId":"f2uD4QSS9xIjAAWgbeVb","level":3,"time":"2023-09-12T15:01:24+00:00","remoteAddr":"1.2.3.4","user":"--","app":"core","method":"GET","url":"/index.php/settings/admin/overview","message":"Permission denied","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36","version":"27.0.2.1","exception":{"Exception":"RedisException","Message":"Permission denied","Code":0,"Trace":[{"file":"/daten/homes/owncloud/public_html/lib/private/RedisFactory.php","line":137,"function":"pconnect","class":"Redis","type":"->"},{"file":"/daten/homes/owncloud/public_html/lib/private/RedisFactory.php","line":178,"function":"create","class":"OC\\RedisFactory","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/daten/homes/owncloud/public_html/lib/private/Memcache/Redis.php","line":66,"function":"getInstance","class":"OC\\RedisFactory","type":"->"},{"file":"/daten/homes/owncloud/public_html/lib/private/Memcache/Redis.php","line":72,"function":"getCache","class":"OC\\Memcache\\Redis","type":"->"},{"file":"/daten/homes/owncloud/public_html/lib/private/App/InfoParser.php","line":58,"function":"get","class":"OC\\Memcache\\Redis","type":"->"},{"file":"/daten/homes/owncloud/public_html/lib/private/App/AppManager.php","line":732,"function":"parse","class":"OC\\App\\InfoParser","type":"->"},{"file":"/daten/homes/owncloud/public_html/lib/private/legacy/OC_App.php","line":434,"function":"getAppInfo","class":"OC\\App\\AppManager","type":"->"},{"file":"/daten/homes/owncloud/public_html/lib/private/AppFramework/App.php","line":71,"function":"getAppInfo","class":"OC_App","type":"::"},{"file":"/daten/homes/owncloud/public_html/lib/private/legacy/OC_App.php","line":155,"function":"buildAppNamespace","class":"OC\\AppFramework\\App","type":"::"},{"file":"/daten/homes/owncloud/public_html/lib/private/AppFramework/Bootstrap/Coordinator.php","line":119,"function":"registerAutoloading","class":"OC_App","type":"::"},{"file":"/daten/homes/owncloud/public_html/lib/private/AppFramework/Bootstrap/Coordinator.php","line":90,"function":"registerApps","class":"OC\\AppFramework\\Bootstrap\\Coordinator","type":"->"},{"file":"/daten/homes/owncloud/public_html/lib/base.php","line":703,"function":"runInitialRegistration","class":"OC\\AppFramework\\Bootstrap\\Coordinator","type":"->"},{"file":"/daten/homes/owncloud/public_html/lib/base.php","line":1180,"function":"init","class":"OC","type":"::"},{"file":"/daten/homes/owncloud/public_html/index.php","line":34,"args":["/daten/homes/owncloud/public_html/lib/base.php"],"function":"require_once"}],"File":"/daten/homes/owncloud/public_html/lib/private/RedisFactory.php","Line":137,"CustomMessage":"--"}} |
continue; |
} |
if (strlen($modul) > 30) { |
echo "Attention: Truncate modul: $modul\n"; |
$modul = substr($modul, 0, 512); |
} |
if (strlen($text) > 512) { |
echo "Attention: Truncate text in file $file: $text\n"; |
$text = substr($text, 0, 512); |
} |
$res = mysql_query("select * from vts_fehlerlog where modul = '".mysql_real_escape_string($modul)."' and logfile = '".mysql_real_escape_string($logfile)."' and text = '".mysql_real_escape_string($text)."';"); |
#echo mysql_error(); |
if (mysql_num_rows($res) > 0) { |
mysql_query("update vts_fehlerlog set anzahl = anzahl + 1, letzter = '$time_mysql' " . |
"where modul = '".mysql_real_escape_string($modul)."' and logfile = '".mysql_real_escape_string($logfile)."' and text = '".mysql_real_escape_string($text)."' and letzter < '".$time_mysql."';"); |
#echo mysql_error(); |
} else { |
mysql_query("insert into vts_fehlerlog (modul, text, anzahl, letzter, logfile) " . |
"values ('".mysql_real_escape_string($modul)."', '".mysql_real_escape_string($text)."', 1, '".$time_mysql."', '".mysql_real_escape_string($logfile)."');"); |
#echo mysql_error(); |
} |
} |
$cache[$file] = md5_file($file); |
} |
echo "\n"; |
file_put_contents($TMP_FILE, serialize($cache)); |
// Prune old logs |
mysql_query('delete from vts_fehlerlog where letzter < date_sub(now(),interval 3 year)'); |
# --- |
function removeLogrotateSuffix($filename) { |
$filename = preg_replace('@\\.(\\d+)(\\.gz){0,1}$@ismU', '', $filename); |
return $filename; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/backend |
---|
Property changes: |
Added: svn:ignore |
+.insertlogs.cache |
+ |
/trunk/config.inc.php |
---|
0,0 → 1,36 |
<?php |
/* |
* ViaThinkSoft LogViewer |
* Copyright 2018-2022 Daniel Marschall, ViaThinkSoft |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
define('COUNT', 200); |
define('MAXYEARS', 1); |
define('apache_log_locations', array('/home/*/log/error*.log*', '/home/*/hosts/*/log/error*.log*', '/var/log/apache2/error*.log*')); |
define('php_log_locations', array('/home/*/log/php_error*.log*', '/home/*/hosts/*/log/php_error*.log*', '/var/log/php/error.log*')); |
// 0 = No source is displayed |
// 1 = Columns "source" (=logfile) and "module" (module) |
// 2 = Column "user" which tries to find out the user's home dir from the logfile |
define('SOURCE_STYLE', 2); |
// Don't look at .gz files. But if you enable it, then it is important that you run insert_logs before log-rotating. |
define('IGNORE_GZ', false); |
define('MAX_DAYS_LOGFILE', 30); // only read the logfiles of the last 30 days |
/trunk/db.inc.php |
---|
0,0 → 1,116 |
<?php |
/* |
* ViaThinkSoft LogViewer |
* Copyright 2018-2022 Daniel Marschall, ViaThinkSoft |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
// Please replace this code with your actual implementation |
db_connect('localhost', 'root', ''); |
db_select_db('logviewer'); |
# --- |
// Liefert die Anzahl der Zeilen im Ergebnis |
function db_num_rows($result) { |
if (!$result) { |
$err = db_error(); |
throw new Exception("Called db_num_rows() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err")); |
} |
return $result->num_rows; |
} |
// Liefert eine Ergebniszeile als Objekt |
function db_fetch_object($result, $class_name="stdClass", $params=null) { |
if (!$result) { |
$err = db_error(); |
throw new Exception("Called db_fetch_object() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err")); |
} |
if ($params) { |
return $result->fetch_object($class_name, $params); |
} else { |
return $result->fetch_object($class_name); |
} |
} |
// Öffnet eine Verbindung zu einem MySQL-Server |
function db_connect($server=null, $username=null, $password=null, $new_link=false, $client_flags=0) { |
global $vts_mysqli; |
$ary = explode(':', $server); |
$host = $ary[0]; |
$ini_port = ini_get("mysqli.default_port"); |
$port = isset($ary[1]) ? (int)$ary[1] : ($ini_port ? (int)$ini_port : 3306); |
if (is_null($server)) $port = ini_get("mysqli.default_host"); |
if (is_null($username)) $port = ini_get("mysqli.default_user"); |
if (is_null($password)) $port = ini_get("mysqli.default_password"); |
$vts_mysqli = new mysqli($host, $username, $password, /*dbname*/'', $port, ini_get("mysqli.default_socket")); |
return (empty($vts_mysqli->connect_error) && ($vts_mysqli->connect_errno == 0)) ? $vts_mysqli : false; |
} |
// Schließt eine Verbindung zu MySQL |
function db_close($link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_close(). No valid connection to server."); |
return $li->close(); |
} |
// Liefert den Fehlertext der zuvor ausgeführten MySQL Operation |
function db_error($link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_error(). No valid connection to server."); |
return !empty($li->connect_error) ? $li->connect_error : $li->error; |
} |
// Maskiert spezielle Zeichen innerhalb eines Strings für die Verwendung in einer SQL-Anweisung |
function db_real_escape_string($unescaped_string, $link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_real_escape_string(). No valid connection to server."); |
return $li->escape_string($unescaped_string); |
} |
// Sendet eine Anfrage an MySQL |
function db_query($query, $link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_query(). No valid connection to server."); |
return $li->query($query, $resultmode=MYSQLI_STORE_RESULT); |
} |
// Auswahl einer MySQL Datenbank |
function db_select_db($database_name, $link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_select_db(). No valid connection to server."); |
return $li->select_db($database_name); |
} |
// Liefert die ID, die in der vorherigen Abfrage erzeugt wurde |
function db_insert_id($link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_insert_id(). No valid connection to server."); |
return $li->insert_id; |
} |
/trunk/index.php |
---|
0,0 → 1,219 |
<?php |
/* |
* ViaThinkSoft LogViewer |
* Copyright 2018-2023 Daniel Marschall, ViaThinkSoft |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
$hostname = trim(file_get_contents('/etc/hostname')); |
if (file_exists(__DIR__."/config_$hostname.inc.php")) { |
require_once __DIR__."/config_$hostname.inc.php"; |
} else { |
require_once __DIR__.'/config.inc.php'; |
} |
if (file_exists(__DIR__."/db_$hostname.inc.php")) { |
require_once __DIR__."/db_$hostname.inc.php"; |
} else { |
require_once __DIR__.'/db.inc.php'; |
} |
if (file_exists(__DIR__."/auth_$hostname.inc.php")) { |
require_once __DIR__."/auth_$hostname.inc.php"; |
} else { |
require_once __DIR__.'/auth.inc.php'; |
} |
try { |
logviewer_check_access(); |
} catch (Exception $e) { |
die('<h1>ViaThinkSoft LogViewer - Error</h1><p>'.$e->getMessage().'</p>'); |
} |
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : ''; |
if ($sort == '') $sort = 'anzahl'; |
if (($sort != 'anzahl') && ($sort != 'letzter') && ($sort != 'random')) die('Sort falsch'); |
# Please keep this code synchronized with ajax_cmd.php |
$add_filters = logviewer_additional_filter(); |
$hardcoded_filters = empty($add_filters) ? '' : " and ($add_filters)"; |
$hardcoded_filters .= " and (letzter >= DATE_SUB(NOW(),INTERVAL ".MAXYEARS." YEAR))"; |
# Please keep this code synchronized with ajax_cmd.php |
$filter_add = ''; |
if (isset($_REQUEST['filter'])) { |
$ary = explode(' ', $_REQUEST['filter']); |
foreach ($ary as $a) { |
$a = trim($a); |
if ($a == '') continue; |
if (substr($a,0,1) == '-') { |
$negate = "NOT "; |
$a = substr($a, 1); // remove "-" |
} else { |
$negate = " "; |
} |
$filter_add .= " and text $negate like '".db_real_escape_string('%'.$a.'%')."' "; |
} |
} |
$where = "(anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters; |
if (isset($_REQUEST['solveall']) && logviewer_allow_solvemark()) { |
db_query("update vts_fehlerlog set anzahlsolved = anzahl where $where"); |
header('location:?sort='.urlencode($sort)); // avoid F5 |
die(); |
} |
?> |
<html> |
<head> |
<title>ViaThinkSoft LogViewer</title> |
<script src="ajax.js"></script> |
<link href="style<?php if (file_exists("style_$hostname.css")) echo "_$hostname"; ?>.css" rel="stylesheet" type="text/css"> |
</head> |
<body> |
<h1>ViaThinkSoft LogViewer</h1> |
<form method="GET" action="index.php"> |
<input type="hidden" name="sort" value="<?php echo htmlentities($sort); ?>"> |
<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 |
if (isset($_REQUEST['filter'])) { |
echo ' <a href="?sort='.htmlentities($sort).'">Clear filter</a>'; |
if (logviewer_allow_solvemark()) { |
echo ' | <a href="?sort='.htmlentities($sort).'&solveall=1&filter='.urlencode($_REQUEST['filter']).'" onclick="return confirm(\'Are you sure?\');">Solve all</a>'; |
} |
} |
?></p> |
<p><font size="-3">Search terms divided with whitespace. Prepend hyphen to exclude a search term. Only field "Message" will be searched.</font></p> |
</form> |
<?php |
if (!empty($add_filters)) { |
echo '<span class="filter_hint">Showing max. '.COUNT.' results of max. '.MAXYEARS.' years; Hardcoded filter: '.htmlentities($add_filters).'</span>'; |
} else { |
echo '<span class="filter_hint">Showing max. '.COUNT.' results of max. '.MAXYEARS.' years</span>'; |
} |
?> |
<div id="sort">Sort by: <?php |
if ($sort == 'anzahl') { |
echo '<span class="selected_menu">Occurrences</span>'; |
} else { |
echo '<a href="?sort=anzahl'.((isset($_REQUEST['filter'])) ? '&filter='.urlencode($_REQUEST['filter']) : '').'">Occurrences</a>'; |
} |
?> | <?php |
if ($sort == 'letzter') { |
echo '<span class="selected_menu">Last occurrence</span>'; |
} else { |
echo '<a href="?sort=letzter'.((isset($_REQUEST['filter'])) ? '&filter='.urlencode($_REQUEST['filter']) : '').'">Last occurrence</a>'; |
} |
?> | <?php |
if ($sort == 'random') { |
echo '<span class="selected_menu">Random order</span>'; |
} else { |
echo '<a href="?sort=random'.((isset($_REQUEST['filter'])) ? '&filter='.urlencode($_REQUEST['filter']) : '').'">Random order</a>'; |
} |
?> (<span id="count"><?php |
$res = db_query("select count(*) as cnt from vts_fehlerlog where $where;"); |
$row = db_fetch_object($res); |
echo $row->cnt; |
?></span>)</div> |
<table border="1" width="100%"> |
<thead> |
<tr> |
<?php |
if (SOURCE_STYLE == 0) { |
// nothing |
} else if (SOURCE_STYLE == 1) { |
?> |
<td>Source</td> |
<td>Module</td> |
<?php |
} else if (SOURCE_STYLE == 2) { |
?> |
<td>User</td> |
<?php |
} |
?> |
<?php if (logviewer_allow_solvemark()) { ?><td>Mark as...</td><?php } ?> |
<td>Count</td> |
<td>Last occurrence</td> |
<td>Message</td> |
</tr> |
</thead> |
<tbody> |
<tr> |
<?php |
$odd = true; |
if ($sort == 'letzter') { |
$res = db_query("select * from vts_fehlerlog where $where order by letzter desc, anzahl desc, id asc limit ".COUNT); |
} else if ($sort == 'anzahl') { |
$res = db_query("select * from vts_fehlerlog where $where order by anzahl desc, letzter desc, id asc limit ".COUNT); |
} else if ($sort == 'random') { |
$res = db_query("select * from vts_fehlerlog where $where order by RAND() limit ".COUNT); |
} |
while ($row = db_fetch_object($res)) { |
$text = htmlentities($row->text); |
$text = preg_replace('@ ([^ ]{2,}) on line@ismU', ' <a href="?sort='.urlencode($sort).'&filter=\1">\1</a> on line', $text); // TODO: urlencode \1 |
$text = preg_replace('@(at|in) ([^ ]{2,}):(\d+)@ismU', '\1 <a href="?sort='.urlencode($sort).'&filter=\2">\2</a>:\3', $text); // TODO: urlencode \2 |
$anzahl = htmlentities($row->anzahl); |
if ($row->anzahlsolved != 0) $anzahl .= '<br>('.$row->anzahlsolved.')'; |
$class = $odd ? 'tr_odd' : 'tr_even'; |
$odd = !$odd; |
echo '<tr id="line'.$row->id.'" class="'.$class.'">'; |
if (SOURCE_STYLE == 0) { |
// nothing |
} else if (SOURCE_STYLE == 1) { |
echo '<td>'.htmlentities($row->logfile).'</td>'; |
echo '<td>'.htmlentities($row->modul).'</td>'; |
} else { |
$user = preg_match('@/home/(.+)/@sU', $row->logfile, $m) ? $m[1] : ((strpos($row->logfile, '/root/') === 0) ? 'root' : ''); |
echo '<td>'.htmlentities($user).'</td>'; |
} |
if (logviewer_allow_solvemark()) echo '<td><a href="javascript:_solve('.$row->id.')">Solved</a></td>'; |
echo '<td>'.$anzahl.'</td>'; |
echo '<td>'.htmlentities($row->letzter).'</td>'; |
echo '<td>'.$text.'</td>'; |
echo '</tr>'; |
flush(); |
} |
?> |
</tr> |
</tbody> |
</table> |
</body> |
</html> |
/trunk/logviewer.sql |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/x-sql |
Property changes: |
Added: svn:mime-type |
+application/x-sql |
\ No newline at end of property |
/trunk/phpstan.neon.dist |
---|
0,0 → 1,18 |
parameters: |
level: 5 |
fileExtensions: |
- php |
- phps |
- sh |
paths: |
- . |
excludePaths: |
analyseAndScan: |
- .phpstan.tmp |
tmpDir: .phpstan.tmp |
bootstrapFiles: |
- config.inc.php |
ignoreErrors: |
- '#is always (true|false)\.#' |
#- '#Call to function assert\(\) with false will always evaluate to false\.#' |
#- '#with no typehint specified\.#' |
/trunk/style.css |
---|
0,0 → 1,25 |
body { |
background-color:#333333; |
color:#BBBBBB; |
font-family:Arial; |
} |
.filter_hint { |
font-size: small; |
} |
.selected_menu { |
text-decoration:underline; |
} |
a { |
color:#E0E000; |
} |
tr:hover { |
background-color: rgba(90, 90, 90, 1); |
} |
thead { |
font-weight:bold; |
background-color:#555555; |
} |
#sort { |
padding-top:20px; |
padding-bottom:20px; |
} |
Property changes: |
Added: svn:mime-type |
+text/css |
\ No newline at end of property |
/trunk/. |
---|
Property changes: |
Added: svn:ignore |
+auth_*.inc.php |
+db_*.inc.php |
+config_*.inc.php |
+style_*.css |
+.phpstan.tmp |
+phpstan.neon |
+ |