insert-coin/beam.php

88 lines
2.1 KiB
PHP
Raw Normal View History

2017-12-03 21:59:23 -06:00
<?php
2017-12-03 22:20:10 -06:00
2017-12-21 01:13:31 -06:00
include("header.html");
2017-12-22 23:07:38 -06:00
echo "<main class=\"text-center\">";
2017-12-21 01:13:31 -06:00
2017-12-19 15:07:09 -06:00
if (empty($_POST["desired_filename"]))
{
$file_name = $_FILES["fileToUpload"]["name"];
}
else
{
$file_name = $_POST["desired_filename"];
}
2017-12-03 22:20:10 -06:00
2017-12-19 15:07:09 -06:00
// check if file-name has any... undesirable characteristics
2017-12-03 22:20:10 -06:00
if (strstr($file_name, " "))
{
$file_name = str_replace(" ", "_", $file_name);
}
if (strstr($file_name, ".."))
{
$file_name = str_replace("..", "_", $file_name);
}
if (strstr($file_name, "/"))
{
$file_name = str_replace("/", "_", $file_name);
}
// and now we pretend that never happened
2017-12-03 21:59:23 -06:00
$dest_dir = "p/";
2017-12-03 22:20:10 -06:00
$dest_file = $dest_dir . $file_name;
2017-12-03 21:59:23 -06:00
$beaming_permitted = 1;
if (file_exists($dest_file))
{
2017-12-22 23:07:38 -06:00
echo "<p class=\"uppercase\">We're getting some interference</p>";
echo "<p class=\"uppercase\">Please use a different coin-name</p>";
2017-12-03 21:59:23 -06:00
$beaming_permitted = 0;
}
elseif ($_FILES["fileToUpload"]["size"] > 50000000)
{
2017-12-22 23:07:38 -06:00
echo "<p class=\"uppercase\">This coin will be up for at least three months</p>";
echo "<p class=\"uppercase\">7 moons in the ordinary sabbatical cycle</p>";
echo "<p class=\"uppercase\">After that, it *may* be de-atomized</p>";
2017-12-03 21:59:23 -06:00
}
elseif ($_FILES["fileToUpload"]["size"] < 25000000)
{
2017-12-22 23:07:38 -06:00
echo "<p class=\"uppercase\">Thank you for feeding me</p>";
echo "<p class=\"uppercase\">Your coin is in safe hands</p>";
echo "<p class=\"uppercase\">It will not be de-atomized for at least a year</p>";
2017-12-03 21:59:23 -06:00
}
if ($beaming_permitted == 0) {
2017-12-19 15:07:09 -06:00
echo "<title>COIN ON FIRE</title>";
2017-12-22 23:07:38 -06:00
echo "<img alt=\"A big coin in bloody flames.\" src=../../res/img/coinfire_big.png>";
echo "<p>sorry <\\3</p>";
2017-12-03 21:59:23 -06:00
}
else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$dest_file)) {
2017-12-19 15:07:09 -06:00
echo "<title>COIN INSERTED <3</title>";
2017-12-22 23:07:38 -06:00
echo "<img alt=\"A coin lovingly inserted to a coin-slot\" src=../../res/img/coininserted_big.png>";
echo "<p class=\"uppercase\">It is <a href=" . $dest_file . ">here</a></p>";
2017-12-03 21:59:23 -06:00
}
else
{
2017-12-19 15:07:09 -06:00
echo "<title>COIN ON FIRE</title>";
2017-12-22 23:07:38 -06:00
echo "<img alt=\"Ouch, that coin is on fire. Literally.\" src=../../res/img/coinfire_big.png>";
echo "<p>...</p>";
echo "<p class=\"uppercase\">That was weird, something went wrong. Try again.</p>";
2017-12-03 21:59:23 -06:00
}
}
2017-12-22 23:07:38 -06:00
?>
</main>
2017-12-03 21:59:23 -06:00
2017-12-22 23:07:38 -06:00
<?php
include("footer.html");
2017-12-21 01:13:31 -06:00
?>