summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2016-01-07 17:35:57 +0100
committerUrban Müller2016-01-07 17:35:57 +0100
commit14675eb397487df6ffa55e399fa585fee7f41da1 (patch)
tree4b04e44cf969664b5bc8ee0e435ef283537d4143
parent81cf679bdb76ca49364bae20ff9a90f52a8cf07a (diff)
downloaditools-14675eb397487df6ffa55e399fa585fee7f41da1.tar.gz
itools-14675eb397487df6ffa55e399fa585fee7f41da1.tar.bz2
itools-14675eb397487df6ffa55e399fa585fee7f41da1.zip
more compact code, correctly maintain link
-rw-r--r--it.class7
1 files 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);