From cad26c8221769b02f5beb556e1603ffce19bd7d6 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 9 Apr 2015 15:13:07 +0100 Subject: [PATCH] moved all settings into an object --- core.php | 138 ++++++++++++++++---------------- index.php | 178 +++++++++++++++++++++--------------------- settings.fragment.php | 36 +++++---- 3 files changed, 180 insertions(+), 172 deletions(-) diff --git a/core.php b/core.php index e31e1ad..448766b 100644 --- a/core.php +++ b/core.php @@ -10,25 +10,25 @@ $version = "0.4"; session_start(); ///////// Login System ///////// //clear expired sessions -if(isset($_SESSION["$sessionprefix-expiretime"]) and - $_SESSION["$sessionprefix-expiretime"] < time()) +if(isset($_SESSION["$settings->sessionprefix-expiretime"]) and + $_SESSION["$settings->sessionprefix-expiretime"] < time()) { //clear the session variables $_SESSION = []; session_destroy(); } -if(!isset($_SESSION[$sessionprefix . "-user"]) and - !isset($_SESSION[$sessionprefix . "-pass"])) +if(!isset($_SESSION[$settings->sessionprefix . "-user"]) and + !isset($_SESSION[$settings->sessionprefix . "-pass"])) { //the user is not logged in $isloggedin = false; } else { - $user = $_SESSION[$sessionprefix . "-user"]; - $pass = $_SESSION[$sessionprefix . "-pass"]; - if($users[$user] == $pass) + $user = $_SESSION[$settings->sessionprefix . "-user"]; + $pass = $_SESSION[$settings->sessionprefix . "-pass"]; + if($settings->users[$user] == $pass) { //the user is logged in $isloggedin = true; @@ -49,7 +49,7 @@ else $isadmin = false; if($isloggedin) { - foreach($admins as $admin_username) + foreach($settings->admins as $admin_username) { if($admin_username == $user) { @@ -78,6 +78,7 @@ if(!file_exists("./pageindex.json")) $pageindex->$pagekey = $newentry; } file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT)); + unset($existingpages); } else { @@ -127,7 +128,7 @@ if(!isset($_GET["action"])) $_GET["action"] = "view"; if(!isset($_GET["page"]) or strlen($_GET["page"]) === 0) - $_GET["page"] = $defaultpage; + $_GET["page"] = $settings->defaultpage; //redirect the user to the safe version of the path if they entered an unsafe character if(makepathsafe($_GET["page"]) !== $_GET["page"]) @@ -148,21 +149,21 @@ $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 $settings, $page, $user, $isloggedin, $isadmin, $start_time, $pageindex; $html = " $title - "; - if(preg_match("/^[^\/]*\/\/|^\//", $css)) + "; + if(preg_match("/^[^\/]*\/\/|^\//", $settings->css)) { - $html .= "\n\t\t\n"; + $html .= "\n\t\t\n"; } else { - $html .= "\n\t\t\n"; + $html .= "\n\t\t\n"; } $html .= "\n"; @@ -172,7 +173,7 @@ function renderpage($title, $content, $minimal = false) { $html .= "$content
-

From $sitename, which is managed by " . $admindetails["name"] . ".

+

From $settings->sitename, which is managed by " . $settings->admindetails["name"] . ".

Timed at " . date("l jS \of F Y \a\\t h:ia T") . ".

Powered by Pepperminty Wiki

"; } @@ -184,14 +185,14 @@ function renderpage($title, $content, $minimal = false) { $html .= "\t\tLogged in as "; if($isadmin) - $html .= $admindisplaychar; + $html .= $settings->admindisplaychar; $html .= "$user. Logout. | \n"; } else $html .= "\t\tBrowsing as Anonymous. Login. | \n"; - foreach($navlinks as $item) + foreach($settings->navlinks as $item) { if(is_string($item)) { @@ -216,13 +217,13 @@ function renderpage($title, $content, $minimal = false) } $html .= " -

$sitename

+

$settings->sitename

$content
\n"; @@ -405,7 +406,7 @@ switch($_GET["action"]) $pagetext = file_get_contents($filename); } - if((!$isloggedin and !$anonedits) or !$editing) + if((!$isloggedin and !$settings->anonedits) or !$settings->editing) { if(!$creatingpage) { @@ -418,9 +419,9 @@ switch($_GET["action"]) exit(renderpage("404 - $page", "

The page $page does not exist, but you do not have permission to create it.

If you haven't already, perhaps you should try logging in.

")); } } - + $content = "

$title

"; - if(!$isloggedin and $anonedits) + if(!$isloggedin and $settings->anonedits) { $content .= "

Warning: You are not logged in! Your IP address may be recorded.

"; } @@ -428,7 +429,7 @@ switch($_GET["action"]) "; - exit(renderpage("$title - $sitename", $content)); + exit(renderpage("$title - $settings->sitename", $content)); break; /* @@ -440,16 +441,16 @@ switch($_GET["action"]) * %save% */ case "save": - if(!$editing) + if(!$settings->editing) { header("location: index.php?page=$page"); exit(renderpage("Error saving edit", "

Editing is currently disabled on this wiki.

")); } - if(!$isloggedin and !$anonedits) + if(!$isloggedin and !$settings->anonedits) { http_response_code(403); 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...."); + exit("You are not logged in, so you are not allowed to save pages on $settings->sitename. Redirecting in 5 seconds...."); } if(!isset($_POST["content"])) { @@ -485,8 +486,8 @@ switch($_GET["action"]) else { http_response_code(507); - exit(renderpage("Error saving page - $sitename", "

$sitename failed to write your changes to the disk. Your changes have not been saved, however you may be able to recover your edit by pressing the back button in your browser.

-

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

")); + exit(renderpage("Error saving page - $settings->sitename", "

$settings->sitename failed to write your changes to the disk. Your changes have not been saved, but you might be able to recover your edit by pressing the back button in your browser.

+

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

")); } break; @@ -500,7 +501,7 @@ switch($_GET["action"]) */ case "list": $title = "All Pages"; - $content = "

$title on $sitename

+ $content = "

$title on $settings->sitename

@@ -520,7 +521,7 @@ switch($_GET["action"]) \n"; } $content .= "
Page Name
"; - exit(renderpage("$title - $sitename", $content)); + exit(renderpage("$title - $settings->sitename", $content)); break; /* @@ -532,7 +533,7 @@ switch($_GET["action"]) * %delete% */ case "delete": - if(!$editing) + if(!$settings->editing) { exit(renderpage("Deleting $page - error", "

You tried to delete $page, but editing is disabled on this wiki.

If you wish to delete this page, please re-enable editing on this wiki first.

@@ -554,7 +555,7 @@ switch($_GET["action"]) 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", "

$page has been deleted. Go back to the main page.

")); + exit(renderpage("Deleting $page - $settings->sitename", "

$page has been deleted. Go back to the main page.

")); break; /* @@ -566,7 +567,7 @@ switch($_GET["action"]) * %move% */ case "move": - if(!$editing) + if(!$settings->editing) { exit(renderpage("Moving $page - error", "

You tried to move $page, but editing is disabled on this wiki.

If you wish to move this page, please re-enable editing on this wiki first.

@@ -602,7 +603,7 @@ switch($_GET["action"]) exit(renderpage("Moving $page - Error", "

You tried to move $page, but the new name you gave is the same as it's current name.

It is possible that you tried to use some characters in the new name that are not allowed and were removed.

Page names may only contain alphanumeric characters, dashes, and underscores.

")); - + //move the page in the page index $pageindex->$new_name = new stdClass(); foreach($pageindex->$page as $key => $value) @@ -611,10 +612,10 @@ switch($_GET["action"]) } 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", "

$page has been moved to $new_name successfully.

")); break; @@ -627,15 +628,15 @@ switch($_GET["action"]) * %help% |_| */ case "help": - $title = "Help - $sitename"; - $content = "

$sitename Help

-

Welcome to $sitename!

-

$sitename is powered by Pepperminty wiki, a complete wiki in a box you can drop into your server.

+ $title = "Help - $settings->sitename"; + $content = "

$settings->sitename Help

+

Welcome to $settings->sitename!

+

$settings->sitename is powered by Pepperminty wiki, a complete wiki in a box you can drop into your server.

Navigating

All the navigation links can be found in the top right corner, along with a box in which you can type a page name and hit enter to be taken to that page (if your site administrator has enabled it).

-

In order to edit pages on $sitename, you probably need to be logged in. If you do not already have an account you will need to ask $sitename's administrator for an account since there is not registration form. Note that the $sitename's administrator may have changed these settings to allow anonymous edits.

+

In order to edit pages on $settings->sitename, you probably need to be logged in. If you do not already have an account you will need to ask $settings->sitename's administrator for an account since there is not registration form. Note that the $settings->sitename's administrator may have changed these settings to allow anonymous edits.

Editing

-

$sitename's editor uses a modified version of slimdown, a flavour of markdown that is implementated using regular expressions. See the credits page for more information and links to the original source for this. A quick reference can be found below:

+

$settings->sitename's editor uses a modified version of slimdown, a flavour of markdown that is implementated using regular expressions. See the credits page for more information and links to the original source for this. A quick reference can be found below:

@@ -656,8 +657,8 @@ switch($_GET["action"])
Type ThisTo get this
_italics_italics

Administrator Actions

By default, the delete and move actions are shown on the nav bar. These can be used by administrators to delete or move pages.

-

The other thing admininistrators can do is update the wiki (provided they know the site's secret). This page can be found here: Update $sitename.

-

$sitename is currently running on Pepperminty Wiki $version

"; +

The other thing admininistrators can do is update the wiki (provided they know the site's secret). This page can be found here: Update $settings->sitename.

+

$settings->sitename is currently running on Pepperminty Wiki $version

"; exit(renderpage($title, $content)); break; @@ -670,8 +671,8 @@ switch($_GET["action"]) * |___/ %login% */ case "login": - $title = "Login to $sitename"; - $content = "

Login to $sitename

\n"; + $title = "Login to $settings->sitename"; + $content = "

Login to $settings->sitename

\n"; if(isset($_GET["failed"])) $content .= "\t\t

Login failed.

\n"; $content .= "\t\t
@@ -699,13 +700,13 @@ switch($_GET["action"]) //the user wants to log in $user = $_POST["user"]; $pass = $_POST["pass"]; - if($users[$user] == hash("sha256", $pass)) + if($settings->users[$user] == hash("sha256", $pass)) { $isloggedin = true; $expiretime = time() + 60*60*24*30; //30 days from now - $_SESSION["$sessionprefix-user"] = $user; - $_SESSION["$sessionprefix-pass"] = hash("sha256", $pass); - $_SESSION["$sessionprefix-expiretime"] = $expiretime; + $_SESSION["$settings->sessionprefix-user"] = $user; + $_SESSION["$settings->sessionprefix-pass"] = hash("sha256", $pass); + $_SESSION["$settings->sessionprefix-expiretime"] = $expiretime; //redirect to wherever the user was going http_response_code(302); if(isset($_POST["goto"])) @@ -758,13 +759,13 @@ switch($_GET["action"]) * %credits% */ case "credits": - $title = "Credits - $sitename"; - $content = "

$sitename credits

-

$sitename is powered by Pepperminty Wiki - an entire wiki packed inside a single file, which was built by Starbeamrainbowlabs, and can be found on github.

+ $title = "Credits - $settings->sitename"; + $content = "

$settings->sitename credits

+

$settings->sitename is powered by Pepperminty Wiki - an entire wiki packed inside a single file, which was built by Starbeamrainbowlabs, and can be found on github.

A slightly modified version of slimdown is used to parse text source into HTML. Slimdown is by Johnny Broadway, which can be found on github.

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

-

Administrators can update $sitename here: Update $sitename.

-

$sitename is currently running on Pepperminty Wiki $version

"; +

Administrators can update $settings->sitename here: Update $settings->sitename.

+

$settings->sitename is currently running on Pepperminty Wiki $version

"; exit(renderpage($title, $content)); break; @@ -776,7 +777,7 @@ switch($_GET["action"]) * |_| %update% */ case "update": - if(!$isadmin) + if(!$settings->isadmin) { http_response_code(401); exit(renderpage("Update - Error", "

You must be an administrator to do that.

")); @@ -784,22 +785,22 @@ switch($_GET["action"]) if(!isset($_GET["do"]) or $_GET["do"] !== "true") { - exit(renderpage("Update $sitename", "

This page allows you to update $sitename.

-

Currently, $sitename is using $version of Pepperminty Wiki.

+ exit(renderpage("Update $settings->sitename", "

This page allows you to update $settings->sitename.

+

Currently, $settings->sitename is using $settings->version of Pepperminty Wiki.

This script will automatically download and install the latest version of Pepperminty Wiki from the url of your choice (see settings), regardless of whether an update is actually needed (version checking isn't implemented yet).

-

To update $sitename, fill out the form below and click click the update button.

+

To update $settings->sitename, fill out the form below and click click the update button.

- +
")); } - if(!isset($_GET["secret"]) or $_GET["secret"] !== $sitesecret) + if(!isset($_GET["secret"]) or $_GET["secret"] !== $settings->sitesecret) { - exit(renderpage("Update $sitename - Error", "

You forgot to enter $sitename's secret code or entered it incorrectly. $sitename's secret can be found in the settings portion of index.php.

")); + exit(renderpage("Update $settings->sitename - Error", "

You forgot to enter $settings->sitename's secret code or entered it incorrectly. $settings->sitename's secret can be found in the settings portion of index.php.

")); } $settings_separator = "/////////////// Do not edit below this line unless you know what you are doing! ///////////////"; @@ -822,7 +823,7 @@ switch($_GET["action"]) file_put_contents(__FILE__, $result); $log .= "done.\n"; - $log .= "Update complete. I am now running on the latest version of $sitename."; + $log .= "Update complete. I am now running on the latest version of Pepperminty Wiki."; $log .= "The version number that I have updated to can be found on the credits or help ages."; exit(renderpage("Update - Success", "")); @@ -842,7 +843,7 @@ switch($_GET["action"]) { http_response_code(400); exit(renderpage("Bad request", "

The GET parameter string must be specified.

-

It is strongly recommended that you utilise this page via a private or incognito window.

")); +

It is strongly recommended that you utilise this page via a private or incognito window in order to prevent your password from appearing in your browser history.

")); } else { @@ -863,7 +864,8 @@ switch($_GET["action"]) //check to make sure that the page exists if(!isset($pageindex->$page)) { - if($editing) + // todo make this intelligent so we only redirect if the user is acutally able to create the page + if($settings->editing) { //editing is enabled, redirect to the editing page http_response_code(307); //temporary redirect @@ -874,10 +876,10 @@ switch($_GET["action"]) { //editing is disabled, show an error message http_response_code(404); - exit(renderpage("$page - 404 - $sitename", "

$page does not exist.

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.

")); + exit(renderpage("$page - 404 - $settings->sitename", "

$page does not exist.

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.

")); } } - $title = "$page - $sitename"; + $title = "$page - $settings->sitename"; $content = "

$page

"; $slimdown_start = microtime(true); diff --git a/index.php b/index.php index 563ac6f..e21aabb 100755 --- a/index.php +++ b/index.php @@ -12,54 +12,56 @@ $start_time = time(true); * Code by @Starbeamrainbowlabs * Slimdown - by Johnny Broadway from https://gist.github.com/jbroadway/2836900 * Bug reports: - * #1 - Incorrect closing tag - nibreh + * #1 - Incorrect closing tag - nibreh */ +$settings = new stdClass(); + // the site's name -$sitename = "Pepperminty Wiki"; +$settings->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). // MAKE SURE THAT THIS POINTS TO A HTTP URL, OTHERWISE SOMEONE COULD INJECT A VIRUS INTO YOUR WIKI -$updateurl = "https://raw.githubusercontent.com/sbrl/pepperminty-wiki/master/index.php"; +$settings->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 (semi)automatic updating of your wiki has not been added yet. -$sitesecret = "ed420502615bac9037f8f12abd4c9f02"; +$settings->sitesecret = "ed420502615bac9037f8f12abd4c9f02"; // whether people can edit the site -$editing = true; +$settings->editing = true; // the maximum number of characters allowed in a single page -$maxpagesize = 135000; //135,000 characters, or 50 pages +$settings->maxpagesize = 135000; //135,000 characters, or 50 pages // whether users who aren't logged in are allowed to edit -$anonedits = false; +$settings->anonedits = false; // the name of the page that will act as the home page for the wiki. This page will be served if the user didn't specify a page. -$defaultpage = "Main Page"; +$settings->defaultpage = "Main Page"; // usernames and passwords - passwords should be hashed with sha256 -$users = [ +$settings->users = [ "admin" => "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", //password "user" => "873ac9ffea4dd04fa719e8920cd6938f0c23cd678af330939cff53c3d2855f34" //cheese ]; // array of usernames that are administrators. // administrators can delete and move pages, though this functionality hasn't been added yet. -$admins = [ "admin" ]; +$settings->admins = [ "admin" ]; // The string that is prepended before an admin's name on the nav bar. defaults to a diamond shape (◆). -$admindisplaychar = "◆"; +$settings->admindisplaychar = "◆"; // contact details for the site administrator. Since user can only be added by editing this file, people will need a contact address to use to ask for an account. Displayed at the bottom of the page, and will be appropriatly obfusticated to deter spammers. -$admindetails = [ +$settings->admindetails = [ "name" => "Administrator", "email" => "admin@localhost" ]; // array of links and display text to display at the top of the site -$navlinks = [ +$settings->navlinks = [ [ "Home", "index.php" ], [ "Login", "index.php?action=login" ], " | ", @@ -69,8 +71,8 @@ $navlinks = [ [ "Edit", "index.php?action=edit&page={page}" ], [ "Printable", "index.php?action=view&printable=yes&page={page}" ], " | ", - [ $admindisplaychar . "Delete", "index.php?action=delete&page={page}" ], - [ $admindisplaychar . "Move", "index.php?action=move&page={page}" ], + [ $settings->admindisplaychar . "Delete", "index.php?action=delete&page={page}" ], + [ $settings->admindisplaychar . "Move", "index.php?action=move&page={page}" ], " | ", [ "All Pages", "index.php?action=list" ], " | ", @@ -80,7 +82,7 @@ $navlinks = [ // string of css to include // may be a url - urls will be referenced via a tag -$css = "body { font-family: sans-serif; color: #333333; background: #f3f3f3; } +$settings->css = "body { font-family: sans-serif; color: #333333; background: #f3f3f3; } label { display: inline-block; min-width: 10rem; } textarea[name=content] { display: block; width: 100%; height: 35rem; } /*input[name=page] { width: 16rem; }*/ @@ -90,13 +92,13 @@ th { text-align: left; } .footerdivider { margin-top: 4rem; }"; // the favicon // default: peppermint from https://openclipart.org/detail/19571/peppermint-candy-by-bluefrog23 -$favicon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAB3VBMVEXhERHbKCjeVVXjb2/kR0fhKirdHBziDg6qAADaHh7qLy/pdXXUNzfMAADYPj7ZPDzUNzfbHx/fERHpamrqMTHgExPdHx/bLCzhLS3fVFTjT0/ibm7kRkbiLi7aKirdISHeFBTqNDTpeHjgERHYJCTVODjYQkLaPj6/AADVOTnpbW3cIyPdFRXcJCThMjLiTU3ibW3fVVXaKyvcERH4ODj+8fH/////fHz+Fxf4KSn0UFD/CAj/AAD/Xl7/wMD/EhL//v70xMT/+Pj/iYn/HBz/g4P/IyP/Kyv/7Oz0QUH/9PT/+vr/ior/Dg7/vr7/aGj/QED/bGz/AQH/ERH/Jib/R0f/goL/0dH/qan/YWH/7e3/Cwv4R0f/MTH/enr/vLz/u7v/cHD/oKD/n5//aWn+9/f/k5P/0tL/trb/QUH/cXH/dHT/wsL/DQ3/p6f/DAz/1dX/XV3/kpL/i4v/Vlb/2Nj/9/f/pKT+7Oz/V1f/iIj/jIz/r6//Zmb/lZX/j4//T0//Dw/4MzP/GBj/+fn/o6P/TEz/xMT/b2//Tk7/OTn/HR3/hIT/ODj/Y2P/CQn/ZGT/6Oj0UlL/Gxv//f3/Bwf/YmL/6+v0w8P/Cgr/tbX0QkL+9fX4Pz/qNzd0dFHLAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfeCxINNSdmw510AAAA5ElEQVQYGQXBzSuDAQCA8eexKXOwmSZepa1JiPJxsJOrCwcnuchBjg4O/gr7D9zk4uAgJzvuMgcTpYxaUZvSm5mUj7TX7ycAqvoLIJBwStVbP0Hom1Z/ejoxrbaR1Jz6nWinbKWttGRgMSSjanPktRY6mB9WtRNTn7Ilh7LxnNpKq2/x5LnBitfz+hx0qxUaxhZ6vwqq9bx6f2XXvuUl9SVQS38NR7cvln3v15tZ9bQpuWDtZN3Lgh5DWJex3Y+z1KrVhw21+CiM74WZo83DiXq0dVBDYNJkFEU7WrwDAZhRtQrwDzwKQbT6GboLAAAAAElFTkSuQmCC"; +$settings->favicon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAB3VBMVEXhERHbKCjeVVXjb2/kR0fhKirdHBziDg6qAADaHh7qLy/pdXXUNzfMAADYPj7ZPDzUNzfbHx/fERHpamrqMTHgExPdHx/bLCzhLS3fVFTjT0/ibm7kRkbiLi7aKirdISHeFBTqNDTpeHjgERHYJCTVODjYQkLaPj6/AADVOTnpbW3cIyPdFRXcJCThMjLiTU3ibW3fVVXaKyvcERH4ODj+8fH/////fHz+Fxf4KSn0UFD/CAj/AAD/Xl7/wMD/EhL//v70xMT/+Pj/iYn/HBz/g4P/IyP/Kyv/7Oz0QUH/9PT/+vr/ior/Dg7/vr7/aGj/QED/bGz/AQH/ERH/Jib/R0f/goL/0dH/qan/YWH/7e3/Cwv4R0f/MTH/enr/vLz/u7v/cHD/oKD/n5//aWn+9/f/k5P/0tL/trb/QUH/cXH/dHT/wsL/DQ3/p6f/DAz/1dX/XV3/kpL/i4v/Vlb/2Nj/9/f/pKT+7Oz/V1f/iIj/jIz/r6//Zmb/lZX/j4//T0//Dw/4MzP/GBj/+fn/o6P/TEz/xMT/b2//Tk7/OTn/HR3/hIT/ODj/Y2P/CQn/ZGT/6Oj0UlL/Gxv//f3/Bwf/YmL/6+v0w8P/Cgr/tbX0QkL+9fX4Pz/qNzd0dFHLAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfeCxINNSdmw510AAAA5ElEQVQYGQXBzSuDAQCA8eexKXOwmSZepa1JiPJxsJOrCwcnuchBjg4O/gr7D9zk4uAgJzvuMgcTpYxaUZvSm5mUj7TX7ycAqvoLIJBwStVbP0Hom1Z/ejoxrbaR1Jz6nWinbKWttGRgMSSjanPktRY6mB9WtRNTn7Ilh7LxnNpKq2/x5LnBitfz+hx0qxUaxhZ6vwqq9bx6f2XXvuUl9SVQS38NR7cvln3v15tZ9bQpuWDtZN3Lgh5DWJex3Y+z1KrVhw21+CiM74WZo83DiXq0dVBDYNJkFEU7WrwDAZhRtQrwDzwKQbT6GboLAAAAAElFTkSuQmCC"; // the prefix that should be used in the names of the session variables. // defaults to an all lower case version of the site name with all non alphanumeric characters removed // remember that changing this will log everyone out since the session varibles' name will have changed // normally you wouldn't have to change this - this setting is left over from when we used a cookie to store login details -$sessionprefix = preg_replace("/[^0-9a-z]/i", "", strtolower($sitename)); +$settings->sessionprefix = preg_replace("/[^0-9a-z]/i", "", strtolower($settings->sitename)); /* Actions: @@ -132,25 +134,25 @@ $version = "0.4"; session_start(); ///////// Login System ///////// //clear expired sessions -if(isset($_SESSION["$sessionprefix-expiretime"]) and - $_SESSION["$sessionprefix-expiretime"] < time()) +if(isset($_SESSION["$settings->sessionprefix-expiretime"]) and + $_SESSION["$settings->sessionprefix-expiretime"] < time()) { //clear the session variables $_SESSION = []; session_destroy(); } -if(!isset($_SESSION[$sessionprefix . "-user"]) and - !isset($_SESSION[$sessionprefix . "-pass"])) +if(!isset($_SESSION[$settings->sessionprefix . "-user"]) and + !isset($_SESSION[$settings->sessionprefix . "-pass"])) { //the user is not logged in $isloggedin = false; } else { - $user = $_SESSION[$sessionprefix . "-user"]; - $pass = $_SESSION[$sessionprefix . "-pass"]; - if($users[$user] == $pass) + $user = $_SESSION[$settings->sessionprefix . "-user"]; + $pass = $_SESSION[$settings->sessionprefix . "-pass"]; + if($settings->users[$user] == $pass) { //the user is logged in $isloggedin = true; @@ -171,7 +173,7 @@ else $isadmin = false; if($isloggedin) { - foreach($admins as $admin_username) + foreach($settings->admins as $admin_username) { if($admin_username == $user) { @@ -200,6 +202,7 @@ if(!file_exists("./pageindex.json")) $pageindex->$pagekey = $newentry; } file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT)); + unset($existingpages); } else { @@ -249,7 +252,7 @@ if(!isset($_GET["action"])) $_GET["action"] = "view"; if(!isset($_GET["page"]) or strlen($_GET["page"]) === 0) - $_GET["page"] = $defaultpage; + $_GET["page"] = $settings->defaultpage; //redirect the user to the safe version of the path if they entered an unsafe character if(makepathsafe($_GET["page"]) !== $_GET["page"]) @@ -270,21 +273,21 @@ $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 $settings, $page, $user, $isloggedin, $isadmin, $start_time, $pageindex; $html = " $title - "; - if(preg_match("/^[^\/]*\/\/|^\//", $css)) + "; + if(preg_match("/^[^\/]*\/\/|^\//", $settings->css)) { - $html .= "\n\t\t\n"; + $html .= "\n\t\t\n"; } else { - $html .= "\n\t\t\n"; + $html .= "\n\t\t\n"; } $html .= "\n"; @@ -294,7 +297,7 @@ function renderpage($title, $content, $minimal = false) { $html .= "$content
-

From $sitename, which is managed by " . $admindetails["name"] . ".

+

From $settings->sitename, which is managed by " . $settings->admindetails["name"] . ".

Timed at " . date("l jS \of F Y \a\\t h:ia T") . ".

Powered by Pepperminty Wiki

"; } @@ -306,14 +309,14 @@ function renderpage($title, $content, $minimal = false) { $html .= "\t\tLogged in as "; if($isadmin) - $html .= $admindisplaychar; + $html .= $settings->admindisplaychar; $html .= "$user. Logout. | \n"; } else $html .= "\t\tBrowsing as Anonymous. Login. | \n"; - foreach($navlinks as $item) + foreach($settings->navlinks as $item) { if(is_string($item)) { @@ -338,13 +341,13 @@ function renderpage($title, $content, $minimal = false) } $html .= " -

$sitename

+

$settings->sitename

$content
\n"; @@ -527,7 +530,7 @@ switch($_GET["action"]) $pagetext = file_get_contents($filename); } - if((!$isloggedin and !$anonedits) or !$editing) + if((!$isloggedin and !$settings->anonedits) or !$settings->editing) { if(!$creatingpage) { @@ -540,9 +543,9 @@ switch($_GET["action"]) exit(renderpage("404 - $page", "

The page $page does not exist, but you do not have permission to create it.

If you haven't already, perhaps you should try logging in.

")); } } - + $content = "

$title

"; - if(!$isloggedin and $anonedits) + if(!$isloggedin and $settings->anonedits) { $content .= "

Warning: You are not logged in! Your IP address may be recorded.

"; } @@ -550,7 +553,7 @@ switch($_GET["action"]) "; - exit(renderpage("$title - $sitename", $content)); + exit(renderpage("$title - $settings->sitename", $content)); break; /* @@ -562,16 +565,16 @@ switch($_GET["action"]) * %save% */ case "save": - if(!$editing) + if(!$settings->editing) { header("location: index.php?page=$page"); exit(renderpage("Error saving edit", "

Editing is currently disabled on this wiki.

")); } - if(!$isloggedin and !$anonedits) + if(!$isloggedin and !$settings->anonedits) { http_response_code(403); 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...."); + exit("You are not logged in, so you are not allowed to save pages on $settings->sitename. Redirecting in 5 seconds...."); } if(!isset($_POST["content"])) { @@ -607,8 +610,8 @@ switch($_GET["action"]) else { http_response_code(507); - exit(renderpage("Error saving page - $sitename", "

$sitename failed to write your changes to the disk. Your changes have not been saved, however you may be able to recover your edit by pressing the back button in your browser.

-

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

")); + exit(renderpage("Error saving page - $settings->sitename", "

$settings->sitename failed to write your changes to the disk. Your changes have not been saved, but you might be able to recover your edit by pressing the back button in your browser.

+

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

")); } break; @@ -622,7 +625,7 @@ switch($_GET["action"]) */ case "list": $title = "All Pages"; - $content = "

$title on $sitename

+ $content = "

$title on $settings->sitename

@@ -642,7 +645,7 @@ switch($_GET["action"]) \n"; } $content .= "
Page Name
"; - exit(renderpage("$title - $sitename", $content)); + exit(renderpage("$title - $settings->sitename", $content)); break; /* @@ -654,7 +657,7 @@ switch($_GET["action"]) * %delete% */ case "delete": - if(!$editing) + if(!$settings->editing) { exit(renderpage("Deleting $page - error", "

You tried to delete $page, but editing is disabled on this wiki.

If you wish to delete this page, please re-enable editing on this wiki first.

@@ -676,7 +679,7 @@ switch($_GET["action"]) 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", "

$page has been deleted. Go back to the main page.

")); + exit(renderpage("Deleting $page - $settings->sitename", "

$page has been deleted. Go back to the main page.

")); break; /* @@ -688,7 +691,7 @@ switch($_GET["action"]) * %move% */ case "move": - if(!$editing) + if(!$settings->editing) { exit(renderpage("Moving $page - error", "

You tried to move $page, but editing is disabled on this wiki.

If you wish to move this page, please re-enable editing on this wiki first.

@@ -724,7 +727,7 @@ switch($_GET["action"]) exit(renderpage("Moving $page - Error", "

You tried to move $page, but the new name you gave is the same as it's current name.

It is possible that you tried to use some characters in the new name that are not allowed and were removed.

Page names may only contain alphanumeric characters, dashes, and underscores.

")); - + //move the page in the page index $pageindex->$new_name = new stdClass(); foreach($pageindex->$page as $key => $value) @@ -733,10 +736,10 @@ switch($_GET["action"]) } 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", "

$page has been moved to $new_name successfully.

")); break; @@ -749,15 +752,15 @@ switch($_GET["action"]) * %help% |_| */ case "help": - $title = "Help - $sitename"; - $content = "

$sitename Help

-

Welcome to $sitename!

-

$sitename is powered by Pepperminty wiki, a complete wiki in a box you can drop into your server.

+ $title = "Help - $settings->sitename"; + $content = "

$settings->sitename Help

+

Welcome to $settings->sitename!

+

$settings->sitename is powered by Pepperminty wiki, a complete wiki in a box you can drop into your server.

Navigating

All the navigation links can be found in the top right corner, along with a box in which you can type a page name and hit enter to be taken to that page (if your site administrator has enabled it).

-

In order to edit pages on $sitename, you probably need to be logged in. If you do not already have an account you will need to ask $sitename's administrator for an account since there is not registration form. Note that the $sitename's administrator may have changed these settings to allow anonymous edits.

+

In order to edit pages on $settings->sitename, you probably need to be logged in. If you do not already have an account you will need to ask $settings->sitename's administrator for an account since there is not registration form. Note that the $settings->sitename's administrator may have changed these settings to allow anonymous edits.

Editing

-

$sitename's editor uses a modified version of slimdown, a flavour of markdown that is implementated using regular expressions. See the credits page for more information and links to the original source for this. A quick reference can be found below:

+

$settings->sitename's editor uses a modified version of slimdown, a flavour of markdown that is implementated using regular expressions. See the credits page for more information and links to the original source for this. A quick reference can be found below:

@@ -778,8 +781,8 @@ switch($_GET["action"])
Type ThisTo get this
_italics_italics

Administrator Actions

By default, the delete and move actions are shown on the nav bar. These can be used by administrators to delete or move pages.

-

The other thing admininistrators can do is update the wiki (provided they know the site's secret). This page can be found here: Update $sitename.

-

$sitename is currently running on Pepperminty Wiki $version

"; +

The other thing admininistrators can do is update the wiki (provided they know the site's secret). This page can be found here: Update $settings->sitename.

+

$settings->sitename is currently running on Pepperminty Wiki $version

"; exit(renderpage($title, $content)); break; @@ -792,8 +795,8 @@ switch($_GET["action"]) * |___/ %login% */ case "login": - $title = "Login to $sitename"; - $content = "

Login to $sitename

\n"; + $title = "Login to $settings->sitename"; + $content = "

Login to $settings->sitename

\n"; if(isset($_GET["failed"])) $content .= "\t\t

Login failed.

\n"; $content .= "\t\t
@@ -821,13 +824,13 @@ switch($_GET["action"]) //the user wants to log in $user = $_POST["user"]; $pass = $_POST["pass"]; - if($users[$user] == hash("sha256", $pass)) + if($settings->users[$user] == hash("sha256", $pass)) { $isloggedin = true; $expiretime = time() + 60*60*24*30; //30 days from now - $_SESSION["$sessionprefix-user"] = $user; - $_SESSION["$sessionprefix-pass"] = hash("sha256", $pass); - $_SESSION["$sessionprefix-expiretime"] = $expiretime; + $_SESSION["$settings->sessionprefix-user"] = $user; + $_SESSION["$settings->sessionprefix-pass"] = hash("sha256", $pass); + $_SESSION["$settings->sessionprefix-expiretime"] = $expiretime; //redirect to wherever the user was going http_response_code(302); if(isset($_POST["goto"])) @@ -880,13 +883,13 @@ switch($_GET["action"]) * %credits% */ case "credits": - $title = "Credits - $sitename"; - $content = "

$sitename credits

-

$sitename is powered by Pepperminty Wiki - an entire wiki packed inside a single file, which was built by Starbeamrainbowlabs, and can be found on github.

+ $title = "Credits - $settings->sitename"; + $content = "

$settings->sitename credits

+

$settings->sitename is powered by Pepperminty Wiki - an entire wiki packed inside a single file, which was built by Starbeamrainbowlabs, and can be found on github.

A slightly modified version of slimdown is used to parse text source into HTML. Slimdown is by Johnny Broadway, which can be found on github.

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

-

Administrators can update $sitename here: Update $sitename.

-

$sitename is currently running on Pepperminty Wiki $version

"; +

Administrators can update $settings->sitename here: Update $settings->sitename.

+

$settings->sitename is currently running on Pepperminty Wiki $version

"; exit(renderpage($title, $content)); break; @@ -898,7 +901,7 @@ switch($_GET["action"]) * |_| %update% */ case "update": - if(!$isadmin) + if(!$settings->isadmin) { http_response_code(401); exit(renderpage("Update - Error", "

You must be an administrator to do that.

")); @@ -906,22 +909,22 @@ switch($_GET["action"]) if(!isset($_GET["do"]) or $_GET["do"] !== "true") { - exit(renderpage("Update $sitename", "

This page allows you to update $sitename.

-

Currently, $sitename is using $version of Pepperminty Wiki.

-

This script will automatically download and install the latest version of Pepperminty Wiki from the url of your choice (see settings), regardless of whether an update is acutally needed (version checking isn't implemented yet).

-

To update $sitename, fill out the form below and click click the update button.

+ exit(renderpage("Update $settings->sitename", "

This page allows you to update $settings->sitename.

+

Currently, $settings->sitename is using $settings->version of Pepperminty Wiki.

+

This script will automatically download and install the latest version of Pepperminty Wiki from the url of your choice (see settings), regardless of whether an update is actually needed (version checking isn't implemented yet).

+

To update $settings->sitename, fill out the form below and click click the update button.

- +
")); } - if(!isset($_GET["secret"]) or $_GET["secret"] !== $sitesecret) + if(!isset($_GET["secret"]) or $_GET["secret"] !== $settings->sitesecret) { - exit(renderpage("Update $sitename - Error", "

You forgot to enter $sitename's secret code or entered it incorrectly. $sitename's secret can be found in the settings portion of index.php.

")); + exit(renderpage("Update $settings->sitename - Error", "

You forgot to enter $settings->sitename's secret code or entered it incorrectly. $settings->sitename's secret can be found in the settings portion of index.php.

")); } $settings_separator = "/////////////// Do not edit below this line unless you know what you are doing! ///////////////"; @@ -944,7 +947,7 @@ switch($_GET["action"]) file_put_contents(__FILE__, $result); $log .= "done.\n"; - $log .= "Update complete. I am now running on the latest version of $sitename."; + $log .= "Update complete. I am now running on the latest version of Pepperminty Wiki."; $log .= "The version number that I have updated to can be found on the credits or help ages."; exit(renderpage("Update - Success", "
  • " . implode("
  • ", explode("\n", $log)) . "
")); @@ -964,7 +967,7 @@ switch($_GET["action"]) { http_response_code(400); exit(renderpage("Bad request", "

The GET parameter string must be specified.

-

It is strongly recommended that you utilise this page via a private or incognito window.

")); +

It is strongly recommended that you utilise this page via a private or incognito window in order to prevent your password from appearing in your browser history.

")); } else { @@ -985,7 +988,8 @@ switch($_GET["action"]) //check to make sure that the page exists if(!isset($pageindex->$page)) { - if($editing) + // todo make this intelligent so we only redirect if the user is acutally able to create the page + if($settings->editing) { //editing is enabled, redirect to the editing page http_response_code(307); //temporary redirect @@ -996,10 +1000,10 @@ switch($_GET["action"]) { //editing is disabled, show an error message http_response_code(404); - exit(renderpage("$page - 404 - $sitename", "

$page does not exist.

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.

")); + exit(renderpage("$page - 404 - $settings->sitename", "

$page does not exist.

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.

")); } } - $title = "$page - $sitename"; + $title = "$page - $settings->sitename"; $content = "

$page

"; $slimdown_start = microtime(true); diff --git a/settings.fragment.php b/settings.fragment.php index a71a27a..084dfaf 100644 --- a/settings.fragment.php +++ b/settings.fragment.php @@ -12,51 +12,53 @@ * #1 - Incorrect closing tag - nibreh */ +$settings = new stdClass(); + // the site's name -$sitename = "Pepperminty Wiki"; +$settings->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). // MAKE SURE THAT THIS POINTS TO A HTTP URL, OTHERWISE SOMEONE COULD INJECT A VIRUS INTO YOUR WIKI -$updateurl = "https://raw.githubusercontent.com/sbrl/pepperminty-wiki/master/index.php"; +$settings->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 (semi)automatic updating of your wiki has not been added yet. -$sitesecret = "ed420502615bac9037f8f12abd4c9f02"; +$settings->sitesecret = "ed420502615bac9037f8f12abd4c9f02"; // whether people can edit the site -$editing = true; +$settings->editing = true; // the maximum number of characters allowed in a single page -$maxpagesize = 135000; //135,000 characters, or 50 pages +$settings->maxpagesize = 135000; //135,000 characters, or 50 pages // whether users who aren't logged in are allowed to edit -$anonedits = false; +$settings->anonedits = false; // the name of the page that will act as the home page for the wiki. This page will be served if the user didn't specify a page. -$defaultpage = "Main Page"; +$settings->defaultpage = "Main Page"; // usernames and passwords - passwords should be hashed with sha256 -$users = [ +$settings->users = [ "admin" => "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8", //password "user" => "873ac9ffea4dd04fa719e8920cd6938f0c23cd678af330939cff53c3d2855f34" //cheese ]; // array of usernames that are administrators. // administrators can delete and move pages, though this functionality hasn't been added yet. -$admins = [ "admin" ]; +$settings->admins = [ "admin" ]; // The string that is prepended before an admin's name on the nav bar. defaults to a diamond shape (◆). -$admindisplaychar = "◆"; +$settings->admindisplaychar = "◆"; // contact details for the site administrator. Since user can only be added by editing this file, people will need a contact address to use to ask for an account. Displayed at the bottom of the page, and will be appropriatly obfusticated to deter spammers. -$admindetails = [ +$settings->admindetails = [ "name" => "Administrator", "email" => "admin@localhost" ]; // array of links and display text to display at the top of the site -$navlinks = [ +$settings->navlinks = [ [ "Home", "index.php" ], [ "Login", "index.php?action=login" ], " | ", @@ -66,8 +68,8 @@ $navlinks = [ [ "Edit", "index.php?action=edit&page={page}" ], [ "Printable", "index.php?action=view&printable=yes&page={page}" ], " | ", - [ $admindisplaychar . "Delete", "index.php?action=delete&page={page}" ], - [ $admindisplaychar . "Move", "index.php?action=move&page={page}" ], + [ $settings->admindisplaychar . "Delete", "index.php?action=delete&page={page}" ], + [ $settings->admindisplaychar . "Move", "index.php?action=move&page={page}" ], " | ", [ "All Pages", "index.php?action=list" ], " | ", @@ -77,7 +79,7 @@ $navlinks = [ // string of css to include // may be a url - urls will be referenced via a tag -$css = "body { font-family: sans-serif; color: #333333; background: #f3f3f3; } +$settings->css = "body { font-family: sans-serif; color: #333333; background: #f3f3f3; } label { display: inline-block; min-width: 10rem; } textarea[name=content] { display: block; width: 100%; height: 35rem; } /*input[name=page] { width: 16rem; }*/ @@ -87,13 +89,13 @@ th { text-align: left; } .footerdivider { margin-top: 4rem; }"; // the favicon // default: peppermint from https://openclipart.org/detail/19571/peppermint-candy-by-bluefrog23 -$favicon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAB3VBMVEXhERHbKCjeVVXjb2/kR0fhKirdHBziDg6qAADaHh7qLy/pdXXUNzfMAADYPj7ZPDzUNzfbHx/fERHpamrqMTHgExPdHx/bLCzhLS3fVFTjT0/ibm7kRkbiLi7aKirdISHeFBTqNDTpeHjgERHYJCTVODjYQkLaPj6/AADVOTnpbW3cIyPdFRXcJCThMjLiTU3ibW3fVVXaKyvcERH4ODj+8fH/////fHz+Fxf4KSn0UFD/CAj/AAD/Xl7/wMD/EhL//v70xMT/+Pj/iYn/HBz/g4P/IyP/Kyv/7Oz0QUH/9PT/+vr/ior/Dg7/vr7/aGj/QED/bGz/AQH/ERH/Jib/R0f/goL/0dH/qan/YWH/7e3/Cwv4R0f/MTH/enr/vLz/u7v/cHD/oKD/n5//aWn+9/f/k5P/0tL/trb/QUH/cXH/dHT/wsL/DQ3/p6f/DAz/1dX/XV3/kpL/i4v/Vlb/2Nj/9/f/pKT+7Oz/V1f/iIj/jIz/r6//Zmb/lZX/j4//T0//Dw/4MzP/GBj/+fn/o6P/TEz/xMT/b2//Tk7/OTn/HR3/hIT/ODj/Y2P/CQn/ZGT/6Oj0UlL/Gxv//f3/Bwf/YmL/6+v0w8P/Cgr/tbX0QkL+9fX4Pz/qNzd0dFHLAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfeCxINNSdmw510AAAA5ElEQVQYGQXBzSuDAQCA8eexKXOwmSZepa1JiPJxsJOrCwcnuchBjg4O/gr7D9zk4uAgJzvuMgcTpYxaUZvSm5mUj7TX7ycAqvoLIJBwStVbP0Hom1Z/ejoxrbaR1Jz6nWinbKWttGRgMSSjanPktRY6mB9WtRNTn7Ilh7LxnNpKq2/x5LnBitfz+hx0qxUaxhZ6vwqq9bx6f2XXvuUl9SVQS38NR7cvln3v15tZ9bQpuWDtZN3Lgh5DWJex3Y+z1KrVhw21+CiM74WZo83DiXq0dVBDYNJkFEU7WrwDAZhRtQrwDzwKQbT6GboLAAAAAElFTkSuQmCC"; +$settings->favicon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAB3VBMVEXhERHbKCjeVVXjb2/kR0fhKirdHBziDg6qAADaHh7qLy/pdXXUNzfMAADYPj7ZPDzUNzfbHx/fERHpamrqMTHgExPdHx/bLCzhLS3fVFTjT0/ibm7kRkbiLi7aKirdISHeFBTqNDTpeHjgERHYJCTVODjYQkLaPj6/AADVOTnpbW3cIyPdFRXcJCThMjLiTU3ibW3fVVXaKyvcERH4ODj+8fH/////fHz+Fxf4KSn0UFD/CAj/AAD/Xl7/wMD/EhL//v70xMT/+Pj/iYn/HBz/g4P/IyP/Kyv/7Oz0QUH/9PT/+vr/ior/Dg7/vr7/aGj/QED/bGz/AQH/ERH/Jib/R0f/goL/0dH/qan/YWH/7e3/Cwv4R0f/MTH/enr/vLz/u7v/cHD/oKD/n5//aWn+9/f/k5P/0tL/trb/QUH/cXH/dHT/wsL/DQ3/p6f/DAz/1dX/XV3/kpL/i4v/Vlb/2Nj/9/f/pKT+7Oz/V1f/iIj/jIz/r6//Zmb/lZX/j4//T0//Dw/4MzP/GBj/+fn/o6P/TEz/xMT/b2//Tk7/OTn/HR3/hIT/ODj/Y2P/CQn/ZGT/6Oj0UlL/Gxv//f3/Bwf/YmL/6+v0w8P/Cgr/tbX0QkL+9fX4Pz/qNzd0dFHLAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfeCxINNSdmw510AAAA5ElEQVQYGQXBzSuDAQCA8eexKXOwmSZepa1JiPJxsJOrCwcnuchBjg4O/gr7D9zk4uAgJzvuMgcTpYxaUZvSm5mUj7TX7ycAqvoLIJBwStVbP0Hom1Z/ejoxrbaR1Jz6nWinbKWttGRgMSSjanPktRY6mB9WtRNTn7Ilh7LxnNpKq2/x5LnBitfz+hx0qxUaxhZ6vwqq9bx6f2XXvuUl9SVQS38NR7cvln3v15tZ9bQpuWDtZN3Lgh5DWJex3Y+z1KrVhw21+CiM74WZo83DiXq0dVBDYNJkFEU7WrwDAZhRtQrwDzwKQbT6GboLAAAAAElFTkSuQmCC"; // the prefix that should be used in the names of the session variables. // defaults to an all lower case version of the site name with all non alphanumeric characters removed // remember that changing this will log everyone out since the session varibles' name will have changed // normally you wouldn't have to change this - this setting is left over from when we used a cookie to store login details -$sessionprefix = preg_replace("/[^0-9a-z]/i", "", strtolower($sitename)); +$settings->sessionprefix = preg_replace("/[^0-9a-z]/i", "", strtolower($settings->sitename)); /* Actions: