From 14675eb397487df6ffa55e399fa585fee7f41da1 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 7 Jan 2016 17:35:57 +0100 Subject: more compact code, correctly maintain link --- it.class | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/it.class b/it.class index 39a1372..3c9c46c 100644 --- a/it.class +++ b/it.class @@ -76,9 +76,7 @@ static function log($name /* ... */) { $args = func_get_args(); $name = array_shift($args); - if (is_array($args[0])) - $p = array_shift($args); - $timestamp = $p['datetime'] ? strtotime($p['datetime']) : time(); + $timestamp = is_array($args[0]) && ($p = array_shift($args)) && $p['datetime'] ? strtotime($p['datetime']) : time(); $line = date("Y-m-d H:i:s", $timestamp) . "\t" . implode("\t", $args) . "\n"; $basefn = substr($name, 0, 1) == "/" ? $name : $GLOBALS['ULTRAHOME'] . "/log/$name"; $fullfn = $basefn . "-" . date('Ymd', $timestamp); @@ -93,7 +91,8 @@ static function log($name /* ... */) @chmod("$fullfn.$tmp", 0664); @rename("$fullfn.$tmp", $fullfn); @unlink($basefn); - @symlink($fullfn, $basefn); + if (@readlink($basefn) < basename($fullfn)) + @symlink($fullfn, $basefn); } file_put_contents($fullfn, $line, FILE_APPEND); -- cgit v1.2.3