1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-06-08 23:54:00 +00:00

Added administrators, ready for page moving / deleting

This commit is contained in:
Starbeamrainbowlabs 2014-12-26 18:14:38 +00:00
parent 9d31bcc6c3
commit aed3cdabbb
3 changed files with 64 additions and 10 deletions

View file

@ -34,6 +34,19 @@ else
setcookie($cookieprefix . "-pass", null, -1, "/"); setcookie($cookieprefix . "-pass", null, -1, "/");
} }
} }
//check to see if the currently logged in user is an admin
$isadmin = false;
if($isloggedin)
{
foreach($admins as $admin_username)
{
if($admin_username == $user)
{
$isadmin = true;
break;
}
}
}
/////// Login System End /////// /////// Login System End ///////
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -123,7 +136,7 @@ if(makepathsafe($_GET["page"]) !== $_GET["page"])
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
function renderpage($title, $content, $minimal = false) function renderpage($title, $content, $minimal = false)
{ {
global $sitename, $css, $favicon, $user, $isloggedin, $navlinks, $admindetails, $start_time, $pageindex; global $sitename, $css, $favicon, $user, $isloggedin, $isadmin, $admindisplaychar, $navlinks, $admindetails, $start_time, $pageindex;
$html = "<!DOCTYPE HTML> $html = "<!DOCTYPE HTML>
<html><head> <html><head>
@ -155,7 +168,13 @@ function renderpage($title, $content, $minimal = false)
$html .= "<nav>\n"; $html .= "<nav>\n";
if($isloggedin) if($isloggedin)
$html .= "\t\tLogged in as $user. <a href='index.php?action=logout'>Logout</a>. | \n"; {
$html .= "\t\tLogged in as ";
if($isadmin)
$html .= $admindisplaychar;
$html .= "$user. <a href='index.php?action=logout'>Logout</a>. | \n";
}
else else
$html .= "\t\tBrowsing as Anonymous. <a href='index.php?action=login'>Login</a>. | \n"; $html .= "\t\tBrowsing as Anonymous. <a href='index.php?action=login'>Login</a>. | \n";

View file

@ -9,6 +9,7 @@ $start_time = time(true);
* Link: https://github.com/am2064/Minty-Wiki * Link: https://github.com/am2064/Minty-Wiki
* *
* Credits: * Credits:
* Code by @Starbeamrainbowlabs
* Slimdown - by Johnny Broadway from https://gist.github.com/jbroadway/2836900 * Slimdown - by Johnny Broadway from https://gist.github.com/jbroadway/2836900
*/ */
@ -43,6 +44,19 @@ $users = [
"user" => "873ac9ffea4dd04fa719e8920cd6938f0c23cd678af330939cff53c3d2855f34" //cheese "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" ];
//The string that is prepended before an admin's name on the nav bar. defaults to a diamond shape (&#9670;).
$admindisplaychar = "&#9670;";
//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 obfusticateed to deter spammers.
$admindetails = [
"name" => "Administrator",
"email" => "admin@localhost"
];
//array of links and display text to display at the top of the site //array of links and display text to display at the top of the site
$navlinks = [ $navlinks = [
[ "Home", "index.php" ], [ "Home", "index.php" ],
@ -60,12 +74,6 @@ $navlinks = [
[ "Help", "index.php?action=help" ] [ "Help", "index.php?action=help" ]
]; ];
//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 obfusticateed to deter spammers.
$admindetails = [
"name" => "Administrator",
"email" => "admin@localhost"
];
//string of css to include //string of css to include
$css = "body { font-family: sans-serif; color: #333333; background: #f3f3f3; } $css = "body { font-family: sans-serif; color: #333333; background: #f3f3f3; }
textarea[name=content] { display: block; width: 100%; height: 35rem; } textarea[name=content] { display: block; width: 100%; height: 35rem; }
@ -135,6 +143,19 @@ else
setcookie($cookieprefix . "-pass", null, -1, "/"); setcookie($cookieprefix . "-pass", null, -1, "/");
} }
} }
//check to see if the currently logged in user is an admin
$isadmin = false;
if($isloggedin)
{
foreach($admins as $admin_username)
{
if($admin_username == $user)
{
$isadmin = true;
break;
}
}
}
/////// Login System End /////// /////// Login System End ///////
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -224,7 +245,7 @@ if(makepathsafe($_GET["page"]) !== $_GET["page"])
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
function renderpage($title, $content, $minimal = false) function renderpage($title, $content, $minimal = false)
{ {
global $sitename, $css, $favicon, $user, $isloggedin, $navlinks, $admindetails, $start_time, $pageindex; global $sitename, $css, $favicon, $user, $isloggedin, $isadmin, $admindisplaychar, $navlinks, $admindetails, $start_time, $pageindex;
$html = "<!DOCTYPE HTML> $html = "<!DOCTYPE HTML>
<html><head> <html><head>
@ -256,7 +277,13 @@ function renderpage($title, $content, $minimal = false)
$html .= "<nav>\n"; $html .= "<nav>\n";
if($isloggedin) if($isloggedin)
$html .= "\t\tLogged in as $user. <a href='index.php?action=logout'>Logout</a>. | \n"; {
$html .= "\t\tLogged in as ";
if($isadmin)
$html .= $admindisplaychar;
$html .= "$user. <a href='index.php?action=logout'>Logout</a>. | \n";
}
else else
$html .= "\t\tBrowsing as Anonymous. <a href='index.php?action=login'>Login</a>. | \n"; $html .= "\t\tBrowsing as Anonymous. <a href='index.php?action=login'>Login</a>. | \n";

View file

@ -6,6 +6,7 @@
* Link: https://github.com/am2064/Minty-Wiki * Link: https://github.com/am2064/Minty-Wiki
* *
* Credits: * Credits:
* Code by @Starbeamrainbowlabs
* Slimdown - by Johnny Broadway from https://gist.github.com/jbroadway/2836900 * Slimdown - by Johnny Broadway from https://gist.github.com/jbroadway/2836900
*/ */
@ -40,6 +41,13 @@ $users = [
"user" => "873ac9ffea4dd04fa719e8920cd6938f0c23cd678af330939cff53c3d2855f34" //cheese "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" ];
//The string that is prepended before an admin's name on the nav bar. defaults to a diamond shape (&#9670;).
$admindisplaychar = "&#9670;";
//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 obfusticateed to deter spammers. //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 obfusticateed to deter spammers.
$admindetails = [ $admindetails = [
"name" => "Administrator", "name" => "Administrator",