From acf8478e396f24703aca603ff0bcefcaaa529b14 Mon Sep 17 00:00:00 2001
From: Jaidyn Lev
Date: Sat, 7 Apr 2018 18:19:14 -0500
Subject: [PATCH] Added configuration, general copyediting, new images, etc.
---
beam.php | 156 +++++++++------------------------
conjure.php | 115 ++++++++++--------------
index.html | 54 ------------
index.php | 20 +++--
lib.php | 57 +++++++++++-
res/config.php | 37 ++++++++
footer.html => res/footer.html | 0
header.html => res/header.php | 4 +-
res/img/coin-big.png | Bin 0 -> 963 bytes
res/img/coin.png | Bin 327 -> 442 bytes
res/img/coin_big.png | Bin 546 -> 0 bytes
res/img/coin_die-big.png | Bin 0 -> 1180 bytes
res/img/coin_die.png | Bin 0 -> 567 bytes
res/img/coin_win-big.png | Bin 0 -> 1034 bytes
res/img/coin_win.png | Bin 0 -> 482 bytes
res/img/coinfire.png | Bin 478 -> 0 bytes
res/img/coinfire_big.png | Bin 1801 -> 0 bytes
res/img/coininserted.png | Bin 366 -> 0 bytes
res/img/coininserted_big.png | Bin 1568 -> 0 bytes
res/img/insertcoin.png | Bin 400 -> 0 bytes
res/img/insertcoin_big.png | Bin 1680 -> 0 bytes
res/img/mask-big.png | Bin 0 -> 619 bytes
res/img/mask.png | Bin 0 -> 251 bytes
res/img/mask_die-big.png | Bin 0 -> 799 bytes
res/img/mask_die.png | Bin 0 -> 344 bytes
res/img/mask_win-big.png | Bin 0 -> 764 bytes
res/img/mask_win.png | Bin 0 -> 277 bytes
res/style.css | 6 +-
url.php | 16 +++-
29 files changed, 205 insertions(+), 260 deletions(-)
mode change 100755 => 100644 beam.php
mode change 100755 => 100644 conjure.php
delete mode 100644 index.html
mode change 100755 => 100644 lib.php
create mode 100644 res/config.php
rename footer.html => res/footer.html (100%)
rename header.html => res/header.php (83%)
create mode 100644 res/img/coin-big.png
delete mode 100644 res/img/coin_big.png
create mode 100644 res/img/coin_die-big.png
create mode 100644 res/img/coin_die.png
create mode 100644 res/img/coin_win-big.png
create mode 100644 res/img/coin_win.png
delete mode 100644 res/img/coinfire.png
delete mode 100644 res/img/coinfire_big.png
delete mode 100644 res/img/coininserted.png
delete mode 100644 res/img/coininserted_big.png
delete mode 100644 res/img/insertcoin.png
delete mode 100644 res/img/insertcoin_big.png
create mode 100644 res/img/mask-big.png
create mode 100644 res/img/mask.png
create mode 100644 res/img/mask_die-big.png
create mode 100644 res/img/mask_die.png
create mode 100644 res/img/mask_win-big.png
create mode 100644 res/img/mask_win.png
diff --git a/beam.php b/beam.php
old mode 100755
new mode 100644
index 84af6f8..e952a76
--- a/beam.php
+++ b/beam.php
@@ -1,153 +1,75 @@
\n");
-
-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
-
-
-
- Your coin's over here
-
- https://coinsh.red/
- It's meta-stuff (or lack thereof) is
- here
-
- COIN ON FIRE
-
- ...
- That was weird, something went wrong.
- Give it another go-- if it happens again, tell me.
-
Also tell this: "File: ,
- Method: ."
-
- 36)
- {
- ?>
- just a friendly note:
- it looks like your filename is total gibberish or really long.
- it could probably be a bit prettier--
-
remember, you can use the filename box when uploading to set a custom filename.
- \n");
-
-if (!empty($_POST["upload_url"]))
-{
- $upload_url = $_POST["upload_url"];
- $file_name = url_to_filename($upload_url);
- $upload_method = 2;
-}
-else if (!empty($_POST["desired_filename"]))
+if (!empty($_POST["desired_filename"]))
{
$file_name = $_POST["desired_filename"];
- $upload_method = 1;
+ $file_name = sanitize_filename($file_name);
+ $dest_file = $file_beam_dir . $file_name;
+
+ $beaming_permitted = 0;
}
else if (!empty($_FILES["fileToUpload"]["name"]))
{
$file_name = $_FILES["fileToUpload"]["name"];
- $upload_method = 1;
+ $file_name = sanitize_filename($file_name);
+ $dest_file = $file_beam_dir . $file_name;
+
+ $beaming_permitted = 0;
}
else
{
- $upload_method = 0;
+ $beaming_permitted = 1;
}
-
-// check if file-name has any... undesirable characteristics
-$file_name = sanitize_filename($file_name);
-
-
-// and now we pretend that never happened
-
-
-$dest_dir = "p/";
-$dest_file = $dest_dir . $file_name;
-
-
-$beaming_permitted = 1;
-
if (file_exists($dest_file))
{
- echo("\tWe're getting some interference
\n");
- echo("\tPlease use a different coin-name
\n\n");
- $beaming_permitted = 0;
+ $beaming_permitted = 2;
}
-if ($beaming_permitted == 0)
+
+
+switch ($beaming_permitted)
{
- echo("\tCOIN ON FIRE\n\n");
- echo("\t\n");
- echo("\tsorry <\\3
\n");
-}
-else
-{
- if ($upload_method == 1)
- {
+ case 1:
+ celebrate_death($dest_file, $file_beam_item,
+ $file_beam_die_img, $file_beam_die_alt,
+ "… you didn't upload anything, dope.
+
Try again.
");
+ break;
+ case 2:
+ celebrate_death($dest_file, $url_aliasize_item,
+ $file_beam_die_img, $file_beam_die_alt,
+ "Er, that coin already exists— try a different file-name.
");
+ break;
+ case 0:
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$dest_file))
{
- write_metadata($dest_file, $_POST["file_desc"], $_POST["file_source"]);
- celebrate($dest_file);
- check_name_length($file_name);
+ write_metadata($dest_file, $_POST["file_source"]);
+ celebrate($dest_file, $file_beam_item,
+ $file_beam_win_img, $file_beam_win_alt, true);
}
else
{
- celebrate_death($dest_file, $upload_method);
+ celebrate_death($dest_file, $url_aliasize_item,
+ $file_beam_die_img, $file_beam_die_alt,
+ "What the hell just happened? :o
+ I dunno, but maybe you should give it another go?
");
}
- }
- 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);
- check_name_length($file_name);
- }
- 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
- {
- celebrate_death($dest_file, $upload_method);
- }
+ break;
}
-
-
?>
diff --git a/conjure.php b/conjure.php
old mode 100755
new mode 100644
index d070056..b90aae2
--- a/conjure.php
+++ b/conjure.php
@@ -1,90 +1,63 @@
\n");
-
-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
-
-
-
- Your coin's over here
-
- https://coinsh.red/
- It's meta-stuff (or lack thereof) is
- here
-
- COIN ON FIRE
-
- ...
- That was weird, something went wrong.
- Give it another go-- if it happens again, tell me.
-
Also tell this: "File: ,
- Method: ."
-
-\n");
if (!empty($_POST["url_target"]) && !empty($_POST["url_alias"]))
{
$url_target = $_POST["url_target"];
$url_alias = $_POST["url_alias"];
- $beaming_permitted = 1;
+ $url_alias = sanitize_filename($url_alias);
+
+ $dest_file = $url_aliasize_dir . $url_alias . $url_aliasize_suffix;
+
+ $beaming_permitted = 0;
}
else
{
- $beaming_permitted = 0;
+ $beaming_permitted = 1;
+}
+
+if (!filter_var($url_target, FILTER_VALIDATE_URL))
+{
+ $beaming_permitted = 3;
+}
+else if (file_exists($dest_file))
+{
+ $beaming_permitted = 2;
}
-// check if file-name has any... undesirable characteristics
-$url_alias = sanitize_filename($url_alias);
-
-
-// and now we pretend that never happened
-
-$dest_dir = "u/";
-$dest_file = $dest_dir . $url_alias;
-
-
-
-if (file_exists($dest_file))
+switch ($beaming_permitted)
{
- echo("\tWe're getting some interference
\n");
- echo("\tPlease use a different coin-name
\n\n");
- $beaming_permitted = 0;
-}
-
-if ($beaming_permitted == 0)
-{
- echo("\tCOIN ON FIRE\n\n");
- echo("\t\n");
- echo("\tsorry <\\3
\n");
-}
-else
-{
- $redirectfile = fopen($dest_file, 'w');
-
- fwrite($redirectfile, "");
- fclose($redirectfile);
-
- celebrate($dest_file);
+ case 1:
+ celebrate_death($dest_file, $url_aliasize_item,
+ $url_aliasize_die_img, $url_aliasize_die_alt,
+ "... you didn't pick a URL/target.
+ Do it next time >;c
");
+ break;
+ case 2:
+ celebrate_death($dest_file, $url_aliasize_item,
+ $url_aliasize_die_img, $url_aliasize_die_alt,
+ "Oh, sorry. Some-one just took that mask before you got here!
+ Try a different target name, doggo
");
+ break;
+ case 3:
+ celebrate_death($dest_file, $url_aliasize_item,
+ $url_aliasize_die_img, $url_aliasize_die_alt,
+ "Are you screwing with me? That's not a URL
+ Nice try, buck-o
");
+ break;
+ case 0:
+ write_alias($dest_file, $url_target);
+ celebrate($dest_file, $url_aliasize_item,
+ $url_aliasize_win_img, $url_aliasize_win_alt);
+ break;
}
?>
@@ -92,5 +65,5 @@ else
diff --git a/index.html b/index.html
deleted file mode 100644
index 96d3b78..0000000
--- a/index.html
+++ /dev/null
@@ -1,54 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-INSERT COIN
-
-
-
-
-
-
-
-
-
-
-
---> rocket scientist edition <--
-source juice
-
-
-
-
diff --git a/index.php b/index.php
index e3567f4..fc641f9 100644
--- a/index.php
+++ b/index.php
@@ -1,4 +1,10 @@
-
+
@@ -13,17 +19,13 @@
name="file_source" class="basic-text">
-
-
-
+
-
+
-
+
diff --git a/lib.php b/lib.php
old mode 100755
new mode 100644
index 801dc5a..2f8e364
--- a/lib.php
+++ b/lib.php
@@ -1,12 +1,29 @@
\n");
+ fclose($file_p);
+
+ return 0;
+}
+
+function write_metadata($filename, $source)
{
$metafile = fopen($filename . ".txt", 'w');
+ if (empty($source))
+ {
+ $source = "[citation needed]";
+ }
+
+
fwrite($metafile, "Source:\n\t" . implode('', sanitize_long_input($source, "\t")) . "\n");
- fwrite($metafile, "Descri:\n\t" . implode('', sanitize_long_input($desc, "\t")) . "\t");
fclose($metafile);
}
@@ -71,4 +88,40 @@ function url_to_filename($url)
return $filename;
}
+function celebrate($dest_file, $item_type, $image_url, $image_alt, $meta_data = false)
+{
+
?>
+ inserted <3
+ Thanks for feeding me
+ Your 's in safe hands
+
+
+
+ Your 's
+ over here
+
+ It's meta-stuff (or lack thereof) is
+ here
+
+ burned 3
+ Oh God, I've never seen so much blood—
+ err, I mean, there're just some minor problems under the hood!
+
+
+
+
+
+
-coinsh.red: Insert Coin
+