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

Update build

This commit is contained in:
Starbeamrainbowlabs 2015-11-06 20:11:58 +00:00
parent 8425660d6b
commit d5f1050d79
2 changed files with 1241 additions and 1246 deletions

View file

@ -19,7 +19,7 @@ $start_time = time(true);
$settings = new stdClass(); $settings = new stdClass();
// The site's name. Used all over the place. // The site's name. Used all over the place.
// Note that by default the session cookie is perfixed with a variant of the // Note that by default the session cookie is prefixed with a variant of the
// sitename so changing this will log everyone out! // sitename so changing this will log everyone out!
$settings->sitename = "Pepperminty Wiki"; $settings->sitename = "Pepperminty Wiki";
@ -36,13 +36,21 @@ $settings->logo_position = "left";
// branch If there is sufficient demand, a separate stable branch will be // branch If there is sufficient demand, a separate stable branch will be
// created. Note that if you use the automatic updater currently it won't save // created. Note that if you use the automatic updater currently it won't save
// your module choices. // your module choices.
// MAKE SURE THAT THIS POINTS TO A *HTTPS* URL, OTHERWISE SOMEONE COULD INJECT A VIRUS INTO YOUR WIKI // MAKE SURE THAT THIS POINTS TO A *HTTPS* URL, OTHERWISE SOMEONE COULD INJECT
// A VIRUS INTO YOUR WIKI
$settings->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, // The secret key used to perform 'dangerous' actions, like updating the wiki,
// and deleting pages. It is strongly advised that you change this! // and deleting pages. It is strongly advised that you change this!
$settings->sitesecret = "ed420502615bac9037f8f12abd4c9f02"; $settings->sitesecret = "ed420502615bac9037f8f12abd4c9f02";
// The directory in which to store all files, except this main index.php.
// A single dot ('.') denotes the current directory.
// Remember to leave the trailing slash from the directory name, as it is added
// automatically by Pepperminty Wiki.
// Note that this setting is currently experimental.
$settings->data_storage_dir = ".";
// Determined whether edit is enabled. Set to false to disable disting for all // Determined whether edit is enabled. Set to false to disable disting for all
// users (anonymous or otherwise). // users (anonymous or otherwise).
$settings->editing = true; $settings->editing = true;
@ -337,12 +345,26 @@ Actions:
/////////////// Do not edit below this line unless you know what you are doing! /////////////// /////////////// Do not edit below this line unless you know what you are doing! ///////////////
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
$version = "v0.9-dev"; $version = "v0.9-dev";
/// Environment ///
$env = new stdClass(); $env = new stdClass();
$env->action = $settings->defaultaction; $env->action = $settings->defaultaction;
$env->page = ""; $env->page = "";
$env->user = "Anonymous"; $env->user = "Anonymous";
$env->is_logged_in = false; $env->is_logged_in = false;
$env->is_admin = false; $env->is_admin = false;
$env->storage_prefix = $settings->data_storage_dir . DIRECTORY_SEPARATOR;
/// Paths ///
$paths = new stdClass();
$paths->pageindex = "pageindex.json"; // The pageindex
$paths->searchindex = "invindex.json"; // The inverted index used for searching
$paths->idindex = "idindex.json"; // The index that converts ids to page names
// Prepend the storage data directory to all the defined paths.
foreach ($paths as &$path) {
$path = $env->storage_prefix . $path;
}
$paths->upload_file_prefix = "Files/"; // The prefix to append to uploaded files
session_start(); session_start();
///////// Login System ///////// ///////// Login System /////////
@ -585,33 +607,6 @@ function starts_with($haystack, $needle)
return (substr($haystack, 0, $length) === $needle); return (substr($haystack, 0, $length) === $needle);
} }
/**
* mb_stripos all occurences
* from http://www.pontikis.net/tip/?id=16
* based on http://www.php.net/manual/en/function.strpos.php#87061
*
* Find all occurrences of a needle in a haystack (case-insensitive, UTF8)
*
* @param string $haystack
* @param string $needle
* @return array or false
*/
function mb_stripos_all($haystack, $needle) {
$s = 0; $i = 0;
while(is_integer($i)) {
$i = function_exists("mb_stripos") ? mb_stripos($haystack, $needle, $s) : stripos($haystack, $needle, $s);
if(is_integer($i)) {
$aStrPos[] = $i;
$s = $i + (function_exists("mb_strlen") ? mb_strlen($needle) : strlen($needle));
}
}
if(isset($aStrPos))
return $aStrPos;
else
return false;
}
function system_mime_type_extensions() { function system_mime_type_extensions() {
global $settings; global $settings;
# Returns the system MIME type mapping of MIME types to extensions, as defined in /etc/mime.types (considering the first # Returns the system MIME type mapping of MIME types to extensions, as defined in /etc/mime.types (considering the first
@ -653,9 +648,9 @@ function system_mime_type_extension($type) {
* Sort out the pageindex. We create it if it doesn't exist, and load and parse * Sort out the pageindex. We create it if it doesn't exist, and load and parse
* it if it does. * it if it does.
*/ */
if(!file_exists("./pageindex.json")) if(!file_exists($paths->pageindex))
{ {
$existingpages = glob_recursive("*.md"); $existingpages = glob_recursive($env->storage_prefix . "*.md");
$pageindex = new stdClass(); $pageindex = new stdClass();
// We use a for loop here because foreach doesn't loop over new values inserted // We use a for loop here because foreach doesn't loop over new values inserted
// while we were looping // while we were looping
@ -665,13 +660,13 @@ if(!file_exists("./pageindex.json"))
// Create a new entry // Create a new entry
$newentry = new stdClass(); $newentry = new stdClass();
$newentry->filename = utf8_encode($pagefilename); // Store the filename $newentry->filename = utf8_encode(substr($pagefilename, strlen($env->storage_prefix))); // Store the filename
$newentry->size = filesize($pagefilename); // Store the page size $newentry->size = filesize($pagefilename); // Store the page size
$newentry->lastmodified = filemtime($pagefilename); // Store the date last modified $newentry->lastmodified = filemtime($pagefilename); // Store the date last modified
// Todo find a way to keep the last editor independent of the page index // Todo find a way to keep the last editor independent of the page index
$newentry->lasteditor = utf8_encode("unknown"); // Set the editor to "unknown" $newentry->lasteditor = utf8_encode("unknown"); // Set the editor to "unknown"
// Extract the name of the (sub)page without the ".md" // Extract the name of the (sub)page without the ".md" or the storage dir
$pagekey = utf8_encode(substr($pagefilename, 0, -3)); $pagekey = utf8_encode(substr($pagefilename, strlen($env->storage_prefix), -3));
// Subpage parent checker // Subpage parent checker
if(strpos($pagekey, "/") !== false) if(strpos($pagekey, "/") !== false)
@ -681,7 +676,7 @@ if(!file_exists("./pageindex.json"))
// make sure that it actually exists. If it doesn't, then we need to // make sure that it actually exists. If it doesn't, then we need to
// create it. // create it.
$subpage_parent_key = substr($pagekey, 0, strrpos($pagekey, "/")); $subpage_parent_key = substr($pagekey, 0, strrpos($pagekey, "/"));
$subpage_parent_filename = "$subpage_parent_key.md"; $subpage_parent_filename = "$env->storage_prefix$subpage_parent_key.md";
if(array_search($subpage_parent_filename, $existingpages) === false) if(array_search($subpage_parent_filename, $existingpages) === false)
{ {
// Our parent page doesn't actually exist - create it // Our parent page doesn't actually exist - create it
@ -695,22 +690,22 @@ if(!file_exists("./pageindex.json"))
// Store the new entry in the new page index // Store the new entry in the new page index
$pageindex->$pagekey = $newentry; $pageindex->$pagekey = $newentry;
} }
file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT)); file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT));
unset($existingpages); unset($existingpages);
} }
else else
{ {
$pageindex_read_start = microtime(true); $pageindex_read_start = microtime(true);
$pageindex = json_decode(file_get_contents("./pageindex.json")); $pageindex = json_decode(file_get_contents($paths->pageindex));
header("x-pageindex-decode-time: " . round(microtime(true) - $pageindex_read_start, 6) . "ms"); header("x-pageindex-decode-time: " . round(microtime(true) - $pageindex_read_start, 6) . "ms");
} }
////////////////////////// //////////////////////////
///// Page id system ///// ///// Page id system /////
////////////////////////// //////////////////////////
if(!file_exists("idindex.json")) if(!file_exists($paths->idindex))
file_put_contents("idindex.json", "{}"); file_put_contents($paths->idindex, "{}");
$idindex = json_decode(file_get_contents("idindex.json")); $idindex = json_decode(file_get_contents($paths->idindex));
class ids class ids
{ {
/* /*
@ -760,7 +755,7 @@ class ids
$idindex->$nextid = utf8_encode($pagename); $idindex->$nextid = utf8_encode($pagename);
// Save the id index // Save the id index
file_put_contents("idindex.json", json_encode($idindex)); file_put_contents($paths->idindex, json_encode($idindex));
return $nextid; return $nextid;
} }

View file

@ -5,7 +5,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a utility action (that anyone can use) called hash that hashes a given string. Useful when changing a user's password.", "description": "Adds a utility action (that anyone can use) called hash that hashes a given string. Useful when changing a user's password.",
"id": "action-hash", "id": "action-hash",
"lastupdate": 1444481636, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -14,7 +14,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Exposes Pepperminty Wiki's new page protection mechanism and makes the protect button in the 'More...' menu on the top bar work.", "description": "Exposes Pepperminty Wiki's new page protection mechanism and makes the protect button in the 'More...' menu on the top bar work.",
"id": "action-protect", "id": "action-protect",
"lastupdate": 1443596834, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -23,7 +23,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a 'raw' action that shows you the raw source of a page.", "description": "Adds a 'raw' action that shows you the raw source of a page.",
"id": "action-raw", "id": "action-raw",
"lastupdate": 1442907118, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -32,7 +32,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a sidebar to the left hand side of every page. Add '$settings->sidebar_show = true;' to your configuration, or append '&sidebar=yes' to the url to enable. Adding to the url sets a cookie to remember your setting.", "description": "Adds a sidebar to the left hand side of every page. Add '$settings->sidebar_show = true;' to your configuration, or append '&sidebar=yes' to the url to enable. Adding to the url sets a cookie to remember your setting.",
"id": "extra-sidebar", "id": "extra-sidebar",
"lastupdate": 1438780254, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -41,7 +41,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds support for redirect pages. Uses the same syntax that Mediawiki does.", "description": "Adds support for redirect pages. Uses the same syntax that Mediawiki does.",
"id": "feature-redirect", "id": "feature-redirect",
"lastupdate": 1444299144, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -50,7 +50,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds proper search functionality to Pepperminty Wiki. Note that this module, at the moment, just contains test code while I figure out how best to write a search engine.", "description": "Adds proper search functionality to Pepperminty Wiki. Note that this module, at the moment, just contains test code while I figure out how best to write a search engine.",
"id": "feature-search", "id": "feature-search",
"lastupdate": 1446473866, "lastupdate": 1446717614,
"optional": false "optional": false
}, },
{ {
@ -59,7 +59,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.", "description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.",
"id": "feature-upload", "id": "feature-upload",
"lastupdate": 1446021592, "lastupdate": 1445716955,
"optional": false "optional": false
}, },
{ {
@ -68,7 +68,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds the credits page. You *must* have this module :D", "description": "Adds the credits page. You *must* have this module :D",
"id": "page-credits", "id": "page-credits",
"lastupdate": 1444327084, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -77,7 +77,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds an action to allow administrators to delete pages.", "description": "Adds an action to allow administrators to delete pages.",
"id": "page-delete", "id": "page-delete",
"lastupdate": 1446021592, "lastupdate": 1445771075,
"optional": false "optional": false
}, },
{ {
@ -86,7 +86,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", "description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id": "page-edit", "id": "page-edit",
"lastupdate": 1446470780, "lastupdate": 1446388267,
"optional": false "optional": false
}, },
{ {
@ -95,7 +95,7 @@
"author": "Starbeamrainbowlabs", "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.", "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", "id": "page-export",
"lastupdate": 1442931546, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -104,7 +104,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds the help action. You really want this one.", "description": "Adds the help action. You really want this one.",
"id": "page-help", "id": "page-help",
"lastupdate": 1432664722, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -113,7 +113,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a page that lists all the pages in the index along with their metadata.", "description": "Adds a page that lists all the pages in the index along with their metadata.",
"id": "page-list", "id": "page-list",
"lastupdate": 1446021592, "lastupdate": 1445787342,
"optional": false "optional": false
}, },
{ {
@ -122,7 +122,7 @@
"author": "Starbeamrainbowlabs", "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.", "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", "id": "page-login",
"lastupdate": 1444481426, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -131,7 +131,7 @@
"author": "Starbeamrainbowlabs", "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.", "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", "id": "page-logout",
"lastupdate": 1442931824, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -140,7 +140,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds an action to allow administrators to move pages.", "description": "Adds an action to allow administrators to move pages.",
"id": "page-move", "id": "page-move",
"lastupdate": 1446021592, "lastupdate": 1445771483,
"optional": false "optional": false
}, },
{ {
@ -149,7 +149,7 @@
"author": "Starbeamrainbowlabs", "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.", "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", "id": "page-update",
"lastupdate": 1442932002, "lastupdate": 1445170746,
"optional": false "optional": false
}, },
{ {
@ -158,7 +158,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Allows you to view pages. You reallyshould include this one.", "description": "Allows you to view pages. You reallyshould include this one.",
"id": "page-view", "id": "page-view",
"lastupdate": 1446021592, "lastupdate": 1445789184,
"optional": false "optional": false
}, },
{ {
@ -167,7 +167,7 @@
"author": "Johnny Broadway & Starbeamrainbowlabs", "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.", "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", "id": "parser-default",
"lastupdate": 1446470780, "lastupdate": 1446116543,
"optional": false "optional": false
}, },
{ {
@ -176,7 +176,7 @@
"author": "Johnny Broadway, Emanuil Rusev & Starbeamrainbowlabs", "author": "Johnny Broadway, Emanuil Rusev & Starbeamrainbowlabs",
"description": "An upgraded parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Also uses a modified Slimdown engine by Johnny Broadway in order to add support for internal links etc. Please be careful, as this module adds a _ton_ of weight to your installation.", "description": "An upgraded parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Also uses a modified Slimdown engine by Johnny Broadway in order to add support for internal links etc. Please be careful, as this module adds a _ton_ of weight to your installation.",
"id": "parser-parsedown", "id": "parser-parsedown",
"lastupdate": 1443972016, "lastupdate": 1445170746,
"optional": true "optional": true
} }
] ]