diff options
author | Abinoam P. Marques Jr. <abinoam@gmail.com> | 2012-02-19 09:56:14 -0800 |
---|---|---|
committer | Abinoam P. Marques Jr. <abinoam@gmail.com> | 2012-02-19 09:56:14 -0800 |
commit | f81e9ee3b2ef79d14ebd6ef844a62e7dcf210a61 (patch) | |
tree | da64f915f12139703a5e11ef416bc2c1f7e811e6 | |
parent | 5734d5f357742814b56d3d8e0e6daf2e86e793d0 (diff) | |
parent | dedfc300a050f3d72840ca02515d483e90965a58 (diff) | |
download | volse-hubzilla-f81e9ee3b2ef79d14ebd6ef844a62e7dcf210a61.tar.gz volse-hubzilla-f81e9ee3b2ef79d14ebd6ef844a62e7dcf210a61.tar.bz2 volse-hubzilla-f81e9ee3b2ef79d14ebd6ef844a62e7dcf210a61.zip |
Merge pull request #39 from abinoam/logfile
Logfile
-rwxr-xr-x | mod/admin.php | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/mod/admin.php b/mod/admin.php index c79af8d5b..028ed8624 100755 --- a/mod/admin.php +++ b/mod/admin.php @@ -635,23 +635,36 @@ function admin_page_logs(&$a){ $t = get_markup_template("admin_logs.tpl"); $f = get_config('system','logfile'); - $size = filesize($f); - if($size > 5000000 || $size < 0) - $size = 5000000; $data = ''; - $fp = fopen($f,'r'); - if($fp) { - $seek = fseek($fp,0-$size,SEEK_END); - if($seek === 0) { - fgets($fp); // throw away the first partial line - $data = escape_tags(fread($fp,$size)); - while(! feof($fp)) - $data .= escape_tags(fread($fp,4096)); - } - fclose($fp); - } + if(!file_exists($f)) { + $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is +readable."); + } + else { + $fp = fopen($f, 'r'); + if(!$fp) { + $data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable."); + } + else { + $fstat = fstat($fp); + $size = $fstat['size']; + if($size != 0) + { + if($size > 5000000 || $size < 0) + $size = 5000000; + $seek = fseek($fp,0-$size,SEEK_END); + if($seek === 0) { + fgets($fp); // throw away the first partial line + $data = escape_tags(fread($fp,$size)); + while(! feof($fp)) + $data .= escape_tags(fread($fp,4096)); + } + } + fclose($fp); + } + } return replace_macros($t, array( '$title' => t('Administration'), |