beam.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. $page_title = "The Beaming";
  3. include("res/config.php");
  4. include("lib.php");
  5. include("res/header.php");
  6. echo("\n<main>\n");
  7. if (!empty($_POST["desired_filename"]))
  8. {
  9. $file_name = $_POST["desired_filename"];
  10. if (!pathinfo($file_name, PATHINFO_EXTENSION))
  11. {
  12. $file_name = $file_name . "." .
  13. (pathinfo($_FILES["fileToUpload"]["name"],
  14. PATHINFO_EXTENSION));
  15. }
  16. $beaming_permitted = 0;
  17. }
  18. else if (!empty($_FILES["fileToUpload"]["name"]))
  19. {
  20. $file_name = $_FILES["fileToUpload"]["name"];
  21. $file_name = sanitize_filename($file_name);
  22. $dest_file = $file_beam_dir . $file_name;
  23. $beaming_permitted = 0;
  24. }
  25. else
  26. {
  27. $beaming_permitted = 1;
  28. }
  29. $file_name = sanitize_filename($file_name);
  30. $dest_file = $file_beam_dir . $file_name;
  31. if (file_exists($dest_file))
  32. {
  33. $beaming_permitted = 2;
  34. }
  35. switch ($beaming_permitted)
  36. {
  37. case 1:
  38. celebrate_death($dest_file, $file_beam_item,
  39. $file_beam_die_img, $file_beam_die_alt,
  40. "<p>… you didn't upload anything, dope.
  41. <p>Try again.</p>");
  42. break;
  43. case 2:
  44. celebrate_death($dest_file, $url_aliasize_item,
  45. $file_beam_die_img, $file_beam_die_alt,
  46. "<p>Er, that coin already exists— try a different file-name.</p>");
  47. break;
  48. case 0:
  49. if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$dest_file))
  50. {
  51. // $file_ext = pathinfo($dest_file, PATHINFO_EXTENSION);
  52. // if ($file_ext == "jpg")
  53. // {
  54. // sanitize_image($dest_file);
  55. // }
  56. write_metadata($dest_file, $_POST["file_source"]);
  57. celebrate($dest_file, $file_beam_item,
  58. $file_beam_win_img, $file_beam_win_alt, true);
  59. }
  60. else
  61. {
  62. celebrate_death($dest_file, $url_aliasize_item,
  63. $file_beam_die_img, $file_beam_die_alt,
  64. "<p>What the hell just happened? :o</p>
  65. <p>I dunno, but maybe you should give it another go?</p>");
  66. }
  67. break;
  68. }
  69. ?>
  70. </main>
  71. <?php
  72. include("res/footer.html");
  73. ?>