Fix bug: prevent CSRF attacks to admin page
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@174 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
15b91c7e66
commit
111bcdec75
1 changed files with 29 additions and 28 deletions
17
admin.php
17
admin.php
|
@ -26,6 +26,9 @@ $bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
|||
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
|
||||
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
||||
|
||||
/* Managing current logged user */
|
||||
$currentUser = $userservice->getCurrentObjectUser();
|
||||
|
||||
// Header variables
|
||||
$tplVars['subtitle'] = T_('Manage users');
|
||||
$tplVars['loadjs'] = true;
|
||||
|
@ -36,19 +39,17 @@ if ( !$userservice->isLoggedOn() ) {
|
|||
exit();
|
||||
}
|
||||
|
||||
//$currentUser = $userservice->getCurrentUser();
|
||||
//$currentUserID = $userservice->getCurrentUserId();
|
||||
//$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
||||
$currentObjectUser = $userservice->getCurrentObjectUser();
|
||||
|
||||
if ( !$currentObjectUser->isAdmin() ) {
|
||||
header('Location: '. createURL('bookmarks', $currentObjectUser->getUsername()));
|
||||
if ( !$currentUser->isAdmin() ) {
|
||||
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
|
||||
exit();
|
||||
}
|
||||
|
||||
@list($url, $action, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
||||
|
||||
if ( $action ) {
|
||||
|
||||
if ( $action
|
||||
&& strpos($_SERVER['HTTP_REFERER'], ROOT.'/admin.php') == 0 // Prevent CSRF attacks
|
||||
) {
|
||||
switch ( $action ) {
|
||||
case 'delete':
|
||||
if ( $user && ($userinfo = $userservice->getUserByUsername($user)) ) {
|
||||
|
|
Loading…
Reference in a new issue