diff options
author | Urban Müller | 2016-01-07 17:35:57 +0100 |
---|---|---|
committer | Urban Müller | 2016-01-07 17:35:57 +0100 |
commit | 14675eb397487df6ffa55e399fa585fee7f41da1 (patch) | |
tree | 4b04e44cf969664b5bc8ee0e435ef283537d4143 /it.class | |
parent | 81cf679bdb76ca49364bae20ff9a90f52a8cf07a (diff) | |
download | itools-14675eb397487df6ffa55e399fa585fee7f41da1.tar.gz itools-14675eb397487df6ffa55e399fa585fee7f41da1.tar.bz2 itools-14675eb397487df6ffa55e399fa585fee7f41da1.zip |
more compact code, correctly maintain link
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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); |