diff --git a/web/config.php.template b/web/config.php.template index feea8220b..bee502ea0 100644 --- a/web/config.php.template +++ b/web/config.php.template @@ -41,6 +41,3 @@ define('STEAMAPIKEY', ''); // Steam API Key for Shizz define('SB_WP_URL', ''); //URL of SourceBans Site define('SB_EMAIL', ''); define('SB_NEW_SALT', '$5$'); //Salt for passwords - -//define('DEVELOPER_MODE', true); // Use if you want to show debugmessages -//define('SB_MEM', '128M'); // Override php memory limit, if isn't enough diff --git a/web/configs/permissions/sourcemod.json b/web/configs/permissions/sourcemod.json new file mode 100644 index 000000000..a62218fa4 --- /dev/null +++ b/web/configs/permissions/sourcemod.json @@ -0,0 +1,106 @@ +{ + "SM_RESERVED_SLOT": { + "value": "a", + "display": "Reserved Slot" + }, + + "SM_GENERIC": { + "value": "b", + "display": "Generic Admin" + }, + + "SM_KICK": { + "value": "c", + "display": "Kick" + }, + + "SM_BAN": { + "value": "d", + "display": "Ban" + }, + + "SM_UNBAN": { + "value": "e", + "display": "Unban" + }, + + "SM_SLAY": { + "value": "f", + "display": "Slay" + }, + + "SM_MAP": { + "value": "g", + "display": "Map Change" + }, + + "SM_CVAR": { + "value": "h", + "display": "Change ConVars" + }, + + "SM_CONFIG": { + "value": "i", + "display": "Run Configs" + }, + + "SM_CHAT": { + "value": "j", + "display": "Admin Chat" + }, + + "SM_VOTE": { + "value": "k", + "display": "Start Votes" + }, + + "SM_PASSWORD": { + "value": "l", + "display": "Password Server" + }, + + "SM_RCON": { + "value": "m", + "display": "RCON" + }, + + "SM_CHEATS": { + "value": "n", + "display": "Enable Cheats" + }, + + "SM_ROOT": { + "value": "z", + "display": "Full Admin" + }, + + "SM_CUSTOM1": { + "value": "o", + "display": "Custom Flag 1" + }, + + "SM_CUSTOM2": { + "value": "p", + "display": "Custom Flag 2" + }, + + "SM_CUSTOM3": { + "value": "q", + "display": "Custom Flag 3" + }, + + "SM_CUSTOM4": { + "value": "r", + "display": "Custom flag 4" + }, + + "SM_CUSTOM5": { + "value": "s", + "display": "Custom Flag 5" + }, + + "SM_CUSTOM6": { + "value": "t", + "display": "Custom Flag 6" + } +} diff --git a/web/configs/permissions/web.json b/web/configs/permissions/web.json new file mode 100644 index 000000000..c5f40f422 --- /dev/null +++ b/web/configs/permissions/web.json @@ -0,0 +1,161 @@ +{ + "ADMIN_LIST_ADMINS": { + "value": 1, + "display": "View Admins" + }, + + "ADMIN_ADD_ADMINS": { + "value": 2, + "display": "Add Admins" + }, + + "ADMIN_EDIT_ADMINS": { + "value": 4, + "display": "Edit Admins" + }, + + "ADMIN_DELETE_ADMINS": { + "value": 8, + "display": "Delete Admins" + }, + + "ADMIN_LIST_SERVERS": { + "value": 16, + "display": "View Servers" + }, + + "ADMIN_ADD_SERVER": { + "value": 32, + "display": "Add Servers" + }, + + "ADMIN_EDIT_SERVERS": { + "value": 64, + "display": "Edit Servers" + }, + + "ADMIN_DELETE_SERVERS": { + "value": 128, + "display": "Delete Servers" + }, + + "ADMIN_ADD_BAN": { + "value": 256, + "display": "Add Bans" + }, + + "ADMIN_EDIT_OWN_BANS": { + "value": 1024, + "display": "Edit Own Bans" + }, + + "ADMIN_EDIT_GROUP_BANS": { + "value": 2048, + "display": "Edit Group Bans" + }, + + "ADMIN_EDIT_ALL_BANS": { + "value": 4096, + "display": "Edit All Bans" + }, + + "ADMIN_BAN_PROTESTS": { + "value": 8192, + "display": "Ban Appeals" + }, + + "ADMIN_BAN_SUBMISSIONS": { + "value": 16384, + "display": "Ban Reports" + }, + + "ADMIN_DELETE_BAN": { + "value": 33554432, + "display": "Delete All Bans" + }, + + "ADMIN_UNBAN": { + "value": 67108864, + "display": "Unban All Bans" + }, + + "ADMIN_BAN_IMPORT": { + "value": 134217728, + "display": "Import Bans" + }, + + "ADMIN_UNBAN_OWN_BANS": { + "value": 1073741824, + "display": "Unban Own Bans" + }, + + "ADMIN_UNBAN_GROUP_BANS": { + "value": 2147483648, + "display": "Unban Group Bans" + }, + + "ADMIN_LIST_GROUPS": { + "value": 32768, + "display": "View Groups" + }, + + "ADMIN_ADD_GROUP": { + "value": 65536, + "display": "Add Groups" + }, + + "ADMIN_EDIT_GROUPS": { + "value": 131072, + "display": "Edit Groups" + }, + + "ADMIN_DELETE_GROUPS": { + "value": 262144, + "display": "Delete Groups" + }, + + "ADMIN_WEB_SETTINGS": { + "value": 524288, + "display": "Web Settings" + }, + + "ADMIN_LIST_MODS": { + "value": 1048576, + "display": "View Mods" + }, + + "ADMIN_ADD_MODS": { + "value": 2097152, + "display": "Add Mods" + }, + + "ADMIN_EDIT_MODS": { + "value": 4194304, + "display": "Edit Mods" + }, + + "ADMIN_DELETE_MODS": { + "value": 8388608, + "display": "Delete Mods" + }, + + "ADMIN_NOTIFY_SUB": { + "value": 268435456, + "display": "Ban Report Email Notifications" + }, + + "ADMIN_NOTIFY_PROTEST": { + "value": 536870912, + "display": "Ban Appeal Email Notifications" + }, + + "ADMIN_OWNER": { + "value": 16777216, + "display": "Owner" + }, + + "ALL_WEB": { + "value": 4294966783, + "display": "All Web Permissions" + } +} diff --git a/web/configs/quotes.json b/web/configs/quotes.json new file mode 100644 index 000000000..c5aaff798 --- /dev/null +++ b/web/configs/quotes.json @@ -0,0 +1,134 @@ +[ + { + "author": "Viper", + "quote": "Buy a new PC!" + }, + { + "author": "Brizad", + "quote": "I'm not lazy! I just utilize technical resources!" + }, + { + "author": "sslice", + "quote": "I need to mow the lawn" + }, + { + "author": "Viper", + "quote": "You're a Noob and You Know It!" + }, + { + "author": "Viper", + "quote": "Like A Glove!" + }, + { + "author": "Viper", + "quote": "Get your ass ingame." + }, + { + "author": "Viper", + "quote": "Mother F***ing Peices of Sh**" + }, + { + "author": "[Everyone]", + "quote": "Shut up Bam" + }, + { + "author": "Viper", + "quote": "Hi OllyBunch" + }, + { + "author": "[Unknown]", + "quote": "Procrastination is like masturbation. Sure it feels good, but in the end you're only F***ing yourself!" + }, + { + "author": "SteamFriend", + "quote": "Rave's momma so fat she sat on the beach and Greenpeace threw her in" + }, + { + "author": "Faith", + "quote": "Im just getting a beer" + }, + { + "author": "Viper", + "quote": "To be honest..., I DON'T CARE!" + }, + { + "author": "teame06", + "quote": "Yams" + }, + { + "author": "gdogg", + "quote": "built in cheat 1.6 - my friend told me theres a cheat where u can buy a car door and run around and it makes u invincible...." + }, + { + "author": "BAILOPAN", + "quote": "I just join conversation when i see a chance to tell people they might be wrong, then i quickly leave, LIKE A BAT" + }, + { + "author": "[Everyone]", + "quote": "Let's just blame it on FlyingMongoose" + }, + { + "author": "Recon", + "quote": "Don't step on that boom... mine..." + }, + { + "author": "Recon", + "quote": "Looks through sniper scope... Sit ;)" + }, + { + "author": "Recon", + "quote": "That plugin looks like something you found in a junk yard." + }, + { + "author": "Recon", + "quote": "That's exactly what I asked you not to do." + }, + { + "author": "Recon", + "quote": "Why are you wasting your time looking at this?" + }, + { + "author": "Recon", + "quote": "You must have better things to do with your time" + }, + { + "author": "Mr. T", + "quote": "I pity da fool" + }, + { + "author": "Tsunami", + "quote": "you grew a 3rd head?" + }, + { + "author": "devicenull", + "quote": "I dont think you want to know..." + }, + { + "author": "Brizad", + "quote": "Sheep sex isn't baaaaaa...aad" + }, + { + "author": "Brizad", + "quote": "Oh wow, he's got skillz spelled with an 's'" + }, + { + "author": "Brizad", + "quote": "I'll get to it this weekend... I promise" + }, + { + "author": "Marge Simpson", + "quote": "People do crazy things all the time... Like eat a Arby's" + }, + { + "author": "SirTiger", + "quote": "I wish my lawn was emo, so it would cut itself" + }, + { + "author": "Olly", + "quote": "Oh no! I've overflowed my balls!" + }, + { + "author": "ISSUE_TEMPLATE.md", + "quote": "Pump me full of your precious information, Senpai!" + } +] diff --git a/web/configs/version.json b/web/configs/version.json new file mode 100644 index 000000000..d6bb3b3e5 --- /dev/null +++ b/web/configs/version.json @@ -0,0 +1,5 @@ +{ + "version": "1.7.0", + "git": "784", + "dev": true +} diff --git a/web/exportbans.php b/web/exportbans.php index 50cc28cb0..143a93e28 100644 --- a/web/exportbans.php +++ b/web/exportbans.php @@ -1,7 +1,6 @@ HasAccess(ADMIN_OWNER) && !$exportpublic) { +if (!$userbank->HasAccess(ADMIN_OWNER) && !Config::getBool('config.exportpublic')) { echo "Don't have access to this feature."; } else if (!isset($_GET['type'])) { echo "You have to specify the type. Only follow links!"; diff --git a/web/includes/CUserManager.php b/web/includes/CUserManager.php index 7d30689ec..7bab81978 100644 --- a/web/includes/CUserManager.php +++ b/web/includes/CUserManager.php @@ -242,7 +242,7 @@ public function login($aid, $password, $save = true) * @param $password password to encrypt. * @return string. */ - public function encrypt_password($password, $salt = SB_SALT) + public function encrypt_password($password, $salt = 'SourceBans') { return sha1(sha1($salt . $password)); } diff --git a/web/includes/Config.php b/web/includes/Config.php new file mode 100644 index 000000000..81d6d016e --- /dev/null +++ b/web/includes/Config.php @@ -0,0 +1,32 @@ +query("SELECT * FROM `:prefix_settings`"); + foreach(self::$dbh->resultset() as $data) { + $config[$data['setting']] = $data['value']; + } + return $config; + } +} diff --git a/web/includes/admin.php b/web/includes/admin.php index 981230f1e..2740fd020 100644 --- a/web/includes/admin.php +++ b/web/includes/admin.php @@ -255,7 +255,7 @@ $banTabMenu = new CTabsMenu(); if ($userbank->HasAccess(ADMIN_OWNER|ADMIN_ADD_BAN)) { $banTabMenu->addMenuItem("Add a ban", 0); - if ($GLOBALS['config']['config.enablegroupbanning']==1) { + if (Config::getBool('config.enablegroupbanning')) { $banTabMenu->addMenuItem("Group ban", 4); } } diff --git a/web/includes/page-builder.php b/web/includes/page-builder.php index 9915ab44a..dea61ae67 100644 --- a/web/includes/page-builder.php +++ b/web/includes/page-builder.php @@ -76,7 +76,7 @@ $page = TEMPLATES_PATH . "/page.home.php"; break; default: - switch ($GLOBALS['config']['config.defaultpage']) { + switch (Config::get('config.defaultpage')) { case 1: RewritePageTitle("Ban List"); $page = TEMPLATES_PATH . "/page.banlist.php"; diff --git a/web/includes/sb-callback.php b/web/includes/sb-callback.php index a8a7a395f..557a5c378 100644 --- a/web/includes/sb-callback.php +++ b/web/includes/sb-callback.php @@ -30,7 +30,7 @@ include_once('system-functions.php'); $xajax = new xajax(); //$xajax->debugOn(); -$xajax->setRequestURI(XAJAX_REQUEST_URI); +$xajax->setRequestURI('./index.php'); global $userbank; if (\SessionManager::checkSession()) { @@ -155,7 +155,7 @@ function LostPassword($email) $message .= "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "?p=lostpassword&email=". $email . "&validation=" . $validation; - $headers = 'From: ' . $GLOBALS['sb-email'] . "\n" . + $headers = 'From: ' . SB_EMAIL . "\n" . 'X-Mailer: PHP/' . phpversion(); $m = mail($email, "SourceBans Password Reset", $message, $headers); @@ -360,7 +360,7 @@ function RemoveGroup($gid, $type) $query0 = $GLOBALS['db']->Execute("DELETE FROM `" . DB_PREFIX . "_srvgroups_overrides` WHERE group_id = $gid"); } - if(isset($GLOBALS['config']['config.enableadminrehashing']) && $GLOBALS['config']['config.enableadminrehashing'] == 1) + if(Config::getBool('config.enableadminrehashing')) { // rehash the settings out of the database on all servers $serveraccessq = $GLOBALS['db']->GetAll("SELECT sid FROM ".DB_PREFIX."_servers WHERE enabled = 1;"); @@ -586,7 +586,7 @@ function RemoveAdmin($aid) $delquery = $GLOBALS['db']->Execute(sprintf("DELETE FROM `%s_admins` WHERE aid = %d LIMIT 1", DB_PREFIX, $aid)); if($delquery) { - if(isset($GLOBALS['config']['config.enableadminrehashing']) && $GLOBALS['config']['config.enableadminrehashing'] == 1) + if(Config::getBool('config.enableadminrehashing')) { // rehash the admins for the servers where this admin was on $serveraccessq = $GLOBALS['db']->GetAll("SELECT s.sid FROM `".DB_PREFIX."_servers` s @@ -1173,7 +1173,7 @@ function AddAdmin($mask, $srv_mask, $a_name, $a_steam, $a_email, $a_password, $a if(!empty($server)) $GLOBALS['db']->Execute($addtosrv,array($aid, $server_admin_group_int, '-1', substr($server, 1))); } - if(isset($GLOBALS['config']['config.enableadminrehashing']) && $GLOBALS['config']['config.enableadminrehashing'] == 1) + if(Config::getBool('config.enableadminrehashing')) { // rehash the admins on the servers $serveraccessq = $GLOBALS['db']->GetAll("SELECT s.sid FROM `".DB_PREFIX."_servers` s @@ -1770,7 +1770,7 @@ function AddBan($nickname, $type, $steam, $ip, $length, $dfile, $dname, $reason, $GLOBALS['db']->Execute("UPDATE `".DB_PREFIX."_submissions` SET archiv = '3', archivedby = '".$userbank->GetAid()."' WHERE SteamId = ?;", array($steam)); - $kickit = isset($GLOBALS['config']['config.enablekickit']) && $GLOBALS['config']['config.enablekickit'] == "1"; + $kickit = Config::getBool('config.enablekickit'); if ($kickit) { $objResponse->addScript("ShowKickBox('".((int)$type==0?$steam:$ip)."', '".(int)$type."');"); } else { @@ -1999,7 +1999,7 @@ function EditAdminPerms($aid, $web_flags, $srv_flags) // Update server stuff $GLOBALS['db']->Execute("UPDATE `".DB_PREFIX."_admins` SET `srv_flags` = ?, `immunity` = ? WHERE `aid` = $aid", array($srv_flags, $immunity)); - if(isset($GLOBALS['config']['config.enableadminrehashing']) && $GLOBALS['config']['config.enableadminrehashing'] == 1) + if(Config::getBool('config.enableadminrehashing')) { // rehash the admins on the servers $serveraccessq = $GLOBALS['db']->GetAll("SELECT s.sid FROM `".DB_PREFIX."_servers` s @@ -2118,7 +2118,7 @@ function EditGroup($gid, $web_flags, $srv_flags, $type, $name, $overrides, $newO } } - if(isset($GLOBALS['config']['config.enableadminrehashing']) && $GLOBALS['config']['config.enableadminrehashing'] == 1) + if(Config::getBool('config.enableadminrehashing')) { // rehash the settings out of the database on all servers $serveraccessq = $GLOBALS['db']->GetAll("SELECT sid FROM ".DB_PREFIX."_servers WHERE enabled = 1;"); @@ -2613,7 +2613,7 @@ function RehashAdmins($server, $do=0) function GroupBan($groupuri, $isgrpurl="no", $queue="no", $reason="", $last="") { $objResponse = new xajaxResponse(); - if($GLOBALS['config']['config.enablegroupbanning']==0) + if(!Config::getBool('config.enablegroupbanning')) return $objResponse; global $userbank, $username; if(!$userbank->HasAccess(ADMIN_OWNER|ADMIN_ADD_BAN)) @@ -2653,7 +2653,7 @@ function BanMemberOfGroup($grpurl, $queue, $reason, $last) { set_time_limit(0); $objResponse = new xajaxResponse(); - if ($GLOBALS['config']['config.enablegroupbanning'] == 0 || !defined('STEAMAPIKEY') || STEAMAPIKEY == '') { + if (!Config::getBool('config.enablegroupbanning') || !defined('STEAMAPIKEY') || STEAMAPIKEY == '') { return $objResponse; } global $userbank, $username; @@ -2746,7 +2746,7 @@ function GetGroups($friendid) { set_time_limit(0); $objResponse = new xajaxResponse(); - if($GLOBALS['config']['config.enablegroupbanning']==0 || !is_numeric($friendid)) + if(!Config::getBool('config.enablegroupbanning') || !is_numeric($friendid)) return $objResponse; global $userbank, $username; if(!$userbank->HasAccess(ADMIN_OWNER|ADMIN_ADD_BAN)) @@ -2825,7 +2825,7 @@ function BanFriends($friendid, $name) global $userbank, $username; $objResponse = new xajaxResponse(); $name = filter_var($name, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES); - if ($GLOBALS['config']['config.enablefriendsbanning'] == 0 || !is_numeric($friendid)) { + if (!Config::getBool('config.enablefriendsbanning') || !is_numeric($friendid)) { return $objResponse; } diff --git a/web/includes/system-functions.php b/web/includes/system-functions.php index 5a585e61e..1d28542cb 100644 --- a/web/includes/system-functions.php +++ b/web/includes/system-functions.php @@ -86,7 +86,7 @@ function AddTab($title, $url, $desc, $active=false) $tabs['title'] = $title; $tabs['url'] = $url; $tabs['desc'] = $desc; - if ($_GET['p'] == "default" && $title == $tab_arr[intval($GLOBALS['config']['config.defaultpage'])]) { + if ($_GET['p'] == "default" && $title == $tab_arr[intval(Config::get('config.defaultpage'))]) { $tabs['active'] = true; $GLOBALS['pagetitle'] = $title; } else { @@ -111,13 +111,13 @@ function BuildPageTabs() AddTab("Dashboard", "index.php?p=home", "This page shows an overview of your bans and servers."); AddTab("Servers", "index.php?p=servers", "All of your servers and their status can be viewed here"); AddTab("Bans", "index.php?p=banlist", "All of the bans in the database can be viewed from here."); - if ($GLOBALS['config']['config.enablecomms'] == "1") { + if (Config::getBool('config.enablecomms')) { AddTab("Comms", "index.php?p=commslist", "All of the communication bans (such as chat gags and voice mutes) in the database can be viewed from here."); } - if ($GLOBALS['config']['config.enablesubmit']=="1") { + if (Config::getBool('config.enablesubmit')) { AddTab("Report a Player", "index.php?p=submit", "You can submit a demo or screenshot of a suspected cheater here. It will then be up for review by one of the admins"); } - if ($GLOBALS['config']['config.enableprotest']=="1") { + if (Config::getBool('config.enableprotest')) { AddTab("Appeal a Ban", "index.php?p=protest", "Here you can appeal your ban. And prove your case as to why you should be unbanned."); } if ($userbank->is_admin()) { @@ -244,226 +244,41 @@ function RewritePageTitle($title) $GLOBALS['TitleRewrite'] = $title; } -/** - * Build sub-menu - * - * @param array $el The array of elements for the menu - * @return noreturn - */ -function SubMenu($el) +function BitToString($mask) { - $output = ""; - $first = true; - foreach ($el as $e) { - preg_match('/.*?&c=(.*)/', html_entity_decode($e['url']), $matches); - if (!empty($matches[1])) { - $c = $matches[1]; - } + $perms = json_decode(file_get_contents(ROOT.'/configs/permissions/web.json'), true); - $output .= "" . $e['title']. ""; - $first = false; - } - $GLOBALS['NavRewrite'] = $output; -} - -/** - * Converts a flag bitmask into a string - * - * @param integer $mask The mask to convert - * @return string - */ -function BitToString($mask, $masktype=0, $head=true) -{ - $string = ""; - if ($head) { - $string .= "Web Permissions
"; - } if ($mask == 0) { - $string .= "None"; - return $string; - } - if (($mask & ADMIN_LIST_ADMINS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• View Admins
"; - } - if (($mask & ADMIN_ADD_ADMINS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Add Admins
"; - } - if (($mask & ADMIN_EDIT_ADMINS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit Admins
"; - } - if (($mask & ADMIN_DELETE_ADMINS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Delete Admins
"; - } - - if (($mask & ADMIN_LIST_SERVERS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• View Servers
"; - } - if (($mask & ADMIN_ADD_SERVER) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Add Servers
"; - } - if (($mask & ADMIN_EDIT_SERVERS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit Servers
"; - } - if (($mask & ADMIN_DELETE_SERVERS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Delete Servers
"; - } - - if (($mask & ADMIN_ADD_BAN) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Add Bans
"; - } - if (($mask & ADMIN_EDIT_OWN_BANS) !=0 && ($mask & ADMIN_EDIT_ALL_BANS) ==0) { - $string .="• Edit Own Bans
"; - } - if (($mask & ADMIN_EDIT_GROUP_BANS) !=0 && ($mask & ADMIN_EDIT_ALL_BANS) ==0) { - $string .= "• Edit Group Bans
"; - } - if (($mask & ADMIN_EDIT_ALL_BANS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit All Bans
"; - } - if (($mask & ADMIN_BAN_PROTESTS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Ban Appeals
"; - } - if (($mask & ADMIN_BAN_SUBMISSIONS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Ban Reports
"; - } - - if (($mask & ADMIN_UNBAN_OWN_BANS) !=0 && ($mask & ADMIN_UNBAN) ==0) { - $string .= "• Unban Own Bans
"; - } - if (($mask & ADMIN_UNBAN_GROUP_BANS) !=0 && ($mask & ADMIN_UNBAN) ==0) { - $string .= "• Unban Group Bans
"; - } - if (($mask & ADMIN_UNBAN) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Unban All Bans
"; - } - if (($mask & ADMIN_DELETE_BAN) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Delete All Bans
"; - } - if (($mask & ADMIN_BAN_IMPORT) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Import Bans
"; - } - - if (($mask & ADMIN_LIST_GROUPS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• View Groups
"; - } - if (($mask & ADMIN_ADD_GROUP) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Add Groups
"; - } - if (($mask & ADMIN_EDIT_GROUPS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit Groups
"; - } - if (($mask & ADMIN_DELETE_GROUPS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Delete Groups
"; - } - - if (($mask & ADMIN_NOTIFY_SUB) !=0 || ($mask & ADMIN_NOTIFY_SUB) !=0) { - $string .= "• Ban Report Email Notifications
"; - } - if (($mask & ADMIN_NOTIFY_PROTEST) !=0 || ($mask & ADMIN_NOTIFY_PROTEST) !=0) { - $string .= "• Ban Appeal Email Notifications
"; - } - - if (($mask & ADMIN_WEB_SETTINGS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Web Settings
"; - } - - if (($mask & ADMIN_LIST_MODS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• View Mods
"; - } - if (($mask & ADMIN_ADD_MODS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Add Mods
"; - } - if (($mask & ADMIN_EDIT_MODS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit Mods
"; - } - if (($mask & ADMIN_DELETE_MODS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Delete Mods
"; + return false; } - if (($mask & ADMIN_OWNER) !=0) { - $string .= "• Owner
"; + foreach ($perms as $perm) { + if (($mask & $perm['value']) != 0 || ($mask & ADMIN_OWNER) != 0) { + if ($perm['value'] != ALL_WEB) { + $out[] = $perm['display']; + } + } } - return $string; + return $out; } -function SmFlagsToSb($flagstring, $head=true) +function SmFlagsToSb($flagstring) { - $string = ""; - if ($head) { - $string .= "Server Permissions
"; - } + $flags = json_decode(file_get_contents(ROOT.'/configs/permissions/sourcemod.json'), true); + if (empty($flagstring)) { - $string .= "None"; - return $string; - } - if ((strstr($flagstring, "a") || strstr($flagstring, "z"))) { - $string .= "• Reserved Slot
"; - } - if ((strstr($flagstring, "b") || strstr($flagstring, "z"))) { - $string .= "• Generic Admin
"; - } - if ((strstr($flagstring, "c") || strstr($flagstring, "z"))) { - $string .= "• Kick
"; - } - if ((strstr($flagstring, "d") || strstr($flagstring, "z"))) { - $string .= "• Ban
"; - } - if ((strstr($flagstring, "e") || strstr($flagstring, "z"))) { - $string .= "• Unban
"; - } - if ((strstr($flagstring, "f") || strstr($flagstring, "z"))) { - $string .= "• Slay
"; - } - if ((strstr($flagstring, "g") || strstr($flagstring, "z"))) { - $string .= "• Map Change
"; - } - if ((strstr($flagstring, "h") || strstr($flagstring, "z"))) { - $string .= "• Change CVars
"; - } - if ((strstr($flagstring, "i") || strstr($flagstring, "z"))) { - $string .= "• Run Configs
"; - } - if ((strstr($flagstring, "j") || strstr($flagstring, "z"))) { - $string .= "• Admin Chat
"; - } - if ((strstr($flagstring, "k") || strstr($flagstring, "z"))) { - $string .="• Start Votes
"; - } - if ((strstr($flagstring, "l") || strstr($flagstring, "z"))) { - $string .="• Password Server
"; - } - if ((strstr($flagstring, "m") || strstr($flagstring, "z"))) { - $string .="• RCON
"; - } - if ((strstr($flagstring, "n") || strstr($flagstring, "z"))) { - $string .="• Enable Cheats
"; - } - if ((strstr($flagstring, "z"))) { - $string .="• Full Admin
"; + return false; } - if ((strstr($flagstring, "o") || strstr($flagstring, "z"))) { - $string .="• Custom Flag 1
"; - } - if ((strstr($flagstring, "p") || strstr($flagstring, "z"))) { - $string .="• Custom Flag 2
"; - } - if ((strstr($flagstring, "q") || strstr($flagstring, "z"))) { - $string .="• Custom Flag 3
"; - } - if ((strstr($flagstring, "r") || strstr($flagstring, "z"))) { - $string .="• Custom flag 4
"; - } - if ((strstr($flagstring, "s") || strstr($flagstring, "z"))) { - $string .="• Custom Flag 5
"; - } - if ((strstr($flagstring, "t") || strstr($flagstring, "z"))) { - $string .="• Custom Flag 6
"; + foreach ($flags as $flag) { + if (strstr($flagstring, $flag['value']) || strstr($flagstring, 'z')) { + $out[] = $flag['display']; + } } - return $string; + return $out; } function NextSid() @@ -493,44 +308,9 @@ function trunc($text, $len, $byword=true) function CreateQuote() { - global $userbank; - $quote = array( - array("Buy a new PC!", "Viper"), - array("I'm not lazy! I just utilize technical resources!", "Brizad"), - array("I need to mow the lawn", "sslice"), - array("Like A Glove!", "Viper"), - array("Your a Noob and You Know It!", "Viper"), - array("Get your ass ingame", "Viper"), - array("Mother F***ing Peices of Sh**", "Viper"), - array("Shut up Bam", "[Everyone]"), - array("Hi OllyBunch", "Viper"), - array("Procrastination is like masturbation. Sure it feels good, but in the end you're only F***ing yourself!", "[Unknown]"), - array("Rave's momma so fat she sat on the beach and Greenpeace threw her in", "SteamFriend"), - array("Im just getting a beer", "Faith"), - array("To be honest " . ($userbank->is_logged_in()?$userbank->getProperty('user'):'...') . ", I DONT CARE!", "Viper"), - array("Yams", "teame06"), - array("built in cheat 1.6 - my friend told me theres a cheat where u can buy a car door and run around and it makes u invincible....", "gdogg"), - array("i just join conversation when i see a chance to tell people they might be wrong, then i quickly leave, LIKE A BAT", "BAILOPAN"), - array("Lets just blame it on FlyingMongoose", "[Everyone]"), - array("Don't step on that boom... mine...", "Recon"), - array("Looks through sniper scope... Sit ;)", "Recon"), - array("That plugin looks like something you found in a junk yard.", "Recon"), - array("That's exactly what I asked you not to do.", "Recon"), - array("Why are you wasting your time looking at this?", "Recon"), - array("You must have better things to do with your time", "Recon"), - array("I pity da fool", "Mr. T"), - array("you grew a 3rd head?", "Tsunami"), - array("I dont think you want to know...", "devicenull"), - array("Sheep sex isn't baaaaaa...aad", "Brizad"), - array("Oh wow, he's got skillz spelled with an 's'", "Brizad"), - array("I'll get to it this weekend... I promise", "Brizad"), - array("People do crazy things all the time... Like eat a Arby's", "Marge Simpson"), - array("I wish my lawn was emo, so it would cut itself", "SirTiger"), - array("Oh no! I've overflowed my balls!", "Olly"), - array("Pump me full of your precious information, Senpai!", "ISSUE_TEMPLATE.md") - ); - $num = rand(0, sizeof($quote)-1); - return '"' . $quote[$num][0] . '" - ' . $quote[$num][1] . ''; + $quotes = json_decode(file_get_contents('configs/quotes.json'), true); + $num = rand(0, count($quotes) - 1); + return '"'.$quotes[$num]['quote'].'" - '.$quotes[$num]['author'].''; } function CheckAdminAccess($mask) diff --git a/web/init.php b/web/init.php index ec2ef0041..4c585b7a7 100644 --- a/web/init.php +++ b/web/init.php @@ -52,31 +52,13 @@ define('SB_THEMES_COMPILE', ROOT . 'themes_c/'); define('IN_SB', true); -define('XAJAX_REQUEST_URI', './index.php'); require_once(INCLUDES_PATH.'/SessionManager.php'); include_once(INCLUDES_PATH . "/CUserManager.php"); \SessionManager::sessionStart('SourceBans'); -// --------------------------------------------------- -// Fix some $_SERVER vars -// --------------------------------------------------- -// Fix for IIS, which doesn't set REQUEST_URI -if (!isset($_SERVER['REQUEST_URI']) || trim($_SERVER['REQUEST_URI']) == '') { - $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; - if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { - $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; - } -} -// Fix for Dreamhost and other PHP as CGI hosts -if (strstr($_SERVER['SCRIPT_NAME'], 'php.cgi')) { - unset($_SERVER['PATH_INFO']); -} - -if (trim($_SERVER['PHP_SELF']) == '') { - $_SERVER['PHP_SELF'] = preg_replace("/(\?.*)?$/", '', $_SERVER["REQUEST_URI"]); -} +require_once(INCLUDES_PATH.'/SourceQuery/bootstrap.php'); // --------------------------------------------------- // Are we installed? @@ -105,24 +87,10 @@ // --------------------------------------------------- // Initial setup // --------------------------------------------------- -define('SB_GIT', true); -if (!defined('SB_VERSION')) { - if (file_exists('version.json')) { - $json = json_decode(file_get_contents('version.json'), true); - define('SB_VERSION', $json['version']); - define('SB_GITREV', $json['git']); - define('SB_DEV', $json['dev']); - } else { - define('SB_VERSION', 'N/A'); - define('SB_GITREV', '0'); - define('SB_DEV', false); - } -} -define('LOGIN_COOKIE_LIFETIME', (60*60*24*7)*2); -define('COOKIE_PATH', '/'); -define('COOKIE_DOMAIN', ''); -define('COOKIE_SECURE', false); -define('SB_SALT', 'SourceBans'); +$version = @json_decode(file_get_contents('configs/version.json'), true); +define('SB_VERSION', isset($version['version']) ? $version['version'] : 'N/A'); +define('SB_GITREV', isset($version['git']) ? $version['git'] : 0); +define('SB_DEV', isset($version['dev']) ? $version['dev'] : false); // --------------------------------------------------- // Setup PHP @@ -153,7 +121,6 @@ require_once(INCLUDES_PATH.'/Database.php'); $GLOBALS['db'] = ADONewConnection("mysqli://".DB_USER.':'.urlencode(DB_PASS).'@'.DB_HOST.':'.DB_PORT.'/'.DB_NAME); $GLOBALS['PDO'] = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASS, DB_PREFIX, DB_CHARSET); -$GLOBALS['sb-email'] = SB_EMAIL; if (!is_object($GLOBALS['db'])) { die(); @@ -161,20 +128,15 @@ $GLOBALS['db']->Execute("SET NAMES ".DB_CHARSET.";"); -$mysql_server_info = $GLOBALS['db']->ServerInfo(); -$GLOBALS['db_version'] = $mysql_server_info['version']; - -$debug = $GLOBALS['db']->Execute("SELECT value FROM `".DB_PREFIX."_settings` WHERE setting = 'config.debug';"); -if ($debug->fields['value']=="1") { - define("DEVELOPER_MODE", true); -} - require_once(INCLUDES_PATH.'/SteamID/bootstrap.php'); \SteamID\SteamID::init($GLOBALS['PDO']); require_once(INCLUDES_PATH.'/Log.php'); Log::init($GLOBALS['PDO']); +require_once(INCLUDES_PATH.'/Config.php'); +Config::init($GLOBALS['PDO']); + // --------------------------------------------------- // Setup our custom error handler // --------------------------------------------------- @@ -183,127 +145,37 @@ function sbError($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_USER_ERROR: - $msg = "[$errno] $errstr
\n"; - $msg .= "Fatal error on line $errline in file $errfile"; - Log::add("e", "PHP Error", $msg); - exit(1); - break; - + Log::add('e', 'PHP Error', "[$errno] $errstr\nFatal Error on line $errline in file $errfile"); + return true; case E_USER_WARNING: - $msg = "[$errno] $errstr
\n"; - $msg .= "Error on line $errline in file $errfile"; - Log::add("w", "PHP Warning", $msg); - break; - + Log::add('w', 'PHP Warning', "[$errno] $errstr\nError on line $errline in file $errfile"); + return true; case E_USER_NOTICE: - $msg = "[$errno] $errstr
\n"; - $msg .= "Notice on line $errline in file $errfile"; - Log::add("m", "PHP Notice", $msg); - break; - + Log::add('m', 'PHP Notice', "[$errno] $errstr\nNotice on line $errline in file $errfile"); + return true; default: return false; - break; } - - /* Don't execute PHP internal error handler */ - return true; } // --------------------------------------------------- // Some defs // --------------------------------------------------- -define('EMAIL_FORMAT', "/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/"); -define('URL_FORMAT', "/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}((:[0-9]{1,5})?\/.*)?$/i"); -define('STEAM_FORMAT', "/^STEAM_[0-9]:[0-9]:[0-9]+$/"); define('STATUS_PARSE', '/#.* +([0-9]+) +"(.+)" +(STEAM_[0-9]:[0-9]:[0-9]+|\[U:[0-9]:[0-9]+\]) +([0-9:]+) +([0-9]+) +([0-9]+) +([a-zA-Z]+).* +([0-9.:]+)/'); -define('IP_FORMAT', '/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/'); -define('SERVER_QUERY', 'http://www.sourcebans.net/public/query/'); - -// Web admin-flags -define('ADMIN_LIST_ADMINS', (1<<0)); -define('ADMIN_ADD_ADMINS', (1<<1)); -define('ADMIN_EDIT_ADMINS', (1<<2)); -define('ADMIN_DELETE_ADMINS', (1<<3)); - -define('ADMIN_LIST_SERVERS', (1<<4)); -define('ADMIN_ADD_SERVER', (1<<5)); -define('ADMIN_EDIT_SERVERS', (1<<6)); -define('ADMIN_DELETE_SERVERS', (1<<7)); - -define('ADMIN_ADD_BAN', (1<<8)); -define('ADMIN_EDIT_OWN_BANS', (1<<10)); -define('ADMIN_EDIT_GROUP_BANS', (1<<11)); -define('ADMIN_EDIT_ALL_BANS', (1<<12)); -define('ADMIN_BAN_PROTESTS', (1<<13)); -define('ADMIN_BAN_SUBMISSIONS', (1<<14)); -define('ADMIN_DELETE_BAN', (1<<25)); -define('ADMIN_UNBAN', (1<<26)); -define('ADMIN_BAN_IMPORT', (1<<27)); -define('ADMIN_UNBAN_OWN_BANS', (1<<30)); -define('ADMIN_UNBAN_GROUP_BANS', (1<<31)); - -define('ADMIN_LIST_GROUPS', (1<<15)); -define('ADMIN_ADD_GROUP', (1<<16)); -define('ADMIN_EDIT_GROUPS', (1<<17)); -define('ADMIN_DELETE_GROUPS', (1<<18)); - -define('ADMIN_WEB_SETTINGS', (1<<19)); - -define('ADMIN_LIST_MODS', (1<<20)); -define('ADMIN_ADD_MODS', (1<<21)); -define('ADMIN_EDIT_MODS', (1<<22)); -define('ADMIN_DELETE_MODS', (1<<23)); - -define('ADMIN_NOTIFY_SUB', (1<<28)); -define('ADMIN_NOTIFY_PROTEST', (1<<29)); - -define('ADMIN_OWNER', (1<<24)); - -// Server admin-flags -define('SM_RESERVED_SLOT', "a"); -define('SM_GENERIC', "b"); -define('SM_KICK', "c"); -define('SM_BAN', "d"); -define('SM_UNBAN', "e"); -define('SM_SLAY', "f"); -define('SM_MAP', "g"); -define('SM_CVAR', "h"); -define('SM_CONFIG', "i"); -define('SM_CHAT', "j"); -define('SM_VOTE', "k"); -define('SM_PASSWORD', "l"); -define('SM_RCON', "m"); -define('SM_CHEATS', "n"); -define('SM_ROOT', "z"); - -define('SM_CUSTOM1', "o"); -define('SM_CUSTOM2', "p"); -define('SM_CUSTOM3', "q"); -define('SM_CUSTOM4', "r"); -define('SM_CUSTOM5', "s"); -define('SM_CUSTOM6', "t"); - - -define('ALL_WEB', ADMIN_LIST_ADMINS|ADMIN_ADD_ADMINS|ADMIN_EDIT_ADMINS|ADMIN_DELETE_ADMINS|ADMIN_LIST_SERVERS|ADMIN_ADD_SERVER| - ADMIN_EDIT_SERVERS|ADMIN_DELETE_SERVERS|ADMIN_ADD_BAN|ADMIN_EDIT_OWN_BANS|ADMIN_EDIT_GROUP_BANS| - ADMIN_EDIT_ALL_BANS|ADMIN_BAN_PROTESTS|ADMIN_BAN_SUBMISSIONS|ADMIN_LIST_GROUPS|ADMIN_ADD_GROUP|ADMIN_EDIT_GROUPS| - ADMIN_DELETE_GROUPS|ADMIN_WEB_SETTINGS|ADMIN_LIST_MODS|ADMIN_ADD_MODS|ADMIN_EDIT_MODS|ADMIN_DELETE_MODS|ADMIN_OWNER| - ADMIN_DELETE_BAN|ADMIN_UNBAN|ADMIN_BAN_IMPORT|ADMIN_UNBAN_OWN_BANS|ADMIN_UNBAN_GROUP_BANS|ADMIN_NOTIFY_SUB|ADMIN_NOTIFY_PROTEST); - -define('ALL_SERVER', SM_RESERVED_SLOT.SM_GENERIC.SM_KICK.SM_BAN.SM_UNBAN.SM_SLAY.SM_MAP.SM_CVAR.SM_CONFIG.SM_VOTE.SM_PASSWORD.SM_RCON. - SM_CHEATS.SM_CUSTOM1.SM_CUSTOM2.SM_CUSTOM3. SM_CUSTOM4.SM_CUSTOM5.SM_CUSTOM6.SM_ROOT); - -$res = $GLOBALS['db']->Execute("SELECT * FROM ".DB_PREFIX."_settings GROUP BY `setting`, `value`"); -$GLOBALS['config'] = array(); -while (!$res->EOF) { - $setting = array($res->fields['setting'] => $res->fields['value']); - $GLOBALS['config'] = array_merge_recursive($GLOBALS['config'], $setting); - $res->MoveNext(); + +$webflags = json_decode(file_get_contents(ROOT.'/configs/permissions/web.json'), true); +foreach ($webflags as $flag => $perm) { + define($flag, $perm['value']); } +$smflags = json_decode(file_get_contents(ROOT.'/configs/permissions/sourcemod.json'), true); +foreach ($smflags as $flag => $perm) { + define($flag, $perm['value']); +} + +define("DEVELOPER_MODE", Config::getBool('config.debug')); +define('SB_BANS_PER_PAGE', Config::get('banlist.bansperpage')); +define('MIN_PASS_LENGTH', Config::get('config.password.minlength')); -define('SB_BANS_PER_PAGE', $GLOBALS['config']['banlist.bansperpage']); -define('MIN_PASS_LENGTH', $GLOBALS['config']['config.password.minlength']); -$dateformat = !empty($GLOBALS['config']['config.dateformat'])?$GLOBALS['config']['config.dateformat']:"m-d-y H:i"; +$dateformat = (Config::getBool('config.dateformat')) ? Config::get('config.dateformat') : 'm-d-y H:i'; // --------------------------------------------------- // Setup our templater @@ -312,7 +184,7 @@ function sbError($errno, $errstr, $errfile, $errline) global $theme, $userbank; -$theme_name = isset($GLOBALS['config']['config.theme'])?$GLOBALS['config']['config.theme']:'default'; +$theme_name = (Config::getBool('config.theme')) ? Config::get('config.theme') : 'default'; if (defined("IS_UPDATE")) { $theme_name = "default"; } diff --git a/web/install/includes/converter.inc.php b/web/install/includes/converter.inc.php index f90cbe134..a60ce68d4 100644 --- a/web/install/includes/converter.inc.php +++ b/web/install/includes/converter.inc.php @@ -66,78 +66,4 @@ function convertAmxbans($oldDB, $newDB) $newDB->execute(); } echo "OK
"; - /* - echo "Converting ".$fromprefix."_banhistory... "; - ob_flush(); - $res = $olddb->Execute("SELECT player_ip, player_id, player_nick, ban_created, ban_length, ban_reason, admin_ip, admin_id, admin_nick - ,server_ip, server_name, unban_created FROM ".$fromprefix."_banhistory"); - $ins = $newdb->Prepare("INSERT INTO ".$toprefix."_banhistory(Type,ip,authid,name,created,ends,length,reason,adminIp,Adminid,RemovedOn,RemovedBy) VALUES ('U',?,?,?,?,?,?,?,?,?,?,?)"); - while (!$res->EOF) - { - $vals = array($res->fields[0],$res->fields[1],$res->fields[2],$res->fields[3],($res->fields[4] == 0 ? 0 : $res->fields[3]+$res->fields[4]) - ,$res->fields[4],$res->fields[5],$res->fields[6],$res->fields[7],$res->fields[8],$res->fields[7]); - - foreach ($vals as $ind=>$cur) - { - if (is_null($cur)) - { - $vals[$ind] = ''; - } - } - $newdb->Execute($ins,$vals); - $res->MoveNext(); - } - echo "OK
"; - - echo "Converting ".$fromprefix."_levels... "; - ob_flush(); - $res = $olddb->Execute("SELECT level, bans_add, bans_edit, bans_delete, bans_unban, bans_import, bans_export, amxadmins_view, amxadmins_edit - , webadmins_view, webadmins_edit, permissions_edit, servers_edit FROM ".$fromprefix."_levels"); - $ins = $newdb->Prepare("INSERT INTO ".$toprefix."_groups(type,name,flags) VALUES (1,?,?)"); - $levelconvert = array(); - while (!$res->EOF) - { - $acc = 0; - if ($res->fields[1] == 'yes' || $res->fields[2] == 'yes' || $res->fields[3] == 'yes' || $res->fields[4] == 'yes') - { - $acc |= ADMIN_WEB_BANS; - } - // amxadmins_view is ignored - if ($res->fields[6] == 'yes') - { - $acc |= ADMIN_SERVER_ADMINS; - } - // webadmins_view is ignored - if ($res->fields[8] == 'yes') - { - $acc |= ADMIN_WEB_AGROUPS; - } - if ($res->fields[9] == 'yes') - { - $acc |= ADMIN_WEB_AGROUPS | ADMIN_SERVER_AGROUPS; - } - if ($res->fields[10] == 'yes') - { - $acc |= ADMIN_SERVER_ADD | ADMIN_SERVER_REMOVE | ADMIN_SERVER_GROUPS; - } - if ($res->fields[0] == '1') - { - $acc |= ADMIN_OWNER; - } - $newdb->Execute($ins,array("AMXBANS_".$res->fields[0],$acc)); - $levelconvert[$res->fields[0]] = $newdb->Insert_ID(); - $res->MoveNext(); - } - echo "OK
"; - - echo "Converting ".$fromprefix."_admins... "; - ob_flush(); - $res = $olddb->Execute("SELECT username, level FROM ".$fromprefix."_webadmins"); - $ins = $newdb->Prepare("INSERT INTO ".$toprefix."_admins(user,name,gid) VALUES (?,?,?)"); - while (!$res->EOF) - { - $newdb->Execute($ins,array($res->fields[0],$res->fields[0],$levelconvert[$res->fields[1]])); - $res->MoveNext(); - } - echo "OK
"; */ - } +} diff --git a/web/install/includes/data.sql b/web/install/includes/data.sql index b992722d4..9e6aec7e2 100644 --- a/web/install/includes/data.sql +++ b/web/install/includes/data.sql @@ -1,43 +1,41 @@ INSERT INTO `{prefix}_mods` (`mid`, `name`, `icon`, `modfolder`, `steam_universe`) VALUES -(1, 'Web', 'web.png', 'NULL', '0'), -(2, 'Half-Life 2 Deathmatch', 'hl2dm.png', 'hl2mp', '0'), -(3, 'Counter-Strike: Source', 'csource.png', 'cstrike', '0'), -(4, 'Day of Defeat: Source', 'dods.png', 'dod', '0'), -(5, 'Insurgency: Source', 'ins.png', 'insurgency', '0'), -(6, 'Dystopia', 'dys.png', 'dystopia_v1', '0'), -(7, 'Hidden: Source', 'hidden.png', 'hidden', '0'), -(8, 'Half-Life 2 Capture the Flag', 'hl2ctf.png', 'hl2ctf', '0'), -(9, 'Pirates Vikings and Knights II', 'pvkii.png', 'pvkii', '0'), -(10, 'Perfect Dark: Source', 'pdark.png', 'pdark', '0'), -(11, 'The Ship', 'ship.png', 'ship', '0'), -(12, 'Fortress Forever', 'hl2-fortressforever.png', 'FortressForever', '0'), -(13, 'Team Fortress 2', 'tf2.png', 'tf', '0'), -(14, 'Zombie Panic', 'zps.png', 'zps', '0'), -(15, "Garry's Mod", 'gmod.png', 'garrysmod', '0'), -(16, "Left 4 Dead", 'l4d.png', 'left4dead', '1'), -(17, "Left 4 Dead 2", 'l4d2.png', 'left4dead2', '1'), -(18, "CSPromod", 'cspromod.png', 'cspromod', '0'), -(19, "Alien Swarm", 'alienswarm.png', 'alienswarm', '0'), -(20, "E.Y.E: Divine Cybermancy", 'eye.png', 'eye', '0'), -(21, "Nuclear Dawn", 'nucleardawn.png', 'nucleardawn', '0'), -(22, "Counter-Strike: Global Offensive", 'csgo.png', 'csgo', '1'), -(23, 'Synergy', 'synergy.png', 'synergy', '0'); - -UPDATE `{prefix}_mods` SET `mid` = '0' WHERE `name` = 'Web'; +(0, 'Web', 'web.png', 'NULL', '0'), +(1, 'Half-Life 2 Deathmatch', 'hl2dm.png', 'hl2mp', '0'), +(2, 'Counter-Strike: Source', 'csource.png', 'cstrike', '0'), +(3, 'Day of Defeat: Source', 'dods.png', 'dod', '0'), +(4, 'Insurgency: Source', 'ins.png', 'insurgency', '0'), +(5, 'Dystopia', 'dys.png', 'dystopia_v1', '0'), +(6, 'Hidden: Source', 'hidden.png', 'hidden', '0'), +(7, 'Half-Life 2 Capture the Flag', 'hl2ctf.png', 'hl2ctf', '0'), +(8, 'Pirates Vikings and Knights II', 'pvkii.png', 'pvkii', '0'), +(9, 'Perfect Dark: Source', 'pdark.png', 'pdark', '0'), +(10, 'The Ship', 'ship.png', 'ship', '0'), +(11, 'Fortress Forever', 'hl2-fortressforever.png', 'FortressForever', '0'), +(12, 'Team Fortress 2', 'tf2.png', 'tf', '0'), +(13, 'Zombie Panic', 'zps.png', 'zps', '0'), +(14, "Garry's Mod", 'gmod.png', 'garrysmod', '0'), +(15, "Left 4 Dead", 'l4d.png', 'left4dead', '1'), +(16, "Left 4 Dead 2", 'l4d2.png', 'left4dead2', '1'), +(17, "CSPromod", 'cspromod.png', 'cspromod', '0'), +(18, "Alien Swarm", 'alienswarm.png', 'alienswarm', '0'), +(19, "E.Y.E: Divine Cybermancy", 'eye.png', 'eye', '0'), +(20, "Nuclear Dawn", 'nucleardawn.png', 'nucleardawn', '0'), +(21, "Counter-Strike: Global Offensive", 'csgo.png', 'csgo', '1'), +(22, 'Synergy', 'synergy.png', 'synergy', '0'); INSERT INTO `{prefix}_settings` (`setting`, `value`) VALUES -('dash.intro.text', '

Your new SourceBans install

SourceBans successfully installed!

'), -('dash.intro.title', 'Your SourceBans install'), +('dash.intro.text', '

Your new SourceBans install

SourceBans++ successfully installed!

'), +('dash.intro.title', 'Your SourceBans++ install'), ('dash.lognopopup', '0'), ('banlist.bansperpage', '30'), -('banlist.hideadminname', '0'), -('banlist.nocountryfetch', '0'), -('banlist.hideplayerips', '0'), +('banlist.hideadminname', '1'), +('banlist.nocountryfetch', '1'), +('banlist.hideplayerips', '1'), ('bans.customreasons', ''), -('config.password.minlength', '4'), +('config.password.minlength', '7'), ('config.debug', '0 '), ('template.logo', 'logos/sb-large.png'), -('template.title', 'SourceBans'), +('template.title', 'SourceBans++'), ('config.enableprotest', '1'), ('config.enablecomms', '1'), ('config.enablesubmit', '1'), @@ -50,13 +48,8 @@ INSERT INTO `{prefix}_settings` (`setting`, `value`) VALUES ('config.enablefriendsbanning', '0'), ('config.enableadminrehashing', '1'), ('protest.emailonlyinvolved', '0'), -('config.version', '604'), +('config.version', '605'), ('config.enablesteamlogin', '1'); - -INSERT INTO `{prefix}_admins` ( -`aid` , `user` , `authid` , `password` , `gid` , `email` , `validate` , `extraflags`, `immunity`) -VALUES ( -NULL , 'CONSOLE', 'STEAM_ID_SERVER', '', '0', '', NULL, '0', 0); - -UPDATE `{prefix}_admins` SET `aid` = '0' WHERE `authid` = 'STEAM_ID_SERVER'; +INSERT INTO `{prefix}_admins` (`aid` , `user` , `authid` , `password` , `gid` , `email` , `validate` , `extraflags`, `immunity`) VALUES +(0 , 'CONSOLE', 'STEAM_ID_SERVER', '', '0', '', NULL, '0', 0); diff --git a/web/install/includes/page-builder.php b/web/install/includes/page-builder.php deleted file mode 100644 index 55e0526ee..000000000 --- a/web/install/includes/page-builder.php +++ /dev/null @@ -1,64 +0,0 @@ - -// -// SourceBans++ 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, per version 3 of the License. -// -// SourceBans++ 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 SourceBans++. If not, see . -// -// This file is based off work covered by the following copyright(s): -// -// SourceBans 1.4.11 -// Copyright (C) 2007-2015 SourceBans Team - Part of GameConnect -// Licensed under GNU GPL version 3, or later. -// Page: - -// -// ************************************************************************* - -$_GET['step'] = isset($_GET['step']) ? $_GET['step'] : '1'; - -switch ($_GET['step']) { - case "6": - RewritePageTitle("Step 6 - AMXBans Import"); - $page = TEMPLATES_PATH . "/page.6.php"; - break; - case "5": - RewritePageTitle("Step 5 - Setup"); - $page = TEMPLATES_PATH . "/page.5.php"; - break; - case "4": - RewritePageTitle("Step 4 - Table Creation"); - $page = TEMPLATES_PATH . "/page.4.php"; - break; - case "3": - RewritePageTitle("Step 3 - System Requirements Check"); - $page = TEMPLATES_PATH . "/page.3.php"; - break; - case "2": - RewritePageTitle("Step 2 - Database Details"); - $page = TEMPLATES_PATH . "/page.2.php"; - break; - default: - RewritePageTitle("Step 1 - License agreement"); - $page = TEMPLATES_PATH . "/page.1.php"; - break; -} - -require_once(TEMPLATES_PATH . "/header.php"); -BuildPageTabs(); -BuildSubMenu(); -BuildContHeader(); -if (!empty($page)) { - include $page; -} -include_once(TEMPLATES_PATH . '/footer.php'); diff --git a/web/install/includes/routing.php b/web/install/includes/routing.php new file mode 100644 index 000000000..9324761fd --- /dev/null +++ b/web/install/includes/routing.php @@ -0,0 +1,27 @@ + -// -// SourceBans++ 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, per version 3 of the License. -// -// SourceBans++ 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 SourceBans++. If not, see . -// -// This file is based off work covered by the following copyright(s): -// -// SourceBans 1.4.11 -// Copyright (C) 2007-2015 SourceBans Team - Part of GameConnect -// Licensed under GNU GPL version 3, or later. -// Page: - -// -// ************************************************************************* - -if (!defined("IN_SB")) { - die("You should not be here. Only follow links!"); -} - -/** - * Displays the sub-nav menu of SourceBans - * - * @return noreturn - */ -function BuildSubMenu() -{ - include TEMPLATES_PATH . "/submenu.php"; -} - -/** - * Displays the content header - * - * @return noreturn - */ -function BuildContHeader() -{ - if (!isset($_GET['s'])) { - $page = "".(isset($GLOBALS['pagetitle']) ? $GLOBALS['pagetitle'] : '').""; - } - include TEMPLATES_PATH . "/content.header.php"; -} - - -/** - * Adds a tab to the page - * - * @param string $title The title of the tab - * @param string $utl The link of the tab - * @param boolean $active Is the tab active? - * @return noreturn - */ - -function AddTab($title, $url, $desc, $active=false) -{ - global $tabs; - $tab_arr = array(); - $tab_arr[0] = "Dashboard"; - $tab_arr[1] = "Ban List"; - $tab_arr[2] = "Servers"; - $tab_arr[3] = "Submit a ban"; - $tab_arr[4] = "Protest a ban"; - $tabs = array(); - $tabs['title'] = $title; - $tabs['url'] = $url; - $tabs['desc'] = $desc; - if (!isset($_GET['p']) && $title == $tab_arr[isset($GLOBALS['config']) ? intval($GLOBALS['config']['config.defaultpage']) : 0]) { - $tabs['active'] = true; - $GLOBALS['pagetitle'] = $title; - } else { - if (isset($_GET['p']) && substr($url, 3) == $_GET['p']) { - $tabs['active'] = true; - $GLOBALS['pagetitle'] = $title; - } else { - $tabs['active'] = false; - } - } - include TEMPLATES_PATH . "/tab.php"; -} - -/** - * Displays the pagetabs - * - * @return noreturn - */ -function BuildPageTabs() -{ - AddTab("SourceBans", "https://www.gameconnect.net/projects/sourcebans/", ""); - AddTab("SourceBans++", "https://sbpp.github.io", ""); - AddTab("SourceMod", "https://www.sourcemod.net/", ""); -} - -/** - * Rewrites the breadcrumb html - * - * @return noreturn - */ -function BuildBreadcrumbs() -{ - $base = $GLOBALS['pagetitle']; - - switch ($_GET['c']) { - case "admins": - $cat = "Admin management"; - break; - case "servers": - $cat = "Server management"; - break; - case "bans": - $cat = "Ban management"; - break; - case "groups": - $cat = "Group management"; - break; - case "settings": - $cat = "SourceBans settings"; - break; - case "mods": - $cat = "Mod management"; - break; - } - - if (!isset($_GET['c'])) { - $bread = "" . $base . ""; - } else { - $bread = "" . $base . " » " . $cat . ""; - } - $text = "» Home » " . $bread; - echo ''; -} -/** - * Creates an anchor tag, and adds tooltip code if needed - * - * @param string $title The title of the tooltip/text to link - * @param string $url The link - * @param string $tooltip The tooltip message - * @param string $target The new links target - * @return noreturn - */ -function CreateLink($title, $url, $tooltip="", $target="_self", $wide=false) -{ - $class = "tip"; - if ($wide) { - $class = "perm"; - } - if (strlen($tooltip) == 0) { - echo '' . $title .' '; - } else { - echo '' . $title .' '; - } -} - -/** - * Creates an anchor tag, and adds tooltip code if needed - * - * @param string $title The title of the tooltip/text to link - * @param string $url The link - * @param string $tooltip The tooltip message - * @param string $target The new links target - * @return URL - */ -function CreateLinkR($title, $url, $tooltip="", $target="_self", $wide=false, $onclick) -{ - $class = "tip"; - if ($wide) { - $class = "perm"; - } - - if (strlen($tooltip) == 0) { - return '' . $title .' '; - } else { - return '' . $title .' '; - } -} - function HelpIcon($title, $text) { - return '  '; -} - -/** - * Allows the title of the page to change wherever the code is being executed from - * - * @param string $title The new title - * @return noreturn - */ -function RewritePageTitle($title) -{ - $GLOBALS['TitleRewrite'] = $title; -} - -/** - * Build sub-menu - * - * @param array $el The array of elements for the menu - * @return noreturn - */ -function SubMenu($el) -{ - $output = ""; - foreach ($el as $e) { - $output .= "" . $e['title']. ""; - } - $GLOBALS['NavRewrite'] = $output; -} - -/** - * Converts a flag bitmask into a string - * - * @param integer $mask The mask to convert - * @return string - */ -function BitToString($mask, $masktype=0, $head=true) -{ - $string = ""; - if ($head) { - $string .= "Web Permissions
"; - } - if ($mask == 0) { - $string .= "None"; - return $string; - } - if (($mask & ADMIN_LIST_ADMINS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• View admins
"; - } - if (($mask & ADMIN_ADD_ADMINS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Add admins
"; - } - if (($mask & ADMIN_EDIT_ADMINS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit admins
"; - } - if (($mask & ADMIN_DELETE_ADMINS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Delete admins
"; - } - - if (($mask & ADMIN_LIST_SERVERS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• View servers
"; - } - if (($mask & ADMIN_ADD_SERVER) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Add servers
"; - } - if (($mask & ADMIN_EDIT_SERVERS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit servers
"; - } - if (($mask & ADMIN_DELETE_SERVERS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Delete servers
"; - } - - if (($mask & ADMIN_ADD_BAN) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Add bans
"; - } - if (($mask & ADMIN_BAN_LIST) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• View bans
"; - } - if (($mask & ADMIN_EDIT_OWN_BANS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .="• Edit own bans
"; - } - if (($mask & ADMIN_EDIT_GROUP_BANS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit groups bans
"; - } - if (($mask & ADMIN_EDIT_ALL_BANS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit all bans
"; - } - if (($mask & ADMIN_BAN_PROTESTS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Ban protests
"; - } - if (($mask & ADMIN_BAN_SUBMISSIONS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Ban submissions
"; - } - - if (($mask & ADMIN_LIST_GROUPS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• List groups
"; - } - if (($mask & ADMIN_ADD_GROUP) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Add groups
"; - } - if (($mask & ADMIN_EDIT_GROUPS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit groups
"; - } - if (($mask & ADMIN_DELETE_GROUPS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Delete groups
"; - } - - if (($mask & ADMIN_WEB_SETTINGS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Web settings
"; - } - - if (($mask & ADMIN_LIST_MODS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• List mods
"; - } - if (($mask & ADMIN_ADD_MODS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Add mods
"; - } - if (($mask & ADMIN_EDIT_MODS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Edit mods
"; - } - if (($mask & ADMIN_DELETE_MODS) !=0 || ($mask & ADMIN_OWNER) !=0) { - $string .= "• Delete mods
"; - } - - if (($mask & ADMIN_OWNER) !=0) { - $string .= "• Owner
"; - } - - return $string; -} - - -function SmFlagsToSb($flagstring, $head=true) -{ - $string = ""; - if ($head) { - $string .= "Server Permissions
"; - } - if (empty($flagstring)) { - $string .= "None"; - return $string; - } - if((strstr($flagstring, "a") || strstr($flagstring, "z"))) - $string .= "• Reserved slot
"; - if((strstr($flagstring, "b") || strstr($flagstring, "z"))) - $string .= "• Generic admin
"; - if((strstr($flagstring, "c") || strstr($flagstring, "z"))) - $string .= "• Kick
"; - if((strstr($flagstring, "d") || strstr($flagstring, "z"))) - $string .= "• Ban
"; - if((strstr($flagstring, "e") || strstr($flagstring, "z"))) - $string .= "• Un-ban
"; - if((strstr($flagstring, "f") || strstr($flagstring, "z"))) - $string .= "• Slay
"; - if((strstr($flagstring, "g") || strstr($flagstring, "z"))) - $string .= "• Map change
"; - if((strstr($flagstring, "h") || strstr($flagstring, "z"))) - $string .= "• Change cvars
"; - if((strstr($flagstring, "i") || strstr($flagstring, "z"))) - $string .= "• Run configs
"; - if((strstr($flagstring, "j") || strstr($flagstring, "z"))) - $string .= "• Admin chat
"; - if((strstr($flagstring, "k") || strstr($flagstring, "z"))) - $string .="• Start votes
"; - if((strstr($flagstring, "l") || strstr($flagstring, "z"))) - $string .="• Password server
"; - if((strstr($flagstring, "m") || strstr($flagstring, "z"))) - $string .="• RCON
"; - if((strstr($flagstring, "n") || strstr($flagstring, "z"))) - $string .="• Enable Cheats
"; - if((strstr($flagstring, "z"))) - $string .="• Full Admin
"; - - if((strstr($flagstring, "o") || strstr($flagstring, "z"))) - $string .="• Custom flag 1
"; - if((strstr($flagstring, "p") || strstr($flagstring, "z"))) - $string .="• Custom flag 2
"; - if((strstr($flagstring, "q") || strstr($flagstring, "z"))) - $string .="• Custom flag 3
"; - if((strstr($flagstring, "r") || strstr($flagstring, "z"))) - $string .="• Custom flag 4
"; - if((strstr($flagstring, "s") || strstr($flagstring, "z"))) - $string .="• Custom flag 5
"; - if((strstr($flagstring, "t") || strstr($flagstring, "z"))) - $string .="• Custom flag 6
"; - - - //if(($mask & SM_DEF_IMMUNITY) != 0) - //{ - // $flagstring .="• Default immunity
"; - //} - //if(($mask & SM_GLOBAL_IMMUNITY) != 0) - //{ - // $flagstring .="• Global immunity
"; - //} - return $string; -} - -function PrintArray($array) -{ - echo "
";
-    print_r($array);
-    echo "
"; -} - -function NextGid() -{ - $gid = $GLOBALS['db']->GetRow("SELECT MAX(gid) AS next_gid FROM `" . DB_PREFIX . "_groups`"); - return ($gid['next_gid']+1); -} -function NextSGid() -{ - $gid = $GLOBALS['db']->GetRow("SELECT MAX(id) AS next_id FROM `" . DB_PREFIX . "_srvgroups`"); - return ($gid['next_id']+1); -} -function NextSid() -{ - $sid = $GLOBALS['db']->GetRow("SELECT MAX(sid) AS next_sid FROM `" . DB_PREFIX . "_servers`"); - return ($sid['next_sid']+1); -} -function NextAid() -{ - $aid = $GLOBALS['db']->GetRow("SELECT MAX(aid) AS next_aid FROM `" . DB_PREFIX . "_admins`"); - return ($aid['next_aid']+1); -} - -function trunc($text, $len, $byword=true) -{ - if(strlen($text) <= $len) - return $text; - $text = $text." "; - $text = substr($text,0,$len); - if($byword) - $text = substr($text,0,strrpos($text,' ')); - $text = $text."..."; - return $text; -} - -function CreateRedBox($title, $content) -{ - $text = '
- Warning - ' . $title .' -
- ' . $content . ' -
'; - - echo $text; -} -function CreateGreenBox($title, $contnet) -{ - $text = '
- Yay! - ' . $title .' -
- ' . $contnet . ' -
'; - - echo $text; + return ''; } function CreateQuote() { - $quote = array( - array("Buy a new PC!", "Viper"), - array("I'm not lazy! I just utilize technical resources!", "Brizad"), - array("I need to mow the lawn", "sslice"), - array("Like A Glove!", "Viper"), - array("Your a Noob and You Know It!", "Viper"), - array("Get your ass ingame", "Viper"), - array("Mother F***ing Peices of Sh**", "Viper"), - array("Shut up Bam", "[Everyone]"), - array("Hi OllyBunch", "Viper"), - array("Procrastination is like masturbation. Sure it feels good, but in the end you're only F***ing yourself!", "[Unknown]"), - array("Rave's momma so fat she sat on the beach and Greenpeace threw her in", "SteamFriend"), - array("Im just getting a beer", "Faith"), - array("To be honest " . (isset($_SESSION['user']['user'])?$_SESSION['user']['user']:'...') . ", I DONT CARE!", "Viper"), - array("Yams", "teame06"), - array("built in cheat 1.6 - my friend told me theres a cheat where u can buy a car door and run around and it makes u invincible....", "gdogg"), - array("i just join conversation when i see a chance to tell people they might be wrong, then i quickly leave, LIKE A BAT", "BAILOPAN"), - array("Lets just blame it on FlyingMongoose", "[Everyone]"), - array("I wish my lawn was emo, so it would cut itself", "SirTiger"), - ); - $num = rand(0, sizeof($quote)-1); - return '"' . $quote[$num][0] . '" - ' . $quote[$num][1] . ''; -} - -function RemoveCode($text) -{ - return addslashes(htmlspecialchars(strip_tags($text))); + $quotes = json_decode(file_get_contents('../configs/quotes.json'), true); + $num = rand(0, count($quotes) - 1); + return sprintf('"%s" - %s', $quotes[$num]['quote'], $quotes[$num]['author']); } - -function SecondsToString($sec, $textual=true) -{ - $div = array( 2592000, 604800, 86400, 3600, 60, 1 ); - if($textual) - { - $desc = array ('mo','wk','d','hr','min','sec'); - $ret = ""; - for ($i=0;$i= 1) - { - $ret .= $cou.' '.$desc[$i].', '; - $sec %= $div[$i]; - } - } - $ret = substr($ret,0,strlen($ret)-2); - }else{ - $hours = floor ($sec / 60 / 60); - $sec -= $hours * 60*60; - $mins = floor ($sec / 60); - $secs = $sec % 60; - $ret = $hours . ":" . $mins . ":" . $secs; - } - return $ret; -} - -function CreateHostnameCache() -{ - require_once INCLUDES_PATH.'/CServerInfo.php'; - - $res = $GLOBALS['db']->Execute("SELECT sid, ip, port, modid, rcon FROM ".DB_PREFIX."_servers WHERE sid > 0 ORDER BY sid"); - $servers = array(); - while (!$res->EOF) - { - $info = array(); - $sinfo = new CServerInfo($res->fields[1],$res->fields[2]); - $info = $sinfo->getInfo(); - $servers[$res->fields[0]] = $info['hostname']; - $res->MoveNext(); - } - return($servers); -} - -function FetchIp($ip) -{ - global $addr; - $addr = $ip; - return include INCLUDES_PATH.'/read_country.php'; -} - -function PageDie() -{ - include TEMPLATES_PATH.'/footer.php'; - die(); -} - -function GetMapImage($map) -{ - if(@file_exists(SB_MAP_LOCATION . "/" . $map . ".jpg")) - return "images/maps/" . $map . ".jpg"; - else - return "images/maps/nomap.jpg"; -} - -?> diff --git a/web/install/includes/user-functions.php b/web/install/includes/user-functions.php deleted file mode 100644 index 8bddb6f94..000000000 --- a/web/install/includes/user-functions.php +++ /dev/null @@ -1,186 +0,0 @@ - -// -// SourceBans++ 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, per version 3 of the License. -// -// SourceBans++ 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 SourceBans++. If not, see . -// -// This file is based off work covered by the following copyright(s): -// -// SourceBans 1.4.11 -// Copyright (C) 2007-2015 SourceBans Team - Part of GameConnect -// Licensed under GNU GPL version 3, or later. -// Page: - -// -// ************************************************************************* - -global $user, $db; -/** - * Checks the database for any identical - * rows, username, email etc - * - * @param string $table the table to lookup - * @param string $field The feild to check - * @param string $value The value to check against - * @return true if the value already exists in that field is found, else false - */ -function is_taken($table, $field, $value) -{ - $GLOBALS['db']->query('SELECT * FROM `:prefix_:table` WHERE `:field` = `:value`'); - $GLOBALS['db']->bind(':table', $table); - $GLOBALS['db']->bind(':field', $field); - $GLOBALS['db']->bind(':value', $value); - $result = $GLOBALS['db']->resultset(); - return (count($result) > 0); -} - -/** - * Returns the current flags associated with the user - * - * @param integer The admin id to check - * @return integer. - */ -function get_user_flags($aid) -{ - if (empty($aid)) { - return 0; - } - - $GLOBALS['db']->query('SELECT `gid`, `extraflags` FROM `:prefix_admins` WHERE `aid` = `:aid`'); - $GLOBALS['db']->bind(':aid', $aid); - $admin = $GLOBALS['db']->single(); - - if (intval($admin['gid']) === -1) { - return intval($admin['extraflags']); - } - - $GLOBALS['db']->query('SELECT `flags` FROM `:prefix_groups` WHERE `gid` = `:gid`'); - $GLOBALS['db']->bind(':gid', $admin['gid']); - $group = $GLOBALS['db']->single(); - return (intval($group['flags']) | intval($admin['extraflags'])); -} - -/** - * Returns the current server flags associated with the user - * - * @param string The admin to check - * @return string. - */ -function get_user_admin($steam) -{ - if (empty($steam)) { - return 0; - } - $GLOBALS['db']->query('SELECT * FROM `:prefix_srvadmins` WHERE `identity` = `:identity`'); - $GLOBALS['db']->bind(':identity', $steam); - $admin = $GLOBALS['db']->single(); - - if (strlen($admin['groups']) > 1) { - $GLOBALS['db']->query('SELECT `flags` FROM `:prefix_srvgroups` WHERE `name` = `:name`'); - $GLOBALS['db']->bind(':name', $admin['groups']); - $query = $GLOBALS['db']->single(); - return $query['flags'] . $admin['flags']; - } - return $admin['flags']; -} - -/** - * Returns the current server flags associated with the user - * - * @param string The admin to check - * @return string. - */ -function get_non_inherited_admin($steam) -{ - if (empty($steam)) { - return 0; - } - $GLOBALS['db']->query('SELECT * FROM `:prefix_srvadmins` WHERE `identity` = `:identity`'); - $GLOBALS['db']->bind(':identity', $steam); - $admin = $GLOBALS['db']->single(); - return $admin['flags']; -} - -/** - * Checks if user is logged in. - * - * @return boolean. - */ -function is_logged_in() -{ - if ($_SESSION['user']['user'] == "Guest" || $_SESSION['user']['user'] == "") { - return false; - } - return true; -} - -/** - * Checks if user is an admin. - * - * @return boolean. - */ -function is_admin($aid) -{ - if (check_flags($aid, ALL_WEB)) { - return true; - } - return false; -} - -/** - * Checks if the admin has ANY the specified flags - * - * @param integet $aid the admin id to check the flags of - * @param integer $flag the flag to check - * @return boolean - */ -function check_flags($aid, $flag) -{ - $mask = get_user_flags($aid); - if (($mask & $flag) !=0) { - return true; - } - return false; -} - -/** - * Checks if the mask contains ANY the specified flags - * - * @param integet $aid the admin id to check the flags of - * @param integer $flag the flag to check - * @return boolean - */ -function check_flag($mask, $flag) -{ - if (($mask & $flag) !=0) { - return true; - } - return false; -} - -function validate_steam($steam) -{ - if (preg_match(STEAM_FORMAT, $steam)) { - return true; - } - return false; -} - -function validate_email($email) -{ - if (preg_match(EMAIL_FORMAT, $email)) { - return true; - } - return false; -} diff --git a/web/install/index.php b/web/install/index.php index 51eb45ba7..da1e95489 100644 --- a/web/install/index.php +++ b/web/install/index.php @@ -1,31 +1,14 @@ - - SourceBans++ is licensed under a - Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. - - You should have received a copy of the license along with this - work. If not, see . - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - - This program is based off work covered by the following copyright(s): - SourceBans 1.4.11 - Copyright © 2007-2014 SourceBans Team - Part of GameConnect - Licensed under CC BY-NC-SA 3.0 - Page: - -*************************************************************************/ - -include_once 'init.php'; -include_once(INCLUDES_PATH . "/user-functions.php"); -include_once(INCLUDES_PATH . "/system-functions.php"); -include_once(INCLUDES_PATH . "/page-builder.php"); +require_once('init.php'); +require_once(INCLUDES_PATH.'/system-functions.php'); +require_once(INCLUDES_PATH.'/routing.php'); + +$options = [ + 'min_range' => 1, + 'max_range' => 6, + 'default' => 1 +]; +$step = filter_input(INPUT_GET, 'step', FILTER_VALIDATE_INT, ['options' => $options]); + +[$title, $page] = route($step); +build($title, $page, $step); diff --git a/web/install/init.php b/web/install/init.php index ffc2014e5..fb6cacdcc 100644 --- a/web/install/init.php +++ b/web/install/init.php @@ -1,30 +1,4 @@ - - SourceBans++ is licensed under a - Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. - - You should have received a copy of the license along with this - work. If not, see . - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - - This program is based off work covered by the following copyright(s): - SourceBans 1.4.11 - Copyright © 2007-2014 SourceBans Team - Part of GameConnect - Licensed under CC BY-NC-SA 3.0 - Page: - -*************************************************************************/ - // --------------------------------------------------- // Directories // --------------------------------------------------- @@ -35,36 +9,8 @@ define('IN_SB', true); define('IN_INSTALL', true); -// --------------------------------------------------- -// Fix some $_SERVER vars -// --------------------------------------------------- -// Fix for IIS, which doesn't set REQUEST_URI -if (!isset($_SERVER['REQUEST_URI']) || trim($_SERVER['REQUEST_URI']) == '') { - $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; - - if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { - $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; - } -} -// Fix for Dreamhost and other PHP as CGI hosts -if (strstr($_SERVER['SCRIPT_NAME'], 'php.cgi')) { - unset($_SERVER['PATH_INFO']); -} -if (trim($_SERVER['PHP_SELF']) == '') { - $_SERVER['PHP_SELF'] = preg_replace("/(\?.*)?$/", '', $_SERVER["REQUEST_URI"]); -} +define('SB_VERSION', '1.7.0 | Installer'); -// --------------------------------------------------- -// Initial setup -// --------------------------------------------------- -if (!defined('SB_VERSION')) { - define('SB_VERSION', '1.6.3-Installer'); -} -define('LOGIN_COOKIE_LIFETIME', (60*60*24*7)*2); -define('COOKIE_PATH', '/'); -define('COOKIE_DOMAIN', ''); -define('COOKIE_SECURE', false); -define('SB_SALT', 'SourceBans'); // --------------------------------------------------- // Setup PHP // --------------------------------------------------- @@ -84,11 +30,3 @@ $handle = fopen("../config.php", "w"); fclose($handle); } - -// --------------------------------------------------- -// Some defs -// --------------------------------------------------- -define('EMAIL_FORMAT', "/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/"); -define('URL_FORMAT', "/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}((:[0-9]{1,5})?\/.*)?$/i"); -define('STEAM_FORMAT', "/^STEAM_[0-9]:[0-9]:[0-9]+$/"); -define('STATUS_PARSE', '/#[ ]*([0-9]+) "(.+)" (STEAM_0:[0-1]:[0-9]+)[ ]{1,2}([0-9]+[:[0-9]+) ([0-9]+)[ ]([0-9]+) ([a-zA-Z]+) ([0-9.:]+)/'); diff --git a/web/install/scripts/mootools.js b/web/install/scripts/mootools.js deleted file mode 100644 index 32f1ade20..000000000 --- a/web/install/scripts/mootools.js +++ /dev/null @@ -1 +0,0 @@ -var MooTools={version:'1.2dev'};function $defined(a){return(a!=undefined)};function $type(a){if(!$defined(a))return false;if(a.htmlElement)return'element';var b=typeof a;if(b=='object'&&a.nodeName){switch(a.nodeType){case 1:return'element';case 3:return(/\S/).test(a.nodeValue)?'textnode':'whitespace'}}if(b=='object'||b=='function'){switch(a.constructor){case Array:return'array';case RegExp:return'regexp';case Class:return'class'}if(typeof a.length=='number'){if(a.item)return'collection';if(a.callee)return'arguments'}}return b};function $merge(){var a={};for(var i=0;i-1:this.indexOf(a)>-1},escapeRegExp:function(){return this.replace(/([.*+?^${}()|[\]\/\\])/g,'\\$1')}});Array.extend({rgbToHex:function(a){if(this.length<3)return false;if(this.length==4&&this[3]==0&&!a)return'transparent';var b=[];for(var i=0;i<3;i++){var c=(this[i]-0).toString(16);b.push((c.length==1)?'0'+c:c)}return a?b:'#'+b.join('')},hexToRgb:function(a){if(this.length!=3)return false;var b=[];for(var i=0;i<3;i++){b.push(parseInt((this[i].length==1)?this[i]+this[i]:this[i],16))}return a?b:'rgb('+b.join(',')+')'}});Function.extend({create:function(d){var e=this;d=$merge({'bind':e,'event':false,'arguments':null,'delay':false,'periodical':false,'attempt':false},d);if($chk(d.arguments)&&$type(d.arguments)!='array')d.arguments=[d.arguments];return function(a){var b;if(d.event){a=a||window.event;b=[(d.event===true)?a:new d.event(a)];if(d.arguments)b.extend(d.arguments)}else b=d.arguments||arguments;var c=function(){return e.apply($pick(d.bind,e),b)};if(d.delay)return setTimeout(c,d.delay);if(d.periodical)return setInterval(c,d.periodical);if(d.attempt)try{return c()}catch(err){return false};return c()}},pass:function(a,b){return this.create({'arguments':a,'bind':b})},attempt:function(a,b){return this.create({'arguments':a,'bind':b,'attempt':true})()},bind:function(a,b){return this.create({'bind':a,'arguments':b})},bindAsEventListener:function(a,b){return this.create({'bind':a,'event':true,'arguments':b})},delay:function(a,b,c){return this.create({'delay':a,'bind':b,'arguments':c})()},periodical:function(a,b,c){return this.create({'periodical':a,'bind':b,'arguments':c})()}});Number.extend({toInt:function(){return parseInt(this)},toFloat:function(){return parseFloat(this)},limit:function(a,b){return Math.min(b,Math.max(a,this))},round:function(a){a=Math.pow(10,a||0);return Math.round(this*a)/a},times:function(a){for(var i=0;i'}a=document.createElement(a)}a=$(a);return(!b||!a)?a:a.set(b)}});var Elements=new Class({initialize:function(a){return(a)?$extend(a,this):this}});Elements.extend=function(a){for(var b in a){this.prototype[b]=a[b];this[b]=$native.generic(b)}};function $(a){if(!a)return false;if(a.htmlElement)return Garbage.collect(a);if([window,document].contains(a))return a;var b=$type(a);if(b=='string'){a=document.getElementById(a);b=(a)?'element':false}if(b!='element')return false;if(a.htmlElement)return Garbage.collect(a);if(['object','embed'].contains(a.tagName.toLowerCase()))return a;$extend(a,Element.prototype);a.htmlElement=function(){};return Garbage.collect(a)};document.getElementsBySelector=document.getElementsByTagName;function $$(){var a=[];for(var i=0,j=arguments.length;i0&&c<13)this.key='f'+c}this.key=this.key||String.fromCharCode(this.code).toLowerCase()}else if(this.type.test(/(click|mouse|menu)/)){this.page={'x':a.pageX||a.clientX+document.documentElement.scrollLeft,'y':a.pageY||a.clientY+document.documentElement.scrollTop};this.client={'x':a.pageX?a.pageX-window.pageXOffset:a.clientX,'y':a.pageY?a.pageY-window.pageYOffset:a.clientY};this.rightClick=(a.which==3)||(a.button==2);switch(this.type){case'mouseover':this.relatedTarget=a.relatedTarget||a.fromElement;break;case'mouseout':this.relatedTarget=a.relatedTarget||a.toElement}this.fixRelatedTarget()}return this},stop:function(){return this.stopPropagation().preventDefault()},stopPropagation:function(){if(this.event.stopPropagation)this.event.stopPropagation();else this.event.cancelBubble=true;return this},preventDefault:function(){if(this.event.preventDefault)this.event.preventDefault();else this.event.returnValue=false;return this}});Event.fix={relatedTarget:function(){if(this.relatedTarget&&this.relatedTarget.nodeType==3)this.relatedTarget=this.relatedTarget.parentNode},relatedTargetGecko:function(){try{Event.fix.relatedTarget.call(this)}catch(e){this.relatedTarget=this.target}}};Event.prototype.fixRelatedTarget=(window.gecko)?Event.fix.relatedTargetGecko:Event.fix.relatedTarget;Event.keys=new Abstract({'enter':13,'up':38,'down':40,'left':37,'right':39,'esc':27,'space':32,'backspace':8,'tab':9,'delete':46});Element.Methods.Events={addEvent:function(a,b){this.$events=this.$events||{};this.$events[a]=this.$events[a]||{'keys':[],'values':[]};if(this.$events[a].keys.contains(b))return this;this.$events[a].keys.push(b);var c=a;var d=Element.Events[a];if(d){if(d.add)d.add.call(this,b);if(d.map)b=d.map;if(d.type)c=d.type}if(!this.addEventListener)b=b.create({'bind':this,'event':true});this.$events[a].values.push(b);return(Element.NativeEvents.contains(c))?this.addListener(c,b):this},removeEvent:function(a,b){if(!this.$events||!this.$events[a])return this;var c=this.$events[a].keys.indexOf(b);if(c==-1)return this;var d=this.$events[a].keys.splice(c,1)[0];var e=this.$events[a].values.splice(c,1)[0];var f=Element.Events[a];if(f){if(f.remove)f.remove.call(this,b);if(f.type)a=f.type}return(Element.NativeEvents.contains(a))?this.removeListener(a,e):this},addEvents:function(a){return Element.setMany(this,'addEvent',a)},removeEvents:function(b){if(!this.$events)return this;if(!b){for(var c in this.$events)this.removeEvents(c);this.$events=null}else if(this.$events[b]){this.$events[b].keys.each(function(a){this.removeEvent(b,a)},this);this.$events[b]=null}return this},fireEvent:function(b,c,d){if(this.$events&&this.$events[b]){this.$events[b].keys.each(function(a){a.create({'bind':this,'delay':d,'arguments':c})()},this)}return this},cloneEvents:function(b,c){if(!b.$events)return this;if(!c){for(var d in b.$events)this.cloneEvents(b,d)}else if(b.$events[c]){b.$events[c].keys.each(function(a){this.addEvent(c,a)},this)}return this}};window.extend(Element.Methods.Events);document.extend(Element.Methods.Events);Element.extend(Element.Methods.Events);Element.Events=new Abstract({'mouseenter':{type:'mouseover',map:function(a){a=new Event(a);if(a.relatedTarget!=this&&!this.hasChild(a.relatedTarget))this.fireEvent('mouseenter',a)}},'mouseleave':{type:'mouseout',map:function(a){a=new Event(a);if(a.relatedTarget!=this&&!this.hasChild(a.relatedTarget))this.fireEvent('mouseleave',a)}},'mousewheel':{type:(window.gecko)?'DOMMouseScroll':'mousewheel'}});Element.NativeEvents=['click','dblclick','mouseup','mousedown','mousewheel','DOMMouseScroll','mouseover','mouseout','mousemove','keydown','keypress','keyup','load','unload','beforeunload','resize','move','focus','blur','change','submit','reset','select','error','abort','contextmenu','scroll'];Function.extend({bindWithEvent:function(a,b){return this.create({'bind':a,'arguments':b,'event':Event})}});Elements.extend({filterByTag:function(b){return new Elements(this.filter(function(a){return(Element.getTag(a)==b)}))},filterByClass:function(b,c){var d=this.filter(function(a){return(a.className&&a.className.contains(b,' '))});return(c)?d:new Elements(d)},filterById:function(b,c){var d=this.filter(function(a){return(a.id==b)});return(c)?d:new Elements(d)},filterByAttribute:function(c,d,e,f){var g=this.filter(function(a){var b=Element.getProperty(a,c);if(!b)return false;if(!d)return true;switch(d){case'=':return(b==e);case'*=':return(b.contains(e));case'^=':return(b.substr(0,e.length)==e);case'$=':return(b.substr(b.length-e.length)==e);case'!=':return(b!=e);case'~=':return b.contains(e,' ')}return false});return(f)?g:new Elements(g)}});function $E(a,b){return($(b)||document).getElement(a)};function $ES(a,b){return($(b)||document).getElementsBySelector(a)};$$.shared={'regexp':/^(\w*|\*)(?:#([\w-]+)|\.([\w-]+))?(?:\[(\w+)(?:([!*^$]?=)["']?([^"'\]]*)["']?)?])?$/,'xpath':{getParam:function(a,b,c,i){var d=[b.namespaceURI?'xhtml:':'',c[1]];if(c[2])d.push('[@id="',c[2],'"]');if(c[3])d.push('[contains(concat(" ", @class, " "), " ',c[3],' ")]');if(c[4]){if(c[5]&&c[6]){switch(c[5]){case'*=':d.push('[contains(@',c[4],', "',c[6],'")]');break;case'^=':d.push('[starts-with(@',c[4],', "',c[6],'")]');break;case'$=':d.push('[substring(@',c[4],', string-length(@',c[4],') - ',c[6].length,' + 1) = "',c[6],'"]');break;case'=':d.push('[@',c[4],'="',c[6],'"]');break;case'!=':d.push('[@',c[4],'!="',c[6],'"]')}}else{d.push('[@',c[4],']')}}a.push(d.join(''));return a},getItems:function(a,b,c){var d=[];var e=document.evaluate('.//'+a.join('//'),b,$$.shared.resolver,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(var i=0,j=e.snapshotLength;i<\/script>');$('ie_ready').onreadystatechange=function(){if(this.readyState=='complete')b()}}}else{window.addListener("load",b);document.addListener("DOMContentLoaded",b)}}};window.extend({getWidth:function(){if(this.webkit419)return this.innerWidth;if(this.opera)return document.body.clientWidth;return document.documentElement.clientWidth},getHeight:function(){if(this.webkit419)return this.innerHeight;if(this.opera)return document.body.clientHeight;return document.documentElement.clientHeight},getScrollWidth:function(){if(this.ie)return Math.max(document.documentElement.offsetWidth,document.documentElement.scrollWidth);if(this.webkit)return document.body.scrollWidth;return document.documentElement.scrollWidth},getScrollHeight:function(){if(this.ie)return Math.max(document.documentElement.offsetHeight,document.documentElement.scrollHeight);if(this.webkit)return document.body.scrollHeight;return document.documentElement.scrollHeight},getScrollLeft:function(){return this.pageXOffset||document.documentElement.scrollLeft},getScrollTop:function(){return this.pageYOffset||document.documentElement.scrollTop},getSize:function(){return{'size':{'x':this.getWidth(),'y':this.getHeight()},'scrollSize':{'x':this.getScrollWidth(),'y':this.getScrollHeight()},'scroll':{'x':this.getScrollLeft(),'y':this.getScrollTop()}}},getPosition:function(){return{'x':0,'y':0}}});var Fx={};Fx.Base=new Class({options:{onStart:Class.empty,onComplete:Class.empty,onCancel:Class.empty,transition:function(p){return-(Math.cos(Math.PI*p)-1)/2},duration:500,unit:'px',wait:true,fps:50},initialize:function(a){this.element=this.element||null;this.setOptions(a);if(this.options.initialize)this.options.initialize.call(this)},step:function(){var a=$time();if(a=(7-4*a)/11){c=-Math.pow((11-6*a-11*p)/4,2)+b*b;break}}return c},Elastic:function(p,x){return Math.pow(2,10*--p)*Math.cos(20*p*Math.PI*(x[0]||1)/3)}});['Quad','Cubic','Quart','Quint'].each(function(a,i){Fx.Transitions[a]=new Fx.Transition(function(p){return Math.pow(p,[i+2])})});var Drag={};Drag.Base=new Class({options:{handle:false,unit:'px',onStart:Class.empty,onBeforeStart:Class.empty,onComplete:Class.empty,onSnap:Class.empty,onDrag:Class.empty,limit:false,modifiers:{x:'left',y:'top'},grid:false,snap:6},initialize:function(a,b){this.setOptions(b);this.element=$(a);this.handle=$(this.options.handle)||this.element;this.mouse={'now':{},'pos':{}};this.value={'start':{},'now':{}};this.bound={'start':this.start.bindWithEvent(this),'check':this.check.bindWithEvent(this),'drag':this.drag.bindWithEvent(this),'stop':this.stop.bind(this)};this.attach();if(this.options.initialize)this.options.initialize.call(this)},attach:function(){this.handle.addEvent('mousedown',this.bound.start);return this},detach:function(){this.handle.removeEvent('mousedown',this.bound.start);return this},start:function(a){this.fireEvent('onBeforeStart',this.element);this.mouse.start=a.page;var b=this.options.limit;this.limit={'x':[],'y':[]};for(var z in this.options.modifiers){if(!this.options.modifiers[z])continue;this.value.now[z]=this.element.getStyle(this.options.modifiers[z]).toInt();this.mouse.pos[z]=a.page[z]-this.value.now[z];if(b&&b[z]){for(var i=0;i<2;i++){if($chk(b[z][i]))this.limit[z][i]=($type(b[z][i])=='function')?b[z][i]():b[z][i]}}}if($type(this.options.grid)=='number')this.options.grid={'x':this.options.grid,'y':this.options.grid};document.addListener('mousemove',this.bound.check);document.addListener('mouseup',this.bound.stop);this.fireEvent('onStart',this.element);a.stop()},check:function(a){var b=Math.round(Math.sqrt(Math.pow(a.page.x-this.mouse.start.x,2)+Math.pow(a.page.y-this.mouse.start.y,2)));if(b>this.options.snap){document.removeListener('mousemove',this.bound.check);document.addListener('mousemove',this.bound.drag);this.drag(a);this.fireEvent('onSnap',this.element)}a.stop()},drag:function(a){this.out=false;this.mouse.now=a.page;for(var z in this.options.modifiers){if(!this.options.modifiers[z])continue;this.value.now[z]=this.mouse.now[z]-this.mouse.pos[z];if(this.limit[z]){if($chk(this.limit[z][1])&&(this.value.now[z]>this.limit[z][1])){this.value.now[z]=this.limit[z][1];this.out=true}else if($chk(this.limit[z][0])&&(this.value.now[z]a.left&&b.xa.top)},stop:function(){if(this.overed&&!this.out)this.overed.fireEvent('drop',[this.element,this]);else this.element.fireEvent('emptydrop',this);this.parent();return this}});Element.extend({makeDraggable:function(a){return new Drag.Move(this,a)}});var XHR=new Class({options:{method:'post',async:true,onRequest:Class.empty,onSuccess:Class.empty,onFailure:Class.empty,urlEncoded:true,encoding:'utf-8',autoCancel:false,headers:{}},setTransport:function(){this.transport=(window.XMLHttpRequest)?new XMLHttpRequest():(window.ie?new ActiveXObject('Microsoft.XMLHTTP'):false);return this},initialize:function(a){this.setTransport().setOptions(a);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers={};if(this.options.urlEncoded&&this.options.method=='post'){var b=(this.options.encoding)?'; charset='+this.options.encoding:'';this.setHeader('Content-type','application/x-www-form-urlencoded'+b)}if(this.options.initialize)this.options.initialize.call(this)},onStateChange:function(){if(this.transport.readyState!=4||!this.running)return;this.running=false;var a=0;try{a=this.transport.status}catch(e){};if(this.options.isSuccess.call(this,a))this.onSuccess();else this.onFailure();this.transport.onreadystatechange=Class.empty},isSuccess:function(a){return((a>=200)&&(a<300))},onSuccess:function(){this.response={'text':this.transport.responseText,'xml':this.transport.responseXML};this.fireEvent('onSuccess',[this.response.text,this.response.xml]);this.callChain()},onFailure:function(){this.fireEvent('onFailure',this.transport)},setHeader:function(a,b){this.headers[a]=b;return this},send:function(a,b){if(this.options.autoCancel)this.cancel();else if(this.running)return this;this.running=true;if(b&&this.options.method=='get'){a=a+(a.contains('?')?'&':'?')+b;b=null}this.transport.open(this.options.method.toUpperCase(),a,this.options.async);this.transport.onreadystatechange=this.onStateChange.bind(this);if((this.options.method=='post')&&this.transport.overrideMimeType)this.setHeader('Connection','close');$extend(this.headers,this.options.headers);for(var c in this.headers)try{this.transport.setRequestHeader(c,this.headers[c])}catch(e){};this.fireEvent('onRequest');this.transport.send($pick(b,null));return this},cancel:function(){if(!this.running)return this;this.running=false;this.transport.abort();this.transport.onreadystatechange=Class.empty;this.setTransport();this.fireEvent('onCancel');return this}});XHR.implement(new Chain,new Events,new Options);var Ajax=XHR.extend({options:{data:null,update:null,onComplete:Class.empty,evalScripts:false,evalResponse:false},initialize:function(a,b){this.addEvent('onSuccess',this.onComplete);this.setOptions(b);if(!['post','get'].contains(this.options.method)){this._method='_method='+this.options.method;this.options.method='post'}this.parent();this.setHeader('X-Requested-With','XMLHttpRequest');this.setHeader('Accept','text/javascript, text/html, application/xml, text/xml, */*');this.url=a},onComplete:function(){if(this.options.update)$(this.options.update).empty().setHTML(this.response.text);if(this.options.evalScripts||this.options.evalResponse)this.evalScripts();this.fireEvent('onComplete',[this.response.text,this.response.xml],20)},request:function(a){a=a||this.options.data;switch($type(a)){case'element':a=$(a).toQueryString();break;case'object':a=Object.toQueryString(a)}if(this._method)a=(a)?[this._method,a].join('&'):this._method;return this.send(this.url,a)},evalScripts:function(){var a,scripts;if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader('Content-type')))scripts=this.response.text;else{scripts=[];var b=/]*>([\s\S]*?)<\/script>/gi;while((a=b.exec(this.response.text)))scripts.push(a[1]);scripts=scripts.join('\n')}if(scripts)(window.execScript)?window.execScript(scripts):eval.call(window,scripts)},getHeader:function(a){try{return this.transport.getResponseHeader(a)}catch(e){};return null}});Object.toQueryString=function(a){var b=[];for(var c in a)b.push(encodeURIComponent(c)+'='+encodeURIComponent(a[c]));return b.join('&')};Element.extend({send:function(a){return new Ajax(this.getProperty('action'),$merge({data:this.toQueryString()},a,{method:'post'})).request()}});var Cookie=new Abstract({options:{domain:false,path:false,duration:false,secure:false},set:function(a,b,c){c=$merge(this.options,c);b=encodeURIComponent(b);if(c.domain)b+='; domain='+c.domain;if(c.path)b+='; path='+c.path;if(c.duration){var d=new Date();d.setTime(d.getTime()+c.duration*24*60*60*1000);b+='; expires='+d.toGMTString()}if(c.secure)b+='; secure';document.cookie=a+'='+b;return $extend(c,{'key':a,'value':b})},get:function(a){var b=document.cookie.match('(?:^|;)\\s*'+a.escapeRegExp()+'=([^;]*)');return b?decodeURIComponent(b[1]):false},remove:function(a,b){if($type(a)=='object')this.set(a.key,'',$merge(a,{duration:-1}));else this.set(a,'',$merge(b,{duration:-1}))}});var Json={toString:function(a){switch($type(a)){case'string':return'"'+a.replace(/(["\\])/g,'\\$1')+'"';case'array':return'['+a.map(Json.toString).join(',')+']';case'object':var b=[];for(var c in a)b.push(Json.toString(c)+':'+Json.toString(a[c]));return'{'+b.join(',')+'}';case'number':if(isFinite(a))break;case false:return'null'}return String(a)},evaluate:function(a,b){return(($type(a)!='string')||(b&&!a.test(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/)))?null:eval('('+a+')')}};Json.Remote=XHR.extend({initialize:function(a,b){this.url=a;this.addEvent('onSuccess',this.onComplete);this.parent(b);this.setHeader('X-Request','JSON')},send:function(a){return this.parent(this.url,'json='+Json.toString(a))},onComplete:function(){this.fireEvent('onComplete',[Json.evaluate(this.response.text,this.options.secure)])}});var Asset=new Abstract({javascript:function(a,b){b=$merge({'onload':Class.empty},b);var c=new Element('script',{'src':a}).addEvents({'load':b.onload,'readystatechange':function(){if(this.readyState=='complete')this.fireEvent('load')}});delete b.onload;return c.setProperties(b).inject(document.head)},css:function(a,b){return new Element('link',$merge({'rel':'stylesheet','media':'screen','type':'text/css','href':a},b)).inject(document.head)},image:function(c,d){d=$merge({'onload':Class.empty,'onabort':Class.empty,'onerror':Class.empty},d);var e=new Image();e.src=c;var f=new Element('img',{'src':c});['load','abort','error'].each(function(a){var b=d['on'+a];delete d['on'+a];f.addEvent(a,function(){this.removeEvent(a,arguments.callee);b.call(this)})});if(e.width&&e.height)f.fireEvent('load',f,1);return f.setProperties(d)},images:function(c,d){d=$merge({onComplete:Class.empty,onProgress:Class.empty},d);if(!c.push)c=[c];var e=[];var f=0;c.each(function(a){var b=new Asset.image(a,{'onload':function(){d.onProgress.call(this,f);f++;if(f==c.length)d.onComplete()}});e.push(b)});return new Elements(e)}});var Hash=new Class({length:0,initialize:function(a){this.obj=a||{};this.setLength()},get:function(a){return(this.hasKey(a))?this.obj[a]:null},hasKey:function(a){return(a in this.obj)},set:function(a,b){if(!this.hasKey(a))this.length++;this.obj[a]=b;return this},setLength:function(){this.length=0;for(var p in this.obj)this.length++;return this},remove:function(a){if(this.hasKey(a)){delete this.obj[a];this.length--}return this},each:function(a,b){$each(this.obj,a,b)},extend:function(a){$extend(this.obj,a);return this.setLength()},merge:function(){this.obj=$merge.apply(null,[this.obj].extend(arguments));return this.setLength()},empty:function(){this.obj={};this.length=0;return this},keys:function(){var a=[];for(var b in this.obj)a.push(b);return a},values:function(){var a=[];for(var b in this.obj)a.push(this.obj[b]);return a}});function $H(a){return new Hash(a)};Hash.Cookie=Hash.extend({initialize:function(a,b){this.name=a;this.options=$extend({'autoSave':true},b||{});this.load()},save:function(){if(this.length==0){Cookie.remove(this.name,this.options);return true}var a=Json.toString(this.obj);if(a.length>4096)return false;Cookie.set(this.name,a,this.options);return true},load:function(){this.obj=Json.evaluate(Cookie.get(this.name),true)||{};this.setLength()}});Hash.Cookie.Methods={};['extend','set','merge','empty','remove'].each(function(a){Hash.Cookie.Methods[a]=function(){Hash.prototype[a].apply(this,arguments);if(this.options.autoSave)this.save();return this}});Hash.Cookie.implement(Hash.Cookie.Methods);var Color=new Class({initialize:function(a,b){b=b||(a.push?'rgb':'hex');var c,hsb;switch(b){case'rgb':c=a;hsb=c.rgbToHsb();break;case'hsb':c=a.hsbToRgb();hsb=a;break;default:c=a.hexToRgb(true);hsb=c.rgbToHsb()}c.hsb=hsb;c.hex=c.rgbToHex();return $extend(c,Color.prototype)},mix:function(){var b=$A(arguments);var c=($type(b[b.length-1])=='number')?b.pop():50;var d=this.copy();b.each(function(a){a=new Color(a);for(var i=0;i<3;i++)d[i]=Math.round((d[i]/100*(100-c))+(a[i]/100*c))});return new Color(d,'rgb')},invert:function(){return new Color(this.map(function(a){return 255-a}))},setHue:function(a){return new Color([a,this.hsb[1],this.hsb[2]],'hsb')},setSaturation:function(a){return new Color([this.hsb[0],a,this.hsb[2]],'hsb')},setBrightness:function(a){return new Color([this.hsb[0],this.hsb[1],a],'hsb')}});function $RGB(r,g,b){return new Color([r,g,b],'rgb')};function $HSB(h,s,b){return new Color([h,s,b],'hsb')};Array.extend({rgbToHsb:function(){var a=this[0],green=this[1],blue=this[2];var b,saturation,brightness;var c=Math.max(a,green,blue),min=Math.min(a,green,blue);var d=c-min;brightness=c/255;saturation=(c!=0)?d/c:0;if(saturation==0){b=0}else{var e=(c-a)/d;var f=(c-green)/d;var g=(c-blue)/d;if(a==c)b=g-f;else if(green==c)b=2+e-g;else b=4+f-e;b/=6;if(b<0)b++}return[Math.round(b*360),Math.round(saturation*100),Math.round(brightness*100)]},hsbToRgb:function(){var a=Math.round(this[2]/100*255);if(this[1]==0){return[a,a,a]}else{var b=this[0]%360;var f=b%60;var p=Math.round((this[2]*(100-this[1]))/10000*255);var q=Math.round((this[2]*(6000-this[1]*f))/600000*255);var t=Math.round((this[2]*(6000-this[1]*(60-f)))/600000*255);switch(Math.floor(b/60)){case 0:return[a,t,p];case 1:return[q,a,p];case 2:return[p,a,t];case 3:return[p,q,a];case 4:return[t,p,a];case 5:return[a,p,q]}}return false}});var Scroller=new Class({options:{area:20,velocity:1,onChange:function(x,y){this.element.scrollTo(x,y)}},initialize:function(a,b){this.setOptions(b);this.element=$(a);this.mousemover=([window,document].contains(a))?$(document.body):this.element},start:function(){this.coord=this.getCoords.bindWithEvent(this);this.mousemover.addListener('mousemove',this.coord)},stop:function(){this.mousemover.removeListener('mousemove',this.coord);this.timer=$clear(this.timer)},getCoords:function(a){this.page=(this.element==window)?a.client:a.page;if(!this.timer)this.timer=this.scroll.periodical(50,this)},scroll:function(){var a=this.element.getSize();var b=this.element.getPosition();var c={'x':0,'y':0};for(var z in this.page){if(this.page[z]<(this.options.area+b[z])&&a.scroll[z]!=0)c[z]=(this.page[z]-this.options.area-b[z])*this.options.velocity;else if(this.page[z]+this.options.area>(a.size[z]+b[z])&&a.scroll[z]+a.size[z]!=a.scrollSize[z])c[z]=(this.page[z]-a.size[z]+this.options.area-b[z])*this.options.velocity}if(c.y||c.x)this.fireEvent('onChange',[a.scroll.x+c.x,a.scroll.y+c.y])}});Scroller.implement(new Events,new Options);var Slider=new Class({options:{onChange:Class.empty,onComplete:Class.empty,onTick:function(a){this.knob.setStyle(this.p,a)},mode:'horizontal',steps:100,offset:0},initialize:function(a,b,c){this.element=$(a);this.knob=$(b);this.setOptions(c);this.previousChange=-1;this.previousEnd=-1;this.step=-1;this.element.addEvent('mousedown',this.clickedElement.bindWithEvent(this));var d,offset;switch(this.options.mode){case'horizontal':this.z='x';this.p='left';d={'x':'left','y':false};offset='offsetWidth';break;case'vertical':this.z='y';this.p='top';d={'x':false,'y':'top'};offset='offsetHeight'}this.max=this.element[offset]-this.knob[offset]+(this.options.offset*2);this.half=this.knob[offset]/2;this.getPos=this.element['get'+this.p.capitalize()].bind(this.element);this.knob.setStyle('position','relative').setStyle(this.p,-this.options.offset);var e={};e[this.z]=[-this.options.offset,this.max-this.options.offset];this.drag=new Drag.Base(this.knob,{limit:e,modifiers:d,snap:0,onStart:function(){this.draggedKnob()}.bind(this),onDrag:function(){this.draggedKnob()}.bind(this),onComplete:function(){this.draggedKnob();this.end()}.bind(this)});if(this.options.initialize)this.options.initialize.call(this)},set:function(a){this.step=a.limit(0,this.options.steps);this.checkStep();this.end();this.fireEvent('onTick',this.toPosition(this.step));return this},clickedElement:function(a){var b=a.page[this.z]-this.getPos()-this.half;b=b.limit(-this.options.offset,this.max-this.options.offset);this.step=this.toStep(b);this.checkStep();this.end();this.fireEvent('onTick',b)},draggedKnob:function(){this.step=this.toStep(this.drag.value.now[this.z]);this.checkStep()},checkStep:function(){if(this.previousChange!=this.step){this.previousChange=this.step;this.fireEvent('onChange',this.step)}},end:function(){if(this.previousEnd!==this.step){this.previousEnd=this.step;this.fireEvent('onComplete',this.step+'')}},toStep:function(a){return Math.round((a+this.options.offset)/this.max*this.options.steps)},toPosition:function(a){return this.max*a/this.options.steps}});Slider.implement(new Events);Slider.implement(new Options);var SmoothScroll=Fx.Scroll.extend({initialize:function(c){this.parent(window,c);this.links=(this.options.links)?$$(this.options.links):$$(document.links);var d=window.location.href.match(/^[^#]*/)[0]+'#';this.links.each(function(a){if(a.href.indexOf(d)!=0)return;var b=a.href.substr(d.length);if(b&&$(b))this.useLink(a,b)},this);if(!window.webkit419)this.addEvent('onComplete',function(){window.location.hash=this.anchor})},useLink:function(b,c){b.addEvent('click',function(a){this.anchor=c;this.toElement(c);a.stop()}.bindWithEvent(this))}});var Sortables=new Class({options:{handles:false,onStart:Class.empty,onComplete:Class.empty,ghost:true,snap:3,onDragStart:function(a,b){b.setStyle('opacity',0.7);a.setStyle('opacity',0.7)},onDragComplete:function(a,b){a.setStyle('opacity',1);b.remove();this.trash.remove()}},initialize:function(a,b){this.setOptions(b);this.list=$(a);this.elements=this.list.getChildren();this.handles=(this.options.handles)?$$(this.options.handles):this.elements;this.bound={'start':[],'moveGhost':this.moveGhost.bindWithEvent(this)};for(var i=0,l=this.handles.length;i0);var d=this.active.getPrevious();var e=this.active.getNext();if(d&&c&&be.getCoordinates().top)this.active.injectAfter(e);this.previous=b},serialize:function(b){return this.list.getChildren().map(b||function(a){return this.elements.indexOf(a)},this)},end:function(){this.previous=null;document.removeListener('mousemove',this.bound.move);document.removeListener('mouseup',this.bound.end);if(this.options.ghost){document.removeListener('mousemove',this.bound.moveGhost);this.fireEvent('onDragComplete',[this.active,this.ghost])}this.fireEvent('onComplete',this.active)}});Sortables.implement(new Events,new Options);var Tips=new Class({options:{onShow:function(a){a.setStyle('visibility','visible')},onHide:function(a){a.setStyle('visibility','hidden')},maxTitleChars:30,showDelay:100,hideDelay:100,className:'tool',offsets:{'x':16,'y':16},fixed:false},initialize:function(a,b){this.setOptions(b);this.toolTip=new Element('div',{'class':this.options.className+'-tip','styles':{'position':'absolute','top':'0','left':'0','visibility':'hidden'}}).inject(document.body);this.wrapper=new Element('div').inject(this.toolTip);$$(a).each(this.build,this);if(this.options.initialize)this.options.initialize.call(this)},build:function(b){b.$tmp.myTitle=(b.href&&b.getTag()=='a')?b.href.replace('http://',''):(b.rel||false);if(b.title){var c=b.title.split('::');if(c.length>1){b.$tmp.myTitle=c[0].trim();b.$tmp.myText=c[1].trim()}else{b.$tmp.myText=b.title}b.removeAttribute('title')}else{b.$tmp.myText=false}if(b.$tmp.myTitle&&b.$tmp.myTitle.length>this.options.maxTitleChars)b.$tmp.myTitle=b.$tmp.myTitle.substr(0,this.options.maxTitleChars-1)+"…";b.addEvent('mouseenter',function(a){this.start(b);if(!this.options.fixed)this.locate(a);else this.position(b)}.bind(this));if(!this.options.fixed)b.addEvent('mousemove',this.locate.bindWithEvent(this));var d=this.end.bind(this);b.addEvent('mouseleave',d);b.addEvent('trash',d)},start:function(a){this.wrapper.empty();if(a.$tmp.myTitle){this.title=new Element('span').inject(new Element('div',{'class':this.options.className+'-title'}).inject(this.wrapper)).setHTML(a.$tmp.myTitle)}if(a.$tmp.myText){this.text=new Element('span').inject(new Element('div',{'class':this.options.className+'-text'}).inject(this.wrapper)).setHTML(a.$tmp.myText)}$clear(this.timer);this.timer=this.show.delay(this.options.showDelay,this)},end:function(a){$clear(this.timer);this.timer=this.hide.delay(this.options.hideDelay,this)},position:function(a){var b=a.getPosition();this.toolTip.setStyles({'left':b.x+this.options.offsets.x,'top':b.y+this.options.offsets.y})},locate:function(a){var b={'x':window.getWidth(),'y':window.getHeight()};var c={'x':window.getScrollLeft(),'y':window.getScrollTop()};var d={'x':this.toolTip.offsetWidth,'y':this.toolTip.offsetHeight};var e={'x':'left','y':'top'};for(var z in e){var f=a.page[z]+this.options.offsets[z];if((f+d[z]-c[z])>b[z])f=a.page[z]-this.options.offsets[z]-d[z];this.toolTip.setStyle(e[z],f)}},show:function(){if(this.options.timeout)this.timer=this.hide.delay(this.options.timeout,this);this.fireEvent('onShow',[this.toolTip])},hide:function(){this.fireEvent('onHide',[this.toolTip])}});Tips.implement(new Events,new Options);var Group=new Class({initialize:function(){this.instances=$A(arguments);this.events={};this.checker={}},addEvent:function(b,c){this.checker[b]=this.checker[b]||{};this.events[b]=this.events[b]||[];if(this.events[b].contains(c))return false;else this.events[b].push(c);this.instances.each(function(a,i){a.addEvent(b,this.check.bind(this,[b,a,i]))},this);return this},check:function(b,c,i){this.checker[b][i]=true;var d=this.instances.every(function(a,j){return this.checker[b][j]||false},this);if(!d)return;this.checker[b]={};this.events[b].each(function(a){a.call(this,this.instances,c)},this)}});var Accordion=Fx.Elements.extend({options:{onActive:Class.empty,onBackground:Class.empty,display:0,show:false,height:true,width:false,opacity:true,fixedHeight:false,fixedWidth:false,wait:false,alwaysHide:false},initialize:function(){var c,togglers,elements,container;$each(arguments,function(a,i){switch($type(a)){case'object':c=a;break;case'element':container=$(a);break;default:var b=$$(a);if(!togglers)togglers=b;else elements=b}});this.togglers=togglers||[];this.elements=elements||[];this.container=$(container);this.setOptions(c);this.previous=-1;if(this.options.alwaysHide)this.options.wait=true;if($chk(this.options.show)){this.options.display=false;this.previous=this.options.show}if(this.options.start){this.options.display=false;this.options.show=false}this.effects={};if(this.options.opacity)this.effects.opacity='fullOpacity';if(this.options.width)this.effects.width=this.options.fixedWidth?'fullWidth':'offsetWidth';if(this.options.height)this.effects.height=this.options.fixedHeight?'fullHeight':'scrollHeight';for(var i=0,l=this.togglers.length;i0));this.fireEvent(b?'onBackground':'onActive',[this.togglers[i],a]);for(var c in this.effects)e[i][c]=b?0:a[this.effects[c]]},this);return this.start(e)},showThisHideOpen:function(a){return this.display(a)}});Fx.Accordion=Accordion; \ No newline at end of file diff --git a/web/install/template/content.header.php b/web/install/template/content.header.php index f69a9b887..863e6481f 100644 --- a/web/install/template/content.header.php +++ b/web/install/template/content.header.php @@ -1,17 +1,3 @@ - - - -