Added configuration, general copyediting, new images, etc.

This commit is contained in:
Jaidyn Lev 2018-04-07 18:19:14 -05:00
parent fa5635be2e
commit acf8478e39
29 changed files with 205 additions and 260 deletions

156
beam.php Executable file → Normal file
View File

@ -1,153 +1,75 @@
<?php
$page_title = "The Beaming";
include("res/config.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
}
function check_name_length($file_name)
{
if (strlen($file_name) > 36)
{
?>
<p> just a friendly note:</p>
<p>it looks like your filename is total gibberish or really long.</p>
<p>it could probably be a bit prettier--<p>
<p> remember, you can use the filename box when uploading to set a custom filename.</p>
<?php
}
}
include("res/header.php");
echo("\n<main>\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;
}
// 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("\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;
$beaming_permitted = 2;
}
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
{
if ($upload_method == 1)
switch ($beaming_permitted)
{
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:
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,
"<p>What the hell just happened? :o</p>
<p>I dunno, but maybe you should give it another go?</p>");
}
break;
}
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<p class=\"uppercase\">(upload something next time, my dumb, sweet honey-pie <3)<p>");
celebrate_death("n/a", "smartassery");
}
else
{
celebrate_death($dest_file, $upload_method);
}
}
?>
</main>
<?php
include("footer.html");
include("res/footer.html");
?>

111
conjure.php Executable file → Normal file
View File

@ -1,90 +1,63 @@
<?php
$page_title = "The Conjuring";
include("res/config.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
}
include("res/header.php");
echo("\n<main>\n");
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);
$dest_file = $url_aliasize_dir . $url_alias . $url_aliasize_suffix;
// 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');
$beaming_permitted = 1;
}
fwrite($redirectfile, "<?php header('Location: " . $url_target . "'); ?>");
fclose($redirectfile);
if (!filter_var($url_target, FILTER_VALIDATE_URL))
{
$beaming_permitted = 3;
}
else if (file_exists($dest_file))
{
$beaming_permitted = 2;
}
celebrate($dest_file);
switch ($beaming_permitted)
{
case 1:
celebrate_death($dest_file, $url_aliasize_item,
$url_aliasize_die_img, $url_aliasize_die_alt,
"<p>... you didn't pick a URL/target.</p>
<p>Do it next time >;c</p>");
break;
case 2:
celebrate_death($dest_file, $url_aliasize_item,
$url_aliasize_die_img, $url_aliasize_die_alt,
"<p>Oh, sorry. Some-one just took that mask before you got here!</p>
<p>Try a different target name, doggo</p>");
break;
case 3:
celebrate_death($dest_file, $url_aliasize_item,
$url_aliasize_die_img, $url_aliasize_die_alt,
"<p>Are you screwing with me? That's not a URL</p>
<p>Nice try, buck-o</p>");
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
</main>
<?php
include("footer.html");
include("res/footer.html");
?>

View File

@ -1,54 +0,0 @@
<html>
<head>
<!-- THIS ENTIRE FILE IS UNDER THE AGPLv3+
https://www.gnu.org/licenses/agpl-3.0.html -->
<link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/connection" type="text/css"/>
<link rel="stylesheet" type="text/css" href="../../res/bootstrap.css">
<link rel="stylesheet" type="text/css" href="../../res/style.css">
<link rel="shortcut icon" href="../../res/img/coin.ico">
<title>INSERT COIN</title>
</head>
<body style="font-family: 'ConnectionRegular'; font-weight: normal; font-style: normal;">
<div class="row text-center">
<a href="../mazes/">
<div class="col-md-4 col-lg-4" id="sectiona">
<h1>ihatemazes</h1>
</div>
</a>
<a href="../naia/">
<div class="col-md-4 col-lg-4" id="sectionb">
<h1>naia</h1>
</div>
</a>
<a href="../files/">
<div class="col-md-4 col-lg-4" id="sectionc">
<h1>image-file_upload</h1>
</div>
</a>
</div>
<center style="margin-top: 30px">
<form action="beam.php" method="post" enctype="multipart/form-data">
<p>
<input type="text" placeholder="Filename (Blank for uploaded name)"
name="desired_filename" id="desired_filename" style="width: 400px;">
</p>
<input type="file" name="fileToUpload" id="fileToUpload">
<input style="margin-top: 10px; margin-bottom: 10px" type="submit" value="INSERT COIN" name="submit">
</form>
<img src="../../res/img/insertcoin_big.png">
<footer>No data will be recorded on who inserts what coin-- all I'll get is a timestamp.</footer>
<p>--> <a href="nerd.html">rocket scientist edition</a> <--</p>
<p><a href="https://notabug.org/jadedctrl/insert-coin">source juice</a></p>
</center>
</body>
</html>

View File

@ -1,4 +1,10 @@
<?php include("header.html");?>
<?php
include("res/config.php");
$page_title = "Insert " . ucfirst($file_beam_item);
include("res/header.php");
?>
<main>
@ -13,17 +19,13 @@
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">
<input style="margin-top: 10px; margin-bottom: 10px" type="submit"
value="INSERT <?php echo(strtoupper($file_beam_item)); ?>" name="submit">
</form>
<img alt="Picture of a pretty big, yellow labour-token." src="res/img/insertcoin_big.png">
<img alt="<?php echo($file_beam_alt); ?>" src="<?php echo($file_beam_img); ?>">
</main>
<?php include("footer.html");?>
<?php include("res/footer.html");?>

57
lib.php Executable file → Normal file
View File

@ -1,12 +1,29 @@
<?php
include("res/config.php");
function write_metadata($filename, $desc, $source)
function write_alias($filename, $target)
{
$file_p = fopen($filename, 'w');
fwrite($file_p, "<?php header('Location: " . $target . "'); ?>\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)
{
?>
<title><?php echo($site_name . ": " . $item_type); ?> inserted <3</title>
<p>Thanks for feeding me</p>
<p>Your <?php echo($item_type); ?>'s in safe hands</p>
<img alt="<?php echo($image_alt); ?>" src="<?php echo($image_url); ?>">
<p>Your <?php echo($item_type); ?>'s
<a href="<?php echo ($dest_file); ?>">over here</a></p>
<?php
if ($meta_data)
{
?>
<p>It's meta-stuff (or lack thereof) is
<a href="<?php echo($dest_file); ?>.txt">here</a></p>
<?php
}
}
function celebrate_death($dest_file, $item_type, $image_url, $image_alt, $message)
{
?>
<title><?php echo($site_name . ": " . $item_type); ?> burned </3</title>
<p>Oh God, I've never seen so much blood—</p>
<p>err, I mean, there're just some minor problems under the hood!</p>
<img alt="<?php echo($image_alt); ?>" src="<?php echo($image_url); ?>">
<?php echo($message); ?>
<?php
}

37
res/config.php Normal file
View File

@ -0,0 +1,37 @@
<?php
//
// This file contains some global configuration you might wanna do
//
$site_name = "insert-coin"; // what the site will be called
// vars related to URL shortening
$url_aliasize_img = "res/img/mask-big.png";
$url_aliasize_alt = "A mask, floating in mid-air.";
$url_aliasize_win_img = "res/img/mask_win-big.png";
$url_aliasize_win_alt = "A whimsical mask sparkling.";
$url_aliasize_die_img = "res/img/mask_die-big.png";
$url_aliasize_die_alt = "A whimsical mask on fire.";
$url_aliasize_item = "mask"; // what the alias is affectionately called
$url_aliasize_dir = "u/"; // where the redirects go
$url_aliasize_suffix = ".php"; // suffix to redirect links; some web-servers
// only execute ".php" files, so you might
// wanna keep ".php" as the suffix
// vars related to file uploading
$file_beam_img = "res/img/coin-big.png";
$file_beam_alt = "A big & yellow coin lying before a coin-slot";
$file_beam_win_img = "res/img/coin_win-big.png";
$file_beam_win_alt = "A coin inserted into a coin slot.";
$file_beam_die_img = "res/img/coin_die-big.png";
$file_beam_die_alt = "A coin on fire.";
$file_beam_item = "coin"; // what the file is affectionately called
$file_beam_dir = "p/"; // where the files go

View File

@ -11,12 +11,12 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>coinsh.red: Insert Coin</title>
<title><?php echo($site_name . ": " . $page_title); ?></title>
</head>
<body>
<div class="menu top-menu">
<h2>coinsh.red</h2>
<h2><a href="."><?php echo($site_name); ?></a></h2>
<ul>
<li><a href="index.php">file-beamer</a></li>
<li><a href="url.php">url-shortener</a></li>

BIN
res/img/coin-big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

BIN
res/img/coin_die-big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
res/img/coin_die.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

BIN
res/img/coin_win-big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
res/img/coin_win.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

BIN
res/img/mask-big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

BIN
res/img/mask.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

BIN
res/img/mask_die-big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

BIN
res/img/mask_die.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

BIN
res/img/mask_win-big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

BIN
res/img/mask_win.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

View File

@ -27,6 +27,11 @@ main
padding-bottom: 20px;
}
.menu h2 a
{
color: #000000;
text-decoration: none;
}
@ -49,7 +54,6 @@ main
.menu h1, .menu h2, .menu h3
{
background-color: #CFA5B4;
}
.menu ul

16
url.php
View File

@ -1,4 +1,10 @@
<?php include("header.html");?>
<?php
$page_title = "Create Mask";
include("res/config.php");
include("res/header.php");
?>
<main>
@ -13,11 +19,13 @@
name="url_alias" class="basic-text">
</p>
<input style="margin-top: 10px; margin-bottom: 10px" type="submit" value="INSERT COIN" name="submit">
<input style="margin-top: 10px; margin-bottom: 10px" type="submit"
value="FORGE <?php echo(strtoupper($url_aliasize_item)); ?>" name="submit">
</form>
<img alt="Picture of a pretty big, yellow labour-token." src="res/img/insertcoin_big.png">
<img alt="<?php echo($url_aliasize_alt); ?>" src="<?php echo($url_aliasize_img); ?>">
</main>
<?php include("footer.html");?>
<?php include("res/footer.html");?>