&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(); } $host = $row['host']; $bis = strtotime($row['bis']); $von = strtotime($row['von']); log_to_file('from_db ' . $key . ' ' . $_POST['msg'] . ' ' . $host . ' ' . $von . ' ' . $bis); if ($bis < $von) { $host = NULL; $bis = $von; } $bis = $bis + 30*60*(floor($now/60/60/24) - floor($von/60/60/24)); if (!is_null($host)) { $von = $now; } $noch = $bis - $von; if ($noch < 0) { $noch = 0; } if ($noch > 4*60*60) { $noch = 4*60*60; } $msg_parts = explode(' ', $_POST['msg'], 2); if ((1<=date('w')) && (date('w')<=5) && (date('G')<16)) { print("0\n"); } else { print($noch . "\n"); } switch ($msg_parts[1]) { case 'start': $host = $msg_parts[0]; break; ;; case 'stop': if ($host == $msg_parts[0]) { $host = NULL; } break; ;; default: print($_POST['msg'] . ' unknown'); die(); ;; } if ($noch == 0) { $host = NULL; } $von = date('Y-m-d H:i:s', $now); $bis = date('Y-m-d H:i:s', $now + $noch); if (is_null($host)) { $print_host = 'NULL'; $host = 'NULL'; } else { $print_host = $host; $host = 'unhex(' . "'" . bin2hex($host) . "'" . ')'; } log_to_file('to_db ' . $key . ' ' . $print_host . ' ' . $von . ' ' . $bis); $db -> exec( 'UPDATE `computer_time`' . ' SET `host`=' . $host . ',' . '`von`="' . $von . '",' . '`bis`="' . $bis . '"' . ' WHERE `name`="' . $key . '"'); die(); } $result = $db->query('select * from `computer_time`'); $is_openmetrics = array_key_exists('openmetrics', $_GET); if ($is_openmetrics) { print('#HELP computer_time_left Available computer time in seconds.' . "\n"); print('#TYPE computer_time_left gauge' . "\n"); } else { print('' . "\n"); } while ($row = $result->fetchArray()) { $bis = strtotime($row['bis']); $von = strtotime($row['von']); $bis = $bis + 30*60*(floor($now/60/60/24) - floor($von/60/60/24)); if (!is_null($row['host'])) { $von = $now; } $noch = $bis - $von; if ($noch < 0) { $noch = 0; } if ($noch > 4*60*60) { $noch = 4*60*60; } if ($is_openmetrics) { print('computer_time_left{who="' . $row['name'] . '"} ' . $noch . "\n"); continue; } print('' . "\n"); } if (!$is_openmetrics) { print ('
' . $row['name'] . '' . date('Y-m-d H:i:s', $bis) . ' (' . $noch . ')'); print('' . $row['host'] . '
' . "\n"); }