diff options
-rw-r--r-- | computer-time-limit.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/computer-time-limit.php b/computer-time-limit.php index fd23b30..b81081d 100644 --- a/computer-time-limit.php +++ b/computer-time-limit.php @@ -1,10 +1,11 @@ <?php $db = new SQLite3('../backstage/computer-time-limit/computer-time-limit.sqlite'); +$now = time(); function log_to_file($line) { $handle = fopen('../backstage/computer-time-limit/log', 'a'); - fwrite($handle, time() . ' ' . $line . "\n"); + fwrite($handle, $now . ' ' . $line . "\n"); fclose($handle); } @@ -46,9 +47,9 @@ if (array_key_exists('msg', $_POST) && array_key_exists('sig', $_POST)) { $aktiv = 0; $bis = $von; } - $bis = $bis + 30*60*(floor(time()/60/60/24) - floor($von/60/60/24)); + $bis = $bis + 30*60*(floor($now/60/60/24) - floor($von/60/60/24)); if ($aktiv) { - $von = time(); + $von = $now; } $noch = $bis - $von; if ($noch < 0) { @@ -76,8 +77,8 @@ if (array_key_exists('msg', $_POST) && array_key_exists('sig', $_POST)) { if ($noch == 0) { $aktiv = 0; } - $von = date('Y-m-d H:i:s', time()); - $bis = date('Y-m-d H:i:s', time() + $noch); + $von = date('Y-m-d H:i:s', $now); + $bis = date('Y-m-d H:i:s', $now + $noch); log_to_file('to_db ' . $key . ' ' . $aktiv . ' ' . $von . ' ' . $bis); $db -> exec( 'UPDATE `computer_time`' . @@ -98,7 +99,7 @@ while ($row = $result->fetchArray()) { $bis = strtotime($row['bis']); $von = strtotime($row['von']); if ($row['aktiv']) { - $von = time(); + $von = $now; } $noch = $bis - $von; |