2013-07-19 01:05:12 +00:00
|
|
|
<?php
|
2013-09-13 22:39:03 +00:00
|
|
|
/**
|
|
|
|
* This function is beign used to change the permission of a ticket_user.
|
|
|
|
* It will first check if the user who executed this function is an admin. If this is not the case the page will be redirected to an error page.
|
|
|
|
* in case the $_GET['value'] is smaller than 4 and the user whoes permission is being changed is different from the admin(id 1), the change will be executed and the page will
|
|
|
|
* redirect to the users profile page.
|
|
|
|
* @author Daan Janssens, mentored by Matthew Lagoe
|
|
|
|
*/
|
2013-07-19 01:05:12 +00:00
|
|
|
function change_permission(){
|
2013-09-09 01:47:32 +00:00
|
|
|
global $INGAME_WEBPATH;
|
|
|
|
global $WEBPATH;
|
|
|
|
//if logged in
|
2013-07-19 01:05:12 +00:00
|
|
|
if(WebUsers::isLoggedIn()){
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//check if user who executed this function is an admin
|
2013-09-09 01:47:32 +00:00
|
|
|
if(ticket_user::isAdmin(unserialize($_SESSION['ticket_user']))){
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//in case the $_GET['value'] is smaller than 4 and the user whoes permission is being changed is different from the admin(id 1)
|
2013-07-19 01:05:12 +00:00
|
|
|
if(isset($_GET['user_id']) && isset($_GET['value']) && $_GET['user_id'] != 1 && $_GET['value'] < 4 ){
|
|
|
|
$user_id = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
|
|
|
|
$value = filter_var($_GET['value'], FILTER_SANITIZE_NUMBER_INT);
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-09-13 22:39:03 +00:00
|
|
|
//execute change.
|
2013-08-06 02:31:01 +00:00
|
|
|
Ticket_User::change_permission(Ticket_User::constr_ExternId($user_id)->getTUserId(), $value);
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-09-09 01:47:32 +00:00
|
|
|
if (Helpers::check_if_game_client()) {
|
|
|
|
header("Location: ".$INGAME_WEBPATH."?page=show_user&id=".$user_id);
|
|
|
|
}else{
|
|
|
|
header("Location: ".$WEBPATH."?page=show_user&id=".$user_id);
|
|
|
|
}
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2014-09-03 05:06:43 +00:00
|
|
|
|
|
|
|
|
2013-07-19 01:05:12 +00:00
|
|
|
}else{
|
|
|
|
//ERROR: GET PARAMS not given or trying to change admin
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-09-09 01:47:32 +00:00
|
|
|
if (Helpers::check_if_game_client()) {
|
|
|
|
header("Location: ".$INGAME_WEBPATH."?page=show_user&id=".$user_id);
|
|
|
|
}else{
|
|
|
|
header("Location: ".$WEBPATH."?page=show_user&id=".$user_id);
|
|
|
|
}
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2013-07-19 01:05:12 +00:00
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-19 01:05:12 +00:00
|
|
|
}else{
|
|
|
|
//ERROR: No access!
|
|
|
|
$_SESSION['error_code'] = "403";
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-07-19 01:05:12 +00:00
|
|
|
header("Location: index.php?page=error");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-19 01:05:12 +00:00
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
|
2013-07-19 01:05:12 +00:00
|
|
|
}else{
|
|
|
|
//ERROR: not logged in!
|
2014-09-03 05:36:10 +00:00
|
|
|
header("Cache-Control: max-age=1");
|
2013-07-19 01:05:12 +00:00
|
|
|
header("Location: index.php");
|
2014-09-03 05:23:39 +00:00
|
|
|
throw new SystemExit();
|
2013-07-19 01:05:12 +00:00
|
|
|
}
|
2014-09-03 05:06:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|