getMessage() . "\n"); } $data[RESPONSE_STRING] = $response[RESPONSE_STRING]; $data[RESPONSE_TIME] = $response[RESPONSE_TIME]; $rc = store_results($data); if($rc == 1) { syslog(LOG_INFO, "signed " . $data[COUNT] . " messages (" . $data[START_ID] . "-" . $data[STOP_ID] . ") on @" . $data[RESPONSE_TIME]); } else { syslog(LOG_INFO, "ERROR: failed to sign " . $data[COUNT] . " messages (" . $data[START_ID] . "-" . $data[STOP_ID] . ") on @" . $data[RESPONSE_TIME]); } function get_last_entry_from_timestamp_table() { $db = Registry::get('db'); $query = $db->query("SELECT start_id, stop_id FROM " . TABLE_TIMESTAMP . " WHERE id < 100000000000 ORDER BY id DESC LIMIT 1"); if($query->num_rows == 0) { return 0; } return $query->row[STOP_ID]; } function get_hash_values() { $s = ''; $count = 0; $db = Registry::get('db'); $last_id = get_last_entry_from_timestamp_table(); if($last_id == 0) { $start_id = TSA_START_ID; } else { $start_id = $last_id + 1; } if(MODE == 'unit') { $limit = TSA_STAMP_REQUEST_UNIT_SIZE; } else { $limit = 100000; // stay well below default PHP memory_limit } $query = $db->query("SELECT id, digest FROM " . TABLE_META . " WHERE id >= ? ORDER BY id LIMIT $limit", array($start_id)); foreach($query->rows as $q) { $count++; $last_id = $q['id']; $s .= $q['digest']; } return [ START_ID => $start_id, STOP_ID => $last_id, COUNT => $count, HASH_VALUE => hash(ALGO, $s) ]; } function store_results($data = array()) { $db = Registry::get('db'); $db->query("INSERT INTO " . TABLE_TIMESTAMP . " (start_id, stop_id, hash_value, `count`, response_time, response_string) VALUES(?,?,?,?,?,?)", array($data[START_ID], $data[STOP_ID], $data[HASH_VALUE], $data[COUNT], $data[RESPONSE_TIME], $data[RESPONSE_STRING])); return $db->countAffected(); } function display_help() { $phpself = basename(__FILE__); echo "\nUsage: $phpself --webui [PATH] [OPTIONS...]\n\n"; echo "\t--webui=\"[REQUIRED: path to the Piler WebUI Directory]\"\n\n"; echo "options:\n"; echo "\t--mode time|unit (default: unit)\n"; echo "\t-v Provide a verbose output\n"; echo "\t-h Prints this help screen and exits\n"; }