1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

Fixed issue #1 and corrected 'built by' url

This commit is contained in:
Starbeamrainbowlabs 2015-01-05 18:44:11 +00:00
parent edec06fb71
commit 5ca2a644e8
2 changed files with 285 additions and 253 deletions

View file

@ -208,7 +208,7 @@ function renderpage($title, $content, $minimal = false)
$content
<hr class='footerdivider' />
<footer>
<p>Powered by Pepperminty Wiki, which was built by <a href='//starbeamrainbowlabs'>Starbeamrainbowlabs</a>. Send bugs to 'bugs at starbeamrainbowlabs dot com' or open an issue <a href='//github.com/sbrl/Pepperminty-Wiki'>on github</a>.</p>
<p>Powered by Pepperminty Wiki, which was built by <a href='//starbeamrainbowlabs.com/'>Starbeamrainbowlabs</a>. Send bugs to 'bugs at starbeamrainbowlabs dot com' or open an issue <a href='//github.com/sbrl/Pepperminty-Wiki'>on github</a>.</p>
<p>Your local friendly administrators are " . implode(", ", $admins) . ".
<p>This wiki is managed by <a href='mailto:" . hide_email($admindetails["email"]) . "'>" . $admindetails["name"] . "</a>.</p>
</footer>
@ -526,6 +526,13 @@ switch($_GET["action"])
* %delete%
*/
case "delete":
if(!$editing)
{
exit(renderpage("Deleting $page - error", "<p>You tried to delete $page, but editing is disabled on this wiki.</p>
<p>If you wish to delete this page, please re-enable editing on this wiki first.</p>
<p><a href='index.php?page=$page'>Go back to $page</a>.</p>
<p>Nothing has been changed.</p>"));
}
if(!$isadmin)
{
exit(renderpage("Deleting $page - error", "<p>You tried to delete $page, but you are not an admin so you don't have permission to do that.</p>
@ -553,9 +560,18 @@ switch($_GET["action"])
* %move%
*/
case "move":
if(!$editing)
{
exit(renderpage("Moving $page - error", "<p>You tried to move $page, but editing is disabled on this wiki.</p>
<p>If you wish to move this page, please re-enable editing on this wiki first.</p>
<p><a href='index.php?page=$page'>Go back to $page</a>.</p>
<p>Nothing has been changed.</p>"));
}
if(!$isadmin)
{
exit(renderpage("Moving $page - Error", "<p>You tried to move $page, but you do not have permission to do that.</p>
<p>You should try <a href='index.php?action=login'>logging in</a> as an admin.</p>"));
}
if(!isset($_GET["new_name"]) or strlen($_GET["new_name"]) == 0)
exit(renderpage("Moving $page", "<h2>Moving $page</h2>

520
index.php
View file

@ -1,5 +1,5 @@
<?php
$start_time = time(true);
$start_time = time(true);
/*
@ -116,7 +116,7 @@ Actions:
page - page name
delete=yes - actually do the deletion (otherwise we display a prompt)
*/
///////////////////////////////////////////////////////////////////////////////////////////////
/////////////// Do not edit below this line unless you know what you are doing! ///////////////
@ -149,19 +149,19 @@ else
setcookie($cookieprefix . "-pass", null, -1, "/");
}
}
//check to see if the currently logged in user is an admin
$isadmin = false;
if($isloggedin)
{
foreach($admins as $admin_username)
{
if($admin_username == $user)
{
$isadmin = true;
break;
}
}
}
//check to see if the currently logged in user is an admin
$isadmin = false;
if($isloggedin)
{
foreach($admins as $admin_username)
{
if($admin_username == $user)
{
$isadmin = true;
break;
}
}
}
/////// Login System End ///////
///////////////////////////////////////////////////////////////////////////////////////////
@ -242,7 +242,7 @@ if(makepathsafe($_GET["page"]) !== $_GET["page"])
header("x-actual-page: " . makepathsafe($_GET["page"]));
exit();
}
$page = $_GET["page"];
$page = $_GET["page"];
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
@ -252,22 +252,22 @@ $page = $_GET["page"];
////////////////////////////////////////////////////////////////////////////////////////////
function renderpage($title, $content, $minimal = false)
{
global $sitename, $page, $css, $favicon, $user, $isloggedin, $isadmin, $admins, $admindisplaychar, $navlinks, $admindetails, $start_time, $pageindex;
global $sitename, $page, $css, $favicon, $user, $isloggedin, $isadmin, $admins, $admindisplaychar, $navlinks, $admindetails, $start_time, $pageindex;
$html = "<!DOCTYPE HTML>
<html><head>
<meta charset='utf-8' />
<title>$title</title>
<link rel='shortcut icon' href='$favicon' />";
if(preg_match("/^[^\/]*\/\/|^\//", $css))
{
$html .= "\n\t\t<link rel='stylesheet' href='$css' />\n";
}
else
{
$html .= "\n\t\t<style>$css</style>\n";
}
$html .= "</head><body>\n";
<link rel='shortcut icon' href='$favicon' />";
if(preg_match("/^[^\/]*\/\/|^\//", $css))
{
$html .= "\n\t\t<link rel='stylesheet' href='$css' />\n";
}
else
{
$html .= "\n\t\t<style>$css</style>\n";
}
$html .= "</head><body>\n";
//////////
@ -284,47 +284,47 @@ function renderpage($title, $content, $minimal = false)
$html .= "<nav>\n";
if($isloggedin)
{
$html .= "\t\tLogged in as ";
if($isadmin)
$html .= $admindisplaychar;
$html .= "$user. <a href='index.php?action=logout'>Logout</a>. | \n";
}
{
$html .= "\t\tLogged in as ";
if($isadmin)
$html .= $admindisplaychar;
$html .= "$user. <a href='index.php?action=logout'>Logout</a>. | \n";
}
else
$html .= "\t\tBrowsing as Anonymous. <a href='index.php?action=login'>Login</a>. | \n";
foreach($navlinks as $item)
foreach($navlinks as $item)
{
if(is_string($item))
if(is_string($item))
{
//the item is a string
switch($item)
{
//keywords
case "search": //displays a search bar
$html .= "<form method='get' action='index.php' style='display: inline;'><input type='search' name='page' list='allpages' placeholder='Type a page name here and hit enter' /></form>";
break;
//it isn't a keyword, so just output it directly
default:
$html .= $item;
}
//the item is a string
switch($item)
{
//keywords
case "search": //displays a search bar
$html .= "<form method='get' action='index.php' style='display: inline;'><input type='search' name='page' list='allpages' placeholder='Type a page name here and hit enter' /></form>";
break;
//it isn't a keyword, so just output it directly
default:
$html .= $item;
}
}
else
{
//output the display as a link to the url
$html .= "\t\t<a href='" . str_replace("{page}", $page, $item[1]) . "'>$item[0]</a>\n";
$html .= "\t\t<a href='" . str_replace("{page}", $page, $item[1]) . "'>$item[0]</a>\n";
}
}
$html .= " </nav>
<h1 class='sitename'>$sitename</h1>
$content
<hr class='footerdivider' />
<footer>
<p>Powered by Pepperminty Wiki, which was built by <a href='//starbeamrainbowlabs'>Starbeamrainbowlabs</a>. Send bugs to 'bugs at starbeamrainbowlabs dot com' or open an issue <a href='//github.com/sbrl/Pepperminty-Wiki'>on github</a>.</p>
<p>Your local friendly administrators are " . implode(", ", $admins) . ".
<p>Powered by Pepperminty Wiki, which was built by <a href='//starbeamrainbowlabs.com/'>Starbeamrainbowlabs</a>. Send bugs to 'bugs at starbeamrainbowlabs dot com' or open an issue <a href='//github.com/sbrl/Pepperminty-Wiki'>on github</a>.</p>
<p>Your local friendly administrators are " . implode(", ", $admins) . ".
<p>This wiki is managed by <a href='mailto:" . hide_email($admindetails["email"]) . "'>" . $admindetails["name"] . "</a>.</p>
</footer>
<datalist id='allpages'>\n";
@ -347,7 +347,7 @@ function renderpage($title, $content, $minimal = false)
////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// Slimdown /////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////// %slimdown% //
////////////////////////////////////////////////////////////////////////////// %slimdown% //
////////////////////////////////////////////////////////////////////////////////////////////
/**
* Slimdown - A very basic regex-based Markdown parser. Supports the
@ -390,7 +390,7 @@ class Slimdown {
'/\~\~(.*?)\~\~/' => '<del>\1</del>', // del
'/\:\"(.*?)\"\:/' => '<q>\1</q>', // quote
'/`(.*?)`/' => '<code>\1</code>', // inline code
'/\n\s*(\*|-)(.*)/' => 'self::ul_list', // ul lists
'/\n\s*(\*|-)(.*)/' => 'self::ul_list', // ul lists
'/\n[0-9]+\.(.*)/' => 'self::ol_list', // ol lists
'/\n(&gt;|\>)(.*)/' => 'self::blockquote', // blockquotes
'/\n-{3,}/' => "\n<hr />", // horizontal rule
@ -408,7 +408,7 @@ class Slimdown {
return sprintf ("\n<p>%s</p>\n", $trimmed);
}
private static function ul_list ($regs) {
$item = $regs[2];
$item = $regs[2];
return sprintf ("\n<ul>\n\t<li>%s</li>\n</ul>", trim($item));
}
private static function ol_list ($regs) {
@ -482,104 +482,104 @@ function human_time_since($time)
switch($_GET["action"])
{
/*
* _ _ _
* ___ __| (_) |_
* / _ \/ _` | | __|
* | __/ (_| | | |_
* \___|\__,_|_|\__|
* %edit%
*/
/*
* _ _ _
* ___ __| (_) |_
* / _ \/ _` | | __|
* | __/ (_| | | |_
* \___|\__,_|_|\__|
* %edit%
*/
case "edit":
if(!$editing)
{
http_response_code(203);
header("location: index.php?page=$page");
header("location: index.php?page=$page");
}
$filename = "$page.md";
$creatingpage = !isset($pageindex->$page);
$filename = "$page.md";
$creatingpage = !isset($pageindex->$page);
if((isset($_GET["newpage"]) and $_GET["newpage"] == "true") or $creatingpage)
{
$title = "Creating $page";
$title = "Creating $page";
}
else
{
$title = "Editing $page";
$title = "Editing $page";
}
$pagetext = "";
if(isset($pageindex->$page))
if(isset($pageindex->$page))
{
$pagetext = file_get_contents($filename);
}
if((!$isloggedin and !$anonedits) or !$editing)
{
if(!$creatingpage)
{
//the page already exists - let the user view the page source
exit(renderpage("Viewing source for $page", "<textarea readonly>$pagetext</textarea>"));
}
else
{
http_response_code(404);
exit(renderpage("404 - $page", "<p>The page <code>$page</code> does not exist, but you do not have permission to create it.</p><p>If you haven't already, perhaps you should try <a href='index.php?action=login'>logging in</a>.</p>"));
}
}
if((!$isloggedin and !$anonedits) or !$editing)
{
if(!$creatingpage)
{
//the page already exists - let the user view the page source
exit(renderpage("Viewing source for $page", "<textarea readonly>$pagetext</textarea>"));
}
else
{
http_response_code(404);
exit(renderpage("404 - $page", "<p>The page <code>$page</code> does not exist, but you do not have permission to create it.</p><p>If you haven't already, perhaps you should try <a href='index.php?action=login'>logging in</a>.</p>"));
}
}
$content = "<h1>$title</h1>";
if(!$isloggedin and $anonedits)
{
$content .= "<p><strong>Warning: You are not logged in! Your IP address <em>may</em> be recorded.</strong></p>";
}
$content .= "<form method='post' action='index.php?action=save&page=" . rawurlencode($page) . "&action=save'>
$content .= "<form method='post' action='index.php?action=save&page=" . rawurlencode($page) . "&action=save'>
<textarea name='content'>$pagetext</textarea>
<input type='submit' value='Save Page' />
</form>";
exit(renderpage("$title - $sitename", $content));
break;
/*
*
* ___ __ ___ _____
* / __|/ _` \ \ / / _ \
* \__ \ (_| |\ V / __/
* |___/\__,_| \_/ \___|
* %save%
*/
/*
*
* ___ __ ___ _____
* / __|/ _` \ \ / / _ \
* \__ \ (_| |\ V / __/
* |___/\__,_| \_/ \___|
* %save%
*/
case "save":
if(!$editing)
{
header("location: index.php?page=$page");
header("location: index.php?page=$page");
exit(renderpage("Error saving edit", "<p>Editing is currently disabled on this wiki.</p>"));
}
if(!$isloggedin and !$anonedits)
{
http_response_code(403);
header("refresh: 5; url=index.php?page=$page");
header("refresh: 5; url=index.php?page=$page");
exit("You are not logged in, so you are not allowed to save pages on $sitename. Redirecting in 5 seconds....");
}
if(!isset($_POST["content"]))
{
http_response_code(400);
header("refresh: 5; url=index.php?page=$page");
header("refresh: 5; url=index.php?page=$page");
exit("Bad request: No content specified.");
}
if(file_put_contents("$page.md", htmlentities($_POST["content"]), ENT_QUOTES) !== false)
if(file_put_contents("$page.md", htmlentities($_POST["content"]), ENT_QUOTES) !== false)
{
//update the page index
if(!isset($pageindex->$page))
if(!isset($pageindex->$page))
{
$pageindex->$page = new stdClass();
$pageindex->$page->filename = "$page.md";
$pageindex->$page = new stdClass();
$pageindex->$page->filename = "$page.md";
}
$pageindex->$page->size = strlen($_POST["content"]);
$pageindex->$page->lastmodified = time();
$pageindex->$page->size = strlen($_POST["content"]);
$pageindex->$page->lastmodified = time();
if($isloggedin)
$pageindex->$page->lasteditor = utf8_encode($user);
$pageindex->$page->lasteditor = utf8_encode($user);
else
$pageindex->$page->lasteditor = utf8_encode("anonymous");
$pageindex->$page->lasteditor = utf8_encode("anonymous");
file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT));
@ -588,7 +588,7 @@ switch($_GET["action"])
else
http_response_code(200);
header("location: index.php?page=$page");
header("location: index.php?page=$page");
exit();
}
else
@ -599,14 +599,14 @@ switch($_GET["action"])
}
break;
/*
* _ _ _
* | (_)___| |_
* | | / __| __|
* | | \__ \ |_
* |_|_|___/\__|
* %list%
*/
/*
* _ _ _
* | (_)___| |_
* | | / __| __|
* | | \__ \ |_
* |_|_|___/\__|
* %list%
*/
case "list":
$title = "All Pages";
$content = " <h1>$title on $sitename</h1>
@ -632,93 +632,109 @@ switch($_GET["action"])
exit(renderpage("$title - $sitename", $content));
break;
/*
* _ _ _
* __| | ___| | ___| |_ ___
* / _` |/ _ \ |/ _ \ __/ _ \
* | (_| | __/ | __/ || __/
* \__,_|\___|_|\___|\__\___|
* %delete%
*/
/*
* _ _ _
* __| | ___| | ___| |_ ___
* / _` |/ _ \ |/ _ \ __/ _ \
* | (_| | __/ | __/ || __/
* \__,_|\___|_|\___|\__\___|
* %delete%
*/
case "delete":
if(!$isadmin)
{
exit(renderpage("Deleting $page - error", "<p>You tried to delete $page, but you are not an admin so you don't have permission to do that.</p>
<p>You should try <a href='index.php?action=login'>logging in</a> as an admin.</p>"));
}
if(!isset($_GET["delete"]) or $_GET["delete"] !== "yes")
{
exit(renderpage("Deleting $page", "<p>You are about to <strong>delete</strong> $page. You can't undo this!</p>
<p><a href='index.php?action=delete&page=$page&delete=yes'>Click here to delete $page.</a></p>
<p><a href='index.php?action=view&page=$page'>Click here to go back.</a>"));
}
unset($pageindex->$page); //delete the page from the page index
file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT)); //save the new page index
unlink("./$page.md"); //delete the page from the disk
exit(renderpage("Deleting $page - $sitename", "<p>$page has been deleted. <a href='index.php'>Go back to the main page</a>.</p>"));
if(!$editing)
{
exit(renderpage("Deleting $page - error", "<p>You tried to delete $page, but editing is disabled on this wiki.</p>
<p>If you wish to delete this page, please re-enable editing on this wiki first.</p>
<p><a href='index.php?page=$page'>Go back to $page</a>.</p>
<p>Nothing has been changed.</p>"));
}
if(!$isadmin)
{
exit(renderpage("Deleting $page - error", "<p>You tried to delete $page, but you are not an admin so you don't have permission to do that.</p>
<p>You should try <a href='index.php?action=login'>logging in</a> as an admin.</p>"));
}
if(!isset($_GET["delete"]) or $_GET["delete"] !== "yes")
{
exit(renderpage("Deleting $page", "<p>You are about to <strong>delete</strong> $page. You can't undo this!</p>
<p><a href='index.php?action=delete&page=$page&delete=yes'>Click here to delete $page.</a></p>
<p><a href='index.php?action=view&page=$page'>Click here to go back.</a>"));
}
unset($pageindex->$page); //delete the page from the page index
file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT)); //save the new page index
unlink("./$page.md"); //delete the page from the disk
exit(renderpage("Deleting $page - $sitename", "<p>$page has been deleted. <a href='index.php'>Go back to the main page</a>.</p>"));
break;
/*
* __ __
* | \/ | _____ _____
* | |\/| |/ _ \ \ / / _ \
* | | | | (_) \ V / __/
* |_| |_|\___/ \_/ \___|
* %move%
*/
case "move":
if(!$isadmin)
exit(renderpage("Moving $page - Error", "<p>You tried to move $page, but you do not have permission to do that.</p>
<p>You should try <a href='index.php?action=login'>logging in</a> as an admin.</p>"));
if(!isset($_GET["new_name"]) or strlen($_GET["new_name"]) == 0)
exit(renderpage("Moving $page", "<h2>Moving $page</h2>
<form method='get' action='index.php'>
<input type='hidden' name='action' value='move' />
<label for='old_name'>Old Name:</label>
<input type='text' name='page' value='$page' readonly />
<br />
<label for='new_name'>New Name:</label>
<input type='text' name='new_name' />
<br />
<input type='submit' value='Move Page' />
</form>"));
$new_name = makepathsafe($_GET["new_name"]);
if(!isset($pageindex->$page))
exit(renderpage("Moving $page - Error", "<p>You tried to move $page to $new_name, but the page with the name $page does not exist in the first place.</p>
<p>Nothing has been changed.</p>"));
if($page == $new_name)
exit(renderpage("Moving $page - Error", "<p>You tried to move $page, but the new name you gave is the same as it's current name.</p>
<p>It is possible that you tried to use some characters in the new name that are not allowed and were removed.</p>
<p>Page names may only contain alphanumeric characters, dashes, and underscores.</p>"));
//move the page in the page index
$pageindex->$new_name = new stdClass();
foreach($pageindex->$page as $key => $value)
{
$pageindex->$new_name->$key = $value;
}
unset($pageindex->$page);
file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT));
//move the page on the disk
rename("$page.md", "$new_name.md");
exit(renderpage("Moving $page", "<p><a href='index.php?page=$page'>$page</a> has been moved to <a href='index.php?page=$new_name'>$new_name</a> successfully.</p>"));
break;
/*
* _ _
* | |__ ___| |_ __
* | '_ \ / _ \ | '_ \
* | | | | __/ | |_) |
* |_| |_|\___|_| .__/
* %help% |_|
*/
/*
* __ __
* | \/ | _____ _____
* | |\/| |/ _ \ \ / / _ \
* | | | | (_) \ V / __/
* |_| |_|\___/ \_/ \___|
* %move%
*/
case "move":
if(!$editing)
{
exit(renderpage("Moving $page - error", "<p>You tried to move $page, but editing is disabled on this wiki.</p>
<p>If you wish to move this page, please re-enable editing on this wiki first.</p>
<p><a href='index.php?page=$page'>Go back to $page</a>.</p>
<p>Nothing has been changed.</p>"));
}
if(!$isadmin)
{
exit(renderpage("Moving $page - Error", "<p>You tried to move $page, but you do not have permission to do that.</p>
<p>You should try <a href='index.php?action=login'>logging in</a> as an admin.</p>"));
}
if(!isset($_GET["new_name"]) or strlen($_GET["new_name"]) == 0)
exit(renderpage("Moving $page", "<h2>Moving $page</h2>
<form method='get' action='index.php'>
<input type='hidden' name='action' value='move' />
<label for='old_name'>Old Name:</label>
<input type='text' name='page' value='$page' readonly />
<br />
<label for='new_name'>New Name:</label>
<input type='text' name='new_name' />
<br />
<input type='submit' value='Move Page' />
</form>"));
$new_name = makepathsafe($_GET["new_name"]);
if(!isset($pageindex->$page))
exit(renderpage("Moving $page - Error", "<p>You tried to move $page to $new_name, but the page with the name $page does not exist in the first place.</p>
<p>Nothing has been changed.</p>"));
if($page == $new_name)
exit(renderpage("Moving $page - Error", "<p>You tried to move $page, but the new name you gave is the same as it's current name.</p>
<p>It is possible that you tried to use some characters in the new name that are not allowed and were removed.</p>
<p>Page names may only contain alphanumeric characters, dashes, and underscores.</p>"));
//move the page in the page index
$pageindex->$new_name = new stdClass();
foreach($pageindex->$page as $key => $value)
{
$pageindex->$new_name->$key = $value;
}
unset($pageindex->$page);
file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT));
//move the page on the disk
rename("$page.md", "$new_name.md");
exit(renderpage("Moving $page", "<p><a href='index.php?page=$page'>$page</a> has been moved to <a href='index.php?page=$new_name'>$new_name</a> successfully.</p>"));
break;
/*
* _ _
* | |__ ___| |_ __
* | '_ \ / _ \ | '_ \
* | | | | __/ | |_) |
* |_| |_|\___|_| .__/
* %help% |_|
*/
case "help":
$title = "Help - $sitename";
$content = " <h1>$sitename Help</h1>
@ -747,14 +763,14 @@ switch($_GET["action"])
exit(renderpage($title, $content));
break;
/*
* _ _
* | | ___ __ _(_)_ __
* | |/ _ \ / _` | | '_ \
* | | (_) | (_| | | | | |
* |_|\___/ \__, |_|_| |_|
* |___/ %login%
*/
/*
* _ _
* | | ___ __ _(_)_ __
* | |/ _ \ / _` | | '_ \
* | | (_) | (_| | | | | |
* |_|\___/ \__, |_|_| |_|
* |___/ %login%
*/
case "login":
$title = "Login to $sitename";
$content = "<h1>Login to $sitename</h1>\n";
@ -770,14 +786,14 @@ switch($_GET["action"])
exit(renderpage($title, $content));
break;
/*
* _ _ _ _
* ___| |__ ___ ___| | _| | ___ __ _(_)_ __
* / __| '_ \ / _ \/ __| |/ / |/ _ \ / _` | | '_ \
* | (__| | | | __/ (__| <| | (_) | (_| | | | | |
* \___|_| |_|\___|\___|_|\_\_|\___/ \__, |_|_| |_|
* %checklogin% |___/
*/
/*
* _ _ _ _
* ___| |__ ___ ___| | _| | ___ __ _(_)_ __
* / __| '_ \ / _ \/ __| |/ / |/ _ \ / _` | | '_ \
* | (__| | | | __/ (__| <| | (_) | (_| | | | | |
* \___|_| |_|\___|\___|_|\_\_|\___/ \__, |_|_| |_|
* %checklogin% |___/
*/
case "checklogin":
if(isset($_POST["user"]) and isset($_POST["pass"]))
{
@ -813,14 +829,14 @@ switch($_GET["action"])
}
break;
/*
* _ _
* | | ___ __ _ ___ _ _| |_
* | |/ _ \ / _` |/ _ \| | | | __|
* | | (_) | (_| | (_) | |_| | |_
* |_|\___/ \__, |\___/ \__,_|\__|
* |___/ %logout%
*/
/*
* _ _
* | | ___ __ _ ___ _ _| |_
* | |/ _ \ / _` |/ _ \| | | | __|
* | | (_) | (_| | (_) | |_| | |_
* |_|\___/ \__, |\___/ \__,_|\__|
* |___/ %logout%
*/
case "logout":
$isloggedin = false;
unset($user);
@ -831,14 +847,14 @@ switch($_GET["action"])
<p>Logout Successful. You can login again <a href='index.php?action=login'>here</a>.</p>"));
break;
/*
* _ _ _
* ___ _ __ ___ __| (_) |_ ___
* / __| '__/ _ \/ _` | | __/ __|
* | (__| | | __/ (_| | | |_\__ \
* \___|_| \___|\__,_|_|\__|___/
* %credits%
*/
/*
* _ _ _
* ___ _ __ ___ __| (_) |_ ___
* / __| '__/ _ \/ _` | | __/ __|
* | (__| | | __/ (_| | | |_\__ \
* \___|_| \___|\__,_|_|\__|___/
* %credits%
*/
case "credits":
$title = "Credits - $sitename";
$content = "<h1>$sitename credits</h1>
@ -848,14 +864,14 @@ switch($_GET["action"])
exit(renderpage($title, $content));
break;
/*
* _ _
* | |__ __ _ ___| |__
* | '_ \ / _` / __| '_ \
* | | | | (_| \__ \ | | |
* |_| |_|\__,_|___/_| |_|
* %hash%
*/
/*
* _ _
* | |__ __ _ ___| |__
* | '_ \ / _` / __| '_ \
* | | | | (_| \__ \ | | |
* |_| |_|\__,_|___/_| |_|
* %hash%
*/
case "hash":
if(!isset($_GET["string"]))
{
@ -869,39 +885,39 @@ switch($_GET["action"])
}
break;
/*
* _
* __ _(_) _____ __
* \ \ / / |/ _ \ \ /\ / /
* \ V /| | __/\ V V /
* \_/ |_|\___| \_/\_/
* %view%
*/
/*
* _
* __ _(_) _____ __
* \ \ / / |/ _ \ \ /\ / /
* \ V /| | __/\ V V /
* \_/ |_|\___| \_/\_/
* %view%
*/
case "view":
default:
//check to make sure that the page exists
if(!isset($pageindex->$page))
if(!isset($pageindex->$page))
{
if($editing)
{
//editing is enabled, redirect to the editing page
http_response_code(307); //temporary redirect
header("location: index.php?action=edit&newpage=yes&page=" . rawurlencode($page));
header("location: index.php?action=edit&newpage=yes&page=" . rawurlencode($page));
exit();
}
else
{
//editing is disabled, show an error message
http_response_code(404);
exit(renderpage("$page - 404 - $sitename", "<p>$page does not exist.</p><p>Since editing is currently disabled on this wiki, you may not create this page. If you feel that this page should exist, try contacting this wiki's Administrator.</p>"));
exit(renderpage("$page - 404 - $sitename", "<p>$page does not exist.</p><p>Since editing is currently disabled on this wiki, you may not create this page. If you feel that this page should exist, try contacting this wiki's Administrator.</p>"));
}
}
$title = "$page - $sitename";
$content = "<h1>$page</h1>";
$title = "$page - $sitename";
$content = "<h1>$page</h1>";
$slimdown_start = microtime(true);
$content .= Slimdown::render(file_get_contents("$page.md"));
$content .= Slimdown::render(file_get_contents("$page.md"));
$content .= "\n\t<!-- Took " . (microtime(true) - $slimdown_start) . " seconds to parse markdown -->\n";