diff --git a/core.php b/core.php index 55bbcd1..b429da5 100644 --- a/core.php +++ b/core.php @@ -5,7 +5,7 @@ $start_time = time(true); * ================ * Inspired by Minty Wiki by am2064: * Link: https://github.com/am2064/Minty-Wiki - * + * * Credits: * Slimdown - by Johnny Broadway from https://gist.github.com/jbroadway/2836900 */ @@ -13,6 +13,14 @@ $start_time = time(true); //the site's name $sitename = "Pepperminty Wiki"; +//the url from which to fetch updates. Defaults to the master (development) branch If there is sufficient demand, a separate stable branch will be created. +//currently not implemented (yet). +$updateurl = "https://raw.githubusercontent.com/sbrl/pepperminty-wiki/master/index.php"; + +//the secret key used to perform 'dangerous' actions, like updating the wiki, and deleting pages. It is strongly advised that you change this! +//note that neither of these features have been added yet. +$sitesecret = "ed420502615bac9037f8f12abd4c9f02"; + //whether people can edit the site $editing = true; @@ -151,14 +159,14 @@ else } /* * @summary makes a path safe - * + * * @details paths may only contain alphanumeric characters, spaces, underscores, and dashes */ function makepathsafe($string) { return preg_replace("/[^0-9a-zA-Z\_\-\ ]/i", "", $string); } /* * @summary Hides an email address from bots by adding random html entities. - * + * * @returns The mangled email address. */ function hide_email($str) @@ -176,7 +184,7 @@ function hide_email($str) else $hidden_email .= "&#" . ord($str[$i]) . ";"; } - + return $hidden_email; } @@ -214,18 +222,24 @@ if(makepathsafe($_GET["page"]) !== $_GET["page"]) function renderpage($title, $content, $minimal = false) { global $sitename, $css, $favicon, $user, $isloggedin, $navlinks, $admindetails, $start_time, $pageindex; - + $html = " $title - - - - "; - + "; + if(preg_match("/^[^\/]*\/\/|^\//", $cs)) + { + $html .= "\n\t\t\n"; + } + else + { + $html .= "\n\t\t\n"; + } + $html .= "\n"; + ////////// - + if($minimal) { $html .= "$content @@ -237,7 +251,7 @@ function renderpage($title, $content, $minimal = false) else { $html .= "

$sitename

$content @@ -271,19 +285,19 @@ function renderpage($title, $content, $minimal = false)

This wiki is managed by " . $admindetails["name"] . ".

\n"; - + foreach($pageindex as $pagename => $pagedetails) { $html .= "\t\t"; } - + ////////// $gentime = microtime(true) - $start_time; $html .= "\n\t "; - + return $html; } @@ -314,7 +328,7 @@ function renderpage($title, $content, $minimal = false) /** * Modified by Starbeamrainbowlabs (starbeamrainbowlabs) - * + * * Changed bold to use single asterisks * Changed italics to use single underscores * Added one to add the heading levels (no

tags allowed) @@ -431,7 +445,7 @@ switch($_GET["action"]) http_response_code(203); header("location: index.php?page=" . $_GET["page"]); } - + if(!$isloggedin and !$anonedits) { //future let the user view the page source instead @@ -450,14 +464,14 @@ switch($_GET["action"]) { $title = "Editing " . $_GET["page"]; } - - + + $pagetext = ""; if(isset($pageindex->$_GET["page"])) { $pagetext = file_get_contents($filename); } - + $content = "

$title

"; if(!$isloggedin and $anonedits) { @@ -469,7 +483,7 @@ switch($_GET["action"]) "; exit(renderpage("$title - $sitename", $content)); break; - + case "save": if(!$editing) { @@ -502,14 +516,14 @@ switch($_GET["action"]) $pageindex->$_GET["page"]->lasteditor = utf8_encode($user); else $pageindex->$_GET["page"]->lasteditor = utf8_encode("anonymous"); - + file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT)); - + if(isset($_GET["newpage"])) http_response_code(201); else http_response_code(200); - + header("location: index.php?page=" . $_GET["page"]); exit(); } @@ -520,7 +534,7 @@ switch($_GET["action"])

Please tell the administrator of this wiki (" . $admindetails["name"] . ") about this problem.

")); } break; - + case "list": $title = "All Pages"; $content = "

$title on $sitename

@@ -545,7 +559,15 @@ switch($_GET["action"]) $content .= " "; exit(renderpage("$title - $sitename", $content)); break; - + + case "delete": + exit(renderpage("Deleting $pagename - $sitename", "Coming soon...")); + break; + + case "dodelete": + exit("Coming soon..."); + break; + case "help": $title = "Help - $sitename"; $content = "

$sitename Help

@@ -573,7 +595,7 @@ switch($_GET["action"]) "; exit(renderpage($title, $content)); break; - + case "login": $title = "Login to $sitename"; $content = "

Login to $sitename

\n"; @@ -588,7 +610,7 @@ switch($_GET["action"]) "; exit(renderpage($title, $content)); break; - + case "checklogin": if(isset($_POST["user"]) and isset($_POST["pass"])) { @@ -623,7 +645,7 @@ switch($_GET["action"]) exit(); } break; - + case "logout": $isloggedin = false; unset($user); @@ -633,7 +655,7 @@ switch($_GET["action"]) exit(renderpage("Logout Successful", "

Logout Successful

Logout Successful. You can login again here.

")); break; - + case "credits": $title = "Credits - $sitename"; $content = "

$sitename credits

@@ -642,7 +664,7 @@ switch($_GET["action"])

The default favicon is from Open Clipart by bluefrog23, and can be found here.

"; exit(renderpage($title, $content)); break; - + case "hash": if(!isset($_GET["string"])) { @@ -655,7 +677,7 @@ switch($_GET["action"]) exit(renderpage("Hashed string", "

" . $_GET["string"] . "" . hash("sha256", $_GET["string"] . "

"))); } break; - + case "view": default: //check to make sure that the page exists @@ -677,13 +699,13 @@ switch($_GET["action"]) } $title = $_GET["page"] . " - $sitename"; $content = "

" . $_GET["page"] . "

"; - + $slimdown_start = microtime(true); - + $content .= Slimdown::render(file_get_contents($_GET["page"] . ".md")); - + $content .= "\n\t\n"; - + if(isset($_GET["printable"]) and $_GET["printable"] === "yes") $minimal = true; else