<?

// Yuba image 0.0.1

$db = $_GET['db'];
$id = $_GET['id'];

$db_file = "db/".$db.".sqlite3";

if (!file_exists($db_file)) {	
	echo "Can't find db!";
	die;
	}

$dbo = new PDO("sqlite:".$db_file);
$dbo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

header('Content-Type: image/png');
echo $dbo->query("SELECT thumb FROM thumbs WHERE (id=".$id.")")->fetch()['thumb'];

?>