summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaidyn Lev <jadedctrl@teknik.io>2018-04-07 04:05:59 +0000
committerJaidyn Lev <jadedctrl@teknik.io>2018-04-07 04:05:59 +0000
commitfa5635be2e3ea27cd11aa15435f7669145e7ea90 (patch)
treed65af5271d5d5404f026d5fcee0ebc34734543ec
parentddd79569890778e9863f7eb3ae72cea627dd0ce5 (diff)
downloadinsert-coin-fa5635be2e3ea27cd11aa15435f7669145e7ea90.zip
insert-coin-fa5635be2e3ea27cd11aa15435f7669145e7ea90.tar.bz2
Added basic url-shortening
-rwxr-xr-xconjure.php96
-rw-r--r--header.html4
-rw-r--r--index.php5
-rw-r--r--url.php23
4 files changed, 126 insertions, 2 deletions
diff --git a/conjure.php b/conjure.php
new file mode 100755
index 0000000..d070056
--- /dev/null
+++ b/conjure.php
@@ -0,0 +1,96 @@
+<?php
+
+include("lib.php");
+
+include("header.html");
+echo("\n<main class=\"text-center\">\n");
+
+function celebrate($dest_file)
+{
+
+?>
+ <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
+ <a href="<?php echo($dest_file); ?>.txt">here</a></p>
+<?php
+}
+
+function celebrate_death($dest_file, $upload_method)
+{
+?>
+ <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>
+
+<?php
+}
+
+
+
+if (!empty($_POST["url_target"]) && !empty($_POST["url_alias"]))
+{
+ $url_target = $_POST["url_target"];
+ $url_alias = $_POST["url_alias"];
+ $beaming_permitted = 1;
+}
+else
+{
+ $beaming_permitted = 0;
+}
+
+
+// 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))
+{
+ 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");
+ $beaming_permitted = 0;
+}
+
+if ($beaming_permitted == 0)
+{
+ 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");
+}
+else
+{
+ $redirectfile = fopen($dest_file, 'w');
+
+ fwrite($redirectfile, "<?php header('Location: " . $url_target . "'); ?>");
+ fclose($redirectfile);
+
+ celebrate($dest_file);
+}
+
+?>
+
+</main>
+
+<?php
+include("footer.html");
+?>
diff --git a/header.html b/header.html
index 29211b9..e6c8f15 100644
--- a/header.html
+++ b/header.html
@@ -18,7 +18,7 @@
<div class="menu top-menu">
<h2>coinsh.red</h2>
<ul>
- <li><a href="/insert-coin/index.php">file-beamer</a></li>
- <li><a href="/insert-coin/u/index.php">url-shortener</a></li>
+ <li><a href="index.php">file-beamer</a></li>
+ <li><a href="url.php">url-shortener</a></li>
</ul>
</div>
diff --git a/index.php b/index.php
index 011748e..e3567f4 100644
--- a/index.php
+++ b/index.php
@@ -13,6 +13,11 @@
name="file_source" class="basic-text">
</p>
+<!-- <p>
+ <input type="text" placeholder="Upload from URL"
+ name="upload_url" id="upload_url" style="width: 400px;">
+ </p> -->
+
<input type="file" name="fileToUpload" id="fileToUpload" style="margin: 0 auto">
<input style="margin-top: 10px; margin-bottom: 10px" type="submit" value="INSERT COIN" name="submit">
</form>
diff --git a/url.php b/url.php
new file mode 100644
index 0000000..4bfb223
--- /dev/null
+++ b/url.php
@@ -0,0 +1,23 @@
+<?php include("header.html");?>
+
+<main>
+
+<form action="conjure.php" method="post" enctype="multipart/form-data">
+ <p>
+ <input type="text" placeholder="URL"
+ name="url_target" class="basic-text">
+ </p>
+
+ <p>
+ <input type="text" placeholder="Alias (Shortened URL)"
+ name="url_alias" class="basic-text">
+ </p>
+
+ <input style="margin-top: 10px; margin-bottom: 10px" type="submit" value="INSERT COIN" name="submit">
+</form>
+
+<img alt="Picture of a pretty big, yellow labour-token." src="res/img/insertcoin_big.png">
+
+</main>
+
+<?php include("footer.html");?>