Documents

Click here for demo
Create and organize documents as either HTML or plain text. HTML is produced using the markdown parser shown on this website. There is also an image library with folders, and each document can be divided into sections. Multiple styles sheets can be made available so that each document can have a unique styling.
DOCUMENTS Code
Download
DOCUMENTS/index.php ▾
<?php
session_start();
include ("inc/db-definitions.php");
include ("inc/functions-no-write.php");
$pageid = getFromQueryString ('page');
if (!$pageid) {
$pageid = "home";
}
$documentid = getFromQueryString ('document');
$documentrecord = readDatabaseRecord ($documentrecordkeys, 'data/documents/'. $documentid . '.txt');
$category = getFromQueryString ('category');
$searchterm = getFromQueryString ('searchterm');
$print = getFromQueryString ('print');
include ("inc/header.php");
if (file_exists ("pages/". $pageid . ".php") ){
include ("pages/" . $pageid . ".php");
}
else {
echo "<h3>404 Page Not Found</h3>";
}
include ("inc/footer.php");
?>
DOCUMENTS/pages
add-update-document.php ▾
<?php
include ("markdown/convert-markdown.php");
$documentid = getFromQueryString ('document');
$versionid = getFromQueryString ('version');
if ($versionid !== '' ) {
$filename = 'data/document-versions/' . $versionid . ".txt";
}
else {
$filename = 'data/documents/' . $documentid . '.txt';
}
$documentrecord = readDatabaseRecord($documentrecordkeys, $filename);
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
include ('inc/process-add-update-document.php');
}
?>
<div class = 'content-column'>
<?php
if ($documentid) {
echo "<h3>Edit Document</h3>";
echo "<b>Document: </b>" . $documentrecord['title']. "<br>";
echo "<b>Id: </b><a href = 'index.php?page=add-update-document&document=" . $documentid . "'>" . $documentid . "</a> <br>";
if ($versionid !== "") {
echo "<b>Version Id: </b>" . $versionid . "<br><br>";
}
}
else {
echo "<h2>New Document</h2>";
}
include ("inc/add-update-document-form.php");
include ('markdown/markdown-instructions.php');
include ('markdown/view-html.php');
?>
</div><div class = 'sidebar-column'>
<?php
echo "<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>";
if ($documentid ) {
echo "<a class = 'adminbutton ' href = 'index.php?page=display-document&document=" . $documentid . "'>View Document</a>";
echo "<a class = 'adminbutton' href = 'index.php?page=remove-document&document=" . $documentid . "'>Remove </a>";
echo "<a class = 'adminbutton' href = 'index.php?page=select-previous-document&document=" . $documentid . "'>Previous Versions</a>";
if ($versionid) {
echo "<a class = 'adminbutton' href = 'index.php?page=add-update-document&document=" . $documentid . "'>Current Version</a> <br>";
}
echo "<a class = 'adminbutton ' href = 'index.php?page=change-document-title&document=" . $documentid . "'>Change Document Title</a>";
}
?>
</div>
<?php
require ("inc/display-media-library.php");
?>
change-document-title.php ▾
<div class = 'content-column'>
<?php
$newtitle = '';
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
if (isset ($_POST['new-title'])) {
$newtitle = $_POST['new-title'];
if ($newtitle) {
$newdocumentid = createRecordId ($newtitle);
$oldfilename = 'data/documents/' . $documentid . '.txt';
$newfilename = 'data/documents/' . $newdocumentid . '.txt';
if (file_exists ($oldfilename)) {
$string = file_get_contents ('data/maps/category-document-map.txt');
$newstring = str_replace ($dl2 . $documentid . $dl2, $dl2 . $newdocumentid . $dl2, $string);
file_put_contents ('data/maps/category-document-map.txt', $newstring);
$string = file_get_contents ('data/maps/date-document-map.txt');
$newstring = str_replace ($dl2 . $documentid . $dl2, $dl2 . $newdocumentid . $dl2, $string);
file_put_contents ('data/maps/date-document-map.txt', $newstring);
rename ($oldfilename, $newfilename);
$documentrecord = readDatabaseRecord ($documentrecordkeys, 'data/documents/' . $newdocumentid . '.txt');
$documentrecord['title'] = $newtitle;
writeDatabaseRecord ($documentrecord, 'data/documents/' . $newdocumentid . '.txt');
}
else {
echo "<div class = 'error'>Old file name not found</div>";
}
}
else {
echo "<div class = 'error'>Unable to create new document id</div>";
}
}
else {
echo "<div class = 'error'>Missing new title</div>";
}
}
?>
<form method = 'post' action = 'index.php?page=change-document-title&document=<?php echo $documentid; ?>' >
<?php
echo "Current Title: " . $documentrecord['title'] . "<br>";
echo "<label for= 'title-textarea'>New Title: </label><br> ";
echo "<textarea id = 'title-textarea' rows = '1' name = 'new-title'>" . $documentrecord['title'] . "</textarea><br><br> ";
?>
<input class = 'submitbutton' type = 'submit' name = 'submit' value = 'Submit' />
</form>
</div> display-document-category.php ▾
<div class = 'content-column'>
<?php
$cat = getFromQueryString ('category');
$categoryarray = selectMapEntries ('data/maps/category-document-map.txt', $cat, '');
$array1 = explode ($dl1, file_get_contents ("data/maps/date-document-map.txt"));
rsort ($array1);
foreach ($array1 as $item1) {
$array2 = explode ($dl2, $item1);
$date = $array2[0];
if (array_key_exists (1, $array2)) {
$documentid = $array2[1];
if (in_array ($documentid, $categoryarray)) {
$othercategories = selectMapEntries ('data/maps/category-document-map.txt', '', $documentid);
$string = implode (' ', $othercategories);
echo $date . " <a href = 'index.php?page=display-document&document=" . $documentid . "'>" . showWords ($documentid). "</a> <i>" . $string . "</i>";
echo " <br>";
}
}
}
?>
</div><div class = 'sidebar-column'>
<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>
<a class = 'adminbutton' href = 'index.php?page=add-update-document'>New Document</a>
<a class = 'adminbutton' href = 'index.php?page=manage-document-categories'>Manage DocumentCategories</a>
<a class = 'adminbutton' href = 'index.php?page=remove-previous-versions'>Previous Versions</a>
<a class = 'adminbutton' href = 'index.php?page=trash'>Trash</a>
</div>
display-document.php ▾
<div class = 'full-column'>
<?php
if (!$print) {
echo "<h1>" . $documentrecord['title'] . "</h1>";
echo "<h5>" . $documentrecord['date'] . "</h5>";
echo "<div class = 'content-column'>";
}
$text = $documentrecord['html-content'];
if ($searchterm) {
$ucsearchterm = ucwords ($searchterm);
$lcsearchterm = strtolower ($searchterm);
$text = strip_tags ($text, "<p>");
$highlightedterm = "<span class = 'searchterm'>" . $lcsearchterm . "</span>";
$text = str_replace ($lcsearchterm, $highlightedterm, $text);
$highlightedterm = "<span class = 'searchterm'>" . $ucsearchterm . "</span>";
$text = str_replace ($ucsearchterm, $highlightedterm, $text);
}
echo nl2br($text);
if (!$print) {
echo "</div><div class = 'sidebar-column'>";
echo "<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>";
echo "<a class = 'adminbutton ' href = 'index.php?page=add-update-document&document=" . $documentid . "'>Edit Document</a>";
echo "<a class = 'adminbutton' target = '_blank' href = 'index.php?page=print-document&document=" .$documentid . "&print=1'>Print Document</a>";
echo "<a class = 'adminbutton' target = '_blank' href = 'index.php?page=print-TPHS-letter&document=" .$documentid . "&print=1'>Print TPHS Letter</a>";
}
?>
</div></div>
home.php ▾
<br><br>
<div class = 'content-column'>
<div class = 'dropdownwrap'>
<div class = 'dropdownbutton' id = 'title' onclick= 'accordionToggle(this.id)'><h3>Documents by Title ▾</h3></div>
<div id ='title-content' class = 'dropdowncontent1' style = 'display: none; ' >
<?php
$documents = getRecordIdsFromFolder ('data/documents');
foreach ($documents as $documentid) {
echo "<a href = 'index.php?page=display-document&document=" . $documentid . "'>" . showWords ($documentid) . "</a>";
$date = selectMapKey ('data/maps/date-document-map.txt', '', $documentid);
echo " <i>" . $date . "</i> ";
$categories = selectMapEntries ('data/maps/category-document-map.txt', '', $documentid);
foreach ($categories as $cat) {
echo " <i>" . $cat . "</i>";
}
echo "<br>";
}
?>
</div>
</div>
<div class = 'dropdownwrap'>
<div class = 'dropdownbutton' id = 'category' onclick= 'accordionToggle(this.id)'><h3>Documents by Category ▾</h3></div>
<div id ='category-content' class = 'dropdowncontent1' style = 'display: none; ' >
<div>
<?php
$array1 = explode ($dl1, file_get_contents ("data/maps/date-document-map.txt"));
rsort ($array1);
$categories = readArray ('data/categories.txt', ',');
foreach ($categories as $cat) {
echo "</div><div class = 'half-column'>";
echo "<h4>" . showWords($cat) . "</h4>";
$documentsincategory = selectMapEntries ('data/maps/category-document-map.txt', $cat, '');
foreach ($array1 as $item1) {
$array2 = explode ($dl2, $item1);
$date = $array2[0];
if (array_key_exists (1, $array2)) {
$documentid = $array2[1];
if (in_array ($documentid, $documentsincategory)) {
echo "<a href = 'index.php?page=display-document&document=" . $documentid . "'>" . showWords ($documentid) . "</a>";
echo " <i>" . $date . "</i><br>";
}
}
}
}
?>
</div></div>
</div>
<div class = 'dropdownwrap'>
<div class = 'dropdownbutton' id = 'date' onclick= 'accordionToggle(this.id)'><h3>Documents by Date ▾</h3></div>
<div id ='date-content' class = 'dropdowncontent1' style = 'display: none; ' >
<?php
$array1 = explode ($dl1, file_get_contents ("data/maps/date-document-map.txt"));
rsort ($array1);
foreach ($array1 as $item1) {
$array2 = explode ($dl2, $item1);
$date = $array2[0];
if (array_key_exists (1, $array2)) {
$documentid = $array2[1];
echo $date . " <a href = 'index.php?page=display-document&document=" . $documentid . "'>" . showWords ($documentid). "</a> ";
$categories = selectMapEntries ('data/maps/category-document-map.txt', '', $documentid);
foreach ($categories as $cat) {
echo " <i>" . $cat . "</i> ";
}
echo "<br>";
}
}
?>
</div>
</div>
</div><div class = 'sidebar-column'>
<a class = 'adminbutton' href = 'index.php?page=add-update-document'>New Document</a>
<a class = 'adminbutton' href = 'index.php?page=manage-document-categories'>Manage Document Categories</a>
<a class = 'adminbutton' href = 'index.php?page=remove-previous-versions'>Previous Versions</a>
<a class = 'adminbutton' href = 'index.php?page=trash'>Trash</a>
<a class = 'adminbutton' href = 'index.php?page=media-library'>Media Library</a>
<a class = 'adminbutton' href = 'index.php?page=print-TPHS-return-labels&print=1'>Print TPHS return labels</a>
<div class = 'box'>
<form method="post" action= "index.php?page=search-for-term">
<label class = 'search-label' for = 'searchterm'>Search</label><br>
<input id = 'searchterm' type= "text" name= "searchterm" /> <br><br>
<input class = 'submitbutton' style = 'margin: auto;' type="submit" name = 'submit' value = "Submit" ><br>
</form>
</div>
</div> image-edit.php ▾
<?php
$imagefolder = getFromQueryString ('imagefolder');
$imagebase = getFromQueryString ('imagebase');
$imagename = pathinfo ($imagebase, PATHINFO_FILENAME);
$extension = pathinfo ($imagebase, PATHINFO_EXTENSION);
$folderfile = $imagefolder . '/' . $imagebase;
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
//Rename image
if (isset($_POST['newimagename'])) {
$newimagename = $_POST['newimagename'];
$newimagename = preg_replace('/[^A-Za-z0-9-.]/', '', $newimagename);
if ($newimagename === "") {
echo "<div class = 'error'>Invalid Image Name</div>";
}
else {
$oldfolderfile = 'data/images/' . $imagefolder . '/' . $imagebase;
$newfolderfile = 'data/images/' . $imagefolder . '/'. $newimagename . '.' . $extension;
rename ($oldfolderfile, $newfolderfile);
$imagebase = $newimagename . "." . $extension;
$imagename = $newimagename;
$folderfile = $newfolderfile;
require ('inc/replace-image-in-files.php');
$folderfile = $newfolderfile;
}
}
//Move Image to new folder
else if (isset($_POST['newfolder'])) {
$newfolder = $_POST['newfolder'];
$oldfolderfile = $imagefolder . "/" . $imagebase;
$newfolderfile = $newfolder . "/". $imagebase;
if ($newfolder !== 'trash') {
require ("inc/replace-image-in-files.php");
}
rename ('data/images/' . $oldfolderfile, 'data/images/' . $newfolderfile);
$imagefolder = $newfolder;
$folderfile = $newfolderfile;
}
//Copy Image to new folder
else if (isset($_POST['copyfolder'])) {
$copyfolder = $_POST['copyfolder'];
$oldfolderfile = $imagefolder . "/" . $imagebase;
$newfolderfile = $copyfolder . "/". $imagebase;
copy ('data/images/' . $oldfolderfile, 'data/images/' . $newfolderfile);
$imagefolder = $copyfolder;
}
}
$imagefolder = getFromQueryString ('imagefolder');
$imagebase = getFromQueryString ('imagebase');
$imagename = pathinfo ($imagebase, PATHINFO_FILENAME);
$extension = pathinfo ($imagebase, PATHINFO_EXTENSION);
$folderfile = $imagefolder . '/' . $imagebase;
?>
<h1>Update Image</h1>
<h3><?php echo $folderfile; ?></h3>
<div class = 'content-column'>
<?php
echo"Image Name: <b>" . $imagebase . "</b><br>";
echo "Folder: <b>" . $imagefolder . "</b><br>";
//Folders where image is found
echo "<br>All folders where image is found: ";
$folders = scandir( "data/images");
foreach ($folders as $item) {
if ($item !== "." && $item !== "..") {
$folder = trim ($item);
$images = getImagesFromFolder ( "data/images/" . $folder );
if (in_array ( $imagebase, $images)){
echo '<b>' . $folder . "</b> ";
}
}
}
//Documents that use image
echo"<br>Documents that include image: <br>";
$documents = getRecordIdsFromFolder ('data/documents');
foreach ($documents as $documentid) {
$string = file_get_contents ('data/documents/' . $documentid . '.txt');
if (strpos ($string, $imagefolder . "/" . $imagebase)) {
echo "Folder: " . $imagefolder . " ";
echo "<a href = 'index.php?page=add-update-document&documentid=" . $documentid . "'>" . $documentid . "</a><br>";
}
}
if ($extension !== 'pdf'){
echo "<img src = 'data/images/" . $folderfile . "' alt = 'selected image'/><br>";
}
?>
<div class = 'half-column'>
<div class = 'adminbox'>
<b>Rename Image</b>
<form action= "index.php?page=image-edit&imagefolder=<?php echo $imagefolder; ?>&imagebase=<?php echo $imagebase; ?>" method="post" >
<label for = 'image-name' >Name</label><br>
<input id = 'image-name' type = 'text' name = 'newimagename' value = '<?php echo $imagename; ?>'/>
<input class = 'submitbutton' type = 'submit' name = 'submit-rename' value='Submit'/>
</form>
</div>
</div><div class = 'half-column'>
<div class = 'adminbox left'>
<b>Change Image imagefolder</b>
<form action= "index.php?page=image-edit&imagefolder=<?php echo $imagefolder; ?>&imagebase=<?php echo $imagebase; ?>" method="post" >
<div class = 'left'>
<?php
$array1 = scandir ("data/images");
foreach ($array1 as $item1) {
if ($item1 !== "." && $item1 !== "..") {
$item1 = trim ($item1);
if ($imagefolder === $item1) {
echo "<br><input id = '" . $item1 . "' type = 'radio' name = 'newfolder' value = '" . $item1 ."' checked />";
}
else {
echo "<br><input id = '" . $item1 . "' type = 'radio' name = 'newfolder' value = '" . $item1 ."' />";
}
echo "<label for= '" . $item1 . "'>" . $item1 . "</label>";
}
}
?>
</div>
<br><input class = 'submitbutton' type = 'submit' name = 'submit-change-folder' value='Select'/>
</form>
</div>
<div class = 'adminbox left'>
<b>Copy to New Folder</b>
<form action= "index.php?page=image-edit&imagefolder=<?php echo $imagefolder; ?>&imagebase=<?php echo $imagebase; ?>" method="post" >
<div class = 'left'>
<?php
$array1 = scandir ("data/images");
foreach ($array1 as $item1) {
if ($item1 !== "." && $item1 !== "..") {
$item1 = trim ($item1);
if ($imagefolder === $item1) {
echo "<br><input id = '" . $item1 . "' type = 'radio' name = 'copyfolder' value = '" . $item1 ."' checked />";
}
else {
echo "<br><input id = '" . $item1 . "' type = 'radio' name = 'copyfolder' value = '" . $item1 ."' />";
}
echo "<label for= '" . $item1 . "'>" . $item1 . "</label>";
}
}
?>
</div>
<br><input class = 'submitbutton' type = 'submit' name = 'submit-copy to-folder' value='Select'/>
</form>
</div>
</div>
</div><div class = 'sidebar-column'>
<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>
<a class = 'adminbutton' href = 'index.php?page=media-library'>Media Library</a> <br>
</div>
logout.php ▾
<?php
session_unset();
session_destroy();
echo "<h3>You are now logged out </h3><br><br>";
echo "<a href = 'index.php'><h5>Log In</h5></a>";
?> manage-document-categories.php ▾
<?php
$categoryarray = readArray ('data/categories.txt', ',');
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
if (isset ($_POST['newcategory'])) {
$newcategory = sanitizeFormInput ($_POST['newcategory']);
$newkey = createRecordId ($newcategory);
if ($newkey !== "") {
if (in_array($newkey, $categoryarray) ){
echo "<div class = 'error'>This category already exists</div>";
}
else {
addNameToArray ("data/categories.txt", $newkey, ',');
$categoryarray = readArray ('data/categories.txt', ",");
}
}
}
else if (isset ($_POST['removearray'])) {
$removearray = $_POST['removearray'];
foreach ($removearray as $item) {
removeNameFromArray ("data/categories.txt", $item, ',');
}
}
else if (isset ($_POST['submit-credentials'])) {
if (isset ($_POST['username'])) {
file_put_contents ("data/username.txt", $_POST['username']);
}
if (isset ($_POST['password'])) {
file_put_contents ("data/password.txt", $_POST['password']);
}
$username = file_get_contents ("data/username.txt");
$password = file_get_contents ("data/password.txt");
}
}
?>
<h2>Manage Document Categories</h2><br>
<div class = 'content-column'>
<div class = 'half-column'>
<div class = 'gridcolumn'>
<form method = 'post' action = 'index.php?page=manage-document-categories'>
<h4>New Category</h4><input type = 'text' name = 'newcategory' />
<input class = 'submitbutton' type = 'submit' name = 'submit' value='Submit'>
</form>
</div>
<div class = 'gridcolumn'>
<h4>Categories</h4>
<?php
$array1 = readArray("data/categories.txt", ',');
foreach ($array1 as $item1) {
echo "<a href = 'index.php?page=update-document-category&category=" . $item1 ."'>" . showWords ($item1) . "</a><br>";
}
?>
</div>
</div><div class = 'half-column'>
<div class = 'gridcolumn'>
<form method = 'post' action = 'index.php?page=manage-document-categories'>
<h4>Remove Category</h4>
<?php
$array1 = readArray("data/categories.txt", ',');
foreach ($array1 as $item) {
echo "<input type = 'checkbox' name = 'removearray[]' value = '" . $item . "' />" . ucwords (str_replace ('-', ' ', $item)) . "<br>";
}
?>
<input class = 'submitbutton' type = 'submit' name = 'remove' value='Remove'>
</form>
</div>
</div>
</div><div class = 'sidebar-column'>
<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>
<a class = 'adminbutton' href = 'index.php?page=trash'>Trash</a>
</div>
manage-image-folders.php ▾
<?php
$oldfolder = $newfolder = "";
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
if (isset ($_POST['newdir'])) {
$newkey = createRecordId($_POST['newdir']);
if ($newkey !== "") {
if (file_exists ("data/images/" . $newkey)) {
echo "<div class = 'error'> The directory: '" . $newkey . "' already exists.</div>";
}
else {
mkdir("data/images/" . $newkey);
echo "Folder " . $newkey . " was successfully created.<br>";
}
}
}
else if (isset ($_POST['selected']) ){
$selected = $_POST['selected'];
foreach ($selected as $imagefolder) {
$array1 = scandir ('data/images/' . $imagefolder);
foreach ($array1 as $item) {
if ($item !== "." && $item !== "..") {
$imagebase = $item;
$oldname = 'data/images/' . $imagefolder . '/'. $imagebase;
$newname = 'data/images/trash/' . $imagebase;
rename ($oldname, $newname);
}
}
rmdir ('data/images/' . $imagefolder);
}
}
}
?>
<div class = 'content-column'>
<h1>Manage Image Folders</h1>
<br><br>
<div class = 'half-column'>
<h3>Add New Folder</h3>
<form action="index.php?page=manage-image-folders" method="post" >
New Folder Name:<br>
<input type = 'text' name = 'newdir' /><br>
<input class = 'submitbutton' type = 'submit' value = 'Submit' name = 'submit-new'>
</form>
<br><br>
<h3>Select Folder to Remove</h3>
<form action= "index.php?page=manage-image-folders" method="post" >
<?php
$array1 = scandir ("data/images");
foreach ($array1 as $item) {
if ($item !== "." && $item !== "..") {
$imagefolder = trim ($item);
if (is_dir("data/images/" . $imagefolder) ) {
if ($imagefolder !== 'trash') {
echo "<input id = '" . $imagefolder . "' type = 'checkbox' name = 'selected[]' value = '" . $imagefolder . "'/>";
echo "<label for = '" . $imagefolder . "'>" . $imagefolder . "</label><br>";
}
}
}
}
?>
<input class = 'submitbutton' type = 'submit' value = 'Remove' name = 'submit-remove'>
</form>
</div><div class = 'half-column'>
<h3>Select Folder to Update</h3>
<?php
$array1 = scandir ("data/images");
foreach ($array1 as $item) {
if ($item !== "." && $item !== "..") {
$imagefolder = trim ($item);
if (is_dir("data/images/" . $imagefolder) ) {
echo "<a href = 'index.php?page=update-image-folder&imagefolder=" . $imagefolder . "'>" . $imagefolder . "</a><br>";
}
}
}
?>
<br><br>
<a class = 'adminbutton' href = 'index.php?page=empty-image-trash' href = 'empty-image-trash' >Empty Image Trash</a>
</div>
</div><div class = 'sidebar-column'>
<br><a class = 'adminbutton' href = 'index.php?page=media-library'>Media Library</a>
</div>
media-library.php ▾
<div class = 'content-column'>
<?php
echo "<div class = 'media-folders'>";
echo "<br><br><h3 >Image Library: </h3>";
$array1 = scandir( "data/images");
foreach ($array1 as $item) {
if ($item !== "." && $item !== "..") {
$imagefolder = trim ($item);
if (is_dir("data/images/" . $imagefolder)) {
echo "<div class = 'dropdownwrap'>";
echo "<div class = 'toggle-banner' id = '" . $imagefolder . "' onclick= 'accordionToggle(this.id)' >" . ucwords(str_replace("-", " ", $imagefolder )). " ▾</div>";
echo "<div id = '" . $imagefolder . "-content' style = 'display: none;'>";
$images = getImagesFromFolder ( "data/images/" . $imagefolder );
foreach ($images as $imagebase) {
$imagesource = "data/images/" . $imagefolder . "/" . $imagebase ;
echo "<div class = 'imagegridcolumn'>";
echo "<a href = 'index.php?page=image-edit&imagefolder=" . $imagefolder . "&imagebase=" . $imagebase . "'>";
echo "<img src = '" . $imagesource . "' alt ='". $imagesource ."' width = '130' /><br>";
echo $imagebase;
echo "</a></div>";
}
echo "</div></div>";
}
}
}
echo "</div>"
?>
</div><div class = 'sidebar-column'>
<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>
<a class = 'adminbutton' href = 'index.php?page=upload-image'>Upload Image</a>
<a class = 'adminbutton' href = 'index.php?page=manage-image-folders'>Manage Image Folders</a>
</div>
print-TPHS-letter.php ▾
<div class = 'letterhead'>
<div class = 'column1'>
<img class = 'logo' src='data/images/TPHS/gazebo2.jpg' alt = 'gazebo' />
</div><div class = 'column2'>
<div class = 'title'>Terrace Park Historical Society</div>
<div class = 'subtitle'>Mission: To foster understanding of and appreciation for the<br> historic heritage of Terrace Park, Ohio</div>
</div>
</div>
<div class = 'letterbody'>
<?php
$text = $documentrecord['html-content'];
echo ($text);
?>
</div>
<div class = 'letterfooter'>
<p><b>The Terrace Park Historical Society is recognized as a nonprofit organization by the IRS.<br>Contributions are tax deductible. IRS Code: Section 501(c)(3). Tax Identification Number: 51093908.</b>
<p>The Terrace Park Historical Society ▪ P.O. Box 3 ▪ Terrace Park, Ohio 45174 ▪ 513-248-1777
<br>tphistoricalsociety@gmail.com ▪ www.tphistoricalsociety.org</p>
</div>
print-TPHS-return-labels.php ▾
<?php
//Prints at 100% scale with custom margin - top: .3
for ($i = 0; $i< 30; $i++) {
echo "<div class = 'outerlabel'>";
echo "Terrace Park Historical Society <br>P.O. Box 3<br>Terrace Park, Ohio 45174";
echo "</div>";
}
print-document.php ▾
<div class = 'full-column'>
<?php
echo "<div class = 'title'>" . $documentrecord['title'] . "</div>";
echo "<div class = 'date'>" . $documentrecord['date'] . "</div>";
$text = $documentrecord['html-content'];
echo ($text);
?>
</div>
remove-document.php ▾
<div class = 'content-column'>
<?php
$documentid = "";
if (isset ($_GET["document"])){
$documentid = filter_input(INPUT_GET, "document", FILTER_SANITIZE_STRING) ;
}
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
if (isset($_POST ['removeflag'])) {
$removeflag = trim($_POST['removeflag']);
if ($removeflag === "REMOVE") {
$oldfilename = "data/documents/" . $documentid . ".txt";
$newfilename = "data/trash/documents----" . $documentid. ".txt";
if (file_exists ($oldfilename)) {
rename ($oldfilename, $newfilename);
removeMapEntries ('data/maps/date-document-map.txt', "", $documentid);
removeMapEntries ("data/maps/category-document-map.txt", "", $documentid);
}
}
}
}
if (file_exists ("data/documents/" . $documentid . ".txt") || file_exists ("data/documents/" . $documentid . ".php")) {
echo "<h2>Remove document: " . $documentid . "</h2>";
?>
<form method = 'post' action = 'index.php?page=remove-document&document=<?php echo $documentid ;?>'>
<h3>Are you sure you want to move <?php echo $documentid ; ?> to the Trash Bin?</h3><br>
NO: <input type = 'radio' name = 'removeflag' value = '' checked />
YES <input type = 'radio' name = 'removeflag' value = 'REMOVE' />
<br><br><input class = 'submitbutton' type = 'submit' name = 'submit' value='Remove'/>
</form>
<?php
}
else {
echo "<h2>This document has been removed</h2>";
}
?>
</div><div class = 'sidebar-column'>
<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>
</div>
remove-extra-posts.php ▾
<?php
$selectedarray = selectMapEntries ('data/maps/category-document-map.txt', 'family', '');
foreach ($selectedarray as $documentid) {
}
?> remove-previous-versions.php ▾
<?php
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
if (isset ($_POST ['document-version-array'] )) {
$documentversionarray = $_POST['document-version-array'];
foreach ($documentversionarray as $item1) {
$oldfilename = "data/document-versions/" . $item1. ".txt";
$newfilename = "data/trash/document-versions----" . $item1 . ".txt";
if (file_exists ($oldfilename)) {
rename ($oldfilename, $newfilename);
}
}
}
}
?>
<div class = 'content-column'>
<h2>Remove Previous Versions </h2>
<button onclick = 'setCheckboxes()'>Remove All</button>
<form method = 'post' action = 'index.php?page=remove-previous-versions'>
<?php
$documentversions = getRecordIdsFromFolder ('data/document-versions');
foreach ($documentversion as $versionid) {
echo "<br><a href = 'index.php?page=add-update-document&version=" . $versionid . "'><b>" . $versionid . "</b></a>";
echo "<label for = '" . $versionid . "'> Remove</label>";
echo "<input class = 'checkbox' id = '" . $versionid . "' type = 'checkbox' name = 'document-version-array[]' value = '" . $versionid . "' />";
}
?>
<br><br><input class = 'submitbutton' type = 'submit' name = 'submit-delete-previous-versions' value='Submit'/>
</form>
</div><div class = 'sidebar-column'>
<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>
</div>
restore-remove-trash.php ▾
<?php
if (isset ($_POST['restorearray'])) {
$restorearray = $_POST['restorearray'];
foreach ($restorearray as $item) {
$item = trim ($item);
$oldfilename = "data/trash/" . $item;
$array1 = explode ("----", $item);
$table = $array1[0];
$newfilename = '';
if (array_key_exists (1, $array1)) {
$newfilename = 'data/' . $table . '/' .$array1[1];
if (file_exists ($oldfilename)) {
rename ($oldfilename, $newfilename);
echo "File Restored";
}
else {
echo "<div class = 'error' >Missing old file name</div>";
}
}
else {
echo "<div class = 'error' >Missing old file name</div>";
}
}
}
else if (isset ($_POST['removearray'])) {
foreach ($_POST['removearray'] as $item) {
if (! unlink("data/trash/" . $item)) {
echo "Error deleting " . $item . "<br>";
}
}
}
?> search-for-term.php ▾
<?php
$foundarray = array();
$searchterm = "";
if (isset ($_POST['searchterm'] )) {
$searchterm = $_POST['searchterm'];
if ($searchterm) {
echo "<h2>Search</h2>";
echo "<h3>Journal entries that contain: <span class = 'display-title'>" . $searchterm . "</span></h3>";
$lcsearchterm = strtolower ($searchterm);
$documents = getRecordIdsFromFolder ('data/documents');
foreach ($documents as $documentid) {
$documentid = str_replace (".txt", "", $item1);
$documentrecord = readDatabaseRecord($documentrecordkeys, 'data/documents/' . $documentid . '.txt');
$lctext = strtolower ($documentrecord['html-content']);
if (strpos ($lctext, $lcsearchterm) ) {
array_push ($foundarray, $documentid);
}
}
}
}
echo "<div class = 'left'>";
if ($foundarray) {
foreach ($foundarray as $documentid) {
echo "<a href = 'index.php?page=display-document&document=" . $documentid . "&searchterm=" . $searchterm . "'>" . $documentid . "</a><br>";
}
}
echo "</div>";
?>
select-previous-document.php ▾
<?php
$documentid = "";
if (isset ($_GET["document"])){
$documentid = filter_input(INPUT_GET, "document", FILTER_SANITIZE_STRING) ;
}
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
$documentversions = getRecordIdsFromFolder ('data/document-versions');
foreach ($documentversion as $versionid) {
if (isset ($_POST['previous-versions'])) {
$previousversions = $_POST['previous-versions'];
foreach ($previousversions as $versionid) {
moveToTrash ("document-versions", $versionid);
}
$documentversions = getRecordIdsFromFolder ('data/document-versions');
}
}
}
?>
<div class = 'content-column'>
<h2>Previous Versions </h2>
<form method = 'post' action = 'index.php?page=select-previous-document&document=<?php echo $documentid; ?>'>
<?php
$documentversions = getRecordIdsFromFolder ('data/document-versions');
foreach ($documentversions as $versionid) {
$origdocumentid = substr ($versionid, 0, -19);
if ($origdocumentid === $documentid) {
echo "<a href = 'index.php?page=add-update-document&version=" . $versionid . "&document=" . $documentid . "'>" . $versionid . "</a>";
echo " Remove: ";
echo "<input type = 'checkbox' name = 'previous-versions[]' value = '" . $versionid . "' /><br><br>";
}
}
?>
<input class = 'submitbutton' type = 'submit' name = 'submit' value = 'Submit' />
</form>
</div><div class = 'sidebar-column'>
<a class = 'submitbutton' href = 'index.php?page=add-update-document&document=<?php echo $documentid; ?>'>Return to edit</a>
</div> single-image-page.php ▾
<?php
$documentid = getFromQueryString ('document');
$imagefolder = $imagebase = '';
$folderfile = getFromQueryString ('folderfile');
$array1 = explode ('/', $folderfile);
$imagefolder = $array1[0];
if (array_key_exists (1, $array1)){
$imagebase = $array1[1];
}
$imagename = pathinfo ($imagebase, PATHINFO_FILENAME);
$extension = pathinfo ($imagebase, PATHINFO_EXTENSION);
if ( file_exists ("data/documents/" . $documentid . ".txt")) {
echo "<a class = 'return' href = 'index.php?page=display-document&document=" . $documentid . "'> ←Return</a><br>";
}
?>
<h1>Update Image</h1>
<h3><?php echo $folderfile; ?></h3>
<div class = 'content-column'>
<?php
echo"Image Name: <b>" . $imagebase . "</b><br>";
echo "Folder: <b>" . $imagefolder . "</b><br>";
if ($extension !== 'pdf'){
echo "<img src = 'data/images/" . $folderfile . "' alt = 'selected image'/><br>";
}
?>
</div><div class = 'sidebar-column'>
<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>
<a class = 'adminbutton' href = 'index.php?page=media-library'>Media Library</a> <br>
</div>
trash.php ▾
<?php
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
if (isset ($_POST['restore-array'])) {
$restorearray = $_POST['restore-array'];
foreach ($restorearray as $item) {
$item = trim ($item);
$array1 = explode ("----", $item);
$table = $array1[0];
if (array_key_exists (1, $array1)) {
$documentid = $array1[1];
$oldname = "data/trash/" . $item . '.txt';
$newname = "data/" . $table . "/" . $documentid . '.txt';
if (file_exists ($oldname)) {
rename ($oldname, $newname);
if ($table === 'documents') {
$documentrecord = readDatabaseRecord ($documentrecordkeys, 'data/documents/'. $documentid . '.txt');
addMapEntry ("data/maps/date-document-map.txt", $documentrecord['date'], $documentid);
addMapEntry ('data/maps/category-document-map.txt', $documentrecord['category'], $documentid);
}
}
}
}
}
if (isset ($_POST['remove-array'])) {
$removearray = $_POST['remove-array'];
foreach ($removearray as $item) {
if (! unlink("data/trash/" . $item . '.txt')) {
echo "Error deleting " . $item . "<br>";
}
}
}
}
?>
<h1>Trash - select items to restore or delete</h1>
<div class = 'full-column'>
<?php
echo "<button class = 'pink-button' onclick = 'setCheckboxes()'>Remove All</button>";
echo "<form method = 'post' action = 'index.php?page=trash' >";
$array1 = scandir ("data/trash");
foreach ($array1 as $item) {
if ($item !== '.' && $item !== "..") {
$id = str_replace ('.txt' , '', $item);
echo " <input id = 'restore-" . $id. "' type= 'checkbox' name = 'restore-array[]' value = '".$id . "' />";
echo "<label for = 'restore-" . $item . "'>Restore </label>";
echo " ";
echo " <input class = 'checkbox' id = 'remove-" . $id. "' class = 'checkbox' type= 'checkbox' name = 'remove-array[]' value = '".$id . "'/>";
echo "<label for = 'remove-" . $id . "'>Delete </label>";
echo " ";
echo $id . "<br>";
}
}
echo "<br><br><input class = 'submitbutton' name = 'submit-restore-trash' type = 'submit' value = 'Submit' />";
echo "</form>";
?>
</div> update-document-category.php ▾
<?php
$category = getFromQueryString ('category');
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
removeMapEntries ("data/maps/category-document-map.txt", $category, "");
if (isset ($_POST['selected'])) {
$selected = $_POST['selected'];
foreach ($selected as $documentid) {
$documentid = trim ($documentid);
addMapEntry ("data/maps/category-document-map.txt", $category, $documentid);
}
}
}
?>
<h2 >Update Category: <?php echo $category; ?></h2>
<a href = 'index.php?page=home'>← Return</a>
<?php
echo "<h3>Documents for this category: </h3>";
echo "<h4>Click to select</h4>";
echo "<form method = 'post' action = 'index.php?page=update-document-category&category=" . $category ."'> ";
$currentarray = selectMapEntries ('data/maps/category-document-map.txt', $category, "");
$documents = getRecordIdsFromFolder ('data/documents');
foreach ($documents as $documentid) {
echo "<div class = 'gridcolumn'>";
if (in_array($documentid, $currentarray)) {
echo "<input id = '" . $documentid . "' class = 'checkbox' type = 'checkbox' name = 'selected[]' value = '" . $documentid . "' checked />";
}
else {
echo "<input id = '" . $documentid . "' class = 'checkbox' type = 'checkbox' name = 'selected[]' value = '" . $documentid . "' /> ";
}
echo "<label for = '" .$documentid . "'>";
echo "<a href = 'index.php?page=display-document&document=" . $documentid . "'>" . $documentid . "</a>";
echo "</label>";
echo "</div>";
}
echo "<input class = 'submitbutton' name = 'submit-record' type = 'submit' value='Select'> ";
echo "</form> ";
?>
<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>
<a class = 'adminbutton' href = 'index.php?page=manage-document-categories'>Manage Document Categories</a>
update-image-folder.php ▾
<?php
$folder = 'images';
$imagefolder = getFromQueryString ('imagefolder');
$origimagefolder = $imagefolder;
$elementarray = array();
$array1 = glob("data/images/" . $imagefolder . "/*");
foreach ($array1 as $item1) {
$newblock = str_replace ('data/images/', '', $item1);
array_push ($elementarray, 'IMAGE:' . $newblock);
}
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
if (isset ($_POST['selectedelements'])){
$selectedelements = $_POST['selectedelements'] ;
$selectedelements = array_unique ($selectedelements);
$newelementstring = implode (",", $selectedelements);
$newelementstring = strip_tags ($newelementstring);
$newelementarray = explode (',' , $newelementstring);
//print_r ($newelementarray);
$additions = array_diff ($newelementarray, $elementarray);
foreach ($additions as $item) {
$array2 = explode ('/', $item);
$oldimagefolder = str_replace ('IMAGE:', "", $array2[0]);
if (array_key_exists (1, $array2) ) {
$imagebase = $array2[1];
$oldname = $oldimagefolder . "/" . $imagebase;
$newname = $imagefolder . "/". $imagebase;
if (file_exists ('data/images/' . $oldname)) {
rename ('data/images/' . $oldname, 'data/images/' . $newname);
}
}
}
//images that were not selected - move to discards
$subtractions = array_diff ($elementarray, $newelementarray);
foreach ($subtractions as $item) {
$array2 = explode ('/', $item);
$oldimagefolder = str_replace ('IMAGE:', "", $array2[0]);
if (array_key_exists (1, $array2) ) {
$imagebase = $array2[1];
$oldname = $oldimagefolder . "/" . $imagebase;
if ($imagefolder !== 'trash') {
$newname = 'trash/' . $imagebase;
rename ('data/images/' . $oldname, 'data/images/' . $newname);
}
}
}
}
$elementarray = array();
$array1 = glob("data/images/" . $imagefolder . "/*");
foreach ($array1 as $item1) {
$newblock = str_replace ('data/images/', '', $item1);
array_push ($elementarray, 'IMAGE:' . $newblock);
}
}
?>
<h1>Update Image Folder</h1>
<h2>Images are stored in alphabetical order</h2>
<h3>Current Content of <?php echo showWords($imagefolder); ?>:</h3><br><br>
<div class = 'fourth-column'>
<?php require ("inc/select-images.php"); ?>
</div><div class = 'half-column'>
<form method = 'post' action = 'index.php?page=update-image-folder&folder=images&imagefolder=<?php echo $origimagefolder; ?>'>
<?php require ("inc/organize-elements-form.php"); ?>
<br><input class = 'submitbutton' type = 'submit' name = 'organize' value='Update' />
</form>
</div><div class = 'fourth-column'>
<div class = 'deletebox' onclick = 'deleteBoxClicked()' >Click here to remove blue items </div><br><br>
<p><h3>Saved Items:</h3></p>
<div id = 'saved-items'></div>
<br><br>
<a class = 'adminbutton' href = 'index.php?page=home'>Return</a>
<a class = 'adminbutton' href = 'index.php?page=manage-image-folders'>Manage Image Folders</a>
</div>
upload-image.php ▾
<?php
$file = "";
$error = false;
$upload = false;
echo "<div class = 'content-column'>";
echo "<h1>Upload Image</h1>";
$postflag = $overwriteflag = $imagepoststatus = "";
$folder = "";
$imagename = "";
$imagebase = "";
if ($_SERVER ["REQUEST_METHOD"] == "POST" ) {
if (isset ($_POST['submit-upload'])){
require ("inc/uploaded-image.php");
}
}
else {
?>
<form action="index.php?page=upload-image" method="post" enctype="multipart/form-data">
<input type = "file" name = "uploadfile" >
<br><br>
<label for = 'imagename' >Image Name: </label><br>
<input id = 'imagename' type = 'text' name = 'newimagename' />
<br><br>
<label>Folder:</label>
<?php
$array1 = scandir ("data/images");
foreach ($array1 as $item) {
if ($item !== "." && $item !== ".."){
if ($item === 'general') {
echo "<br><input type = 'radio' name = 'imagefolder' value = '" . $item . "' checked />" . $item ;
}
else {
echo "<br><input type = 'radio' name = 'imagefolder' value = '" . $item . "'/>" . $item ;
}
}
}
?>
<br><br><br><input class = 'submitbutton' type = 'submit' name ="submit-upload" value = 'Upload'>
</form>
<?php
}
echo "</div><div class = 'sidebar-column'>";
echo "<br><a class = 'adminbutton' href = 'index.php?page=control-panel'>Control Panel</a> ";
echo "<a class = 'adminbutton' href = 'index.php?page=media-library'>Media Library</a>";
if ($upload === true) {
echo "<a class = 'adminbutton' href = 'index.php?page=image-edit&folder=" . $folder . "&imagebase=" . $imagebase . "'>Edit Image</a><br>";
}
echo "<a class = 'adminbutton' href = 'index.php?page=upload-image'>Upload Another Image</a> ";
echo "</div>";
?>
DOCUMENTS/inc
add-update-document-form.php ▾
<form method = 'post' action = 'index.php?page=add-update-document&document=<?php echo $documentid; ?>' >
<?php
echo "<label for= 'title-textarea'>Title: </label><br> ";
echo "<textarea id = 'title-textarea' rows = '1' name = 'title'>" . $documentrecord['title'] . "</textarea><br><br> ";
if ($documentrecord['date'] === '') {
$documentrecord['date'] = date ('Y-m-d');
}
echo "<label for = 'date'>Date: </label><br>";
echo "<input type = 'date' id = 'date' name = 'date' value = '" . $documentrecord['date'] . "' /><br><br>";
//Text
$mdcontent = $documentrecord['md-content'];
include ('inc/edit-text-sections.php');
?>
<h4>Convert text to HTML?</h4>
<?php
if ($documentrecord['convert-to-html'] === '1') {
echo "<input id = 'convert-to-html-yes' type = 'radio' name = 'convert-to-html' value = '1' checked />";
echo "<label for = 'convert-to-html-yes'>Yes</label> ";
echo "<input id = 'convert-to-html-no' type = 'radio' name = 'convert-to-html' value = '' />";
echo "<label for ='convert-to-html-no'>No</label>";
}
else {
echo "<input id = 'convert-to-html-yes' type = 'radio' name = 'convert-to-html' value = '1' />";
echo "<label for ='convert-to-html-yes'>Yes</label> ";
echo "<input id = 'convert-to-html-no' type = 'radio' name = 'convert-to-html' value = '' checked/>";
echo "<label for ='convert-to-html-no'>No</label>";
}
?>
<h4>Category:</h4>
<?php
$selectedarray = selectmapEntries ('data/maps/category-document-map.txt','', $documentid );
$array1 = readArray("data/categories.txt", ',');
foreach ($array1 as $item1) {
if (in_array ($item1, $selectedarray)) {
echo "<input id = '" . $item1 . "-id' type = 'checkbox' name = 'categories[]' value = '" . $item1 . "' checked />";
}
else {
echo "<input id = '" . $item1 . "-id' type = 'checkbox' name = 'categories[]' value = '" . $item1 . "' />";
}
echo "<label for = '" . $item1 . "-id'>" . $item1 . " </label>";
}
?>
<h4>Styles</h4>
<?php
$styles = getRecordIdsFromFolder ('data/styles');
foreach ($styles as $styleid) {
if ($documentrecord['style'] === $styleid) {
echo "<input id = '" . $styleid . "' type = 'radio' name = 'style' value = '" . $styleid . "' checked >";
echo "<label for = '" . $styleid . " '>" . $styleid . "</label><br>";
}
else {
echo "<input id = '" . $styleid . "' type = 'radio' name = 'style' value = '" . $styleid . "' >";
echo "<label for = '" . $styleid . " '>" . $styleid . "</label><br>";
}
}
?>
<br><br>
<input type = 'submit' class = 'submitbutton' name = 'submit' value = 'Submit' />
<h4>Styles</h4>
</form>
db-definitions.php ▾
<?php
$dl1 = "%%%";
$dl2 = "%#%";
$documentrecordkeys = array ('title', 'html-content', 'md-content', 'category' , 'date', 'convert-to-html' , 'style', 'sections');
default-style.css ▾
@font-face {
font-family: PlayfairDisplaySC;
src: url('../data/fonts/PlayfairDisplaySC-Regular.ttf');
}
@font-face {
font-family: HindSiliguri;
src: url('../fonts/HindSiliguri-Regular.ttf');
}
@font-face {
font-family: Raleway;
src: url('../fonts/Raleway-Regular.ttf');
}
@font-face {
font-family: RalewayLight;
src: url('../fonts/Raleway-Light.ttf');
}
@font-face {
font-family: Cinzel;
src: url('../fonts/Cinzel-Regular.ttf');
}
@font-face {
font-family: Lato;
src: url('../data/fonts/Lato-Regular.ttf');
}
body {
font-size: 16px;
box-sizing: border-box;
color: #333;
line-height: 140%;
font-family: 'Arial';
}
hr {
margin: 0;
}
h1 {
text-align: center;
}
h2{
text-align: center;
margin:0;
padding-top: 30px;
font-size: 18px;
text-transform: uppercase;
}
h3 {
text-align: left;
}
h4 {
font-size: 12px;
color: #444;
text-transform: uppercase;
margin: 5px 0;
}
h5 {
text-align: center;
}
a {
color:#652c77;
text-decoration: none;
}
a:hover {
color: darkmagenta;
}
label {
color: purple;
}
b {
color: black;
}
i {
font-size: 14px;
color: black;
}
.error {
color: red;
font-size: 20px;
}
.logo {
width: 260px;
max-width: 100%;
}
textarea, input {
width: 100%;
vertical-align: bottom;
font-size: 16px;
box-sizing: border-box;
border: 1px solid #4a4682;
padding: 10px;
background-color: #eee;
max-width: 100%;
font-family: 'Arial';
}
input[type=checkbox], input[type=radio] {
max-width: 20px;
padding: 0;
margin: 3px;
vertical-align: middle;
}
input[type=date] {
width: 160px;
}
/** OUTERWRAP */
.outerwrap {
display: block;
margin: 0 auto;
max-width: 100%;
box-sizing: border-box;
text-align: center;
width: 1400px;
}
a.menuitem {
font-size: 14px;
padding: 3px 12px;
border: 1px solid #bbb;
margin: 7px;
display: inline-block;
vertical-align: top;
background-color: #eee;
}
a.menuitem.current {
background-color: #652c77;
color: white;
}
main {
text-align: center;
display: block;
margin: auto;
margin-top: 30px;
}
/* Columns */
.full-column {
display: block;
margin: auto;
width: 100%;
text-align: left;
margin: auto;
}
.content-column, .sidebar-column, .half-column, .fourth-column, .half-column-1, .half-column-2, .third-column-1, .third-column-2, .third-column-3, .gridcolumn, .imagegridcolumn, .box, .grid, .grid1, .fourth-column {
display: inline-block;
text-align: left;
vertical-align: top;
padding: 0 20px;
max-width: 100%;
box-sizing: border-box;
}
.third-column-1, .third-column-2, .third-column-3 {
width: 27%;
border: 1px solid #bbb;
padding: 15px;
margin: 3px;
}
.box {
border: 1px solid #bbb;
margin: 5px;
}
.content-column {
width: 75%;
padding: 0 20px;
}
.sidebar-column {
width: 25%;
text-align: center;
}
.half-column , .half-column-1, .half-column-2 {
width: 50%;
padding: 0 20px;
}
.third-column input {
padding: 5px;
}
.fourth-column {
width: 23%;
text-align: center;
}
.gridcolumn {
width: 300px;
border: 1px solid #bbb;
background-color: #eee;
margin: 5px 5px;
}
.grid, .grid1 {
width: 280px;
border: 1px solid #bbb;
margin: 5px;
padding: 0 10px;
}
.grid1 {
background-color: #eee;
border: 1px solid black;
}
.section-image {
width: 160px;
max-width: 100%;
margin: 5px;
display: inline-block;
}
.imagegridcolumn {
max-width: 100%;
margin: 5px;
}
.imagegridcolumn img{
max-width: 100%;
}
.display-document .imagegridcolumn {
width: 300px;
padding: 0;
}
footer {
margin-top: 100px;
}
.pink-background {
background-color: pink;
padding: 10px;
}
.adminbutton , .submitbutton {
color: white;
padding: 5px 0;
margin: 10px auto;
font-size: 14px;
background-color: #4a4682;
text-align: center;
border-radius: 3px;
box-sizing: border-box;
max-width: 100%;
border: 1px solid #bbb;
width: 160px;
line-height: 120%;
display: block;
text-align: center;
}
.submitbutton {
background-color: darkmagenta;
width: 100px;
margin: 10px 0 ;
}
.dropdownwrap {
margin: 10px 0;
}
.toggle-banner, .toggle-banner2 {
background-color: #ddd;
color: white;
border: 1px solid #bbb;
padding: 5px;
color: black;
vertical-align: top;
max-width: 100%;
margin: 3px auto;
font-size: 14px;
width: 100%;
}
.toggle-banner2 {
background-color: #eee;
margin: 5px;
}
/** IMAGES */
.full-column img {
max-width: 100%;
}
figure {
max-width: 100%;
}
img {
max-width: 100%;
display: block;
box-sizing: border-box;
object-fit: contain;
margin: 5px auto;
}
.image-center {
float: none;
}
.image-right {
float: right;
}
.image-left {
float: left;
}
.image-xsmall {
width: 100px;
max-width: 100%;
}
.image-small {
width: 180px;
max-width: 100%;
}
.image-medium {
width: 260px;
max-width: 100%;
}
.image-large {
width: 400px;
max-width: 100%;
}
.image-xlarge {
width: 600px;
max-width: 100%;
}
.image-full {
max-width: 100%;
}
figcaption {
font-size: 16px;
font-weight: bold;
text-align: center;
margin: auto;
padding: 0 30px 30px 30px;
line-height: 120%;
}
.searchterm {
background-color: pink;
}
/** Click and drop javascript */
.slot, #open-slot {
display: inline-block;
padding: 5px;
border: 1px solid #bbb;
margin: 3px 5px;
max-width: 100%;
font-size: .9em;
cursor: pointer;
background-color: #eee;
min-height: 40px;
vertical-align: top;
}
.red {
color: red;
}
.pink {
background-color: #eac0c7;
}
.deletebox {
color: white;
margin: 5px auto;
padding: 7px 12px;
font-size: 14px;
cursor: pointer;
text-align: center;
text-decoration: none;
background-color: blue;
width: 160px;
}
.hidden {
display: none;
}
.highlighted {
border: 2px solid blue;
}
.select-image {
cursor: pointer;
}
.markdown-instructions {
text-align: left;
padding: 20px;
max-width: 100%;
}
.pink-background {
background-color: pink;
padding: 10px 15px 30px 15px;
color: black;
line-height: 170%;
}
.left {
text-align: left;
}
.right {
text-align: right;
}
.centered {
text-align: center;
}
.outerlabel {
display: inline-block;
box-sizing: border-box;
vertical-align: top;
max-width: 100%;
width: 33%;
margin:20px 0;
text-align: center;
font-size: 15px;
}
@media print {
.endpage {
page-break-before: always;
}
}
display-media-library.php ▾
<div class = 'content-column'>
<?php
echo "<div class = 'media-folders'>";
echo "<br><br><h3 >Image Library: </h3>";
$array1 = scandir( "data/images");
foreach ($array1 as $item) {
if ($item !== "." && $item !== "..") {
$imagefolder = trim ($item);
if (is_dir("data/images/" . $imagefolder)) {
echo "<div class = 'dropdownwrap'>";
echo "<div class = 'toggle-banner' id = '" . $imagefolder . "' onclick= 'accordionToggle(this.id)' >" . ucwords(str_replace("-", " ", $imagefolder )). " ▾</div>";
echo "<div id = '" . $imagefolder . "-content' style = 'display: none;'>";
$images = getImagesFromFolder ( "data/images/" . $imagefolder );
foreach ($images as $id => $imagebase) {
$key = $imagefolder . ($id );
$imagesource = "data/images/" . $imagefolder . "/" . $imagebase ;
echo "<div class = 'imagegridcolumn'>";
echo "<div id = '" . $key . "' onclick = 'selectItemForTextarea(this.id)'>";
echo "<img id = '" . $key . "-image' src = '" . $imagesource . "' alt ='". $imagesource ."' width = '130' /><br>";
echo $imagebase;
echo "</div></div>";
}
echo "</div></div>";
}
}
}
echo "</div>"
?>
</div><div class = 'sidebar-column'>
<a class = 'adminbutton' href = 'index.php?page=home'>← Home</a>
</div>
edit-text-sections.php ▾
<?php
$mdarray = explode ($dl2, $mdcontent);
//Text sections
foreach ($mdarray as $id => $item1) {
$i = $id + 1;
//Show section numbers if text-sections enabled
echo "<br><label for ='text-element-" . $i . "' >Text section: " . $i . "</label><br>";
echo "<textarea id = 'text-element-" . $i . "' class = 'textarea' name = 'mdarray[]' rows = '16' >" . $item1 . "</textarea><br> ";
//Show all images in this section
$array2 = explode ('![', $item1);
foreach ($array2 as $id => $item2) {
if ($id === 0 && substr ($item2, 0, 2) !== '![') {
//First item is not an image
}
else {
$pos1 = strpos ($item2, '(');
if ($pos1 !== false) {
$pos1++;
$pos2 = strpos ($item2, '.');
$pos2 = $pos2 + 4;
$img = substr ($item2, $pos1 , $pos2 - $pos1);
echo "<div class = 'section-image'>";
echo "<img src = '" . $img . "' alt = 'image ' >";
$pos3 = strpos ($item2, ']');
echo substr ($item2,0,$pos3);
echo "</div>";
}
}
}
echo "<br><br>";
}
//New text section
$i ++;
echo "<br><label for ='text-element-" . $i . "' >Text section: " . $i . "</label><br>";
echo "<textarea id = 'text-element-" . $i . "' class = 'textarea' name = 'mdarray[]' rows = '16' ></textarea><br> ";
?> footer.php ▾
</main>
<?php
if ($print !== '1') {
if (isset ($_SESSION['admin'])){
echo "<br><a href = 'index.php?page=logout'>Log Out </a>";
}
}
?>
</div>
<script src= "inc/scripts.js"></script>
</body>
</html> functions-no-write.php ▾
<?php
function createRecordId ($name) {
$newname = "";
if ($name !== "") {
$newname = trim ($name);
$newname = str_replace (" " , "-", $newname);
$newname = strtolower ($newname);
$newname = preg_replace('/[^A-Za-z0-9-]/', '', $newname);
$newname = preg_replace('/-+/', '-', $newname);
}
return $newname;
}
function initializeRecord ($keys){
$record = array ();
foreach ($keys as $Id => $key) {
$record[$key] = "";
}
return ($record);
}
function readDatabaseRecord ($keys, $filename) {
//Creates 'record' variable by assigning keys and values to associative array,
global $dl1;
//Initialize record
$record = array();
foreach ($keys as $Id => $key) {
$record[$key] = "";
}
if ($filename && file_exists($filename)) {
$string = file_get_contents ($filename);
$Array1= explode ($dl1, $string);
foreach ($keys as $Id => $key) {
if (array_key_exists ($Id, $Array1)) {
$record [$key] = $Array1[$Id];
}
}
}
return $record;
}
function writeDatabaseRecord ($record, $filename) {
//Stores record variable as text file
global $dl1;
$String = implode ($dl1, $record);
//file_put_contents ($filename, $String);
}
function createAssocArray ($map) {
global $dl1, $dl2;
$assocarray = array();
$Array1 = readArray ($map, $dl1);
foreach ($Array1 as $Id => $Item1) {
$Array2 = explode ($dl2, $Item1);
$key = $Array2[0];
if (array_key_exists (1, $Array2)) {
$value = $Array2[1];
$assocarray[$key] = $value;
}
}
return $assocarray;
}
// Maps for table relationships
function addMapEntry ($map, $key1, $key2) {
global $dl1, $dl2;
$Array1 = readArray ($map, $dl1);
$newentry = $key1 . $dl2 . $key2 . $dl2 . "\n";
array_push ($Array1, $newentry);
$Array1 = array_unique ($Array1);
sort ($Array1);
writeArray ($map, $Array1, $dl1);
}
function removeMapEntries ($map, $key0, $key1) {
//Remove entries containing either or both key0 and key1
global $dl1, $dl2;
$Array1 = readArray ($map, $dl1);
foreach ($Array1 as $Id => $Item1) {
$Array2 = explode ($dl2, $Item1);
if (array_key_exists (0, $Array2) && array_key_exists (1, $Array2)) {
if ($key0 && $key1 ) {
if ( $Array2[0] === $key0 && $Array2[1] === $key1 ) {
unset ($Array1 [$Id]);
}
}
else if (! $key0 && $key1 ) {
if ($Array2[1] === $key1) {
unset ($Array1 [$Id]);
}
}
else if ($key0 && !$key1) {
if ($Array2[0] === $key0) {
unset ($Array1 [$Id]);
}
}
}
}
writeArray ($map, $Array1, $dl1);
}
function selectMapEntries ($map, $key0, $key1) {
//for many-to-many relationships
//returns an array with selected key
global $dl1, $dl2;
$Array1 = readArray ($map, $dl1);
$selectedarray = array();
if ($key0 && !$key1 ) {
foreach ($Array1 as $Item1) {
$Array2 = explode ($dl2, $Item1);
if (array_key_exists (1, $Array2)) {
if ($Array2[0] == $key0 ){
array_push ($selectedarray, $Array2[1]);
}
}
}
}
else if (!$key0 && $key1) {
foreach ($Array1 as $Item1) {
$Array2 = explode ($dl2, $Item1);
if (array_key_exists (1, $Array2)) {
if ($Array2[1] === $key1) {
array_push ($selectedarray, $Array2[0]);
}
}
}
}
return $selectedarray;
}
function selectMapKey ($map, $key0, $key1) {
//For one-to-many relationships
//returns an single value
global $dl1, $dl2;
$returnvalue = '';
$Array1 = readArray ($map, $dl1);
foreach ($Array1 as $Id => $Item1) {
$Array2 = explode ($dl2, $Item1);
if ( array_key_exists (1, $Array2)) {
if (!$key0 && $key1) {
if ($Array2[1] === $key1) {
$returnvalue = $Array2[0];
break;
}
}
else if ($key0 && ! $key1) {
if ($Array2[0] === $key0){
$returnvalue = $Array2[1];
break;
}
}
}
}
return $returnvalue;
}
function extractFromMap($map, $key) {
//returns a new array of either the the first or second columns
global $dl1, $dl2;
$selectedarray = array();
$Array1 = readArray ($map, $dl1);
foreach ($Array1 as $Item1) {
$Array2 = explode ($dl2, $Item1);
if ($key == 0) {
array_push ($selectedarray, $Array2[0]);
}
else if ($key == 1) {
if (array_key_exists (1, $Array2)) {
array_push ($selectedarray, $Array2[1]);
}
}
}
return $selectedarray;
}
function moveToTrash ($table, $recordid) {
$oldfilename = 'data/' . $table . '/' . $recordid . '.txt';
$newfilename = 'data/trash/' . $table . '----' . $recordid . '.txt';
if (file_exists ($oldfilename)) {
//rename ($oldfilename, $newfilename);
}
}
function restoreFromTrash ($filename) {
$oldfilename = 'data/trash/' . $filename;
if (file_exists ($oldfilename)) {
$array2 = explode ('----', $filename);
if (array_key_exists (1, $array2)) {
$filename = str_replace ('----', '', $array2[1]);
$table = $array2[0];
$newfilename = 'data/' . $table . '/' . $filename;
//rename ($oldfilename, $newfilename);
}
}
}
//ARRAYS
function readArray ($filename, $delimiter){
$Array1 = array();
if (file_exists($filename)) {
$String = file_get_contents ($filename);
if ($String !== "") {
$Array1 = explode ($delimiter, $String);
}
}
return $Array1;
}
function writeArray ($filename, $array, $delimiter){
$String = implode ($delimiter, $array);
//file_put_contents ($filename, $String);
}
function addNameToArray ($filename, $name, $delimiter) {
if (file_exists($filename)) {
$String = file_get_contents ($filename);
$Array1 = explode ($delimiter, $String);
array_push ($Array1, $name);
$Array1 = array_unique ($Array1);
sort ($Array1);
$String = implode ($delimiter, $Array1);
$String = preg_replace('/,+/', ',', $String);
$String = ltrim ($String, $delimiter);
//file_put_contents ($filename, $String);
}
}
function removeNameFromArray ($filename, $name, $delimiter) {
if (file_exists($filename)) {
$String = file_get_contents ($filename);
$Array = explode ($delimiter, $String);
foreach ($Array as $Id => $Item) {
$Item = trim ($Item);
if ($Item === $name) {
unset ($Array [$Id]);
}
}
array_values ($Array);
sort ($Array);
$String = implode ($delimiter, $Array);
//file_put_contents ($filename, $String);
}
}
//Validate 'GET' value
function getFromQueryString ($label) {
$value = "";
if (isset ($_GET[$label])) {
$value = $_GET[$label];
if (specialChars($value) || strlen ($value) > 300) {
//Invalid input
$value = '';
}
}
return $value;
}
//Filter input text for record delimiters
function sanitizeFormInput($text) {
global $dl1, $dl2;
$text = trim($text);
$text = str_replace ($dl1, '', $text);
$text = str_replace ($dl2, '', $text);
return $text;
}
function showWords ($text) {
$Ancytext = str_replace (',', ', ', $text);
$Ancytext = ucwords (str_replace ('-', ' ', $Ancytext));
return $Ancytext;
}
function assignPostValuesToRecord ($postarray, $keys) {
//Assign values to record
$record = array();
foreach ($keys as $Id => $key) {
$record[$key] = "";
if (isset ($postarray[$key])) {
if (!is_array ($postarray[$key])) {
$record[$key] = sanitizeFormInput ($postarray[$key]);
}
}
}
return $record;
}
function saveToLog ($text) {
global $dl1, $dl2;
$currenttime = date ("h-i:sa");
$date = date ("Y-m-d");
$filename = 'data/log.txt';
$String = file_get_contents ($filename);
$String = $String . "\n\n " . $date . " " . $currenttime . " ". $text;
//file_put_contents ($filename, $String);
}
function formatDate ($inputdate) {
$returndate = '';
if (is_numeric (substr ($inputdate, 0,4))) {
//format yyyy/mm/dd
$month = substr ($inputdate, 5, 2);
$day = substr ($inputdate, 8,2);
$year = substr ($inputdate, 0, 4);
$returndate = $year . '-' . $month . '-' . $day;
}
else if (is_numeric (substr ($inputdate, 0, 2))) {
//Year is last mm/dd/yyyy
$month = substr ($inputdate, 0, 2);
$day = substr ($inputdate, 3,2);
$year = substr ($inputdate, 6, 4);
$returndate = $year . '-' . $month . '-' . $day;
}
else {
//default current date
$returndate = date('Y-m-d');
}
return $returndate;
}
//CHECK FOR DUPLICATE EMAILS
function checkForDuplicateEmail ($sendtoemail, $message) {
global $dl1, $dl2;
$error = false;
$emailarchive = readArray ('data/email-archive.txt', $dl1);
$emailentry = date ("Y-m-d") . $dl2 .$sendtoemail . $dl2 . $message . "\n";
if ( in_array ($emailentry, $emailarchive)) {
$error = true;
echo "<div class = 'error'>Message is a duplicate</div>";
}
else {
array_push ( $emailarchive, $emailentry);
$String = implode ($dl1, $emailarchive);
//file_put_contents ('data/email-archive.txt', $String);
}
return $error;
}
function randomString () {
$String = "";
$chars = "abcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen($chars);
for ($i = 0; $i < 7; $i++) {
$String .= $chars[rand(0, $size - 1)];
}
return $String;
}
function specialChars($str) {
global $dl1, $dl2;
//return preg_match("/[^a-zA-Z0-9-:!?*'@#$,\.\s\)\(]/", $str) > 0;
if (strpos ($str, "<") !== false || strpos ($str, ">") !== false | strpos ($str, $dl1) !== false | strpos ($str, $dl2) !== false ) {
return true;
}
}
function notPhoneNumber($str) {
return preg_match('/[^0-9-\)\(\s]/', $str) > 0;
}
function getRecordIdsFromFolder ($folder) {
$Newarray = array();
$Array1 = scandir ($folder);
foreach ($Array1 as $Item1) {
if (substr ($Item1, 0, 1) !== '.') {
$Recordid = str_replace (".txt", "", $Item1);
$Recordid = str_replace ('.php', '', $Recordid);
$Recordid = str_replace ('.css', '', $Recordid);
$Recordid = trim ($Recordid);
array_push ($Newarray, $Recordid);
}
}
return $Newarray;
}
?>
functions.php ▾
<?php
function createRecordId ($name) {
$newname = "";
if ($name !== "") {
$newname = trim ($name);
$newname = str_replace (" " , "-", $newname);
$newname = strtolower ($newname);
$newname = preg_replace('/[^A-Za-z0-9-?!]/', '', $newname);
$newname = preg_replace('/-+/', '-', $newname);
}
return $newname;
}
function initializeRecord ($keys){
$record = array ();
foreach ($keys as $Id => $key) {
$record[$key] = "";
}
return ($record);
}
function readDatabaseRecord ($keys, $filename) {
global $dl1;
//Initialize record
$record = array();
foreach ($keys as $Id => $key) {
$record[$key] = "";
}
if ($filename && file_exists($filename)) {
$string = file_get_contents ($filename);
$fArray1= explode ($dl1, $string);
foreach ($keys as $Id => $key) {
if (array_key_exists ($Id, $fArray1)) {
$record [$key] = $fArray1[$Id];
}
}
}
return $record;
}
function writeDatabaseRecord ($record, $filename) {
global $dl1;
$String = implode ($dl1, $record);
file_put_contents ($filename, $String);
}
// Maps for table relationships
function addMapEntry ($map, $key1, $key2) {
global $dl1, $dl2;
$fArray1 = readArray ($map, $dl1);
$newentry = $key1 . $dl2 . $key2 . $dl2 . "\n";
array_push ($fArray1, $newentry);
$fArray1 = array_unique ($fArray1);
sort ($fArray1);
writeArray ($map, $fArray1, $dl1);
}
function removeMapEntries ($map, $key0, $key1) {
//Remove entries containing either or both key0 and key1
global $dl1, $dl2;
$fArray1 = readArray ($map, $dl1);
foreach ($fArray1 as $Id => $Item1) {
$fArray2 = explode ($dl2, $Item1);
if (array_key_exists (0, $fArray2) && array_key_exists (1, $fArray2)) {
if ($key0 && $key1 ) {
if ( $fArray2[0] === $key0 && $fArray2[1] === $key1 ) {
unset ($fArray1 [$Id]);
}
}
else if (! $key0 && $key1 ) {
if ($fArray2[1] === $key1) {
unset ($fArray1 [$Id]);
}
}
else if ($key0 && !$key1) {
if ($fArray2[0] === $key0) {
unset ($fArray1 [$Id]);
}
}
}
}
writeArray ($map, $fArray1, $dl1);
}
function selectMapEntries ($map, $key0, $key1) {
//for many-to-many relationships
//returns an array with selected key
global $dl1, $dl2;
$fArray1 = readArray ($map, $dl1);
$selectedarray = array();
if ($key0 && !$key1 ) {
foreach ($fArray1 as $Item1) {
$fArray2 = explode ($dl2, $Item1);
if (array_key_exists (1, $fArray2)) {
if ($fArray2[0] == $key0 ){
array_push ($selectedarray, $fArray2[1]);
}
}
}
}
else if (!$key0 && $key1) {
foreach ($fArray1 as $Item1) {
$fArray2 = explode ($dl2, $Item1);
if (array_key_exists (1, $fArray2)) {
if ($fArray2[1] === $key1) {
array_push ($selectedarray, $fArray2[0]);
}
}
}
}
return $selectedarray;
}
function selectMapKey ($map, $key0, $key1) {
//For one-to-many relationships
//returns an single value
global $dl1, $dl2;
$returnvalue = '';
$fArray1 = readArray ($map, $dl1);
foreach ($fArray1 as $Id => $Item1) {
$fArray2 = explode ($dl2, $Item1);
if ( array_key_exists (1, $fArray2)) {
if (!$key0 && $key1) {
if ($fArray2[1] === $key1) {
$returnvalue = $fArray2[0];
break;
}
}
else if ($key0 && ! $key1) {
if ($fArray2[0] === $key0){
$returnvalue = $fArray2[1];
break;
}
}
}
}
return $returnvalue;
}
function extractFromMap($map, $key) {
//returns a new array of either the the first or second columns
global $dl1, $dl2;
$selectedarray = array();
$fArray1 = readArray ($map, $dl1);
foreach ($fArray1 as $Item1) {
$fArray2 = explode ($dl2, $Item1);
if ($key == 0) {
array_push ($selectedarray, $fArray2[0]);
}
else if ($key == 1) {
if (array_key_exists (1, $fArray2)) {
array_push ($selectedarray, $fArray2[1]);
}
}
}
return $selectedarray;
}
function moveToTrash ($table, $recordid) {
$oldfilename = 'data/' . $table . '/' . $recordid . '.txt';
$newfilename = 'data/trash/' . $table . '----' . $recordid . '.txt';
if (file_exists ($oldfilename)) {
rename ($oldfilename, $newfilename);
}
}
//ARRAYS
function readArray ($filename, $delimiter){
$fArray1 = array();
if (file_exists($filename)) {
$String = file_get_contents ($filename);
if ($String !== "") {
$fArray1 = explode ($delimiter, $String);
}
}
return $fArray1;
}
function writeArray ($filename, $array, $delimiter){
$String = implode ($delimiter, $array);
file_put_contents ($filename, $String);
}
function addNameToArray ($filename, $name, $delimiter) {
if (file_exists($filename)) {
$String = file_get_contents ($filename);
$fArray1 = explode ($delimiter, $String);
array_push ($fArray1, $name);
$fArray1 = array_unique ($fArray1);
sort ($fArray1);
$String = implode ($delimiter, $fArray1);
$String = preg_replace('/,+/', ',', $String);
file_put_contents ($filename, $String);
}
}
function removeNameFromArray ($filename, $name, $delimiter) {
if (file_exists($filename)) {
$String = file_get_contents ($filename);
$fArray = explode ($delimiter, $String);
foreach ($fArray as $Id => $Item) {
$Item = trim ($Item);
if ($Item === $name) {
unset ($fArray [$Id]);
}
}
array_values ($fArray);
sort ($fArray);
$String = implode ($delimiter, $fArray);
file_put_contents ($filename, $String);
}
}
//Validate 'GET' value
function getFromQueryString ($label) {
$value = "";
if (isset ($_GET[$label])) {
$value = $_GET[$label];
if (specialChars($value) || strlen ($value) > 300) {
//Invalid input
$value = '';
}
}
return $value;
}
//Filter input text
function sanitizeFormInput($text) {
global $dl1, $dl2;
$text = trim($text);
$text = str_replace ($dl1, '', $text);
$text = str_replace ($dl2, '', $text);
return $text;
}
function showWords ($text) {
$fancytext = str_replace (',', ', ', $text);
$fancytext = ucwords (str_replace ('-', ' ', $fancytext));
return $fancytext;
}
//CHECK FOR DUPLICATE EMAILS
function checkForDuplicateEmail ($sendtoemail, $message) {
global $dl1, $dl2;
$error = false;
$emailarchive = readArray ('data/email-archive.txt', $dl1);
$emailentry = date ("Y-m-d") . $dl2 .$sendtoemail . $dl2 . $message . "\n";
if ( in_array ($emailentry, $emailarchive)) {
$error = true;
echo "<div class = 'error'>Message is a duplicate</div>";
}
else {
array_push ( $emailarchive, $emailentry);
$String = implode ($dl1, $emailarchive);
file_put_contents ('data/email-archive.txt', $String);
}
return $error;
}
function randomString () {
$String = "";
$chars = "abcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen($chars);
for ($i = 0; $i < 7; $i++) {
$String .= $chars[rand(0, $size - 1)];
}
return $String;
}
function assignPostValuesToRecord ($postarray, $keys) {
//Assign values to record
$record = array();
foreach ($keys as $Id => $key) {
$record[$key] = "";
if (isset ($postarray[$key])) {
$record[$key] = sanitizeFormInput ($postarray[$key]);
}
}
return $record;
}
function saveToLog ($text) {
global $dl1, $dl2;
$currenttime = date ("h-i:sa");
$date = date ("Y-m-d");
$filename = 'data/log.txt';
$String = file_get_contents ($filename);
$String = $String . "\n\n " . $date . " " . $currenttime . " ". $text;
file_put_contents ($filename, $String);
}
function formatDate ($inputdate) {
$returndate = '';
if (is_numeric (substr ($inputdate, 0,4))) {
//format yyyy/mm/dd
$month = substr ($inputdate, 5, 2);
$day = substr ($inputdate, 8,2);
$year = substr ($inputdate, 0, 4);
$returndate = $year . '-' . $month . '-' . $day;
}
else if (is_numeric (substr ($inputdate, 0, 2))) {
//Year is last mm/dd/yyyy
$month = substr ($inputdate, 0, 2);
$day = substr ($inputdate, 3,2);
$year = substr ($inputdate, 6, 4);
$returndate = $year . '-' . $month . '-' . $day;
}
else {
//default current date
$returndate = date('Y-m-d');
}
return $returndate;
}
function specialChars($str) {
return preg_match("/[^a-zA-Z0-9-:!?*@#$,\.\s]/", $str) > 0;
}
function notPhoneNumber($str) {
return preg_match('/[^0-9-\)\(\s]/', $str) > 0;
}
function getRecordIdsFromFolder ($folder) {
$Newarray = array();
$Array1 = scandir ($folder);
foreach ($Array1 as $Item1) {
if (substr ($Item1, 0, 1) !== '.') {
$Recordid = str_replace (".txt", "", $Item1);
$Recordid = str_replace ('.php', '', $Recordid);
$Recordid = str_replace ('.css', '', $Recordid);
$Recordid = trim ($Recordid);
array_push ($Newarray, $Recordid);
}
}
return $Newarray;
}
function getImagesFromFolder ($folder) {
$Newarray = array();
$Array1 = scandir ($folder);
foreach ($Array1 as $Item1) {
if (substr ($Item1, 0, 1) !== '.') {
$Imagebase = trim ($Item1);
array_push ($Newarray, $Imagebase);
}
}
return ($Newarray);
}
?>
header.php ▾
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Documents </title>
<link rel= 'stylesheet' type='text/css' href= 'inc/default-style.css'>
<?php
if ($documentrecord['style']) {
echo "<link rel= 'stylesheet' type='text/css' href= 'data/styles/" . $documentrecord['style'] . ".css'>";
}
?>
</head>
<body>
<div class = 'outerwrap <?php echo $pageid; ?>'>
<?php
if (! $print){
echo "<a href = '../../documents'> ← Return</a>";
$selectedarray = selectMapEntries ('data/maps/category-document-map.txt', '', $documentid);
echo "<header> ";
echo "<a href = 'index.php'><h1>Documents</h1></a>";
$array1 = readArray ('data/categories.txt', ',');
foreach ($array1 as $cat) {
$current = "";
if (in_array ($cat, $selectedarray) || $cat === $category) {
$current = 'current ';
}
echo "<a class = 'menuitem " . $current . "' href = 'index.php?page=display-document-category&category=" . $cat . "' >" . showWords($cat) . "</a>";
}
echo "</header>";
}
?>
<main>
highlight-searchterm.php ▾
<?php
$highlightedterm = "<span class = 'searchterm'>" . $lcsearchterm . "</span>";
$text = str_replace ($lcsearchterm, $highlightedterm, $text);
$highlightedterm = "<span class = 'searchterm'>" . $ucsearchterm . "</span>";
$text = str_replace ($ucsearchterm, $highlightedterm, $text); organize-elements-form.php ▾
<?php
$limit = 400;
$id = 0;
$length = sizeof ($elementarray);
//empty slot
//echo "<div class = 'input-group'>";
//echo "HERE1" . $id;
echo "<div id = 'slots'>";
echo "<div id = '" . $id . "' class = 'slot pink ' onclick = 'slotClicked(id)'></div>";
echo "<input class = 'checkbox hidden' type = 'checkbox' name = 'selectedelements[]' value = '' checked />" ;
$id++;
//add a filled slot for each item in block array
if ($length > 0) {
foreach ($elementarray as $x => $element) {
if ($id < $limit) {
$pos1 = strpos ($element , ":");
$type = substr ($element, 0, $pos1);
if ($type === 'COLUMN' || $type === 'STARTDROPDOWN' || $type === 'ENDDROPDOWN' ){
if ($id > 1){
echo "<br>";
}
echo "<div id = '" . $id . "' class = 'slot red' onclick = 'slotClicked(id)' >" . $element;
echo "</div>";
}
else if ($type === "POST") {
echo "<div id = '". $id . "' class = 'slot ' onclick = 'slotClicked(id)'>" . $element;
$postid = str_replace ('POST:' ,'', $element);
$postrecord = readDatabaseRecord( $postrecordkeys, "data/posts/" . $postid . ".txt");
$alt = preg_replace('/[^A-Za-z0-9-]/', '', $postrecord['title']);
if ($postrecord['thumbnail']!== "") {
echo "<br><img src = '" . $postrecord['thumbnail'] . "' alt = '" . $alt . "' width= '80' /><br>";
}
echo "</div>";
}
else if ($type === 'IMAGE' ) {
echo "<div id = '" . $id . "' class = 'slot' onclick = 'slotClicked(id)'>" . $element;
$imagefile = str_replace ("IMAGE:", '', $element);
if (file_exists ("data/images/" . $imagefile )) {
echo "<br><img src = 'data/images/" . $imagefile . "' alt = '' width= '80' /><br>";
}
echo "</div>";
}
else if ($type === 'LINK') {
echo "<div id = '". $id . "' class = 'slot' onclick = 'slotClicked(id)'>" . $element;
$linkid = str_replace ('LINK:', '', $element);
$linkrecord = readDatabaseRecord($linkrecordkeys, "data/links/". $linkid .'.txt');
$alt = preg_replace('/[^A-Za-z0-9-]/', '', $linkrecord['title']);
if ($linkrecord['image'] !== "") {
echo "<br><img src = '" . $linkrecord['image'] . "' alt = '" . $alt . "' width= '80' /><br>";
}
echo "</div>";
}
else if ($type === 'TEXT-BLOCK') {
echo "<div id = '". $id . "' class = 'slot' onclick = 'slotClicked(id)'>" . $element;
$blockid = str_replace ('TEXT-BLOCK:', '', $element);
$blockrecord = readDatabaseRecord($blockrecordkeys, "data/blocks/". $blockid .'.txt');
//echo "<br>" . $blockrecord['title'] . "<br>";
echo "</div>";
}
else {
echo "<div id = '". $id . "' class = 'slot' onclick = 'slotClicked(id)'>" . $element;
echo "</div>";
}
//Create a checkbox for this slot
echo "<input class = 'checkbox hidden ' type = 'checkbox' name = 'selectedelements[]' value = '" . $element . "' checked />" ;
$id++;
// echo "</div><div class = 'input-group'>";
//echo "HERE2" . $id;
//empty slot
echo "<div id = '" . $id . "' class = 'slot pink ' onclick = 'slotClicked(id)'></div>";
echo "<input class = 'checkbox hidden' type = 'checkbox' name = 'selectedelements[]' value = '' checked />" ;
if ($type === 'COLUMN' || $type === 'STARTDROPDOWN' || $type === 'ENDDROPDOWN'){
echo "<br>";
}
$id++;
}
}
}
echo "</div>";
?>
organize-elements-instructions.php ▾
<h3>Instructions: </h3>
<div class = 'instructions'>
<b>To Add an Item: </b> - click available items(s), then click vertical bar to insert
<br><br><b>To Rearrange </b>- click item(s) to select, then click vertical bar to insert
<br><br><b>To Delete </b>- click current item(s), then click blue delete button
</div>
<button class = 'blue' onclick = 'chooseToDelete()' >Click here to remove blue items </button><br><br>
<div style = 'display: none;'>
Selected Resources: <div id = 'saved-resources'></div>
</div><br> process-add-update-document.php ▾
<?php
//save earlier version
writeDatabaseRecord($documentrecord, 'data/document-versions/' . $documentid . "-" . date ("Y-m-d-h-ia") . '.txt');
$documentrecord = assignPostValuesToRecord ($_POST, $documentrecordkeys);
$categories = array();
if (isset ($_POST['categories'])) {
$categories = $_POST['categories'];
}
//save markdown and html text to record
$htmlcontent = '';
$mdarray= $newmdarray = array();
if (isset ($_POST['mdarray'])) {
$mdarray = $_POST['mdarray'];
//concatenate html sections
foreach ($mdarray as $id => $item) {
if ($item !== '') {
if ($documentrecord ['convert-to-html'] === '1') {
$htmlitem = convertMD($item, $documentid);
}
else {
$htmlitem = $item;
}
$htmlcontent .= $htmlitem;
array_push ($newmdarray, $item);
}
}
}
//save markdown sections delimited by dl2
$string = implode ($dl2, $newmdarray);
$documentrecord['md-content'] = $string;
$documentrecord['html-content'] = $htmlcontent;
//Create new id
$error = false;
if ($documentid === "") {
$documentid = createRecordId ($documentrecord['title']);
//Check if id can be created
if ($documentid === '') {
echo "<div class = 'error'>Unable to create record id from title</div>";
$error = true;
}
//Check if file already exists
else if (file_exists ('data/documents/' . $documentid . '.txt')) {
echo "<div class = 'error'>Text document already exists</div>";
$error = true;
}
}
$documentrecord['date'] = formatDate ($documentrecord['date']);
if (!$categories) {
echo "<div class = 'error'>Choose a category</div>";
$error = true;
}
if ($error === false) {
writeDatabaseRecord ($documentrecord, 'data/documents/' . $documentid . '.txt');
removeMapEntries ('data/maps/date-document-map.txt', '', $documentid);
addMapEntry ('data/maps/date-document-map.txt', $documentrecord['date'], $documentid);
removeMapEntries ('data/maps/category-document-map.txt', '', $documentid);
foreach ($categories as $cat) {
addMapEntry ('data/maps/category-document-map.txt', $cat , $documentid);
}
}
?> process-image-edit.php ▾
<?php
//Create Post for Image
if (isset($_POST ['submit-create-post'])) {
require ("admin/inc/create-post-for-image.php");
}
//Update Image Description
else if (isset ($_POST['description'])) {
$description = $_POST['description'];
addMapEntry('data/maps/image-description-map.txt', $folderfile, $description);
}
//Rename image
else if (isset($_POST['newimagename'])) {
$newimagename = $_POST['newimagename'];
$newimagename = preg_replace('/[^A-Za-z0-9-.]/', '', $newimagename);
if ($newimagename === "") {
echo "<div class = 'error'>Invalid Image Name</div>";
}
else {
$oldfolderfile = $imagefolder . '/' . $imagebase;
$newfolderfile = $imagefolder . '/'. $newimagename. '.' . $extension;
rename ('data/images/' . $oldfolderfile, 'data/images/' . $newfolderfile);
$imagebase = $newimagename . "." . $extension;
$imagename = $newimagename;
$folderfile = $newfolderfile;
require ('admin/inc/replace-image-in-files.php');
$folderfile = $newfolderfile;
}
}
//Move Image to new folder
else if (isset($_POST['newfolder'])) {
$newfolder = $_POST['newfolder'];
$oldfolderfile = $imagefolder . "/" . $imagebase;
$newfolderfile = $newfolder . "/". $imagebase;
if ($newfolder !== 'trash') {
require ("admin/inc/replace-image-in-files.php");
}
rename ('data/images/' . $oldfolderfile, 'data/images/' . $newfolderfile);
$imagefolder = $newfolder;
$folderfile = $newfolderfile;
}
//Copy Image to new folder
else if (isset($_POST['copyfolder'])) {
$copyfolder = $_POST['copyfolder'];
$oldfolderfile = $imagefolder . "/" . $imagebase;
$newfolderfile = $copyfolder . "/". $imagebase;
copy ('data/images/' . $oldfolderfile, 'data/images/' . $newfolderfile);
$imagefolder = $copyfolder;
$folderfile = $newfolderfile;
addMapEntry ( 'data/maps/image-description-map.txt', $newfolderfile, $description);
}
//Rotate Image
else if (isset ($_POST['imagedegrees'])) {
$degrees = $_POST['imagedegrees'];
$resource = "";
$oldfolderfile = $imagefolder .'/' . $imagebase;
$newfolderfile = $imagefolder .'/rotated-' . $imagebase;
$filename = 'data/images/' . $oldfolderfile;
$extension = strtolower (pathinfo ($filename, PATHINFO_EXTENSION));
if ($extension === 'jpg' || $extension === 'jpeg') {
$resource = imagecreatefromjpeg($filename);
}
else if ($extension == 'png') {
$resource = imagecreatefrompng($filename);
}
$rotated = imagerotate($resource, $degrees, 0);
if ($extension === 'jpg' || $extension === 'jpeg') {
imagejpeg ($rotated, 'data/images/' . $newfolderfile);
}
else if ($extension === 'png') {
imagepng ($rotated, 'data/images/' . $newfolderfile);
}
imagedestroy($rotated);
imagedestroy ($resource);
echo "<h3>Image Rotated</h3>";
echo "<img src = 'data/images/" . $newfolderfile . "' width = '160' alt = 'img' />";
echo "<br>" . 'rotated-' . $imagebase;
}
?> replace-image-in-files.php ▾
<?php
$documents = getRecordIdsFromFolder ('data/documents');
foreach ($documents as $documentid) {
$string = file_get_contents ('data/documents/' . $documentid . '.txt');
if (strpos ($string, $imagefolder . "/" . $imagebase)) {
$newstring = str_replace ($oldfolderfile, $newfolderfile, $string);
file_put_contents ($item2, $newstring);
echo "Folder: " . $folder . " ";
echo "<a href = 'index.php?page=add-update-document&documentid=" . $documentid . "'>" . $documentid . "</a><br>";
}
}
?> scripts.js ▾
function accordionToggle(bttn) {
///Used tp display sections in Control Panel
var x = document.getElementById(bttn+"-content");
if (x.style.display === "block" ) {
x.style.display = 'none';
}
else {
x.style.display = 'block';
}
}
//
//PAGE LAYOUT FUNCTIONS
//
function availableItemClicked(id) {
var availablearray = document.getElementsByClassName('available');
//Save selected item
var saveditems = document.getElementById('saved-items').innerHTML;
var clickeditem = availablearray[id].innerHTML;
var newsaveditems = '';
//Item has already been selected - need to remove it from saved items
if (document.getElementById(id).style.backgroundColor === 'pink') {
document.getElementById(id).style.backgroundColor = 'white';
newsaveditems = saveditems.replace (clickeditem + ',', '');
}
else {
newsaveditems = saveditems + clickeditem + ',';
document.getElementById(id).style.backgroundColor = 'pink';
}
//Update saved items in html
document.getElementById('saved-items').innerHTML = newsaveditems;
}
function slotClicked(id) {
var slotarray = document.getElementsByClassName('slot');
if (slotarray[id].innerHTML !== "" ) {
//NON-EMPTY SLOT - item is saved and can be moved
nonEmptySlotClicked (id);
}
else {
//EMPTY SLOT - any previously saved items will be moved to selected location
emptySlotClicked (id);
}
//Reset background in available resources
var availablearray = document.getElementsByClassName('available');
for (i = 0; i < availablearray.length ; i++) {
availablearray[i].style.backgroundColor = '#fff';
}
}
function nonEmptySlotClicked(id){
//Column2 All slots, filled and empty
var slotarray = document.getElementsByClassName('slot');
//Column 2 - Input form checkboxes
var saveditems = document.getElementById('saved-items').innerHTML;
var clickeditem = slotarray[id].innerHTML;
var newsaveditems = '';
//Change color of slot
if (document.getElementById(id).style.backgroundColor === 'blue') {
//Change color to back to grey
document.getElementById(id).style.backgroundColor = '#eee';
//remove item from saved items
newsaveditems = saveditems.replace ( clickeditem + ',', '');
}
else {
//Add item to saved items
newsaveditems = saveditems + clickeditem + ',';
//Change color to blue
document.getElementById(id).style.backgroundColor = 'blue';
}
//Update saved items in html
document.getElementById('saved-items').innerHTML = newsaveditems;
}
function emptySlotClicked (id) {
var slotarray = document.getElementsByClassName('slot');
var checkboxarray = document.getElementsByClassName('checkbox');
var saveditems = document.getElementById('saved-items').innerHTML;
var saveditemsarray = saveditems.split(',');
//remove items with blue background from slot array
for ( i = 0; i < slotarray.length ; i++) {
if (slotarray[i].style.backgroundColor === 'blue') {
//remove contents of slot
slotarray[i].innerHTML = "";
checkboxarray[i].value = "";
}
}
//create a new array that includes saved items
var updatedslotarray = new Array();
//Check each current slot
for (i = 0; i < slotarray.length ; i++) {
if (i == id) {
//Insert saved items at clicked id
for (j = 0; j < saveditemsarray.length; j++){
//insert saved items into updated slot array
if (saveditemsarray[j] !== ""){
//remove the comma
saveditemsarray[j] = saveditemsarray[j].replace (',' ,'');
updatedslotarray.push (saveditemsarray[j]);
}
}
}
else if (slotarray[i].innerHTML !== '') {
//Add remaining slot contents to updated slot array
updatedslotarray.push (slotarray[i].innerHTML);
}
}
//Remove pink backgrounds in available list
var availablearray = document.getElementsByClassName('available');
for (i = 0; i< availablearray.length; i++){
availablearray[i].style.backgroundColor = '#eee';
}
//REBUILD SLOT ARRAY ON PAGE
//Show empty pink slot at top
document.getElementById('slots').innerHTML = "<div id = '0' class = 'slot pink' onclick = 'slotClicked(id)'></div><input class = 'checkbox hidden ' type = 'checkbox' name = 'selectedelements[]' value = '' checked />" ;
//Show updated
var id = 1;
for (i = 0; i < updatedslotarray.length ; i++) {
if (updatedslotarray[i] !== "" ){
//check if itme is a column or a menu dropdown
$position1 = (updatedslotarray[i].search("COLUMN"));
$position2 = (updatedslotarray[i].search ("DROPDOWN"));
//create filled slot
if ($position1 === -1 && $position2 === -1) {
document.getElementById('slots').innerHTML +=
"<div id = '" + id + "' class = 'slot ' onclick = 'slotClicked(id)'>" + updatedslotarray[i] + "</div><input class = 'checkbox hidden ' type = 'checkbox' name = 'selectedelements[]' value = '" + updatedslotarray[i] + "' checked />";
}
else {
document.getElementById('slots').innerHTML +=
"<div id = '" + id + "' class = 'slot red' onclick = 'slotClicked(id)'>" + updatedslotarray[i] + "</div><input class = 'checkbox hidden ' type = 'checkbox' name = 'selectedelements[]' value = '" + updatedslotarray[i] + "' checked /><br>";
}
id++;
//empty slot
document.getElementById('slots').innerHTML +=
"<div id = '" + id + "' class = 'slot pink' onclick = 'slotClicked(id)'></div><input class = 'checkbox hidden ' type = 'checkbox' name = 'selectedelements[]' value = '' checked />" ;
id++;
}
}
//Set saved items list to empty
document.getElementById('saved-items').innerHTML = "";
}
function deleteBoxClicked() {
//Column2 All slots, filled and empty
var slotarray = document.getElementsByClassName('slot');
//Column 2 - Input form checkboxes
var checkboxarray = document.getElementsByClassName('checkbox');
var limit = slotarray.length;
//Remove item with blue background
for (var i = 0; i < limit ; i++) {
if (slotarray[i].style.backgroundColor === 'blue') {
//remove contents of slot
slotarray[i].innerHTML = "";
checkboxarray[i].value = "";
slotarray[i].style.display = 'none';
}
}
//remove item from saved items
document.getElementById('saved-items').innerHTML = '';
}
function selectImageForPost(key) {
//assigns a thumbnail or featured image, or adds image to page content
var imagedestination = "";
var cancel = 0;
var pic = (document.getElementById(key+'-image').alt);
var imageLocation = pic;
imagedestination = prompt("Where do you want this image to be used? Select b (body of text), t (thumbnail), or f (featured image))");
if (imagedestination === 't') {
document.getElementById('thumbnail').value = pic;
document.getElementById('thumbnailimg').src = pic;
}
else if (imagedestination === 'f') {
document.getElementById('featured').value = pic;
document.getElementById('featuredimg').src = pic;
}
else {
selectItemForTextarea(key);
}
}
function selectItemForTextarea(key) {
var pic = (document.getElementById(key+'-image').alt);
var result = pic.includes(".pdf");
if (result === true) {
selectPDFForTextarea(key);
}
else {
selectImageForTextarea(key);
}
}
function selectImageForTextarea(key) {
var pic = (document.getElementById(key+'-image').alt);
var sectionNumber = "1";
sectionNumber = prompt("Please enter section number: ");
var imageLocation = pic;
var cancel = 0;
var array1 = document.getElementsByClassName ('textarea');
var myElement = document.getElementById('text-element-' + sectionNumber );
var startPosition = myElement.selectionStart;
var newElement = myElement;
var iName = "";
iName = prompt("Please enter image name: ");
if (iName === "" || iName === null) {
cancel = 1;
}
if (cancel === 0){
//Select justification
var justify ;
var justifyInput = prompt ("Select justification: r (right), l (left) g (grid) - center is default");
if (justifyInput === 'l') {
justify = "LEFT";
}
else if (justifyInput === "r") {
justify = "RIGHT";
}
else if (justifyInput === 'g') {
justify = 'GRID';
}
else {
justify = 'CENTER';
}
//Select size
var size = "";
var sizeInput;
sizeInput = prompt ("Select size: xs, s, m, l, xl - default if full size");
if (sizeInput === 'xs') {
size = ' XSMALL';
}
else if (sizeInput === 's') {
size = ' SMALL';
}
else if (sizeInput === 'm') {
size = ' MEDIUM';
}
else if (sizeInput === 'l') {
size = ' LARGE';
}
else if (sizeInput === 'xl' ){
size = ' XLARGE';
}
//Check for link
var newElementFirst = newElement.value.substring (0, startPosition);
var newElementSecond = newElement.value.substring (startPosition, myElement.value.length) ;
var folderFile = imageLocation.replace ("data/images/", "");
var imagelink = prompt ("Is this an image link? y or n)");
var iDestination = "";
if (imagelink === "y" ) {
iDestination = prompt ("If picture is a link, enter destination: ", " ");
newElement.value = newElementFirst + "[]" + "(" + iDestination + ")" + newElementSecond;
}
else {
//default is single-image-page
newElement.value = newElementFirst + " " + newElementSecond;
}
}
}
function selectPDFForTextarea(key) {
var pic = (document.getElementById(key+'-image').alt);
var myElement = document.getElementById('text-element');
var startPosition = myElement.selectionStart;
var endPosition = myElement.selectionEnd;
imageLocation = pic;
var newElement = myElement;
var iName = prompt("Please enter document name: ", " ");
if (iName !== null) {
var newElementFirst = newElement.value.substring (0, startPosition);
var newElementSecond = newElement.value.substring (startPosition, myElement.value.length) ;
newElement.value = newElementFirst + "[" + iName + "](" + imageLocation + ")" + newElementSecond;
}
}
function createLink() {
var myElement = document.getElementById('text-element');
var startPosition = myElement.selectionStart;
var endPosition = myElement.selectionEnd;
var newElement = myElement;
var iName = prompt("Please enter link text: ");
if (iName !== null) {
var iDestination = prompt ("Please enter link destination: ");
if (iDestination !== null) {
var newElementFirst = newElement.value.substring (0, startPosition);
var newElementSecond = newElement.value.substring (startPosition, myElement.value.length) ;
newElement.value = newElementFirst + "[" + iName + "](" + iDestination + ")" + newElementSecond;
}
}
}
function selectImage(key) {
alert ("Image selected");
var pic = (document.getElementById(key+'-image').alt);
document.getElementById('image-input').value = pic;
document.getElementById('image-img').src = pic;
}
function setCheckboxes () {
var boxes = document.getElementsByClassName ('checkbox');
var i;
if (boxes[0].checked === false) {
for (i = 0; i < boxes.length; i++) {
boxes[i].checked = true;
}
}
else {
for (i = 0; i < boxes.length; i++) {
boxes[i].checked = false;
}
}
}
select-images.php ▾
<div class = 'dropdownwrap'>
<button class = 'toggle-banner' id = 'images' onclick= 'accordionToggle(this.id)'>Images ▾</button>
<div id ='images-content' class = 'dropdowncontent' style = 'display: none; ' >
<?php
$array1 = scandir( "data/images");
foreach ($array1 as $item1) {
if (substr ($item1, 0,1) !== "." ) {
$imagefolder = trim ($item1);
echo "<div class = 'dropdownwrap'>";
echo "<button class = 'toggle-banner2' id = 'IMAGE-" . $imagefolder . "' onclick= 'accordionToggle(this.id)' >" . ucwords(str_replace("-", " ", $imagefolder )). " ▾</button>";
echo "<div id = 'IMAGE-" . $imagefolder . "-content' class = 'dropdowncontent' style = 'display: none;'>";
$images = getImagesFromFolder ( "data/images/" . $imagefolder );
foreach ($images as $imagebase) {
$newblockid = "IMAGE:" . $imagefolder . "/" . $imagebase ;
if (in_array ($newblockid, $elementarray)) {
echo "<button id = '" . $newblockid . "' class = 'available highlighted' onclick = 'availableItemClicked(id)'>" . $newblockid;
}
else {
echo "<button id = '" . $newblockid . "' class = 'available ' onclick = 'availableItemClicked(id)'>" . $newblockid;
}
echo "<br><img src = 'data/images/" . $imagefolder . "/" . $imagebase . "' alt ='". $imagebase ."' width = '100' /><br>";
echo "</button>";
}
echo "</div></div>";
}
}
?>
</div>
</div>
uploaded-image.php ▾
<?php
$imagefolder = "";
if (isset ($_POST['imagefolder'])) {
$imagefolder = sanitizeFormInput ($_POST['imagefolder']);
}
$newimagename = "";
if (isset ($_POST['newimagename'])) {
$newimagename = sanitizeFormInput ($_POST['newimagename']);
}
$error = false;
//Check if file is an image
$check = getimagesize($_FILES["uploadfile"]["tmp_name"]);
if ($check === false) {
echo "<div class = 'error' >File is not an image </div>";
$error = true;
}
// Check file size
if ($_FILES["uploadfile"]["size"] > 500000) {
echo "<div class = 'error'>File too large to upload</div>";
$error = true;
}
// check file type
$imagebase = $_FILES['uploadfile']['name'];
$imagename = pathinfo ($imagebase, PATHINFO_FILENAME);
$extension = strtolower (pathinfo ($imagebase, PATHINFO_EXTENSION));
if($extension === 'pdf' || $extension === 'jpg' || $extension === 'jpeg' || $extension === 'png' || $extension === 'gif') {
//ok
}
else {
echo "<div class = 'error'>Invalid file type</div>";
$error = true;
}
//Folder
if ($imagefolder === "") {
$error = true;
echo "<div class ='error'>Select an image folder</div>";
}
//Replace imagename with new Image Name
if ($newimagename !== "") {
$imagename = str_replace(" ", "-", $newimagename);
$imagename = strtolower ($imagename);
$imagename = preg_replace('/[^A-Za-z0-9\-]/', '', $imagename);
$imagename = preg_replace('/-+/', '-', $imagename);
}
if ($imagename === "") {
echo "<div class = 'error'>Image Name Missing</div>";
$error = true;
}
$imagebase = $imagename ."." . $extension;
//Image Size
$fileTmpName = $_FILES['uploadfile']['tmp_name'];
$destination = 'data/images/' . $imagefolder . '/' . $imagebase;
$framewidth = $frameheight = 0;
if ( move_uploaded_file($fileTmpName, $destination)){
if ($extension !== 'pdf') {
//Determine image size
$imageinfo = getimagesize($destination);
$framewidth = $imageinfo[0];
$frameheight = $imageinfo[1];
}
}
else {
echo "<div class = 'error'>Image upload error</div>";
$error = true;
}
if ($error === false ) {
if ( ($extension === 'jpeg' || $extension === 'jpg' || $extension === 'png' ) && $framewidth > 1000) {
//Determine smaller image size
$newwidth = 1000;
$newheight = ($newwidth * $frameheight) / $framewidth;
if ($imageinfo ['mime'] == 'image/jpeg') {
$resource = imagecreatefromjpeg($destination);
}
else if ($imageinfo ['mime'] == 'image/png') {
$resource = imagecreatefrompng($destination);
}
$dst = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled ($dst, $resource, 0, 0, 0, 0, $newwidth, $newheight, $framewidth, $frameheight);
if ($imageinfo ['mime'] == 'image/jpeg') {
imagejpeg ($dst, $destination);
}
else if ($imageinfo ['mime'] == 'image/png') {
imagepng ($dst, $destination);
}
imagedestroy ($resource);
imagedestroy ($dst);
}
echo "<a href = 'index.php?page=image-edit&imagefolder=" . $imagefolder . "&imagebase=" . $imagebase . "' <h4> " . $imagebase . " successfully uploaded</h4></a>";
}
?>
DOCUMENTS/markdown
convert-markdown-blanklines.php ▾
<?php
if (strpos ($newstring, "[BLANKLINES](") !== false){
$array1 = explode ("[BLANKLINES](", $newstring);
$newstring1 = "";
foreach ($array1 as $id => $item) {
$item = trim ($item);
if ($id === 0 && substr ($newstring, 0, 13) !== '[BLANKLINES](') {
$newstring1 = $item;
}
else {
$pos2 = strpos ($item, ")");
$count = substr ($item, 0, $pos2);
$numcount = intval ($count);
$remaining = substr ($item, $pos2 + 1) ;
$lines = "";
for ($l = 0; $l < $numcount; $l++) {
$lines .= " [BLANKLINE] ";
}
$newitem = $lines . $remaining;
$newstring1 .= $newitem;
}
}
$newstring = $newstring1;
}
?> convert-markdown-colors.php ▾
<?php
$newstring1 = "";
if (strpos ($newstring, "[COLOR](" ) !== false) {
$array1 = explode ("[COLOR](", $newstring);
foreach ($array1 as $id => $item) {
$item = trim ($item);
if ($id === 0 ) {
//beginning of string
$newstring1 .= $item;
}
else {
$pos2 = strpos ($item, ")");
$color = substr ($item, 0, $pos2);
$remaining = substr ($item, $pos2 + 1);
$newitem = "<span style = 'color: " . $color . ";'>" . $remaining;
$newstring1 .= $newitem;
}
}
$newstring = $newstring1;
$newstring = str_replace ("[ENDCOLOR]", "</span>", $newstring);
}
?> convert-markdown-divs.php ▾
<?php
//Start new line after image
$newstring = str_replace ("[BREAK]", "<div style = 'clear: both; float: none;'></div><br>", $newstring);
// Columns
$newstring = str_replace ("[2COL2]", "</div><div class = 'half-column-2'><br>", $newstring);
$newstring = str_replace ("[2COL1]", "<div class = 'half-column-1'><br>", $newstring);
$newstring = str_replace ("[23COL1]", "<div class = 'two-thirds-column-1'><br>", $newstring);
$newstring = str_replace ("[23COL2]", "</div><div class = 'two-thirds-column-2'><br>", $newstring);
$newstring = str_replace ("[3COL3]", "</div><div class = 'third-column-3'><br>", $newstring);
$newstring = str_replace ("[3COL2]", "</div><div class = 'third-column-2'><br>", $newstring);
$newstring = str_replace ("[3COL1]", "<div class = 'third-column-1'><br>", $newstring);
$newstring = str_replace ("[4COL4]", "</div><div class = 'fourth-column-4'><br>", $newstring);
$newstring = str_replace ("[4COL3]", "</div><div class = 'fourth-column-3'><br>", $newstring);
$newstring = str_replace ("[4COL2]", "</div><div class = 'fourth-column-2'><br>", $newstring);
$newstring = str_replace ("[4COL1]", "<div class = 'fourth-column-1'><br>", $newstring);
$newstring = str_replace ("[34COL1]", "<div class = 'three-fourths-column-1'><br>", $newstring);
$newstring = str_replace ("[34COL2]", "</div><div class = 'three-fourths-column-2'><br>", $newstring);
$newstring = str_replace ("[ENDCOL]", "</div><br>", $newstring);
?>
convert-markdown-headings.php ▾
<?php
$newarray = array();
$array = explode ("<br>", $newstring);
foreach ($array as $id => $item) {
$item = trim ($item);
if (substr ($item, 0, 5) === "#####"){
$array[$id] = "<h5>" . substr($item, 5) . "</h5>";
}
else if (substr ($item, 0, 4) === "####"){
$array[$id] = "<h4>" . substr($item, 4) . "</h4>";
}
else if (substr ($item, 0, 3) === "###") {
$array[$id] = "<h3>" . substr($item, 3) . "</h3>";
}
else if (substr ($item, 0, 2) === "##") {
$array[$id] = "<h2>" . substr($item, 2) . "</h2>";
}
else if (substr ($item, 0, 1) === "#" ) {
$array[$id] = "<h1>" . substr($item, 1) . "</h1>";
}
}
$newstring = implode ("<br>", $array);
?> convert-markdown-image-links.php ▾
<?php
$newstring = trim ($newstring);
$newstring1 = "";
if (strpos ($newstring, "[![") !== false) {
$array1 = explode ("[![", $newstring);
foreach ($array1 as $id => $item) {
$item = trim ($item);
$newitem = '';
if ($id === 0 && substr ($newstring, 0, 3) !== '[![') {
//beginning of string before any matches
$newitem = $item;
}
else {
$imagedata = $linkaddress = $name = "";
$pos1 = 0;
$pos2 = strpos ($item, "]");
//name
$name = substr ($item, 0, $pos2);
$name = htmlspecialchars ($name);
//image location including size and justification
$pos3 = strpos ($item, "(");
$pos4 = strpos ($item, ")");
$imagedata = substr ($item, $pos3 + 1, $pos4-$pos3 -1);
$remaining = substr ($item, $pos4 + 1 );
//closing image ']' and opening link '('
$pos5 = strpos ($remaining, '](');
//Closing ')' for link address
$pos6 = strpos ($remaining, ')');
$linkaddress = substr ($remaining, $pos5 + 2, $pos6 - $pos5 -2);
//rest of the characters in item after end of link
$remaining = substr ($remaining, $pos6 + 1 );
//Determine width of image
$size = "";
if (strpos($imagedata, "XSMALL")) {
$size = 'image-xsmall';
$imagedata = str_replace ("XSMALL", "", $imagedata);
}
if (strpos($imagedata, "SMALL")) {
$size = 'image-small';
$imagedata = str_replace ("SMALL", "", $imagedata);
}
else if (strpos ($imagedata, "MEDIUM")) {
$size = 'image-medium';
$imagedata = str_replace ("MEDIUM", "", $imagedata);
}
else if (strpos ($imagedata, "XLARGE") ) {
$size = 'image-xlarge';
$imagedata = str_replace ("XLARGE", "", $imagedata);
}
else if (strpos ($imagedata, "LARGE") ) {
$size = 'image-large';
$imagedata = str_replace ("LARGE", "", $imagedata);
}
//Determine image justification
$justify = "";
if (strpos ($imagedata, "RIGHT") ) {
$justify = 'image-right';
$imagedata = str_replace ('RIGHT', "", $imagedata);
}
else if (strpos ($imagedata, "CENTER")) {
$justify = 'centered';
$imagedata = str_replace ('CENTER', "", $imagedata);
}
else if (strpos ($imagedata, "LEFT")) {
$justify = 'image-left';
$imagedata = str_replace ('LEFT', "", $imagedata);
}
else if (strpos ($imagedata, "GRID")) {
$justify = 'imagegridcolumn';
$imagedata = str_replace ('GRID', "", $imagedata);
}
//Add Caption
$caption = "";
$pos7 = strpos ($item, '[CAPTION');
$pos8 = strpos ($item, '[ENDCAPTION]');
if ($pos7 && $pos8 ) {
$captionlength = $pos8 - $pos7 - 9;
$caption = substr ($item, $pos7 + 9 , $captionlength);
$remaining = substr ($item, $pos8 + 12);
$newitem .= "<a href = '" . $linkaddress . "'>";
$newitem .= "<figure class = '" . $justify . " " . $size . "' >";
$newitem .= "<img src = '" . $imagedata . " ' alt = '" . $name . "' />";
$newitem .= "<figcaption>" . $caption . "</figcaption>";
$newitem .= "</figure></a>";
}
else {
//build html for this image link
$newitem .= "<a href = '" . $linkaddress . "'>";
$newitem .= "<img src = '" . $imagedata . " ' alt = '" . $name . "' class = '" . $justify . " " . $size . "' /></a>";
}
$newitem .= $remaining;
}
$newstring1 .= $newitem;
}
//final converted string
$newstring = $newstring1;
}
?>
convert-markdown-images.php ▾
<?php
$newstring1 = "";
$imagecount = 0;
$newstring = trim ($newstring);
if (strpos ($newstring, "![") !== false) {
$array1 = explode ("![", $newstring);
foreach ($array1 as $id => $item) {
$item = trim ($item);
$newitem = '';
if ($id === 0 && substr ($item, 0, 2) !== '![') {
//beginning of string before image
$newitem = $item;
}
else {
$imagedata = $name = "";
$pos1 = 0;
$pos2 = strpos ($item, "]");
//name
$name = substr ($item, 0, $pos2);
$name = htmlspecialchars ($name);
//image location including size and justification
$pos3 = strpos ($item, "(");
$pos4 = strpos ($item, ")");
$imagedata = substr ($item, $pos3 + 1, $pos4-$pos3 -1);
$remaining = substr ($item, $pos4 + 1 );
//Assign a number to this image
$imagenumber = 'img-' . $imagecount;
$imagecount++;
//Determine width of image
$size = "";
if (strpos($imagedata, "XSMALL")) {
$size = 'image-xsmall';
$imagedata = str_replace ("XSMALL", "", $imagedata);
}
else if (strpos ($imagedata, "SMALL") ) {
$size = 'image-small';
$imagedata = str_replace ("SMALL", "", $imagedata);
}
else if (strpos ($imagedata, "MEDIUM")) {
$size = 'image-medium';
$imagedata = str_replace ("MEDIUM", "", $imagedata);
}
else if (strpos ($imagedata, "XLARGE") ) {
$size = 'image-xlarge';
$imagedata = str_replace ("XLARGE", "", $imagedata);
}
else if (strpos ($imagedata, "LARGE") ) {
$size = 'image-large';
$imagedata = str_replace ("LARGE", "", $imagedata);
}
//Determine image justification
$justify = "";
if (strpos ($imagedata, "RIGHT") ) {
$justify = 'image-right';
$imagedata = str_replace ('RIGHT', "", $imagedata);
}
else if (strpos ($imagedata, "LEFT")) {
$justify = 'image-left';
$imagedata = str_replace ('LEFT', "", $imagedata);
}
else if (strpos ($imagedata, "CENTER")) {
$justify = 'centered';
$imagedata = str_replace ('CENTER', "", $imagedata);
}
else if (strpos ($imagedata, "GRID")) {
$justify = 'imagegridcolumn';
$imagedata = str_replace ('GRID', "", $imagedata);
}
//add caption
$caption = "";
$pos5 = strpos ($item, '[CAPTION');
$pos6 = strpos ($item, '[ENDCAPTION]');
$imagefolderfile = str_replace ('data/images/', '', $imagedata);
if ($pos5 && $pos6 ) {
$captionlength = $pos6 - $pos5 - 9;
$caption = substr ($item, $pos5 + 9 , $captionlength);
$remaining = substr ($item, $pos6 + 12);
$newitem .= "<figure class = '" . $justify . " " . $size . "' >";
$newitem .= "<img src = '" . $imagedata . " ' alt = '" . $name . "' />";
$newitem .= "<figcaption>" . $caption . "</figcaption>";
$newitem .= "</figure>";
}
else {
$newitem = "<div class ='" . $justify . "'>";
$newitem .= "<img src = '" . $imagedata . "' alt = '" . $name . "' class = '" . $imagenumber . " " . $size . "' /></div>";
}
$newitem .= $remaining;
}
$newstring1 .= $newitem;
}
$newstring = $newstring1;
}
?>
convert-markdown-inline.php ▾
<?php
//Convert bold and italic at at start of line
if (strpos ($newstring, "***", 0) !== false) {
$tag = 0;
$newstring1 = "";
$array1 = explode ("***", $newstring);
foreach ($array1 as $item) {
if ($tag === 0) {
$newstring1 .= $item;
$tag = 1;
//echo "<br><br>" . htmlentities ($newstring1);
}
else {
$newstring1 .= "<b><i>" . $item . "</i></b>" ;
$tag = 0;
}
}
$newstring = $newstring1;
//echo "<br>" . htmlentities ($newstring);
}
if (strpos ($newstring, "**", 0) !== false) {
$tag = 0;
$newstring1 = "";
$array2 = explode ("**", $newstring);
foreach ($array2 as $item) {
if ($tag === 0) {
$newstring1 .= $item;
$tag = 1;
//echo "<br><br>" . htmlentities ($newstring1);
}
else {
$newstring1 .= "<b>" . $item . "</b>" ;
$tag = 0;
}
}
$newstring = $newstring1;
// echo "<br>" . htmlentities ($newstring);
}
if (strpos ($newstring, "*", 0) !== false) {
$newstring1 = "";
$tag = 0;
$array1 = explode ("*", $newstring);
foreach ($array1 as $item) {
if ($tag === 0) {
$newstring1 .= $item;
$tag = 1;
//echo "<br><br>" . htmlentities ($newstring1);
}
else {
$newstring1 .= "<i>" . $item . "</i>" ;
$tag = 0;
}
}
$newstring = $newstring1;
// echo "<br>" . htmlentities ($newstring);
}
?> convert-markdown-links.php ▾
<?php
if (strpos ($newstring, "[") !== false) {
$newstring1 = "";
$array1 = explode("[", $newstring);
foreach ($array1 as $id => $item) {
if ($id === 0 && substr ($newstring, 0, 1) !== '[') {
$newitem = $item;
}
else {
$linkfield = "";
$pos1 = 0;
$pos2 = strpos ($item, "]");
$pos3 = strpos ($item, "(");
$pos4 = strpos ($item, ")");
$namelength = $pos2;
$hreflength = $pos4 - $pos3;
$name = substr ($item, 0 , $namelength);
$href = substr ($item, $pos3+1, $hreflength -1);
$linkfield = "<a href = '" . $href . "'>" . $name . "</a>";
$newitem = $linkfield . substr ($item, $pos4+1);
}
$newstring1 .= $newitem;
}
$newstring = $newstring1;
}
?> convert-markdown-paragraphs.php ▾
<?php
//remove extra br tags at beginning and end
$array1 = explode ("<br>", $newstring);
$newarray = array();;
$breakcount = 0;
$paragraph = false;
$quote = false;
foreach ($array1 as $id => $item) {
$item = trim ($item);
if (substr ($item, 0, 1) === ">") {
//blockquote
if ($paragraph) {
array_push ( $newarray, '</p>');
$paragraph = false;
}
$quote = true;
$item = substr ($item, 1);
array_push ($newarray, "<blockquote>" . $item );
}
//A non-inline tag has been detected -
else if (substr ($item, 0, 1) === '<' &&
substr ($item, 0, 3) !== "<i>" &&
substr ($item, 0, 3) !== "<b>" &&
substr ($item, 0, 5) !== "<span" &&
substr ($item, 0, 2) !== "<a") {
if ($paragraph ) {
array_push ($newarray, "</p>" . $item);
$paragraph = false;
}
else if ($quote) {
array_push ($newarray, "</blockquote>" . $item);
$quote = false;
}
else {
array_push ($newarray, $item );
}
}
//Item contains text
else if ($item !== "" ) {
if ($paragraph === false && $quote === false) {
//for an image or image link, just save item
if ( strpos ($item, '![')) {
array_push ($newarray, $item);
}
else if ($quote === false) {
//Open paragraph
array_push ($newarray, "<p>" . $item);
$paragraph = true;
}
}
else {
//paragraph or quote already open, insert a blank line
array_push ($newarray, "[BLANKLINE]" . $item);
}
}
else {
//This is a blank line
$breakcount ++;
if ($breakcount > 0) {
//2 blank lines indicate a paragraph has ended
if ($paragraph) {
array_push ($newarray , "</p>");
$paragraph = false;
$breakcount = 0;
}
else if ($quote) {
array_push ($newarray , "</blockquote>");
$quote = false;
$breakcount = 0;
}
}
}
}
if ($paragraph) {
array_push ($newarray, "</p>");
}
if ($quote) {
array_push ($newarray, '</blockquote>');
}
//print_r ($newarray);
$newstring = implode ("<br>", $newarray);
?> convert-markdown-styles.php ▾
<?php
$newstring1 = "";
if (strpos ($newstring, "[STYLE](" ) !== false) {
$array1 = explode ("[STYLE](", $newstring);
foreach ($array1 as $id => $item) {
$item = trim ($item);
if ($id === 0 ) {
//beginning of string
$newstring1 .= $item;
}
else {
$pos2 = strpos ($item, ")");
$style = substr ($item, 0, $pos2);
$remaining = substr ($item, $pos2 + 1);
$newitem = "<div class = '" . $style . "'>" . $remaining;
$newstring1 .= $newitem;
}
}
$newstring = $newstring1;
$newstring = str_replace ("[ENDSTYLE]", "</div>", $newstring);
}
?>
convert-markdown-ul.php ▾
<?php
$newstring1 = "";
$open = false;
$array1 = explode ("<br>", $newstring);
foreach ($array1 as $id => $item) {
$item = trim ($item);
if (substr ($item, 0, 2) === "- " || substr ($item, 0, 2) === "* " ) {
//List item
if ($open === false) {
//first list item
$newstring1 .= "<br><ul>";
$open = true;
}
//Markdown character starts the line
$newstring1 .= "<li>" . substr ($item, 2) . "</li>";
}
//not list item
else if ($open === true) {
$newstring1 .= "</ul><br>" . $item;
$open = false;
}
else {
$newstring1 .= $item . "<br>";
}
}
if ($open === true) {
$newstring1 .= "</ul><br>";
$open = false;
}
$newstring = $newstring1 ;
?>
convert-markdown.php ▾
<?php
//Copyright (c) 2024, Susan V. Rodgers, Lila Avenue, LLC, https://lilaavenue@gmail.com
function convertMD ($text) {
$text = trim ($text);
//Eliminate any preexisting break tags
$text = str_replace ("<br>", "", $text);
$text = str_replace ("<br/>", "", $text);
$text = str_replace ("<br />", "", $text);
$newstring = str_replace ("\n", "<br>", $text);
$newstring = str_replace ("\>", "ESCAPEDTAG", $newstring);
$newstring = str_replace ("\#", "ESCAPEDHASH", $newstring);
$newstring = str_replace ('\*', 'ESCAPEDASTERIX', $newstring);
$newstring = str_replace ('\-', 'ESCAPEDDASH', $newstring);
$newstring = str_replace ('\[', 'ESCAPEDSQUARE', $newstring);
require ("markdown/convert-markdown-headings.php");
require ("markdown/convert-markdown-divs.php");
require ("markdown/convert-markdown-styles.php");
require ("markdown/convert-markdown-ul.php");
require ("markdown/convert-markdown-inline.php");
require ("markdown/convert-markdown-image-links.php");
require ("markdown/convert-markdown-images.php");
require ("markdown/convert-markdown-blanklines.php");
require ("markdown/convert-markdown-paragraphs.php");
require ("markdown/convert-markdown-colors.php");
$newstring = str_replace ("<br>", "", $newstring);
$newstring = str_replace ("[BLANKLINE]", "<br>", $newstring);
require ("markdown/convert-markdown-links.php");
$newstring = str_replace ("ESCAPEDASH", "-", $newstring);
$newstring = str_replace ("ESCAPEDTAG", '>', $newstring);
$newstring = str_replace ("ESCAPEDHASH", '#', $newstring);
$newstring = str_replace ("ESCAPEDASTERIX", "*", $newstring);
$newstring = str_replace ("ESCAPEDDASH", '-', $newstring);
$newstring = str_replace ("ESCAPEDSQUARE", '[', $newstring);
require ("markdown/validate-HTML.php");
return $newstring;
}
?> markdown-instructions.php ▾
<div class = 'dropdownwrap'>
<button class = 'dropdownbutton' id = 'editing' onclick= 'accordionToggle(this.id)'>Markdown Editor Instructions ▾</button>
<div id ='editing-content' class = 'dropdowncontent1 left' style = 'display: none; ' >
<div class = 'pink-background'>
<div class = 'half-column-1'>
<h2>Standard Markdown Syntax</h2>
<b>#</b> Heading1 <br>
<b>##</b> Heading2 <br>
<b>###</b> Heading3 <br>
<b>####</b> Heading4 <br>
<b>#####</b> Heading5 <br>
<br>Note: To use '#' in text, use backslash: \#
<br>
<br>*<i>Italics</i>*
<br>**<b>Bold</b>**
<br> ***<i><b>Bold Italics</b></i>***<br>
<br>Note: To use '*' in text, use backslash: \*
<br><br>
<b>Bullet List</b><br>
Line starts with * followed by a space
<br><br>
<b>Bullet List</b><br>
Line starts with - followed by a space
<br><br>
<b>Images:</b>
<br> ![image description ] (image location )
<br><br>
<b>Link</b>
<br>[link name] (link url)<br>
Note: To use '[' in text, use backslash: \[<br>
Not necessary for the closing bracket ]
<br><br>
<b>Image Link</b><br>
[](link url )
<br><br>
<b>Arrows</b>
To insert an arrow, use '&' followed by 'larr;' or 'rarr;'<br>
← →
</div><div class = 'half-column-2'>
<h2>Shortcodes</h2>
<b>Select a snippet: </b>READ MORE...<br><br>
<b>Image sizes and justification</b>
<br> ![image description ] (image location RIGHT )<b></b>
<br> ![image description ] (image location FULL )<b></b>
<br> ![image description ] (image location LEFT SMALL )<b></b>
<br><br>
<b>Image sizes:</b><br>
XSMALL: 100px, SMALL: 150px, MEDUIM: 300px, LARGE: 450px, XLARGE: 600px
<br><br>
<b>Image with Caption:</b>
<br> ^^This is a caption/^^
<br><br>
<b>Quote</b>
<br>Paragraph starts with >
<br><br>
<b>Style</b>
<br>[STYLE](class name)Text to be styled [ENDSTYLE]
<br><br>
<b>Color</b>
<br>[COLOR](Color code or name)Text to be colored[ENDCOLOR]
<br><br>
<b>Break from left or right float</b>
<br>[BREAK]
<br><br>
<b>Single blank line</b>
<br>[BLANKLINE]
<br><br>
<b>Multiple blank lines</b>
<br>[BLANKLINES](number of blank lines)
<br><br>
<b>2 Columns: </b><br>
[2COL1]Text[2COL2]Text [ENDCOL]
<br><br>
<b>3 Columns:</b><br>
[3COL1]Text[3COL2]Text[3COL3]Text[ENDCOL]
<br><br>
<b>2/3 Columns:</b><br>
[23COL1]Text[3COL3] Text [ENDCOL]<br>
[3COL1]Text[23COL2] Text [ENDCOL]
</div>
</div>
</div>
</div>
validate-HTML.php ▾
<?php
$error = false;
$openbracketcount = substr_count($newstring,"<", 0);
$closingbracketcount = substr_count ($newstring, ">", 0);
//Checi for scripts
$tagarray = array();
$voidtags = array ("img", "br", "input", "hr", "col");
$tag = "";
$array1 = explode ("<", $newstring);
foreach ($array1 as $item) {
$item = trim($item);
//echo "<br>" . $item;
if ($item !== "") {
//Retrieve tag from string
$pos1 = strpos ($item, ">");
$tag = substr ($item, 0, $pos1);
$pos2 = strpos ($item, " ");
if ($pos2 !== false) {
$tag = substr ($tag, 0, $pos2);
}
if (! in_array ($tag, $voidtags)) {
array_push ($tagarray, $tag);
}
}
}
$opentagarray = array();
$previd = 0;
// print_r ($tagarray);
foreach ($tagarray as $item2) {
$item2 = trim ($item2);
if (strpos ($item2, "/") === false) {
array_push ($opentagarray, $item2);
//echo "<br>OPEN:" . $item2;
}
else {
$tag = str_replace ("/", "", $item2);
if ($tag === end($opentagarray)) {
// echo "<br>END: " . $item2;
array_pop ($opentagarray);
}
else {
//echo "TAG: " .$tag ;
$error = true;
}
}
}
if (count ($opentagarray) > 0) {
$error = true;
}
if ($error === true ) {
echo "<div style = 'background-color: white; color: red; padding: 20px; font-size: 18px;'>Invalid Syntax </div>";
}
?> view-html.php ▾
<div class = 'dropdownwrap'>
<button class = 'dropdownbutton' id = 'html' onclick= 'accordionToggle(this.id)'>View HTML ▾</button>
<div id ='html-content' class = 'dropdowncontent1 left' style = 'display: none; ' >
<div class = 'pink-background'>
<?php
if ($pageid === 'add-update-block') {
$htmlcontent = $blockrecord['html-content'];
}
else if ($pageid === 'add-update-post') {
$htmlcontent = $postrecord['html-content'];
}
$codeblock = htmlentities ($htmlcontent);
$codeblock = str_replace (">", ">\n", $codeblock);
echo nl2br ($codeblock);
?>
</div>
</div>
</div>
DOCUMENTS/data
categories.txt ▾
letters,poetry,recipes,resumes document-versions ▾
-2024-09-16-04-31pm.txt
-2024-09-16-04-33pm.txt
-2025-01-03-07-51pm.txt
-2025-01-03-07-52pm.txt
braised-hummingbird-tongues-2021-09-04-09-22pm.txt
braised-hummingbird-tongues-2025-01-03-07-43pm.txt
chewy-chipmonk-breakfast-bars-2021-09-04-08-34pm.txt
chocolate-mouse-2021-09-04-08-19pm.txt
chocolate-mouse-2021-09-04-08-29pm.txt
letter-to-wealthy-cats-magazine-2021-09-04-08-37pm.txt
marbled-rat-ribs-2020-12-28-09_34pm.txt
marbled-rat-ribs-2020-12-28-09_35pm.txt
marbled-rat-ribs-2020-12-31-12_59pm.txt
marbled-rat-ribs-2021-09-04-08-06pm.txt
pickled-mouse-brain-salad-2021-09-04-09-23pm.txt
pickled-mouse-brain-salad-2025-01-03-07-46pm.txt
ralphs-resume-2024-09-16-04-33pm.txt
ralphs-resume-2024-09-16-04-35pm.txt
ralphs-resume-2024-09-16-04-42pm.txt
ralphs-resume-2024-09-16-04-47pm.txt
ralphs-resume-2024-09-16-04-50pm.txt
ralphs-resume-2024-09-16-04-51pm.txt
ralphs-resume-2024-09-16-04-54pm.txt
ralphs-resume-2024-09-16-08-39pm.txt
ralphs-resume-2024-09-16-08-41pm.txt
ralphs-resume-2024-09-16-08-46pm.txt
ralphs-resume-2024-09-16-08-54pm.txt
ralphs-resume-2024-09-16-08-58pm.txt
ralphs-resume-2024-09-16-08-59pm.txt
ralphs-resume-2024-09-16-09-02pm.txt
ralphs-resume-2024-09-16-09-03pm.txt
ralphs-resume-2024-09-16-09-05pm.txt
ralphs-resume-2024-09-16-09-07pm.txt
the-litter-box-2021-09-02-09-19pm.txt
wake-up!-2025-01-03-07-52pm.txt
-2024-09-16-04-33pm.txt
-2025-01-03-07-51pm.txt
-2025-01-03-07-52pm.txt
braised-hummingbird-tongues-2021-09-04-09-22pm.txt
braised-hummingbird-tongues-2025-01-03-07-43pm.txt
chewy-chipmonk-breakfast-bars-2021-09-04-08-34pm.txt
chocolate-mouse-2021-09-04-08-19pm.txt
chocolate-mouse-2021-09-04-08-29pm.txt
letter-to-wealthy-cats-magazine-2021-09-04-08-37pm.txt
marbled-rat-ribs-2020-12-28-09_34pm.txt
marbled-rat-ribs-2020-12-28-09_35pm.txt
marbled-rat-ribs-2020-12-31-12_59pm.txt
marbled-rat-ribs-2021-09-04-08-06pm.txt
pickled-mouse-brain-salad-2021-09-04-09-23pm.txt
pickled-mouse-brain-salad-2025-01-03-07-46pm.txt
ralphs-resume-2024-09-16-04-33pm.txt
ralphs-resume-2024-09-16-04-35pm.txt
ralphs-resume-2024-09-16-04-42pm.txt
ralphs-resume-2024-09-16-04-47pm.txt
ralphs-resume-2024-09-16-04-50pm.txt
ralphs-resume-2024-09-16-04-51pm.txt
ralphs-resume-2024-09-16-04-54pm.txt
ralphs-resume-2024-09-16-08-39pm.txt
ralphs-resume-2024-09-16-08-41pm.txt
ralphs-resume-2024-09-16-08-46pm.txt
ralphs-resume-2024-09-16-08-54pm.txt
ralphs-resume-2024-09-16-08-58pm.txt
ralphs-resume-2024-09-16-08-59pm.txt
ralphs-resume-2024-09-16-09-02pm.txt
ralphs-resume-2024-09-16-09-03pm.txt
ralphs-resume-2024-09-16-09-05pm.txt
ralphs-resume-2024-09-16-09-07pm.txt
the-litter-box-2021-09-02-09-19pm.txt
wake-up!-2025-01-03-07-52pm.txt
documents ▾
braised-hummingbird-tongues.txt
chewy-chipmonk-breakfast-bars.txt
chocolate-mouse.txt
letter-to-mayor.txt
letter-to-travelling-tabby.txt
letter-to-wealthy-cats-magazine.txt
marbled-rat-ribs.txt
pickled-mouse-brain-salad.txt
ralphs-resume.txt
the-litter-box.txt
wake-up!.txt
chewy-chipmonk-breakfast-bars.txt
chocolate-mouse.txt
letter-to-mayor.txt
letter-to-travelling-tabby.txt
letter-to-wealthy-cats-magazine.txt
marbled-rat-ribs.txt
pickled-mouse-brain-salad.txt
ralphs-resume.txt
the-litter-box.txt
wake-up!.txt
fonts ▾
Elsie-Regular.ttf
Mulish-Regular.ttf
Mulish-Regular.ttf
images ▾
general
info.txt ▾
amex-m3499918417836323
%%%android-phone-pin
1515
%%%date
2008/11/25
%%%ein---lila-avenue
81-2796949
%%%medicare
9yd1-qa4-km39
%%%monthly-discretionary
Paypal:
AM Ex:
freedom:
%%%my-passport
Clmnschase
%%%passport
659309550
%%%socsec-account--me
msrodgers/ZieatChlls2020* reentry 82297432
%%%socsec-account--mike
mrodgers/wnbt!AA42$@
%%%ssn
415-98-6026
%%%ssn--dad
452-34-0165
%%%ssn-fio
257-87-8452
%%%ssn-me
253-02-1093
%%%ssn-mom
254-24-4698
%%%tsa-precheck
TT125YR14
%%%ubuntu-computers
Lpnglzrd2017
%%%updegrove-estate-ein---estate
26-6729878
%%%viking-cruises
5909 ktistof sun - thurs 8-5 - 11-8
%%%viv
rodv993@gmail.com
%%%wifi
Itlopocal2017
%%%wifi---gwen
93r8vae5b+ny
%%%yearly-payments
FreemanTV: 08: 85, Dropbox: 08: 119.98,
maps ▾
category-document-map.txt
date-document-map.txt
date-document-map.txt
password.txt ▾
daintypaws1 styles ▾
resume-style.css
trash ▾
document-versions----marbled-rat-ribs-2020-12-28-09_31pm.txt
document-versions----poetry-2021-09-02-09-17pm.txt
document-versions----poetry-2021-09-02-09-17pm.txt
username.txt ▾
Princess