Fixed sign.php to handle non-continuous id values

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2022-03-11 20:21:25 +01:00
parent 333dd08d36
commit 1931caec2b

View File

@ -128,27 +128,27 @@ function get_hash_values() {
if($last_id == 0) { if($last_id == 0) {
$start_id = TSA_START_ID; $start_id = TSA_START_ID;
if(MODE == 'unit') { $stop_id = $start_id + TSA_STAMP_REQUEST_UNIT_SIZE - 1; } } else {
else { $stop_id = 1000000000; }
}
else {
$start_id = $last_id + 1; $start_id = $last_id + 1;
if(MODE == 'unit') { $stop_id = $start_id + TSA_STAMP_REQUEST_UNIT_SIZE - 1; }
else { $stop_id = 1000000000; }
} }
$query = $db->query("SELECT id, digest FROM " . TABLE_META . " WHERE id >= ? AND id <= ? ORDER BY id", array($start_id, $stop_id)); 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) { foreach($query->rows as $q) {
$count++; $count++;
$last_id = $q['id'];
$s .= $q['digest']; $s .= $q['digest'];
} }
if(MODE == 'time') { $stop_id = $start_id + $count - 1; }
return [ return [
START_ID => $start_id, START_ID => $start_id,
STOP_ID => $stop_id, STOP_ID => $last_id,
COUNT => $count, COUNT => $count,
HASH_VALUE => hash(ALGO, $s) HASH_VALUE => hash(ALGO, $s)
]; ];