This blob has been accessed 308 times via Git panel.
- <?php
- session_start();
- header("Cache-control: private");
- $login_username = file_get_contents("data/username.txt");
- if (!isset($_SESSION['logged_in']) or ($_SESSION['logged_in'] != $login_username)) {
- }
- function rmdirr($recurse_dirname)
- {
- if (!file_exists($recurse_dirname)) {
- return false;
- }
- if (is_file($recurse_dirname)) {
- return unlink($recurse_dirname);
- }
- $recurse_dir = dir($recurse_dirname);
- while (false !== $recurse_entry = $recurse_dir->read()) {
- if ($recurse_entry == '.' || $recurse_entry == '..') {
- continue;
- }
- rmdirr("$recurse_dirname/$recurse_entry");
- }
- $recurse_dir->close();
- return rmdir($recurse_dirname);
- }
- if (isset($_REQUEST['new_id']) and !empty($_REQUEST['new_id'])) {
- if (!file_exists("data/categories")) {
- mkdir("data/categories", 0777);
- }
- $new_id = trim(strip_tags(strtolower(str_replace(" ", "_", $_REQUEST['new_id']))));
- if (!file_exists("data/categories/$new_id")) {
- mkdir("data/categories/$new_id", 0777);
- }
- if (isset($_REQUEST['new_title']) and !empty($_REQUEST['new_title'])) {
- $new_title = ucfirst(strip_tags(trim($_REQUEST['new_title'])));
- chmod("data/categories/$new_id/title.txt", 0666);
- }
- }
- if (isset($_REQUEST['cat_del']) and !empty($_REQUEST['cat_del']) and ($_REQUEST['cat_del'] == "on")) {
- rmdirr("data/categories/{$_REQUEST['cat_id']}");
- }
- if ((!isset($_REQUEST['cat_hide']) or !empty($_REQUEST['cat_hide'])) and ($_REQUEST['cat_edit'] == "on")) {
- if (file_exists("data/categories/{$_REQUEST['cat_id']}/private.txt")) {
- unlink("data/categories/{$_REQUEST['cat_id']}/private.txt");
- }
- }
- if (isset($_REQUEST['cat_hide']) and !empty($_REQUEST['cat_hide']) and ($_REQUEST['cat_hide'] == "on")) {
- if (!file_exists("data/categories/{$_REQUEST['cat_id']}/private.txt")) {
- touch("data/categories/{$_REQUEST['cat_id']}/private.txt");
- chmod("data/categories/{$_REQUEST['cat_id']}/private.txt", 0666);
- }
- }
- if ((!isset($_REQUEST['cat_book']) or !empty($_REQUEST['cat_book'])) and ($_REQUEST['cat_edit'] == "on")) {
- if (file_exists("data/categories/{$_REQUEST['cat_id']}/book.txt")) {
- unlink("data/categories/{$_REQUEST['cat_id']}/book.txt");
- }
- }
- if (isset($_REQUEST['cat_book']) and !empty($_REQUEST['cat_book']) and ($_REQUEST['cat_book'] == "on")) {
- if (!file_exists("data/categories/{$_REQUEST['cat_id']}/book.txt")) {
- touch("data/categories/{$_REQUEST['cat_id']}/book.txt");
- chmod("data/categories/{$_REQUEST['cat_id']}/book.txt", 0666);
- }
- }
- if (isset($_REQUEST['cat_title']) and !empty($_REQUEST['cat_title'])) {
- $cat_title = ucfirst(strip_tags(trim($_REQUEST['cat_title'])));
- if ($cat_title != file_get_contents("data/categories/{$_REQUEST['cat_id']}/title.txt")) {
- chmod("data/categories/{$_REQUEST['cat_id']}/title.txt", 0666);
- }
- }
- if (empty($_REQUEST['cat_title']) and file_exists("data/categories/{$_REQUEST['cat_id']}/title.txt")) {
- unlink("data/categories/{$_REQUEST['cat_id']}/title.txt");
- }
- ?>
- <style>
- body
- {
- color: #666666;
- margin: 10px;
- padding: 0px;
- text-align: left;
- font-family: verdana, helvetica, sans-serif;
- background-color: #FFFFFF;
- }
- p
- {
- font-size: 11px;
- }
- a
- {
- font-weight: bold;
- text-decoration: none;
- }
- a:link, a:visited
- {
- color: #666666;
- }
- a:hover
- {
- color: #336699;
- }
- a:active {
- color: #336699;
- }
- .input {
- color: #666666;
- background: #ffffff;
- border: #999999 solid 1px;
- width: 300px;
- font-family: verdana,helvetica,sans-serif;
- font-size: 11px
- }
- .submit {
- color: #666666;
- background: #ffffff;
- border: #999999 solid 1px;
- width: 100px;
- font-family: verdana,helvetica,sans-serif;
- font-size: 11px
- }
- </style>
- <p><b>Add Category</b></p><p>Enter a unique category ID and optional title or description.</p>
- <table border=0 cellspacing=1 cellpadding=2>
- <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
- <tr><td><p>category id*</p></td><td><input type=text class=input name=new_id autocomplete=off maxlength=30></td></tr>
- <tr><td><p>title or description</p></td><td><input type=text class=input name=new_title autocomplete=off maxlength=90></td></tr>
- <tr><td><p></p></td><td><input type=submit class=input value="click here to add a new category"></td></tr>
- </form>
- <form enctype="multipart/form-data" action="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); ?>" method="post">
- <tr><td><p></p></td><td><input class=input type=submit value="click here to go to the index page"></td></tr>
- </form>
- </table>
- <?php
- if (file_exists("data/categories")) {
- if ($dh_cat = opendir("data/categories")) {
- while (($entry_cat = readdir($dh_cat)) !== false) {
- if ($entry_cat != "." && $entry_cat != ".." && fnmatch("*", $entry_cat)) {
- $show_cat[] = $entry_cat;
- }
- }
- closedir($dh_cat);
- }
- sort($show_cat);
- reset($show_cat);
- $count_cat = count($show_cat);
- if ($count_cat > 0) {
- echo "<p><br><b>Category Management</b></p><p>Hiding a category will make it, and all associated entries, invisible to visitors. Override per entry if needed.<br>Booking a category, for lack of a better term, will unconditionally display all associated entries from oldest to newest.<br>Deleting a category will unfile all its associated entries.</p>";
- echo "<table border=0 cellspacing=1 cellpadding=2>";
- echo "<tr><td><p>category id</p></td><td><p align=center>title or description</p></td><td><p align=center>hide</p></td><td><p align=center>book</p></td><td><p align=center>delete</p></td><td><p></p></td></tr>";
- foreach ($show_cat as $category) {
- echo '<form enctype="multipart/form-data" action="';
- echo $_SERVER['PHP_SELF'];
- echo '" method="post">';
- echo "<tr><td><p><b>";
- echo strtolower(str_replace("_", " ", $category));
- echo '</b></p></td><td><p><input type=text class=input name=cat_title value="';
- readfile("data/categories/$category/title.txt");
- echo '" autocomplete=off maxlength=90></p></td><td><p align=center><input type=checkbox name=cat_hide';
- if (file_exists("data/categories/$category/private.txt")) {
- echo " checked";
- }
- echo "></p></td>";
- echo "<td><p align=center><input type=checkbox name=cat_book";
- if (file_exists("data/categories/$category/book.txt")) {
- echo " checked";
- }
- echo "></p></td>";
- echo "<td><p align=center><input type=checkbox name=cat_del></p></td><td><p><input type=hidden name=cat_id value=$category><input type=hidden name=cat_edit value=on><input type=submit class=submit value=submit></p></td>";
- echo "</tr></form>";
- }
- echo "</table>";
- }
- }
- ?>