2019-07-24 20:29:53 +02:00
|
|
|
<?php
|
|
|
|
// This is just a dummy implementation during the development of the GTK+3 GUI
|
|
|
|
|
2019-07-24 21:35:40 +02:00
|
|
|
|
2019-07-26 20:38:33 +02:00
|
|
|
if ($_SERVER['HTTP_X_TOKEN'] != "123456") {
|
|
|
|
http_response_code(403);
|
|
|
|
die("Invalid token.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
$id = $_GET['id'];
|
|
|
|
preg_match("/^[A-Za-z0-9]{6,10}$/", $id, $matches);
|
|
|
|
if (!$matches) {
|
|
|
|
http_response_code(400);
|
|
|
|
die ("Invalid tag ID.");
|
|
|
|
}
|
|
|
|
|
|
|
|
// $id is now safe to use
|
2019-07-24 21:35:40 +02:00
|
|
|
|
2019-07-24 20:29:53 +02:00
|
|
|
if (isset($_GET['meta'])) {
|
2019-07-26 20:38:33 +02:00
|
|
|
if ($id == "BF09CE") {
|
2019-07-24 20:29:53 +02:00
|
|
|
?>
|
|
|
|
{
|
|
|
|
"title" : "Cute Wifi Cat",
|
|
|
|
"description" : "802.11nya~",
|
|
|
|
"comment" : "It's mewine!"
|
|
|
|
}
|
|
|
|
<?php
|
2019-07-26 20:38:33 +02:00
|
|
|
} else if ($id == "BE6200") {
|
2019-07-24 20:29:53 +02:00
|
|
|
?>
|
|
|
|
{
|
|
|
|
"title" : "Crazy Stuff",
|
|
|
|
"description" : "It blinks. Or explodes.",
|
|
|
|
"comment" : "Like the kittens."
|
|
|
|
}
|
|
|
|
<?php
|
|
|
|
} else {
|
2019-07-26 20:38:33 +02:00
|
|
|
http_response_code(400);
|
2019-07-24 20:29:53 +02:00
|
|
|
?>
|
|
|
|
{
|
|
|
|
"title" : "INVALID",
|
|
|
|
"description" : "INVALID",
|
|
|
|
"comment" : "INVALID"
|
|
|
|
}
|
|
|
|
<?php
|
|
|
|
}
|
2019-07-26 20:38:33 +02:00
|
|
|
} else if (isset($_GET['image'])) {
|
|
|
|
header('Content-Type: image/png');
|
|
|
|
$fn = "img/$id.png";
|
|
|
|
if (file_exists($fn)) {
|
|
|
|
readfile($fn);
|
|
|
|
} else {
|
|
|
|
http_response_code(404);
|
|
|
|
die ("Image not found.");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
http_response_code(400);
|
|
|
|
die("Invalid request.");
|
2019-07-24 20:29:53 +02:00
|
|
|
}
|
|
|
|
?>
|