From 8a5129bb87bc525cc9d6f08979a314e78efe5080 Mon Sep 17 00:00:00 2001 From: Jade Levesque Date: Sat, 3 Feb 2018 23:14:25 -0600 Subject: [PATCH] Added metadata, upload from URL --- beam.php | 145 +++++++++++++++++++++++++++++++++++----------------- footer.html | 4 +- index.php | 15 +++++- lib.php | 74 +++++++++++++++++++++++++++ 4 files changed, 188 insertions(+), 50 deletions(-) create mode 100755 lib.php diff --git a/beam.php b/beam.php index 828fb9a..095a8ab 100755 --- a/beam.php +++ b/beam.php @@ -1,82 +1,133 @@ -"; +echo("\n
\n"); -if (empty($_POST["desired_filename"])) +function celebrate($dest_file) +{ + +?> +

Thank you for feeding me

+

Your coin is in safe hands

+

It will not be de-atomized for at least a year

+ + COIN INSERTED <3 + + A coin lovingly inserted to a coin-slot + +

Your coin's over here

+

+ https://coinsh.red/

+

It's meta-stuff (or lack thereof) is + here

+ + COIN ON FIRE + Ouch, that coin's on fire. Literally. +

...

+

That was weird, something went wrong.

+

Give it another go-- if it happens again, tell me.

+

Also tell this: "File: , + Method: ."

+ +We're getting some interference

"; - echo "

Please use a different coin-name

"; + echo("\t

We're getting some interference

\n"); + echo("\t

Please use a different coin-name

\n\n"); $beaming_permitted = 0; } -elseif ($_FILES["fileToUpload"]["size"] > 50000000) -{ - echo "

This coin will be up for at least three months

"; - echo "

7 moons in the ordinary sabbatical cycle

"; - echo "

After that, it *may* be de-atomized

"; -} -elseif ($_FILES["fileToUpload"]["size"] < 25000000) -{ - echo "

Thank you for feeding me

"; - echo "

Your coin is in safe hands

"; - echo "

It will not be de-atomized for at least a year

"; -} - -if ($beaming_permitted == 0) { - echo "COIN ON FIRE"; - echo "\"A"; - echo "

sorry <\\3

"; +if ($beaming_permitted == 0) +{ + echo("\tCOIN ON FIRE\n\n"); + echo("\t\"A\n"); + echo("\t

sorry <\\3

\n"); } -else { - if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$dest_file)) { - echo "COIN INSERTED <3"; - echo "\"A"; - echo "

It is here

"; +else +{ + 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); + } + 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); + } + else + { + celebrate_death($dest_file, $upload_method); + } + } + else if ($upload_method == 0) + { + echo("\t

(upload something next time, my dumb, sweet honey-pie <3)

"); + celebrate_death("n/a", "smartassery"); } else { - echo "COIN ON FIRE"; - echo "\"Ouch,"; - echo "

...

"; - echo "

That was weird, something went wrong. Try again.

"; + celebrate_death($dest_file, $upload_method); } } + + ?> diff --git a/footer.html b/footer.html index e385796..41789b7 100644 --- a/footer.html +++ b/footer.html @@ -1,4 +1,4 @@ -
+
No data will be recorded on who inserts what coin-- all I'll get is a timestamp.
@@ -6,7 +6,7 @@

source juice

-
+ diff --git a/index.php b/index.php index 9edcdc6..c1ff787 100644 --- a/index.php +++ b/index.php @@ -1,11 +1,24 @@
-
+

+ +

+ + +

+ + +
diff --git a/lib.php b/lib.php new file mode 100755 index 0000000..801dc5a --- /dev/null +++ b/lib.php @@ -0,0 +1,74 @@ +