本文整理汇总了PHP中Ticket_User::isMod方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket_User::isMod方法的具体用法?PHP Ticket_User::isMod怎么用?PHP Ticket_User::isMod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticket_User
的用法示例。
在下文中一共展示了Ticket_User::isMod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plugins_update
/**
* function plugins_update to get
* plugins updates from the Database using pagination object.
*
* @author shubham meena mentored by Matthew Lagoe
*/
function plugins_update()
{
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$pagination = new Pagination("SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId", "lib", 5, "Plugincache");
$pageResult['plug'] = Gui_Elements::make_table($pagination->getElements(), array("getId", "getPluginName", "getPluginInfo", "getUpdateInfo"), array("id", "plugin_name", "plugin_info", "update_info"));
$pageResult['links'] = $pagination->getLinks(5);
$pageResult['lastPage'] = $pagination->getLast();
$pageResult['currentPage'] = $pagination->getCurrent();
global $INGAME_WEBPATH;
$pageResult['ingame_webpath'] = $INGAME_WEBPATH;
// check if shard is online
try {
$dbs = new DBLayer("shard");
$pageResult['shard'] = "online";
} catch (PDOException $e) {
$pageResult['shard'] = "offline";
}
return $pageResult;
} else {
// ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
}
示例2: userlist
/**
* This function is beign used to load info that's needed for the userlist page.
* this function will return all users by using he pagination class, so that it can be used in the template. Only Mods and Admins can browse this page though.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function userlist()
{
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$pagination = new Pagination(WebUsers::getAllUsersQuery(), "web", 10, "WebUsers");
$pageResult['userlist'] = Gui_Elements::make_table($pagination->getElements(), array("getUId", "getUsername", "getEmail"), array("id", "username", "email"));
$pageResult['links'] = $pagination->getLinks(5);
$pageResult['lastPage'] = $pagination->getLast();
$pageResult['currentPage'] = $pagination->getCurrent();
$i = 0;
foreach ($pageResult['userlist'] as $user) {
$pageResult['userlist'][$i]['permission'] = Ticket_User::constr_ExternId($pageResult['userlist'][$i]['id'])->getPermission();
$i++;
}
if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) {
$pageResult['isAdmin'] = "TRUE";
}
global $INGAME_WEBPATH;
$pageResult['ingame_webpath'] = $INGAME_WEBPATH;
global $BASE_WEBPATH;
$pageResult['base_webpath'] = $BASE_WEBPATH;
return $pageResult;
} else {
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
}
示例3: reply_on_ticket
/**
* This function is beign used to reply on a ticket.
* It will first check if the user who executed this function is a mod/admin or the topic creator himself. If this is not the case the page will be redirected to an error page.
* in case the isset($_POST['hidden'] is set and the user is a mod, the message will be hidden for the topic starter. The reply will be created. If $_POST['ChangeStatus']) & $_POST['ChangePriority'] is set
* it will try to update the status and priority. Afterwards the page is being redirecte to the ticket again.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function reply_on_ticket()
{
global $INGAME_WEBPATH;
global $WEBPATH;
//if logged in
if (WebUsers::isLoggedIn() && isset($_POST['ticket_id'])) {
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
$target_ticket = new Ticket();
$target_ticket->load_With_TId($ticket_id);
//check if the user who executed this function is a mod/admin or the topic creator himself.
if ($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
try {
$author = unserialize($_SESSION['ticket_user'])->getTUserId();
if (isset($_POST['Content'])) {
$content = $_POST['Content'];
} else {
$content = "";
}
$hidden = 0;
if (isset($_POST['hidden']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$hidden = 1;
}
//create the reply
Ticket::createReply($content, $author, $ticket_id, $hidden);
//try to update the status & priority in case these are set.
if (isset($_POST['ChangeStatus']) && isset($_POST['ChangePriority']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$newStatus = filter_var($_POST['ChangeStatus'], FILTER_SANITIZE_NUMBER_INT);
$newPriority = filter_var($_POST['ChangePriority'], FILTER_SANITIZE_NUMBER_INT);
Ticket::updateTicketStatusAndPriority($ticket_id, $newStatus, $newPriority, $author);
}
header("Cache-Control: max-age=1");
if (Helpers::check_if_game_client()) {
header("Location: " . $INGAME_WEBPATH . "?page=show_ticket&id=" . $ticket_id);
} else {
header("Location: " . $WEBPATH . "?page=show_ticket&id=" . $ticket_id);
}
throw new SystemExit();
} catch (PDOException $e) {
//ERROR: LIB DB is not online!
print_r($e);
//header("Location: index.php");
throw new SystemExit();
}
} else {
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
} else {
//ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php");
throw new SystemExit();
}
}
示例4: settings
/**
* This function is beign used to load info that's needed for the settings page.
* check if the person who wants to view this page is a mod/admin or the user to whom te settings belong himself, if this is not the case, he will be redirected to an error page.
* it will return a lot of information of that user, that's being used for loading the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function settings()
{
if (WebUsers::isLoggedIn()) {
//in case id-GET param set it's value as target_id, if no id-param is given, ue the session id.
if (isset($_GET['id'])) {
if ($_GET['id'] != $_SESSION['id'] && !Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
} else {
$webUser = new Webusers($_GET['id']);
$result = $webUser->getInfo();
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) && $_GET['id'] != $_SESSION['id']) {
$result['changesOther'] = "TRUE";
}
$result['target_id'] = $_GET['id'];
$result['current_mail'] = $webUser->getEmail();
$result['target_username'] = $webUser->getUsername();
}
} else {
$webUser = new Webusers($_SESSION['id']);
$result = $webUser->getInfo();
$result['target_id'] = $_SESSION['id'];
$result['current_mail'] = $webUser->getEmail();
$result['target_username'] = $webUser->getUsername();
}
//Sanitize Data
$result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL);
$result['target_username'] = filter_var($result['target_username'], FILTER_SANITIZE_STRING);
$result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING);
$result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING);
$result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING);
$result['Gender'] = filter_var($result['Gender'], FILTER_SANITIZE_NUMBER_INT);
$result['ReceiveMail'] = filter_var($result['ReceiveMail'], FILTER_SANITIZE_NUMBER_INT);
$result['country_array'] = getCountryArray();
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
$dbl = new DBLayer("lib");
$statement = $dbl->executeWithoutParams("SELECT * FROM settings");
$rows = $statement->fetchAll();
foreach ($rows as &$value) {
$result[$value['Setting']] = $value['Value'];
}
return $result;
} else {
//ERROR: not logged in!
header("Location: index.php");
header("Cache-Control: max-age=1");
throw new SystemExit();
}
}
示例5: show_ticket_info
/**
* This function is beign used to load info that's needed for the show_ticket_info page.
* check if the person browsing this page is a mod/admin or the ticket creator himself, if not he'll be redirected to an error page.
* not all tickets have this page related to it, only tickets created ingame will have additional information. The returned info will be used by the template to show the show_ticket_info page.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function show_ticket_info()
{
//if logged in
if (WebUsers::isLoggedIn() && isset($_GET['id'])) {
$result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$target_ticket = new Ticket();
$target_ticket->load_With_TId($result['ticket_id']);
if ($target_ticket->hasInfo() && ($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])))) {
$result['ticket_title'] = $target_ticket->getTitle();
$result['ticket_author'] = $target_ticket->getAuthor();
$ticket_info = new Ticket_Info();
$ticket_info->load_With_Ticket($result['ticket_id']);
$result['shard_id'] = $ticket_info->getShardId();
$result['user_position'] = $ticket_info->getUser_Position();
$result['view_position'] = $ticket_info->getView_Position();
$result['client_version'] = $ticket_info->getClient_Version();
$result['patch_version'] = $ticket_info->getPatch_Version();
$result['server_tick'] = $ticket_info->getServer_Tick();
$result['connect_state'] = $ticket_info->getConnect_State();
$result['local_address'] = $ticket_info->getLocal_Address();
$result['memory'] = $ticket_info->getMemory();
$result['os'] = $ticket_info->getOS();
$result['processor'] = $ticket_info->getProcessor();
$result['cpu_id'] = $ticket_info->getCPUId();
$result['cpu_mask'] = $ticket_info->getCPU_Mask();
$result['ht'] = $ticket_info->getHT();
$result['nel3d'] = $ticket_info->getNel3D();
$result['user_id'] = $ticket_info->getUser_Id();
global $IMAGELOC_WEBPATH;
$result['IMAGELOC_WEBPATH'] = $IMAGELOC_WEBPATH;
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$result['isMod'] = "TRUE";
}
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
} else {
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
} else {
//ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php");
throw new SystemExit();
}
}
示例6: change_receivemail
/**
* This function is beign used to change the users receiveMail setting.
* It will first check if the user who executed this function is the person of whom the setting is or if it's a mod/admin. If this is not the case the page will be redirected to an error page.
* it will check if the new value equals 1 or 0 and it will update the setting and redirect the page again.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function change_receivemail()
{
try {
//if logged in
global $INGAME_WEBPATH;
global $WEBPATH;
if (WebUsers::isLoggedIn()) {
if (isset($_POST['target_id'])) {
//check if the user who executed this function is the person of whom the setting is or if it's a mod/admin.
if (($_POST['target_id'] == $_SESSION['id'] || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) && isset($_POST['ReceiveMail'])) {
$user_id = filter_var($_POST['target_id'], FILTER_SANITIZE_NUMBER_INT);
$receiveMail = filter_var($_POST['ReceiveMail'], FILTER_SANITIZE_NUMBER_INT);
if ($receiveMail == 0 || $receiveMail == 1) {
WebUsers::setReceiveMail($user_id, $receiveMail);
}
if (Helpers::check_if_game_client()) {
header("Cache-Control: max-age=1");
header("Location: " . $INGAME_WEBPATH . "?page=settings&id=" . $user_id);
} else {
header("Cache-Control: max-age=1");
header("Location: " . $WEBPATH . "?page=settings&id=" . $user_id);
}
throw new SystemExit();
} else {
//ERROR: permission denied!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
} else {
//ERROR: The form was not filled in correclty
header("Cache-Control: max-age=1");
header("Location: index.php?page=settings");
throw new SystemExit();
}
} else {
//ERROR: user is not logged in
header("Cache-Control: max-age=1");
header("Location: index.php");
throw new SystemExit();
}
} catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
throw new SystemExit();
}
}
示例7: settings
function settings()
{
if (WebUsers::isLoggedIn()) {
//in case id-GET param set it's value as target_id, if no id-param is given, ue the session id.
if (isset($_GET['id'])) {
if ($_GET['id'] != $_SESSION['id'] && !Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
} else {
$webUser = new Webusers($_GET['id']);
//$result = $webUser->getInfo();
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) && $_GET['id'] != $_SESSION['id']) {
$result['changesOther'] = "TRUE";
}
$result['target_id'] = $_GET['id'];
$result['current_mail'] = $webUser->getEmail();
$result['target_username'] = $webUser->getUsername();
}
} else {
$webUser = new Webusers($_SESSION['id']);
//$result = $webUser->getInfo();
$result['target_id'] = $_SESSION['id'];
$result['current_mail'] = $webUser->getEmail();
$result['target_username'] = $webUser->getUsername();
}
//Sanitize Data
$result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL);
$result['target_username'] = filter_var($result['target_username'], FILTER_SANITIZE_STRING);
//$result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING);
//$result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING);
//$result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING);
//$result['Gender'] = filter_var($result['Gender'], FILTER_SANITIZE_NUMBER_INT);
//$result['ReceiveMail'] = filter_var($result['ReceiveMail'], FILTER_SANITIZE_NUMBER_INT);
//$result['country_array'] = getCountryArray();
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
} else {
//ERROR: not logged in!
header("Location: index.php");
exit;
}
}
示例8: show_reply
/**
* This function is beign used to load info that's needed for the show_reply page.
* check if the person is allowed to see the reply, if not he'll be redirected to an error page.
* data regarding to the reply will be returned by this function that will be used by the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function show_reply()
{
//if logged in
if (WebUsers::isLoggedIn() && isset($_GET['id'])) {
$result['reply_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$reply = new Ticket_Reply();
$reply->load_With_TReplyId($result['reply_id']);
$ticket = new Ticket();
$ticket->load_With_TId($reply->getTicket());
//check if the user is allowed to see the reply
if ($ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() && !$reply->getHidden() || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$content = new Ticket_Content();
$content->load_With_TContentId($reply->getContent());
$author = new Ticket_User();
$author->load_With_TUserId($reply->getAuthor());
$result['hidden'] = $reply->getHidden();
$result['ticket_id'] = $reply->getTicket();
$result['reply_timestamp'] = $reply->getTimestamp();
$result['author_permission'] = $author->getPermission();
$result['reply_content'] = $content->getContent();
$result['author'] = $author->getExternId();
$webUser = new WebUsers($author->getExternId());
$result['authorName'] = $webUser->getUsername();
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$result['isMod'] = "TRUE";
}
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
} else {
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
} else {
//ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php");
throw new SystemExit();
}
}
示例9: show_user
/**
* This function is beign used to load info that's needed for the show_user page.
* Users can only browse their own user page, while mods/admins can browse all user pages. The current settings of the user being browsed will be loaded, as also their created tickets
* and this info will be returned so it can be used by the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function show_user()
{
//if logged in
if (WebUsers::isLoggedIn()) {
//Users can only browse their own user page, while mods/admins can browse all user pages
if (!isset($_GET['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) || $_GET['id'] == $_SESSION['id']) {
if (isset($_GET['id'])) {
$result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
} else {
$result['target_id'] = $_SESSION['id'];
}
$webUser = new WebUsers($result['target_id']);
$result['target_name'] = $webUser->getUsername();
$result['mail'] = $webUser->getEmail();
$info = $webUser->getInfo();
$result['firstName'] = $info['FirstName'];
$result['lastName'] = $info['LastName'];
$result['country'] = $info['Country'];
$result['gender'] = $info['Gender'];
$ticket_user = Ticket_User::constr_ExternId($result['target_id']);
$result['userPermission'] = $ticket_user->getPermission();
if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) {
$result['isAdmin'] = "TRUE";
}
$ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId());
$result['ticketlist'] = Gui_Elements::make_table($ticketlist, array("getTId", "getTimestamp", "getTitle", "getStatus", "getStatusText", "getStatusText", "getCategoryName"), array("tId", "timestamp", "title", "status", "statustext", "statusText", "category"));
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
} else {
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
} else {
//ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php");
throw new SystemExit();
}
}
示例10: sgroup_list
/**
* This function is beign used to load info that's needed for the sgroup_list page.
* check if the person who wants to view this page is a mod/admin, if this is not the case, he will be redirected to an error page.
* It will return all suppport groups information. Also if the $_GET['delete'] var is set and the user is an admin, he will delete a specific entry.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function sgroup_list()
{
global $INGAME_WEBPATH;
global $WEBPATH;
//if logged in
if (WebUsers::isLoggedIn()) {
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
//if delete GET var is set and user is admin, then delete the groups entry.
if (isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) {
$delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT);
$result['delete'] = Support_Group::deleteSupportGroup($delete_id);
header("Cache-Control: max-age=1");
if (Helpers::check_if_game_client()) {
header("Location: " . $INGAME_WEBPATH . "?page=sgroup_list");
} else {
header("Location: " . $WEBPATH . "?page=sgroup_list");
}
throw new SystemExit();
}
if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))) {
$result['isAdmin'] = "TRUE";
}
$result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), array("getSGroupId", "getName", "getTag", "getGroupEmail"), array("sGroupId", "name", "tag", "groupemail"));
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
} else {
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
} else {
//ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php");
throw new SystemExit();
}
}
示例11: change_mail
/**
* This function is beign used to change the users emailaddress info.
* It will first check if the user who executed this function is the person of whom the emailaddress is or if it's a mod/admin. If this is not the case the page will be redirected to an error page.
* The emailaddress will be validated first. If the checking was successful the email will be updated and the settings template will be reloaded. Errors made by invalid data will be shown
* also after reloading the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function change_mail()
{
try {
//if logged in
if (WebUsers::isLoggedIn()) {
if (isset($_POST['target_id'])) {
//check if the user who executed this function is the person of whom the emailaddress is or if it's a mod/admin.
if ($_POST['target_id'] == $_SESSION['id'] || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
if ($_POST['target_id'] == $_SESSION['id']) {
//if the email is of the executing user himself
$target_username = $_SESSION['user'];
} else {
//if its from someone else.
$webUser = new WebUsers($_POST['target_id']);
$target_username = $webUser->getUsername();
}
$webUser = new WebUsers($_POST['target_id']);
//check if emailaddress is valid.
$reply = $webUser->checkEmail($_POST['NewEmail']);
global $SITEBASE;
require_once $SITEBASE . '/inc/settings.php';
$result = settings();
if ($reply != "success") {
$result['EMAIL_ERROR'] = 'TRUE';
} else {
$result['EMAIL_ERROR'] = 'FALSE';
}
$result['prevNewEmail'] = filter_var($_POST["NewEmail"], FILTER_SANITIZE_EMAIL);
if ($reply == "success") {
//if validation was successful, update the emailaddress
$status = WebUsers::setEmail($target_username, filter_var($_POST["NewEmail"], FILTER_SANITIZE_EMAIL));
if ($status == 'ok') {
$result['SUCCESS_MAIL'] = "OK";
} else {
if ($status == 'shardoffline') {
$result['SUCCESS_MAIL'] = "SHARDOFF";
}
}
$result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
$result['no_visible_elements'] = 'FALSE';
$result['username'] = $_SESSION['user'];
$result['target_id'] = $_POST['target_id'];
if (isset($_GET['id'])) {
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) && $_POST['target_id'] != $_SESSION['id']) {
$result['isMod'] = "TRUE";
}
}
helpers::loadtemplate('settings', $result);
throw new SystemExit();
} else {
$result['EMAIL'] = $reply;
$result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
$result['no_visible_elements'] = 'FALSE';
$result['username'] = $_SESSION['user'];
$result['target_id'] = $_POST['target_id'];
if (isset($_GET['id'])) {
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) && $_POST['target_id'] != $_SESSION['id']) {
$result['isMod'] = "TRUE";
}
}
$result['CEMAIL_ERROR'] = true;
helpers::loadtemplate('settings', $result);
throw new SystemExit();
}
} else {
//ERROR: permission denied!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
throw new SystemExit();
}
} else {
//ERROR: The form was not filled in correctly
header("Location: index.php?page=settings");
throw new SystemExit();
}
} else {
//ERROR: user is not logged in
header("Location: index.php");
throw new SystemExit();
}
} catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
throw new SystemExit();
}
}
示例12: change_password
/**
* This function is beign used to change the users password.
* It will first check if the user who executed this function is the person of whom the emailaddress is or if it's a mod/admin. If this is not the case the page will be redirected to an error page.
* If the executing user tries to change someone elses password, he doesn't has to fill in the previous password. The password will be validated first. If the checking was successful the password will be updated and the settings template will be reloaded. Errors made by invalid data will be shown
* also after reloading the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function change_password()
{
try {
//if logged in
if (WebUsers::isLoggedIn()) {
if (isset($_POST['target_id'])) {
$adminChangesOther = false;
//if target_id is the same as session id or is admin
if ($_POST['target_id'] == $_SESSION['id'] || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
if ($_POST['target_id'] == $_SESSION['id']) {
//if the password is of the executing user himself
$target_username = $_SESSION['user'];
} else {
//if the password is of someone else.
$webUser = new WebUsers($_POST['target_id']);
$target_username = $webUser->getUsername();
//isAdmin is true when it's the admin, but the target_id != own id
$adminChangesOther = true;
$_POST["CurrentPass"] = "dummypass";
}
$webUser = new WebUsers($_POST['target_id']);
$params = array('user' => $target_username, 'CurrentPass' => $_POST["CurrentPass"], 'NewPass' => $_POST["NewPass"], 'ConfirmNewPass' => $_POST["ConfirmNewPass"], 'adminChangesOther' => $adminChangesOther);
$result = $webUser->check_change_password($params);
if ($result == "success") {
//edit stuff into db
global $SITEBASE;
require_once $SITEBASE . '/inc/settings.php';
$succresult = settings();
$status = WebUsers::setPassword($target_username, $_POST["NewPass"]);
if ($status == 'ok') {
$succresult['SUCCESS_PASS'] = "OK";
} else {
if ($status == 'shardoffline') {
$succresult['SUCCESS_PASS'] = "SHARDOFF";
}
}
$succresult['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
$succresult['no_visible_elements'] = 'FALSE';
$succresult['username'] = $_SESSION['user'];
$succresult['target_id'] = $_POST['target_id'];
helpers::loadtemplate('settings', $succresult);
throw new SystemExit();
} else {
$result['prevCurrentPass'] = filter_var($_POST["CurrentPass"], FILTER_SANITIZE_STRING);
$result['prevNewPass'] = filter_var($_POST["NewPass"], FILTER_SANITIZE_STRING);
$result['prevConfirmNewPass'] = filter_var($_POST["ConfirmNewPass"], FILTER_SANITIZE_STRING);
$result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
$result['no_visible_elements'] = 'FALSE';
$result['username'] = $_SESSION['user'];
$result['target_id'] = $_POST['target_id'];
global $SITEBASE;
require_once $SITEBASE . '/inc/settings.php';
$settings = settings();
$result = array_merge($result, $settings);
helpers::loadtemplate('settings', $result);
throw new SystemExit();
}
} else {
//ERROR: permission denied!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
} else {
//ERROR: The form was not filled in correclty
header("Cache-Control: max-age=1");
header("Location: index.php?page=settings");
throw new SystemExit();
}
} else {
//ERROR: user is not logged in
header("Cache-Control: max-age=1");
header("Location: index.php");
throw new SystemExit();
}
} catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
throw new SystemExit();
}
}
示例13: install_plugin
/**
* This function is used in installing plugins or adding updates
* for previously installed plugins.
*
*/
function install_plugin()
{
$result = array();
// if logged in
if (WebUsers::isLoggedIn()) {
// path of temporary folder for storing files
$temp_path = "../../ams_lib/temp";
// create a temp directory if not exist
// temp folder where we first store all uploaded plugins before install
if (!file_exists("{$temp_path}")) {
mkdir($temp_path);
}
// checking the server if file is uploaded or not
if (isset($_FILES["file"]) && $_FILES["file"]["size"] > 0) {
$fileName = $_FILES["file"]["name"];
//the files name takes from the HTML form
$fileTmpLoc = $_FILES["file"]["tmp_name"];
//file in the PHP tmp folder
$dir = trim($_FILES["file"]["name"], ".zip");
$target_path = "../../ams_lib/plugins/{$dir}";
//path in which the zip extraction is to be done
$destination = "../../ams_lib/plugins/";
// scanning plugin folder if plugin with same name is already exists or not
$x = checkForUpdate($dir, $destination, $fileTmpLoc, $temp_path);
if ($x == '1') {
echo "update found";
throw new SystemExit();
} else {
if ($x == '2') {
echo "Plugin already exists with same name .";
throw new SystemExit();
} else {
if ($x == '3') {
echo "Update info is not present in the update";
throw new SystemExit();
}
}
}
// checking for the command to install plugin is given or not
if (!isset($_POST['install_plugin'])) {
if ($_FILES["file"]["type"] == 'application/zip') {
if (move_uploaded_file($fileTmpLoc, $temp_path . "/" . $fileName)) {
echo "{$fileName} upload is complete.</br>" . "<button type='submit' class='btn btn-primary' style='margin-left:5px; margin-top:10px;' name='install_plugin'>Install Plugin</button></br>";
throw new SystemExit();
} else {
echo "Error in uploading file.";
throw new SystemExit();
}
} else {
echo "Please select a file with .zip extension to upload.";
throw new SystemExit();
}
} else {
// calling function to unzip archives
if (zipExtraction($temp_path . "/" . $fileName, $destination)) {
if (file_exists($target_path . "/.info")) {
$result = readPluginFile(".info", $target_path);
// sending all info to the database
$install_result = array();
$install_result['FileName'] = $target_path;
$install_result['Name'] = $result['PluginName'];
$install_result['Type'] = $result['Type'];
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$install_result['Permission'] = 'admin';
} else {
$install_result['Permission'] = 'user';
}
$install_result['Info'] = json_encode($result);
// connection with the database
$dbr = new DBLayer("lib");
$dbr->insert("plugins", $install_result);
// if everything is successfull redirecting to the plugin template
header("Cache-Control: max-age=1");
header("Location: index.php?page=plugins&result=1");
throw new SystemExit();
} else {
// file .info not exists
rmdir($target_path);
header("Cache-Control: max-age=1");
header("Location: index.php?page=install_plugin&result=2");
throw new SystemExit();
}
} else {
// extraction failed
header("Cache-Control: max-age=1");
header("Location: index.php?page=install_plugin&result=0");
throw new SystemExit();
}
}
} else {
echo "Please Browse for a file before clicking the upload button";
throw new SystemExit();
}
}
}
示例14: create_ticket
/**
* This function is beign used to create a new ticket.
* It will first check if the user who executed this function is the person of whom the setting is or if it's a mod/admin. If this is not the case the page will be redirected to an error page.
* next it will filter the POST data and it will try to create the new ticket. Afterwards a redirecion to the ticket will occur.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function create_ticket()
{
//if logged in
global $INGAME_WEBPATH;
global $WEBPATH;
$return = array();
$error = false;
if (WebUsers::isLoggedIn() && isset($_SESSION['ticket_user'])) {
if (strlen(preg_replace('/\\s\\s+/', ' ', $_POST['Title'])) < 2) {
$return = array_merge($_POST, $return);
$return['no_visible_elements'] = 'FALSE';
$catArray = Ticket_Category::getAllCategories();
$return['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
$return['category'] = Gui_Elements::make_table_with_key_is_id($catArray, array("getName"), "getTCategoryId");
$return['TITLE_ERROR_MESSAGE'] = "Title must not be blank!";
$return['TITLE_ERROR'] = true;
$error = true;
}
if (strlen(preg_replace('/\\s\\s+/', ' ', $_POST['Content'])) < 2) {
$return = array_merge($_POST, $return);
$return['no_visible_elements'] = 'FALSE';
$catArray = Ticket_Category::getAllCategories();
$return['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
$return['category'] = Gui_Elements::make_table_with_key_is_id($catArray, array("getName"), "getTCategoryId");
$return['CONTENT_ERROR_MESSAGE'] = "Content must not be blank!";
$return['CONTENT_ERROR'] = true;
$error = true;
}
if ($error) {
helpers::loadTemplate('createticket', $return);
throw new SystemExit();
}
if (isset($_POST['target_id'])) {
//if target_id is the same as session id or is admin
if ($_POST['target_id'] == $_SESSION['id'] || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$category = filter_var($_POST['Category'], FILTER_SANITIZE_NUMBER_INT);
$title = filter_var($_POST['Title'], FILTER_SANITIZE_STRING);
$content = filter_var($_POST['Content'], FILTER_SANITIZE_STRING);
try {
if ($_POST['target_id'] == $_SESSION['id']) {
//if the ticket is being made for the executing user himself
$author = unserialize($_SESSION['ticket_user'])->getTUserId();
} else {
//if a mod tries to make a ticket for someone else
$author = Ticket_User::constr_ExternId($_POST['target_id'])->getTUserId();
}
//create the ticket & return the id of the newly created ticket.
$ticket_id = Ticket::create_Ticket($title, $content, $category, $author, unserialize($_SESSION['ticket_user'])->getTUserId(), 0, $_POST);
//redirect to the new ticket.
if (Helpers::check_if_game_client()) {
header("Cache-Control: max-age=1");
header("Location: " . $INGAME_WEBPATH . "?page=show_ticket&id=" . $ticket_id);
} else {
header("Cache-Control: max-age=1");
header("Location: " . $WEBPATH . "?page=show_ticket&id=" . $ticket_id);
throw new SystemExit();
}
} catch (PDOException $e) {
//ERROR: LIB DB is not online!
print_r($e);
throw new SystemExit();
header("Cache-Control: max-age=1");
header("Location: index.php");
throw new SystemExit();
}
} else {
//ERROR: permission denied!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
} else {
//ERROR: The form was not filled in correclty
header("Cache-Control: max-age=1");
header("Location: index.php?page=createticket");
throw new SystemExit();
}
} else {
//ERROR: user is not logged in
header("Cache-Control: max-age=1");
header("Location: index.php");
throw new SystemExit();
}
}
示例15: show_ticket_log
/**
* This function is beign used to load info that's needed for the show_ticket_log page.
* This page shows the logs related to a ticket: who created the ticket, who replied on it, who viewed it, assigned or forwarded it.
* Only mods/admins are able to browse the log though. The found information is returned so it can be used by the template.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function show_ticket_log()
{
global $INGAME_WEBPATH;
global $WEBPATH;
//if logged in
if (WebUsers::isLoggedIn() && isset($_GET['id'])) {
//only allow admins to browse the log!
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$target_ticket = new Ticket();
$target_ticket->load_With_TId($result['ticket_id']);
$result['ticket_title'] = $target_ticket->getTitle();
//return all logs related to a ticket.
$ticket_logs = Ticket_Log::getLogsOfTicket($result['ticket_id']);
$log_action_array = Ticket_Log::getActionTextArray();
//fetch information about each returned ticket in a format that is usable for the template
$result['ticket_logs'] = Gui_Elements::make_table($ticket_logs, array("getTLogId", "getTimestamp", "getAuthor()->getExternId", "getAction", "getArgument()"), array("tLogId", "timestamp", "authorExtern", "action", "argument"));
$i = 0;
//for each ticket add action specific informaton to the to-be-shown text: uses the query_backpart
foreach ($result['ticket_logs'] as $log) {
$webUser = new WebUsers($log['authorExtern']);
$author = $webUser->getUsername();
$result['ticket_logs'][$i]['author'] = $author;
$query_backpart = "";
if ($log['action'] == 2) {
$webUser2 = new WebUsers($log['argument']);
$query_backpart = $webUser2->getUsername();
} else {
if ($log['action'] == 4) {
if (Helpers::check_if_game_client()) {
$query_backpart = "<a href='" . $INGAME_WEBPATH . "?page=show_reply&id=" . $log['argument'] . "'>ID#" . $log['argument'] . "</a>";
} else {
$query_backpart = "<a href='" . $WEBPATH . "?page=show_reply&id=" . $log['argument'] . "'>ID#" . $log['argument'] . "</a>";
}
} else {
if ($log['action'] == 5) {
$statusArray = Ticket::getStatusArray();
$query_backpart = $statusArray[$log['argument']];
} else {
if ($log['action'] == 6) {
$priorityArray = Ticket::getPriorityArray();
$query_backpart = $priorityArray[$log['argument']];
} else {
if ($log['action'] == 8) {
if (Helpers::check_if_game_client()) {
$query_backpart = "<a href='" . $INGAME_WEBPATH . "?page=show_sgroupy&id=" . $log['argument'] . "'>" . Support_Group::getGroup($log['argument'])->getName() . "</a>";
} else {
$query_backpart = "<a href='" . $WEBPATH . "?page=show_sgroupy&id=" . $log['argument'] . "'>" . Support_Group::getGroup($log['argument'])->getName() . "</a>";
}
}
}
}
}
}
$result['ticket_logs'][$i]['query'] = $author . " " . $log_action_array[$log['action']] . " " . $query_backpart;
$result['ticket_logs'][$i]['timestamp_elapsed'] = Gui_Elements::time_elapsed_string($log['timestamp']);
$i++;
}
if (Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) {
$result['isMod'] = "TRUE";
}
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
} else {
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
throw new SystemExit();
}
} else {
//ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php");
throw new SystemExit();
}
}