$item) {
if ($item["id"] === $id) {
$selectedIndex = $index;
$selected = $item;
break;
}
}
if ($selected === null) {
header("Location: /-/toys");
die();
}
unset($data[$selectedIndex]);
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json", utf8_encode(json_encode($data)));
header("Location: /-/toys/?d&id=" . $id);
die();
}
if (isset($_POST['updateAction'])) {
$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true);
$selected = null;
$selectedIndex = -1;
$id = $_POST['action'];
foreach ($data as $index => $item) {
if ($item["id"] === $id) {
$selectedIndex = $index;
$selected = $item;
break;
}
}
if ($selected === null) {
header("Location: /-/toys");
die();
}
if (isset($_POST["sexual"])) {
$selected["sexual"] = true;
} else {
$selected["sexual"] = false;
}
if (isset($_POST["name"])) $selected["name"] = strip_tags(trim($_POST["name"]));
if (isset($_POST["usage"])) $selected["usage"] = strip_tags(trim($_POST["usage"]));
if (isset($_POST["irl"])) $selected["irl"] = strip_tags(trim($_POST["irl"]));
if (isset($_POST["keywords"])) $selected["keywords"] = array_map(function ($i) {
return trim($i);
}, explode(",", strip_tags(trim($_POST["keywords"]))));
if (isset($_POST["description"])) $selected["description"] = strip_tags(trim($_POST["description"]));
if (isset($_POST["water"])) $selected["water"] = match ($_POST["water"]) {
"0" => "out",
"1" => "in",
"2" => "both",
"3" => "playground"
};
if (isset($_POST["relations"])) {
$ponies = [];
foreach ($_POST["relations"] as $relation => $d) {
$ponies[] = [
"members" => explode("-", $relation),
"deprecated" => isset($d["deprecated"]),
"sexual" => isset($d["sexual"])
];
}
$selected["ponies"] = $ponies;
}
global $_PROFILE;
if ($_PROFILE['login'] === "raindrops" && isset($_POST["verified"])) {
$selected["verified"] = true;
} else {
unset($selected["verified"]);
}
if (isset($_POST["untested"])) {
$selected["untested"] = true;
} else {
unset($selected["untested"]);
}
$data[$selectedIndex] = $selected;
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json", utf8_encode(json_encode($data)));
header("Location: /-/toys/" . $id);
die();
}
if (isset($_POST['createAction'])) {
require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/random.inc";
$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true);
if (!isset($_POST["name"]) || !isset($_POST["water"])) {
header("Location: /-/toys");
die();
}
if (trim($_POST["name"]) === "" || !is_numeric($_POST["water"])) {
header("Location: /-/toys");
die();
}
$water = match ($_POST["water"]) {
"0" => "out",
"1" => "in",
"2" => "both",
"3" => "playground"
};
$name = strip_tags(trim($_POST["name"]));
$id = random();
$ponies = [];
if (isset($_POST["relations"])) {
foreach ($_POST["relations"] as $relation => $_) {
$ponies[] = [
"members" => explode("-", $relation),
"deprecated" => false
];
}
}
if (isset($_POST["sexual"])) {
$sexual = true;
} else {
$sexual = false;
}
$data[] = [
"id" => $id,
"name" => $name,
"water" => $water,
"description" => null,
"ponies" => $ponies,
"usage" => null,
"irl" => null,
"keywords" => [],
"sexual" => $sexual
];
file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json", utf8_encode(json_encode($data)));
header("Location: /-/toys/" . $id);
die();
}
global $pagename;
$parts = explode("/", $pagename);
$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true);
$selected = null;
if (isset($parts[1])) {
$id = $parts[1];
foreach ($data as $item) {
if ($item["id"] === $id) {
$selected = $item;
break;
}
}
if ($selected === null) {
header("Location: /-/toys/?nf&id=" . $id);
die();
} else {
$title = $selected["name"] . " · " . $title;
}
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc';
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/keywords.inc';
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json")) file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json", "[]");
global $_PROFILE;
global $pagename;
$parts = explode("/", $pagename);
?>
= strip_tags($_GET['id'] ?? "-") ?>
) was not found, it may have been deleted or has never existed.
= strip_tags($_GET['id'] ?? "-") ?>
has been successfully deleted.
Edit · Sexual Pleasurable Unverified Untested Underwater Outside of water In playground Underwater Outside of water
= replaceKeyWords(str_replace("\n", "No description provided for this toy. Enter edit mode to add a description to this toy.
No usage provided for this toy. Enter edit mode to add usage information to this toy.
Instructions to craft in real life:This toy is not craftable in real life.
= count($data) ?> toys (= count(array_filter($data, function ($i) { return $i["sexual"] === false; })) ?> non-sexual, = count(array_filter($data, function ($i) { return $i["sexual"] === true; })) ?> sexual, = count(array_filter($data, function ($i) { return isset($i["untested"]) && $i["untested"]; })) ?> untested, = count(array_filter($data, function ($i) { return (isset($i["description"]) && trim($i["description"]) === "") || !isset($i["description"]); })) ?> incomplete)
Not finding what you are looking for? Add a toy.