format('Y-m-d')}";
// extremely crap but we only need consistency
$seed = hash('xxh128', $hash_data, true);
$randeng = new \Random\Engine\PcgOneseq128XslRr64($seed);
$rng = new \Random\Randomizer($randeng);
$key = $rng->pickArrayKeys($titles, 1)[0];
if (array_key_exists('sub', $titles[$key])) {
echo "
{$titles[$key]['main']}
\n";
} else {
echo "
{$titles[$key]['main']}
\n";
}
}
function format_size($size) {
if ($size < 1000) {
return "$size B";
} else if ($size < 1000000) {
// who needs floats?
$str = "$size";
$whole = substr($str, 0, strlen($str) - 3);
$frac = substr($str, strlen($str) - 3, 2);
return "$whole.$frac KB";
} else {
$str = "$size";
$whole = substr($str, 0, strlen($str) - 6);
$frac = substr($str, strlen($str) - 6, 2);
return "$whole.$frac MB";
}
}
$public_name = '';
$mode = AppMode::Index;
try {
$db = new SQLite3(DB_NAME, SQLITE3_OPEN_READONLY);
} catch (Exception $e) {
// you know, we might want to log that somewhere
$mode = AppMode::DbError;
}
if (isset($_SERVER['QUERY_STRING'])) {
$qs = $_SERVER['QUERY_STRING'];
if (str_starts_with($qs, '/') &&
$qs !== $_SERVER['SCRIPT_NAME']) { // php-fpm plz
$public_name = substr($_SERVER['QUERY_STRING'], 1);
}
}
if (strlen($public_name) && isset($db)) {
$mode = AppMode::Image;
$stmt = $db->prepare('SELECT timestamp, internal_path FROM pics WHERE public_name = :p');
$stmt->bindValue(':p', $public_name);
$res = $stmt->execute();
// those extra $res checks make it fugly, but whatever
if ($res !== false) {
$row = $res->fetchArray();
if ($row !== false) {
$timestamp = $row['timestamp'];
$internal_path = $row['internal_path'];
$stmt->close();
$stmt = $db->prepare('SELECT public_name FROM pics WHERE timestamp < :t ORDER BY timestamp DESC LIMIT 1');
$stmt->bindValue(':t', $timestamp, SQLITE3_INTEGER);
$res = $stmt->execute();
if ($res !== false) {
$row = $res->fetchArray();
if ($row !== false) {
$prev_name = $row['public_name'];
$stmt->close();
} else {
$stmt->close();
// loop back to the top
$res = $db->query('SELECT public_name FROM pics ORDER BY timestamp DESC LIMIT 1');
if ($res !== false) {
$row = $res->fetchArray();
$prev_name = $row['public_name'];
$res->finalize();
} else {
$mode = AppMode::DbError;
}
}
} else {
$mode = AppMode::DbError;
}
} else {
$mode = AppMode::FourOhFour;
$stmt->close();
}
} else {
$mode = AppMode::DbError;
}
}
if ($mode == AppMode::FourOhFour) {
http_response_code(404);
} else if ($mode == AppMode::DbError) {
http_response_code(500);
}
// echo "mode={$mode->name} timestamp=$timestamp internal_path=$internal_path prev_name=$prev_name\n";
?>
pics.dosamp.net 0.10a - Wir bohren einfach weiter
pics.dosamp.net
404
Datenbank-Fehler
Tipp: Klicke einfach auf das Bild, um das nächste zu sehen.
oh neim das SQLite ist putt
Das haben wir nicht mehr. Kriegen wir auch nicht mehr rein.
Filename
Size
Date
query("SELECT public_name, size, whflag, DATE(timestamp, 'unixepoch') as formatted_date FROM pics ORDER BY timestamp DESC");
if ($res !== false) {
while (($row = $res->fetchArray()) !== false) {
$pn = $row['public_name'];
$size = format_size($row['size']);
$date = $row['formatted_date'];
if ($row['whflag']) {
echo "