/** * 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(); } }
/** * Global Hook to return global variables which contains * the content to use in the smarty templates extracted from * the database * * @return $domain_management_return_set global array returns the template data */ function domain_management_hook_get_db() { global $domain_management_return_set; if (isset($_GET['ModifyDomain']) && ($_GET['ModifyDomain'] = '1' && isset($_POST['domain_name']))) { try { $dbs = new DBLayer('shard'); $dbs->update("domain", array('domain_name' => $_POST['domain_name'], 'status' => $_POST['status'], 'patch_version' => $_POST['patch_version'], 'backup_patch_url' => $_POST['backup_patch_url'], 'patch_urls' => $_POST['patch_urls'], 'login_address' => $_POST['login_address'], 'session_manager_address' => $_POST['session_manager_address'], 'ring_db_name' => $_POST['ring_db_name'], 'web_host' => $_POST['web_host'], 'web_host_php' => $_POST['web_host_php'], 'description' => $_POST['description']), '`domain_id` = ' . $_GET['edit_domain']); } catch (Exception $e) { return null; } } if (isset($_GET['ModifyPermission']) && ($_GET['ModifyPermission'] = '1' && isset($_POST['user']))) { try { $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", array('setting' => 'Domain_Auto_Add')); $json = $statement->fetch(); $json = json_decode($json['Value'], true); $json[$_GET['edit_domain']]['1'] = $_POST['user']; $json[$_GET['edit_domain']]['2'] = $_POST['moderator']; $json[$_GET['edit_domain']]['3'] = $_POST['admin']; $update = json_encode($json); $dbl->update("settings", array('Value' => $update), "`Setting` = 'Domain_Auto_Add'"); } catch (Exception $e) { return null; } } try { $db = new DBLayer('shard'); // get all domains $statement = $db->executeWithoutParams("SELECT * FROM domain"); $rows = $statement->fetchAll(); $domain_management_return_set['domains'] = $rows; if (isset($_GET['edit_domain'])) { // get permissions $statement = $db->executeWithoutParams("SELECT * FROM `domain` WHERE `domain_id` = '" . $_GET['edit_domain'] . "'"); $rows = $statement->fetchAll(); $domain_management_return_set['domains'] = $rows; $statement = $db->executeWithoutParams("SELECT * FROM `permission` WHERE `DomainId` = '" . $_GET['edit_domain'] . "'"); $rows = $statement->fetchAll(); $domain_management_return_set['permissions'] = $rows; // get all users $pagination = new Pagination(WebUsers::getAllUsersQuery(), "web", 10, "WebUsers"); $domain_management_return_set['userlist'] = Gui_Elements::make_table($pagination->getElements(), array("getUId", "getUsername", "getEmail"), array("id", "username", "email")); $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM `settings` WHERE `Setting` = :setting", array('setting' => 'Domain_Auto_Add')); $json = $statement->fetch(); $json = json_decode($json['Value'], true); $domain_management_return_set['Domain_Auto_Add'] = $json[$_GET['edit_domain']]; } return $rows; } catch (Exception $e) { return null; } }