insert-coin/beam.php

90 lines
1.8 KiB
PHP
Raw Normal View History

2018-02-03 23:14:25 -06:00
<?php
$page_title = "The Beaming";
2018-02-03 23:14:25 -06:00
include("res/config.php");
2018-02-03 23:14:25 -06:00
include("lib.php");
2017-12-03 22:20:10 -06:00
include("res/header.php");
echo("\n<main>\n");
2017-12-19 15:07:09 -06:00
2017-12-03 22:20:10 -06:00
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"];
if (!pathinfo($file_name, PATHINFO_EXTENSION))
{
$file_name = $file_name . "." .
(pathinfo($_FILES["fileToUpload"]["name"],
PATHINFO_EXTENSION));
}
$beaming_permitted = 0;
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"];
$file_name = sanitize_filename($file_name);
$dest_file = $file_beam_dir . $file_name;
$beaming_permitted = 0;
2017-12-03 22:20:10 -06:00
}
2018-02-03 23:14:25 -06:00
else
{
$beaming_permitted = 1;
2018-02-03 23:14:25 -06:00
}
$file_name = sanitize_filename($file_name);
$dest_file = $file_beam_dir . $file_name;
2017-12-03 21:59:23 -06:00
if (file_exists($dest_file))
{
$beaming_permitted = 2;
2017-12-03 21:59:23 -06:00
}
2018-02-03 23:14:25 -06:00
switch ($beaming_permitted)
2017-12-03 21:59:23 -06:00
{
case 1:
celebrate_death($dest_file, $file_beam_item,
$file_beam_die_img, $file_beam_die_alt,
"<p>… you didn't upload anything, dope.
<p>Try again.</p>");
break;
case 2:
celebrate_death($dest_file, $url_aliasize_item,
$file_beam_die_img, $file_beam_die_alt,
"<p>Er, that coin already exists— try a different file-name.</p>");
break;
case 0:
2018-02-03 23:14:25 -06:00
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$dest_file))
{
2018-04-07 23:09:34 -05:00
// $file_ext = pathinfo($dest_file, PATHINFO_EXTENSION);
// if ($file_ext == "jpg")
// {
// sanitize_image($dest_file);
// }
write_metadata($dest_file, $_POST["file_source"]);
2018-04-07 23:09:34 -05:00
celebrate($dest_file, $file_beam_item,
$file_beam_win_img, $file_beam_win_alt, true);
2018-02-03 23:14:25 -06:00
}
else
{
celebrate_death($dest_file, $url_aliasize_item,
$file_beam_die_img, $file_beam_die_alt,
"<p>What the hell just happened? :o</p>
<p>I dunno, but maybe you should give it another go?</p>");
2018-02-03 23:14:25 -06:00
}
break;
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("res/footer.html");
2017-12-21 01:13:31 -06:00
?>