&1; echo $?'); if ($erg != 'Signature Verified' . "\n" . '0' . "\n") { print($erg); die(); } unlink($sig_file); unlink($msg_file); $result = $db->query('SELECT * FROM `computer_time` WHERE `name`="' . $key . '"'); $row = $result->fetchArray(); if (!$row) { print($key . ' is not known.'); die(); } $aktiv = $row['aktiv']; $bis = strtotime($row['bis']); $von = strtotime($row['von']); log_to_file('from_db ' . $key . ' ' . $_POST['msg'] . ' ' . $aktiv . ' ' . $von . ' ' . $bis); if ($bis < $von) { $aktiv = 0; $bis = $von; } $bis = $bis + 30*60*(floor(time()/60/60/24) - floor($von/60/60/24)); if ($aktiv) { $von = time(); } $noch = $bis - $von; if ($noch < 0) { $noch = 0; } if ($noch > 4*60*60) { $noch = 4*60*60; } print($noch . "\n"); switch ($_POST['msg']) { case 'start': $aktiv = 1; break; ;; case 'stop': $aktiv = 0; break; ;; default: print($_POST['msg'] . ' unknown'); die(); ;; } if ($noch == 0) { $aktiv = 0; } log_to_file('to_db ' . $key . ' ' . $aktiv . ' ' . $von . ' ' . $bis); $db -> exec( 'UPDATE `computer_time`' . ' SET `aktiv`=' . $aktiv . ',' . '`von`="' . date('Y-m-d H:i:s', time()) . '",' . '`bis`="' . date('Y-m-d H:i:s', time() + $noch) . '"' . ' WHERE `name`="' . $key . '"'); die(); } $result = $db->query('select * from `computer_time`'); ?>