diff --git a/public_html/beam.php b/public_html/beam.php
index 286a396..8d50d2d 100644
--- a/public_html/beam.php
+++ b/public_html/beam.php
@@ -2,7 +2,7 @@
$page_title = "The Beaming";
include("../resources/config.php");
-include("../resources/library/insert-coin.php");
+include("../resources/library/main.php");
include("../resources/templates/header.php");
echo("\n\n");
diff --git a/public_html/conjure.php b/public_html/conjure.php
index 981d19a..005250f 100644
--- a/public_html/conjure.php
+++ b/public_html/conjure.php
@@ -2,7 +2,7 @@
$page_title = "The Conjuring";
include("../resources/config.php");
-include("../resources/library/insert-coin.php");
+include("../resources/library/main.php");
include("../resources/templates/header.php");
echo("\n\n");
diff --git a/resources/library/array.php b/resources/library/array.php
new file mode 100644
index 0000000..152c15c
--- /dev/null
+++ b/resources/library/array.php
@@ -0,0 +1,10 @@
+ LAST_ELEMENT_OF_ARRAY
+// Get the last element in an array.
+function last($array)
+{
+ $array[count($array) - 1];
+}
+
+?>
diff --git a/resources/library/file.php b/resources/library/file.php
new file mode 100644
index 0000000..947a874
--- /dev/null
+++ b/resources/library/file.php
@@ -0,0 +1,41 @@
+ RELATIVE_PATH
+// SIDE-EFFECT: Written redirect PHP to filepath
+// Create a simple PHP redirection file at $filepath to $url;
+// return the relative path to it.
+function write_alias($filepath, $url)
+{
+ $file_p = fopen($filepath, 'w');
+
+ fwrite($file_p, "\n");
+ fclose($file_p);
+
+ return $filepath;
+}
+
+
+
+// FILEPATH SOURCE_STRING --> RELATIVE_PATH
+// SIDE-EFFECT: Written metadata TXT at $filepath.txt
+// Create a metadata file for set path;
+// return the relative path to it.
+function write_metadata($filepath, $source)
+{
+ if (empty($source)) {
+ $source = "[citation needed]";
+ }
+
+ $file_p = fopen($filepath . ".txt", 'w');
+ $source_string = "Source:\n"
+ . prefix_text(set_line_length($source, 50),
+ " ");
+
+ fwrite($file_p, $source_string);
+ fclose($file_p);
+}
+
+
+?>
diff --git a/resources/library/insert-coin.php b/resources/library/insert-coin.php
index e9fdb35..cd4b4e7 100644
--- a/resources/library/insert-coin.php
+++ b/resources/library/insert-coin.php
@@ -2,197 +2,6 @@
include("../config.php");
-// FILEPATH URL --> RELATIVE_PATH
-// SIDE-EFFECT: Written redirect PHP to filepath
-// Create a simple PHP redirection file at $filepath to $url;
-// return the relative path to it.
-function write_alias($filepath, $url)
-{
- $file_p = fopen($filepath, 'w');
-
- fwrite($file_p, "\n");
- fclose($file_p);
-
- return $filepath;
-}
-
-
-
-// FILEPATH SOURCE_STRING --> RELATIVE_PATH
-// SIDE-EFFECT: Written metadata TXT at $filepath.txt
-// Create a metadata file for set path;
-// return the relative path to it.
-function write_metadata($filepath, $source)
-{
- if (empty($source)) {
- $source = "[citation needed]";
- }
-
- $file_p = fopen($filepath . ".txt", 'w');
- $source_string = "Source:\n"
- . prefix_text(set_line_length($source, 50),
- " ");
-
- fwrite($file_p, $source_string);
- fclose($file_p);
-}
-
-
-
-// TEXT STRING_PREFIX --> TEXT_STARTING_WITH_PREFIX
-// Places $prefix at the start of every line in $text.
-function prefix_text($text, $prefix)
-{
- $separator = "\r\n";
- $line = strtok($text, $separator);
- $prefixed_text="";
-
- while ($line !== false) {
- $prefixed_text=$prefixed_text . $prefix . $line . "\n";
- $line = strtok($separator);
- }
-
- return $prefixed_text;
-}
-
-
-
-// STRING COLUMN_SIZE_NUMBER --> TEXT_FORMATTED_TO_SIZED_LINES
-// Turns all lines in a string into, at the max, sized at $column_size
-// Perfect for consistent formatting <3
-function set_line_length($original, $line_width)
-{
- $text_len = strlen($original) - 1;
- $line_width = $line_width - 1;
-
- $resized = [];
- $new_line = true;
-
- if ($text_len + 1 == 0) {
- return 0;
- }
-
- // j is the index for $resized, the string deriving from $text
- // they will both be different sizes, and so need different indexes
- $j = 0;
-
- for($i = 0; $i <= $text_len; $i++) {
- $cur_character = substr($original, $i, 1);
-
- if ($i % $line_width == 0 && $i != 0) {
- // if not in middle of word, just start a newline
- // otherwise, hypenate the word across a newline
- if ($cur_character == ' ') {
- $resized[$j] = "\n";
- $j++;
- }
- else if (is_punctuation($cur_character)) {
- $resized[$j] = "$cur_character";
- $resized[$j + 1] = "\n";
- $j++;
- }
- else {
-
- $resized[$j] = "-";
- $resized[$j + 1] = "\n";
- $resized[$j + 2] = $original[$i];
- $j += 2;
- }
-
- $new_line = true;
- }
- else {
- if ($new_line == true && $cur_character == ' ') {
- }
- else {
- $resized[$j] = $original[$i];
- }
-
- $new_line = false;
- }
-
- $j++;
- }
-
- return implode($resized);
-}
-
-
-
-// CHARACTER --> BOOLEAN
-// Check whether or not a character is punctuation.
-function is_punctuation($character)
-{
- $punctuations = array("!", "@", "#", "$", "%", "^", "&", "*", "(", ")",
- "[", "{", "}", "]", "`", "~", ";", ":", "'",
- "\"", ",", ".", "<", ">", "/", "?");
-
- return in_array($character, $punctuations);
-}
-
-
-
-// FILENAME --> SAFE_FILENAME_STRING
-// Sanitize a filename by replacing common suspicious characters with "_".
-function sanitize_filename($filename)
-{
- $death_characters = array(" ", ",", "/", "\\", "%", "$", "^");
-
- $sanitized_filename = str_replace($death_characters, "_", $filename);
-
- return $sanitized_filename;
-}
-
-
-
-// ARRAY --> LAST_ELEMENT_OF_ARRAY
-// Get the last element in an array.
-function last($array)
-{
- $array[count($array) - 1];
-}
-
-
-
-// URL --> FILENAME_AT_END_OF_URL
-// Return the filename of a URL.
-function url_to_filename($url)
-{
- return last(explode('/', $url));
-}
-
-
-
-// ??? --> ???
-// ???
-function get_cwd($url)
-{
- $url_array = (explode("/", $url));
-
- if (end($url_array)) {
- $parts = count($url_array);
-
- $url = $_SERVER["HTTP_HOST"] . implode(array_splice($url_array, 1, $parts - 2));
-
- return $url;
- }
- else {
- return $url;
- }
-}
-
-
-
-// IMAGE_PATH --> IMAGE_PATH
-// Sanitize an image (EXIF, etc) with external program from config.php
-function sanitize_image($path)
-{
- exec($image_sanitize_command . $image_sanitize_args . $path, $result);
-
- return $path;
-}
-
-
function celebrate($dest_file, $item_type, $image_url, $image_alt, $meta_data = false)
{
diff --git a/resources/library/main.php b/resources/library/main.php
new file mode 100644
index 0000000..acdda2c
--- /dev/null
+++ b/resources/library/main.php
@@ -0,0 +1,12 @@
+
diff --git a/resources/library/sanitization.php b/resources/library/sanitization.php
new file mode 100644
index 0000000..4311736
--- /dev/null
+++ b/resources/library/sanitization.php
@@ -0,0 +1,27 @@
+ SAFE_FILENAME_STRING
+// Sanitize a filename by replacing common suspicious characters with "_".
+function sanitize_filename($filename)
+{
+ $death_characters = array(" ", ",", "/", "\\", "%", "$", "^");
+
+ $sanitized_filename = str_replace($death_characters, "_", $filename);
+
+ return $sanitized_filename;
+}
+
+
+
+// IMAGE_PATH --> IMAGE_PATH
+// Sanitize an image (EXIF, etc) with external program from config.php
+function sanitize_image($path)
+{
+ exec($image_sanitize_command . $image_sanitize_args . $path, $result);
+
+ return $path;
+}
+
+?>
diff --git a/resources/library/string.php b/resources/library/string.php
new file mode 100644
index 0000000..e76771b
--- /dev/null
+++ b/resources/library/string.php
@@ -0,0 +1,95 @@
+ TEXT_STARTING_WITH_PREFIX
+// Places $prefix at the start of every line in $text.
+function prefix_text($text, $prefix)
+{
+ $separator = "\r\n";
+ $line = strtok($text, $separator);
+ $prefixed_text="";
+
+ while ($line !== false) {
+ $prefixed_text=$prefixed_text . $prefix . $line . "\n";
+ $line = strtok($separator);
+ }
+
+ return $prefixed_text;
+}
+
+
+
+// STRING COLUMN_SIZE_NUMBER --> TEXT_FORMATTED_TO_SIZED_LINES
+// Turns all lines in a string into, at the max, sized at $column_size
+// Perfect for consistent formatting <3
+function set_line_length($original, $line_width)
+{
+ $text_len = strlen($original) - 1;
+ $line_width = $line_width - 1;
+
+ $resized = [];
+ $new_line = true;
+
+ if ($text_len + 1 == 0) {
+ return 0;
+ }
+
+ // j is the index for $resized, the string deriving from $text
+ // they will both be different sizes, and so need different indexes
+ $j = 0;
+
+ for($i = 0; $i <= $text_len; $i++) {
+ $cur_character = substr($original, $i, 1);
+
+ if ($i % $line_width == 0 && $i != 0) {
+ // if not in middle of word, just start a newline
+ // otherwise, hypenate the word across a newline
+ if ($cur_character == ' ') {
+ $resized[$j] = "\n";
+ $j++;
+ }
+ else if (is_punctuation($cur_character)) {
+ $resized[$j] = "$cur_character";
+ $resized[$j + 1] = "\n";
+ $j++;
+ }
+ else {
+
+ $resized[$j] = "-";
+ $resized[$j + 1] = "\n";
+ $resized[$j + 2] = $original[$i];
+ $j += 2;
+ }
+
+ $new_line = true;
+ }
+ else {
+ if ($new_line == true && $cur_character == ' ') {
+ }
+ else {
+ $resized[$j] = $original[$i];
+ }
+
+ $new_line = false;
+ }
+
+ $j++;
+ }
+
+ return implode($resized);
+}
+
+
+
+// CHARACTER --> BOOLEAN
+// Check whether or not a character is punctuation.
+function is_punctuation($character)
+{
+ $punctuations = array("!", "@", "#", "$", "%", "^", "&", "*", "(", ")",
+ "[", "{", "}", "]", "`", "~", ";", ":", "'",
+ "\"", ",", ".", "<", ">", "/", "?");
+
+ return in_array($character, $punctuations);
+}
+
+
+?>
diff --git a/resources/library/url.php b/resources/library/url.php
new file mode 100644
index 0000000..f6bdb3c
--- /dev/null
+++ b/resources/library/url.php
@@ -0,0 +1,30 @@
+ FILENAME_AT_END_OF_URL
+// Return the filename of a URL.
+function url_to_filename($url)
+{
+ return last(explode('/', $url));
+}
+
+
+
+// ??? --> ???
+// ???
+function get_cwd($url)
+{
+ $url_array = (explode("/", $url));
+
+ if (end($url_array)) {
+ $parts = count($url_array);
+
+ $url = $_SERVER["HTTP_HOST"] . implode(array_splice($url_array, 1, $parts - 2));
+
+ return $url;
+ }
+ else {
+ return $url;
+ }
+}
+
+?>