From 7d425c399853827c426e6f937c8cc18e75373582 Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Tue, 22 Sep 2015 14:47:12 +0100
Subject: [PATCH] Bugfix: undefined variable on line 1831

---
 build/index.php   | 211 +++++++++++++++++++++++++---------------------
 core.php          |   2 +-
 module_index.json |  38 ++++-----
 3 files changed, 135 insertions(+), 116 deletions(-)

diff --git a/build/index.php b/build/index.php
index 4529826..dff95e4 100644
--- a/build/index.php
+++ b/build/index.php
@@ -228,53 +228,63 @@ Actions:
 /////////////// Do not edit below this line unless you know what you are doing! ///////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////
 $version = "0.7";
+$env = new stdClass();
+$env->action = $settings->defaultaction;
+$env->page = "";
+$env->user = "Anonymous";
+$env->is_logged_in = false;
+$env->is_admin = false;
+
 session_start();
 ///////// Login System /////////
-//clear expired sessions
+// Clear expired sessions
 if(isset($_SESSION["$settings->sessionprefix-expiretime"]) and
    $_SESSION["$settings->sessionprefix-expiretime"] < time())
 {
-	//clear the session variables
+	// Clear the session variables
 	$_SESSION = [];
 	session_destroy();
+	$env->is_logged_in = false;
+	$env->user = "Anonymous";
 }
 
 if(!isset($_SESSION[$settings->sessionprefix . "-user"]) and
   !isset($_SESSION[$settings->sessionprefix . "-pass"]))
 {
-	//the user is not logged in
-	$isloggedin = false;
+	// The user is not logged in
+	$env->is_logged_in = false;
 }
 else
 {
-	$user = $_SESSION[$settings->sessionprefix . "-user"];
-	$pass = $_SESSION[$settings->sessionprefix . "-pass"];
-	if($settings->users[$user] == $pass)
+	$env->user = $_SESSION[$settings->sessionprefix . "-user"];
+	$env->pass = $_SESSION[$settings->sessionprefix . "-pass"];
+	if($settings->users[$env->user] == $env->pass)
 	{
-		//the user is logged in
-		$isloggedin = true;
+		// The user is logged in
+		$env->is_logged_in = true;
 	}
 	else
 	{
-		//the user's login details are invalid (what is going on here?)
-		//unset the session variables, treat them as an anonymous user, and get out of here
-		$isloggedin = false;
-		unset($user);
-		unset($pass);
-		//clear the session data
-		$_SESSION = []; //delete al lthe variables
+		// The user's login details are invalid (what is going on here?)
+		// Unset the session variables, treat them as an anonymous user,
+		// and get out of here
+		$env->is_logged_in = false;
+		$env->user = "Anonymous";
+		$env->pass = "";
+		// Clear the session data
+		$_SESSION = []; //delete all the variables
 		session_destroy(); //destroy the session
 	}
 }
 //check to see if the currently logged in user is an admin
-$isadmin = false;
-if($isloggedin)
+$env->is_admin = false;
+if($env->is_logged_in)
 {
 	foreach($settings->admins as $admin_username)
 	{
-		if($admin_username == $user)
+		if($admin_username == $env->user)
 		{
-			$isadmin = true;
+			$env->is_admin = true;
 			break;
 		}
 	}
@@ -535,7 +545,9 @@ if(makepathsafe($_GET["page"]) !== $_GET["page"])
 	header("x-actual-page: " . makepathsafe($_GET["page"]));
 	exit();
 }
-$page = $_GET["page"];
+
+$env->page = $_GET["page"];
+$env->action = strtolower($_GET["action"]);
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////
@@ -591,6 +603,8 @@ class page_renderer
 	// Registers a function as a part post processor.
 	public static function register_part_preprocessor($function)
 	{
+		global $settings;
+		
 		// Make sure that the function we are about to register is valid
 		if(!is_callable($function))
 		{
@@ -685,7 +699,7 @@ class page_renderer
 	 */
 	public static function render_navigation_bar($nav_links, $nav_links_extra, $class = "")
 	{
-		global $settings, $user, $isloggedin, $page;
+		global $settings, $env;
 		$result = "<nav class='$class'>\n";
 		
 		// Loop over all the navigation links
@@ -698,7 +712,7 @@ class page_renderer
 				{
 					//keywords
 					case "user-status":
-						if($isloggedin)
+						if($env->is_logged_in)
 						{
 							$result .= "<span class='inflexible'>Logged in as " . self::render_username($user) . ".</span> "/* . page_renderer::$nav_divider*/;
 							$result .= "<span><a href='index.php?action=logout'>Logout</a></span>";
@@ -731,7 +745,7 @@ class page_renderer
 			else
 			{
 				// Output the item as a link to a url
-				$result .= "<span><a href='" . str_replace("{page}", $page, $item[1]) . "'>$item[0]</a></span>";
+				$result .= "<span><a href='" . str_replace("{page}", $env->page, $item[1]) . "'>$item[0]</a></span>";
 			}
 		}
 		
@@ -833,18 +847,18 @@ register_module([
 
 register_module([
 	"name" => "Raw page source",
-	"version" => "0.2",
+	"version" => "0.3",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds a 'raw' action that shows you the raw source of a page.",
 	"id" => "action-raw",
 	"code" => function() {
 		add_action("raw", function() {
-			global $page;
+			global $env;
 			
 			http_response_code(307);
-			header("x-filename: " . rawurlencode($page) . ".md");
+			header("x-filename: " . rawurlencode($env->page) . ".md");
 			header("content-type: text/markdown");
-			exit(file_get_contents("$page.md"));
+			exit(file_get_contents("$env->page.md"));
 			exit();
 		});
 	}
@@ -1027,36 +1041,37 @@ register_module([
 
 register_module([
 	"name" => "Page deleter",
-	"version" => "0.5",
+	"version" => "0.6",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds an action to allow administrators to delete pages.",
 	"id" => "page-delete",
 	"code" => function() {
 		add_action("delete", function() {
-			global $pageindex, $settings, $page, $isadmin;
+			global $pageindex, $settings, $env;
 			if(!$settings->editing)
 			{
-				exit(page_renderer::render_main("Deleting $page - error", "<p>You tried to delete $page, but editing is disabled on this wiki.</p>
+				exit(page_renderer::render_main("Deleting $env->page - error", "<p>You tried to delete $env->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><a href='index.php?page=$env->page'>Go back to $env->page</a>.</p>
 				<p>Nothing has been changed.</p>"));
 			}
-			if(!$isadmin)
+			if(!$env->is_admin)
 			{
-				exit(page_renderer::render_main("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>
+				exit(page_renderer::render_main("Deleting $env->page - error", "<p>You tried to delete $env->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(page_renderer::render_main("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>"));
+				exit(page_renderer::render_main("Deleting $env->page", "<p>You are about to <strong>delete</strong> $env->page. You can't undo this!</p>
+				<p><a href='index.php?action=delete&page=$env->page&delete=yes'>Click here to delete $env->page.</a></p>
+				<p><a href='index.php?action=view&page=$env->page'>Click here to go back.</a>"));
 			}
+			$page = $env->page;
 			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
+			unlink("./$env->page.md"); //delete the page from the disk
 
-			exit(page_renderer::render_main("Deleting $page - $settings->sitename", "<p>$page has been deleted. <a href='index.php'>Go back to the main page</a>.</p>"));
+			exit(page_renderer::render_main("Deleting $env->page - $settings->sitename", "<p>$env->page has been deleted. <a href='index.php'>Go back to the main page</a>.</p>"));
 		});
 	}
 ]);
@@ -1066,7 +1081,7 @@ register_module([
 
 register_module([
 	"name" => "Page editor",
-	"version" => "0.8",
+	"version" => "0.9",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
 	"id" => "page-edit",
@@ -1082,20 +1097,21 @@ register_module([
 		 *             %edit%
 		 */
 		add_action("edit", function() {
-			global $pageindex, $settings, $page, $isloggedin;
+			global $pageindex, $settings, $env;
 			
-			$filename = "$page.md";
+			$filename = "$env->page.md";
 			$creatingpage = !isset($pageindex->$page);
 			if((isset($_GET["newpage"]) and $_GET["newpage"] == "true") or $creatingpage)
 			{
-				$title = "Creating $page";
+				$title = "Creating $env->page";
 			}
 			else
 			{
-				$title = "Editing $page";
+				$title = "Editing $env->page";
 			}
 			
 			$pagetext = "";
+			$page = $env->$page;
 			if(isset($pageindex->$page))
 			{
 				$pagetext = file_get_contents($filename);
@@ -1106,17 +1122,17 @@ register_module([
 				if(!$creatingpage)
 				{
 					// The page already exists - let the user view the page source
-					exit(page_renderer::render_main("Viewing source for $page", "<p>$settings->sitename does not allow anonymous users to make edits. You can view the source of $page below, but you can't edit it.</p><textarea name='content' readonly>$pagetext</textarea>"));
+					exit(page_renderer::render_main("Viewing source for $env->page", "<p>$settings->sitename does not allow anonymous users to make edits. You can view the source of $env->page below, but you can't edit it.</p><textarea name='content' readonly>$pagetext</textarea>"));
 				}
 				else
 				{
 					http_response_code(404);
-					exit(page_renderer::render_main("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>"));
+					exit(page_renderer::render_main("404 - $env->page", "<p>The page <code>$env->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 $settings->anonedits)
+			if(!$env->is_logged_in and $settings->anonedits)
 			{
 				$content .= "<p><strong>Warning: You are not logged in! Your IP address <em>may</em> be recorded.</strong></p>";
 			}
@@ -1136,35 +1152,36 @@ register_module([
 		 *                %save%
 		 */
 		add_action("save", function() {
-			global $pageindex, $settings, $page, $isloggedin, $user;
+			global $pageindex, $settings, $env; 
 			if(!$settings->editing)
 			{
-				header("location: index.php?page=$page");
+				header("location: index.php?page=$env->page");
 				exit(page_renderer::render_main("Error saving edit", "<p>Editing is currently disabled on this wiki.</p>"));
 			}
-			if(!$isloggedin and !$settings->anonedits)
+			if(!$env->is_logged_in and !$settings->anonedits)
 			{
 				http_response_code(403);
-				header("refresh: 5; url=index.php?page=$page");
+				header("refresh: 5; url=index.php?page=$env->page");
 				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"]))
 			{
 				http_response_code(400);
-				header("refresh: 5; url=index.php?page=$page");
+				header("refresh: 5; url=index.php?page=$env->page");
 				exit("Bad request: No content specified.");
 			}
 			
 			// Make sure that the directory in which the page needs to be saved exists
-			if(!is_dir(dirname("$page.md")))
+			if(!is_dir(dirname("$env->page.md")))
 			{
 				// Recursively create the directory if needed
-				mkdir(dirname("$page.md"), null, true);
+				mkdir(dirname("$env->page.md"), null, true);
 			}
 			
 			
-			if(file_put_contents("$page.md", htmlentities($_POST["content"]), ENT_QUOTES) !== false)
+			if(file_put_contents("$env->page.md", htmlentities($_POST["content"]), ENT_QUOTES) !== false)
 			{
+				$page = $env->page;
 				// Make sure that this page's parents exist
 				check_subpage_parents($page);
 				
@@ -1172,12 +1189,12 @@ register_module([
 				if(!isset($pageindex->$page))
 				{
 					$pageindex->$page = new stdClass();
-					$pageindex->$page->filename = "$page.md";
+					$pageindex->$page->filename = "$env->page.md";
 				}
 				$pageindex->$page->size = strlen($_POST["content"]);
 				$pageindex->$page->lastmodified = time();
 				if($isloggedin)
-					$pageindex->$page->lasteditor = utf8_encode($user);
+					$pageindex->$page->lasteditor = utf8_encode($env->user);
 				else
 					$pageindex->$page->lasteditor = utf8_encode("anonymous");
 				
@@ -1188,7 +1205,7 @@ register_module([
 				else
 					http_response_code(200);
 				
-				header("location: index.php?page=$page&edit_status=success");
+				header("location: index.php?page=$env->page&edit_status=success");
 				exit();
 			}
 			else
@@ -1206,15 +1223,15 @@ register_module([
 
 register_module([
 	"name" => "Export",
-	"version" => "0.1",
+	"version" => "0.2",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds a page that you can use to export your wiki as a .zip file. Uses \$settings->export_only_allow_admins, which controls whether only admins are allowed to export the wiki.",
 	"id" => "page-export",
 	"code" => function() {
 		add_action("export", function() {
-			global $settings, $pageindex, $isadmin;
+			global $settings, $pageindex, $env;
 			
-			if($settings->export_allow_only_admins && !$isadmin)
+			if($settings->export_allow_only_admins && !$env->is_admin)
 			{
 				http_response_code(401);
 				exit(page_renderer::render("Export error - $settings->sitename", "Only administrators of $settings->sitename are allowed to export the wiki as a zip. <a href='?action=$settings->defaultaction&page='>Return to the $settings->defaultpage</a>."));
@@ -1361,7 +1378,7 @@ register_module([
 
 register_module([
 	"name" => "Login",
-	"version" => "0.5",
+	"version" => "0.6",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds a pair of actions (login and checklogin) that allow users to login. You need this one if you want your users to be able to login.",
 	"id" => "page-login",
@@ -1401,7 +1418,7 @@ register_module([
 		 *     %checklogin%                   |___/
 		 */
 		add_action("checklogin", function() {
-			global $settings;
+			global $settings, $env;
 			
 			//actually do the login
 			if(isset($_POST["user"]) and isset($_POST["pass"]))
@@ -1411,7 +1428,7 @@ register_module([
 				$pass = $_POST["pass"];
 				if($settings->users[$user] == hash("sha256", $pass))
 				{
-					$isloggedin = true;
+					$env->is_logged_in = true;
 					$expiretime = time() + 60*60*24*30; //30 days from now
 					$_SESSION["$settings->sessionprefix-user"] = $user;
 					$_SESSION["$settings->sessionprefix-pass"] = hash("sha256", $pass);
@@ -1445,16 +1462,16 @@ register_module([
 
 register_module([
 	"name" => "Logout",
-	"version" => "0.5",
+	"version" => "0.6",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds an action to let users user out. For security reasons it is wise to add this module since logging in automatically opens a session that is valid for 30 days.",
 	"id" => "page-logout",
 	"code" => function() {
 		add_action("logout", function() {
-			global $user, $pass, $isloggedin;
-			$isloggedin = false;
-			unset($user);
-			unset($pass);
+			global $env;
+			$env->is_logged_in = false;
+			unset($env->user);
+			unset($env->pass);
 			//clear the session variables
 			$_SESSION = [];
 			session_destroy();
@@ -1470,32 +1487,32 @@ register_module([
 
 register_module([
 	"name" => "Page mover",
-	"version" => "0.5",
+	"version" => "0.6",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds an action to allow administrators to move pages.",
 	"id" => "page-move",
 	"code" => function() {
 		add_action("move", function() {
-			global $pageindex, $settings, $page, $isadmin;
+			global $pageindex, $settings, $env;
 			if(!$settings->editing)
 			{
-				exit(page_renderer::render_main("Moving $page - error", "<p>You tried to move $page, but editing is disabled on this wiki.</p>
+				exit(page_renderer::render_main("Moving $env->page - error", "<p>You tried to move $env->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><a href='index.php?page=$env->page'>Go back to $env->page</a>.</p>
 				<p>Nothing has been changed.</p>"));
 			}
-			if(!$isadmin)
+			if(!$env->is_admin)
 			{
-				exit(page_renderer::render_main("Moving $page - Error", "<p>You tried to move $page, but you do not have permission to do that.</p>
+				exit(page_renderer::render_main("Moving $env->page - Error", "<p>You tried to move $env->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(page_renderer::render_main("Moving $page", "<h2>Moving $page</h2>
+				exit(page_renderer::render_main("Moving $env->page", "<h2>Moving $env->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 />
+					<input type='text' name='page' value='$env->page' readonly />
 					<br />
 					<label for='new_name'>New Name:</label>
 					<input type='text' name='new_name' />
@@ -1505,12 +1522,13 @@ register_module([
 			
 			$new_name = makepathsafe($_GET["new_name"]);
 			
+			$page = $env->page;
 			if(!isset($pageindex->$page))
-				exit(page_renderer::render_main("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>
+				exit(page_renderer::render_main("Moving $env->page - Error", "<p>You tried to move $env->page to $new_name, but the page with the name $env->page does not exist in the first place.</p>
 				<p>Nothing has been changed.</p>"));
 			
-			if($page == $new_name)
-				exit(page_renderer::render_main("Moving $page - Error", "<p>You tried to move $page, but the new name you gave is the same as it's current name.</p>
+			if($env->page == $new_name)
+				exit(page_renderer::render_main("Moving $env->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>"));
 			
@@ -1524,26 +1542,27 @@ register_module([
 			file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT));
 			
 			//move the page on the disk
-			rename("$page.md", "$new_name.md");
+			rename("$env->page.md", "$new_name.md");
 			
-			exit(page_renderer::render_main("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>"));
+			exit(page_renderer::render_main("Moving $env->page", "<p><a href='index.php?page=$env->page'>$env->page</a> has been moved to <a href='index.php?page=$new_name'>$new_name</a> successfully.</p>"));
 		});
 	}
 ]);
 
+
 
 
 register_module([
 	"name" => "Update",
-	"version" => "0.6",
+	"version" => "0.6.1",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds an update page that downloads the latest stable version of Pepperminty Wiki. This module is currently outdated as it doesn't save your module preferences.",
 	"id" => "page-update",
 	"code" => function() {
 		add_action("update", function() {
-			global $settings, $isadmin;
+			global $settings, $env;
 			
-			if(!$isadmin)
+			if(!$env->is_admin)
 			{
 				http_response_code(401);
 				exit(page_renderer::render_main("Update - Error", "<p>You must be an administrator to do that.</p>"));
@@ -1602,15 +1621,16 @@ register_module([
 
 register_module([
 	"name" => "Page viewer",
-	"version" => "0.8",
+	"version" => "0.9",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Allows you to view pages. You should include this one.",
 	"id" => "page-view",
 	"code" => function() {
 		add_action("view", function() {
-			global $pageindex, $settings, $page, $parse_page_source;
+			global $pageindex, $settings, $env, $parse_page_source;
 			
 			// Check to make sure that the page exists
+			$page = $env->page;
 			if(!isset($pageindex->$page))
 			{
 				// todo make this intelligent so we only redirect if the user is acutally able to create the page
@@ -1618,26 +1638,26 @@ register_module([
 				{
 					// 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($env->page));
 					exit();
 				}
 				else
 				{
 					// Editing is disabled, show an error message
 					http_response_code(404);
-					exit(page_renderer::render_main("$page - 404 - $settings->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(page_renderer::render_main("$env->page - 404 - $settings->sitename", "<p>$env->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 - $settings->sitename";
-			$content = "<h1>$page</h1>";
+			$title = "$env->page - $settings->sitename";
+			$content = "<h1>$env->page</h1>";
 			
 			$parsing_start = microtime(true);
 			
-			$content .= $parse_page_source(file_get_contents("$page.md"));
+			$content .= $parse_page_source(file_get_contents("$env->page.md"));
 			
 			if($settings->show_subpages)
 			{
-				$subpages = get_object_vars(get_subpages($pageindex, $page));
+				$subpages = get_object_vars(get_subpages($pageindex, $env->page));
 				
 				if(count($subpages) > 0)
 				{
@@ -1723,11 +1743,9 @@ class Slimdown {
 		'/(\*)(.*?)\1/' => '<strong>\2</strong>',					// bold
 		'/(_)(.*?)\1/' => '<em>\2</em>',							// emphasis
 		
-		// todo test these
 		'/!\[(.*)\]\(([^\s]+)\s(\d+.+)\s(left|right)\)/' => '<img src="\2" alt="\1" style="max-width: \3; float: \4;" />',		// images with size
 		'/!\[(.*)\]\(([^\s]+)\s(\d+.+)\)/' => '<img src="\2" alt="\1" style="max-width: \3;" />',		// images with size
 		'/!\[(.*)\]\((.*)\)/' => '<img src="\2" alt="\1" />',		// basic images
-		// todo end
 		
 		'/\[\[([a-zA-Z0-9\_\- ]+)\|([a-zA-Z0-9\_\- ]+)\]\]/' => '<a href=\'index.php?page=\1\'>\2</a>',	//internal links with display text
 		'/\[\[([a-zA-Z0-9\_\- ]+)\]\]/' => '<a href=\'index.php?page=\1\'>\1</a>',	//internal links
@@ -1810,7 +1828,7 @@ if(!isset($actions->credits))
 }
 
 // Perform the appropriate action
-$action_name = strtolower($_GET["action"]);
+$action_name = $env->action;
 if(isset($actions->$action_name))
 {
 	$req_action_data = $actions->$action_name;
@@ -1820,4 +1838,5 @@ else
 {
 	exit(page_renderer::render_main("Error - $settings->sitename", "<p>No action called " . strtolower($_GET["action"]) ." has been registered. Perhaps you are missing a module?</p>"));
 }
+
 ?>
diff --git a/core.php b/core.php
index 2119dbe..451283c 100644
--- a/core.php
+++ b/core.php
@@ -613,9 +613,9 @@ if(!isset($actions->credits))
 }
 
 // Perform the appropriate action
+$action_name = $env->action;
 if(isset($actions->$action_name))
 {
-	$action_name = $env->action;
 	$req_action_data = $actions->$action_name;
 	$req_action_data();
 }
diff --git a/module_index.json b/module_index.json
index 8690248..19ad4dd 100644
--- a/module_index.json
+++ b/module_index.json
@@ -9,11 +9,11 @@
     },
     {
         "name": "Raw page source",
-        "version": "0.2",
+        "version": "0.3",
         "author": "Starbeamrainbowlabs",
         "description": "Adds a 'raw' action that shows you the raw source of a page.",
         "id": "action-raw",
-        "lastupdate": 1442855075
+        "lastupdate": 1442903519
     },
     {
         "name": "Sidebar",
@@ -33,27 +33,27 @@
     },
     {
         "name": "Page deleter",
-        "version": "0.5",
+        "version": "0.6",
         "author": "Starbeamrainbowlabs",
         "description": "Adds an action to allow administrators to delete pages.",
         "id": "page-delete",
-        "lastupdate": 1432497591
+        "lastupdate": 1442929182
     },
     {
         "name": "Page editor",
-        "version": "0.8",
+        "version": "0.9",
         "author": "Starbeamrainbowlabs",
         "description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
         "id": "page-edit",
-        "lastupdate": 1437037997
+        "lastupdate": 1442903905
     },
     {
         "name": "Export",
-        "version": "0.1",
+        "version": "0.2",
         "author": "Starbeamrainbowlabs",
         "description": "Adds a page that you can use to export your wiki as a .zip file. Uses $settings->export_only_allow_admins, which controls whether only admins are allowed to export the wiki.",
         "id": "page-export",
-        "lastupdate": 1437213501
+        "lastupdate": 1442927946
     },
     {
         "name": "Help page",
@@ -73,43 +73,43 @@
     },
     {
         "name": "Login",
-        "version": "0.5",
+        "version": "0.6",
         "author": "Starbeamrainbowlabs",
         "description": "Adds a pair of actions (login and checklogin) that allow users to login. You need this one if you want your users to be able to login.",
         "id": "page-login",
-        "lastupdate": 1438004499
+        "lastupdate": 1442928221
     },
     {
         "name": "Logout",
-        "version": "0.5",
+        "version": "0.6",
         "author": "Starbeamrainbowlabs",
         "description": "Adds an action to let users user out. For security reasons it is wise to add this module since logging in automatically opens a session that is valid for 30 days.",
         "id": "page-logout",
-        "lastupdate": 1432497592
+        "lastupdate": 1442928225
     },
     {
         "name": "Page mover",
-        "version": "0.5",
+        "version": "0.6",
         "author": "Starbeamrainbowlabs",
         "description": "Adds an action to allow administrators to move pages.",
         "id": "page-move",
-        "lastupdate": 1432497592
+        "lastupdate": 1442928409
     },
     {
         "name": "Update",
-        "version": "0.6",
+        "version": "0.6.1",
         "author": "Starbeamrainbowlabs",
         "description": "Adds an update page that downloads the latest stable version of Pepperminty Wiki. This module is currently outdated as it doesn't save your module preferences.",
         "id": "page-update",
-        "lastupdate": 1432497592
+        "lastupdate": 1442928402
     },
     {
         "name": "Page viewer",
-        "version": "0.8",
+        "version": "0.9",
         "author": "Starbeamrainbowlabs",
         "description": "Allows you to view pages. You should include this one.",
         "id": "page-view",
-        "lastupdate": 1436889857
+        "lastupdate": 1442928503
     },
     {
         "name": "Default Parser",
@@ -117,6 +117,6 @@
         "author": "Johnny Broadway & Starbeamrainbowlabs",
         "description": "The default parser for Pepperminty Wiki. Based on Johnny Broadway's Slimdown (with more than a few modifications). This parser's features are documented in the help page.",
         "id": "parser-default",
-        "lastupdate": 1432720270
+        "lastupdate": 1442928533
     }
 ]
\ No newline at end of file
