2018-02-03 23:14:25 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include("lib.php");
|
2017-12-03 22:20:10 -06:00
|
|
|
|
2017-12-21 01:13:31 -06:00
|
|
|
include("header.html");
|
2018-02-03 23:14:25 -06:00
|
|
|
echo("\n<main class=\"text-center\">\n");
|
2017-12-21 01:13:31 -06:00
|
|
|
|
2018-02-03 23:14:25 -06:00
|
|
|
function celebrate($dest_file)
|
2017-12-19 15:07:09 -06:00
|
|
|
{
|
2018-02-03 23:14:25 -06:00
|
|
|
|
|
|
|
?>
|
|
|
|
<p class="uppercase">Thank you for feeding me</p>
|
|
|
|
<p class="uppercase">Your coin is in safe hands</p>
|
|
|
|
<p class="uppercase">It will not be de-atomized for at least a year</p>
|
|
|
|
|
|
|
|
<title>COIN INSERTED <3</title>
|
|
|
|
|
|
|
|
<img alt="A coin lovingly inserted to a coin-slot" src=res/img/coininserted_big.png>
|
|
|
|
|
|
|
|
<p class="uppercase">Your coin's <a href="<?php echo($dest_file); ?>">over here</a></p>
|
|
|
|
<p class="uppercase"><a href="<?php echo($dest_file); ?>">
|
|
|
|
https://coinsh.red/<?php echo($dest_file); ?></a></p>
|
|
|
|
<p class="uppercase">It's meta-stuff (or lack thereof) is
|
2018-02-03 23:33:43 -06:00
|
|
|
<a href="<?php echo($dest_file); ?>.txt">here</a></p>
|
2018-02-03 23:14:25 -06:00
|
|
|
<?php
|
2017-12-19 15:07:09 -06:00
|
|
|
}
|
2018-02-03 23:14:25 -06:00
|
|
|
|
|
|
|
function celebrate_death($dest_file, $upload_method)
|
2017-12-19 15:07:09 -06:00
|
|
|
{
|
2018-02-03 23:14:25 -06:00
|
|
|
?>
|
|
|
|
<title>COIN ON FIRE</title>
|
|
|
|
<img alt="Ouch, that coin's on fire. Literally." src="res/img/coinfire_big.png">
|
|
|
|
<p>...</p>
|
|
|
|
<p class="uppercase">That was weird, something went wrong.</p>
|
|
|
|
<p class="uppercase">Give it another go-- if it happens again, tell me.<p>
|
|
|
|
<p class="uppercase">Also tell this: "File: <?php echo($dest_file); ?>,
|
|
|
|
Method: <?php echo($upload_method); ?>."</p>
|
2017-12-03 22:20:10 -06:00
|
|
|
|
2018-02-03 23:14:25 -06:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2018-02-03 23:33:43 -06:00
|
|
|
function check_name_length($file_name)
|
|
|
|
{
|
|
|
|
if (strlen($file_name) > 36)
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<p> just a friendly note:</p>
|
|
|
|
<p>it looks like your filename is total gibberish or really long.</p>
|
|
|
|
<p>it could probably be a bit prettier--<p>
|
|
|
|
<p> remember, you can use the filename box when uploading to set a custom filename.</p>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-19 15:07:09 -06:00
|
|
|
|
2017-12-03 22:20:10 -06:00
|
|
|
|
2018-02-03 23:14:25 -06:00
|
|
|
if (!empty($_POST["upload_url"]))
|
2017-12-03 22:20:10 -06:00
|
|
|
{
|
2018-02-03 23:14:25 -06:00
|
|
|
$upload_url = $_POST["upload_url"];
|
|
|
|
$file_name = url_to_filename($upload_url);
|
|
|
|
$upload_method = 2;
|
2017-12-03 22:20:10 -06:00
|
|
|
}
|
2018-02-03 23:14:25 -06:00
|
|
|
else if (!empty($_POST["desired_filename"]))
|
2017-12-03 22:20:10 -06:00
|
|
|
{
|
2018-02-03 23:14:25 -06:00
|
|
|
$file_name = $_POST["desired_filename"];
|
|
|
|
$upload_method = 1;
|
2017-12-03 22:20:10 -06:00
|
|
|
}
|
2018-02-03 23:14:25 -06:00
|
|
|
else if (!empty($_FILES["fileToUpload"]["name"]))
|
2017-12-03 22:20:10 -06:00
|
|
|
{
|
2018-02-03 23:14:25 -06:00
|
|
|
$file_name = $_FILES["fileToUpload"]["name"];
|
|
|
|
$upload_method = 1;
|
2017-12-03 22:20:10 -06:00
|
|
|
}
|
2018-02-03 23:14:25 -06:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$upload_method = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// check if file-name has any... undesirable characteristics
|
|
|
|
$file_name = sanitize_filename($file_name);
|
2017-12-03 22:20:10 -06:00
|
|
|
|
|
|
|
|
|
|
|
// and now we pretend that never happened
|
|
|
|
|
2018-02-03 23:14:25 -06:00
|
|
|
|
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;
|
|
|
|
|
2018-02-03 23:14:25 -06:00
|
|
|
|
2017-12-03 21:59:23 -06:00
|
|
|
$beaming_permitted = 1;
|
|
|
|
|
|
|
|
if (file_exists($dest_file))
|
|
|
|
{
|
2018-02-03 23:14:25 -06:00
|
|
|
echo("\t<p class=\"uppercase\">We're getting some interference</p>\n");
|
|
|
|
echo("\t<p class=\"uppercase\">Please use a different coin-name</p>\n\n");
|
2017-12-03 21:59:23 -06:00
|
|
|
$beaming_permitted = 0;
|
|
|
|
}
|
2018-02-03 23:14:25 -06:00
|
|
|
|
|
|
|
if ($beaming_permitted == 0)
|
2017-12-03 21:59:23 -06:00
|
|
|
{
|
2018-02-03 23:14:25 -06:00
|
|
|
echo("\t<title>COIN ON FIRE</title>\n\n");
|
|
|
|
echo("\t<img alt=\"A big coin in bloody flames.\" src=res/img/coinfire_big.png>\n");
|
|
|
|
echo("\t<p>sorry <\\3</p>\n");
|
2017-12-03 21:59:23 -06:00
|
|
|
}
|
2018-02-03 23:14:25 -06:00
|
|
|
else
|
2017-12-03 21:59:23 -06:00
|
|
|
{
|
2018-02-03 23:14:25 -06:00
|
|
|
if ($upload_method == 1)
|
|
|
|
{
|
|
|
|
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$dest_file))
|
|
|
|
{
|
|
|
|
write_metadata($dest_file, $_POST["file_desc"], $_POST["file_source"]);
|
|
|
|
celebrate($dest_file);
|
2018-02-03 23:33:43 -06:00
|
|
|
check_name_length($file_name);
|
2018-02-03 23:14:25 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
celebrate_death($dest_file, $upload_method);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($upload_method == 2)
|
|
|
|
{
|
|
|
|
$download = file_get_contents($upload_url);
|
|
|
|
if (file_put_contents($dest_file, $download))
|
|
|
|
{
|
|
|
|
write_metadata($dest_file, $_POST["file_desc"], $upload_url . "\n\t" . $_POST["file_source"]);
|
|
|
|
celebrate($dest_file);
|
2018-02-03 23:33:43 -06:00
|
|
|
check_name_length($file_name);
|
2018-02-03 23:14:25 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
celebrate_death($dest_file, $upload_method);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ($upload_method == 0)
|
|
|
|
{
|
|
|
|
echo("\t<p class=\"uppercase\">(upload something next time, my dumb, sweet honey-pie <3)<p>");
|
|
|
|
celebrate_death("n/a", "smartassery");
|
2017-12-03 21:59:23 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-03 23:14:25 -06:00
|
|
|
celebrate_death($dest_file, $upload_method);
|
2017-12-03 21:59:23 -06:00
|
|
|
}
|
|
|
|
}
|
2018-02-03 23:14:25 -06:00
|
|
|
|
|
|
|
|
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
|
|
|
?>
|