forked from supertuxkart/stk-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[stkaddons] Rewrote "access denied" page to be less annoying to code …
…around
- Loading branch information
stephenjust
committed
Sep 26, 2012
1 parent
7ab29a7
commit 67bbad8
Showing
27 changed files
with
174 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
*/ | ||
|
||
define('ROOT','./web/'); | ||
$security = ''; | ||
require (ROOT.'include.php'); | ||
|
||
log_email(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
*/ | ||
|
||
define('ROOT','./'); | ||
$security = ''; | ||
include_once('include.php'); | ||
|
||
$xml = writeNewsXML(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
/** | ||
* copyright 2012 Stephen Just <[email protected]> | ||
* | ||
* This file is part of stkaddons | ||
* | ||
* stkaddons is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* stkaddons is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with stkaddons. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
require_once(ROOT.'include/sql.php'); | ||
require_once(ROOT.'include/File.class.php'); | ||
require_once(ROOT.'include/User.class.php'); | ||
|
||
class AccessControl { | ||
// Define permission levels | ||
private static $permissions = array( | ||
'basicUser' => array( | ||
'basicPage' => true, | ||
'addAddon' => true, | ||
'manageaddons' => false, | ||
'managebasicUsers' => false, | ||
'managemoderators' => false, | ||
'manageadministrators' => false, | ||
'manageroots' => false, | ||
'managesettings' => false | ||
), | ||
'moderator' => array( | ||
'basicPage' => true, | ||
'addAddon' => true, | ||
'manageaddons' => true, | ||
'managebasicUsers' => true, | ||
'managemoderators' => false, | ||
'manageadministrators' => false, | ||
'manageroots' => false, | ||
'managesettings' => false | ||
), | ||
'administrator' => array( | ||
'basicPage' => true, | ||
'addAddon' => true, | ||
'manageaddons' => true, | ||
'managebasicUsers' => true, | ||
'managemoderators' => true, | ||
'manageadministrators' => false, | ||
'manageroots' => false, | ||
'managesettings' => true | ||
), | ||
'root' => array( | ||
'basicPage' => true, | ||
'addAddon' => true, | ||
'manageaddons' => true, | ||
'managebasicUsers' => true, | ||
'managemoderators' => true, | ||
'manageadministrators' => true, | ||
'manageroots' => true, | ||
'managesettings' => true | ||
) | ||
); | ||
|
||
public static function setLevel($accessLevel) { | ||
$role = User::getRole(); | ||
if (is_null($accessLevel)) return true; | ||
|
||
$allow = false; | ||
if ($role == 'unregistered' && $accessLevel == NULL) { | ||
$allow = true; | ||
} elseif ($role == 'unregistered') { | ||
$allow = false; | ||
} else | ||
$allow = AccessControl::$permissions[$role][$accessLevel]; | ||
|
||
if ($allow === false) | ||
AccessControl::showAccessDeniedPage(); | ||
} | ||
|
||
public static function showAccessDeniedPage() { | ||
header('HTTP/1.0 401 Unauthorized'); | ||
Template::setFile('access-denied.tpl'); | ||
$fields = array( | ||
'ad_reason' => htmlspecialchars(_('You do not have permission to access this page.')), | ||
'ad_action' => htmlspecialchars(_('You will be redirected to the home page.')), | ||
'ad_redirect_url' => File::rewrite('index.php') | ||
); | ||
|
||
Template::assignments($fields); | ||
Template::display(); | ||
|
||
exit; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.