diff --git a/web/includes/SteamID/SteamID.php b/web/includes/SteamID/SteamID.php index 7e24bf400..c704f002c 100644 --- a/web/includes/SteamID/SteamID.php +++ b/web/includes/SteamID/SteamID.php @@ -35,6 +35,9 @@ public static function toSteam64($steamid) private static function to($format, $steamid) { + if (empty($steamid)) + return false; + if (!in_array($format, self::$validFormat)) { throw new \Exception("No valid fromat input!"); } diff --git a/web/includes/sb-callback.php b/web/includes/sb-callback.php index 542326ed6..64e2a2f64 100644 --- a/web/includes/sb-callback.php +++ b/web/includes/sb-callback.php @@ -1652,7 +1652,7 @@ function PasteBan($sid, $name, $type=0) $objResponse->addScript("$('dialog-control').setStyle('display', 'block');"); return $objResponse; } - $objResponse->addScript("SwapPane(0);"); + $objResponse->addScript("swapTab(0);"); $objResponse->addScript("$('dialog-control').setStyle('display', 'block');"); $objResponse->addScript("$('dialog-placement').setStyle('display', 'none');"); return $objResponse; @@ -1791,13 +1791,17 @@ function AddBan($nickname, $type, $steam, $ip, $length, $dfile, $dname, $reason, return $objResponse; } -function SetupBan($subid) +function SetupBan(int $subid) { $objResponse = new xajaxResponse(); - $subid = (int)$subid; - $ban = $GLOBALS['db']->GetRow("SELECT * FROM ".DB_PREFIX."_submissions WHERE subid = $subid"); - $demo = $GLOBALS['db']->GetRow("SELECT * FROM ".DB_PREFIX."_demos WHERE demid = $subid AND demtype = \"S\""); + $GLOBALS['PDO']->query("SELECT * FROM `:prefix_submissions` WHERE subid = :subid"); + $GLOBALS['PDO']->bind(':subid', $subid); + $ban = $GLOBALS['PDO']->single(); + + $GLOBALS['PDO']->query("SELECT * FROM `:prefix_demos` WHERE demid = :subid AND demtype = 'S'"); + $GLOBALS['PDO']->bind(':subid', $subid); + $demo = $GLOBALS['PDO']->single(); // clear any old stuff $objResponse->addScript("$('nickname').value = ''"); $objResponse->addScript("$('fromsub').value = ''"); @@ -1806,22 +1810,19 @@ function SetupBan($subid) $objResponse->addScript("$('txtReason').value = ''"); $objResponse->addAssign("demo.msg", "innerHTML", ""); // add new stuff - $objResponse->addScript("$('nickname').value = '" . $ban['name'] . "'"); - $objResponse->addScript("$('steam').value = '" . $ban['SteamId']. "'"); - $objResponse->addScript("$('ip').value = '" . $ban['sip'] . "'"); - if(trim($ban['SteamId']) == "") - $type = "1"; - else - $type = "0"; + $objResponse->addScript("$('nickname').value = '$ban[name]'"); + $objResponse->addScript("$('steam').value = '$ban[SteamId]'"); + $objResponse->addScript("$('ip').value = '$ban[sip]'"); + + $type = (trim($ban['SteamId']) == "") ? 1 : 0; $objResponse->addScriptCall("selectLengthTypeReason", "0", $type, addslashes($ban['reason'])); $objResponse->addScript("$('fromsub').value = '$subid'"); - if($demo) - { - $objResponse->addAssign("demo.msg", "innerHTML", $demo['origname']); - $objResponse->addScript("demo('" . $demo['filename'] . "', '" . $demo['origname'] . "');"); + if($demo) { + $objResponse->addAssign("demo.msg", "innerHTML", $demo['origname']); + $objResponse->addScript("demo('$demo[filename]', '$demo[origname]');"); } - $objResponse->addScript("SwapPane(0);"); + $objResponse->addScript("swapTab(0);"); return $objResponse; } @@ -1852,7 +1853,7 @@ function PrepareReban($bid) $objResponse->addAssign("demo.msg", "innerHTML", $demo['origname']); $objResponse->addScript("demo('" . $demo['filename'] . "', '" . $demo['origname'] . "');"); } - $objResponse->addScript("SwapPane(0);"); + $objResponse->addScript("swapTab(0);"); return $objResponse; } @@ -3108,7 +3109,7 @@ function PrepareReblock($bid) $objResponse->addScript("$('steam').value = '" . $ban['authid']. "'"); $objResponse->addScriptCall("selectLengthTypeReason", $ban['length'], $ban['type']-1, addslashes($ban['reason'])); - $objResponse->addScript("SwapPane(0);"); + $objResponse->addScript("swapTab(0);"); return $objResponse; } @@ -3137,7 +3138,7 @@ function PrepareBlockFromBan($bid) $objResponse->addScript("$('nickname').value = '" . $ban['name'] . "'"); $objResponse->addScript("$('steam').value = '" . $ban['authid']. "'"); - $objResponse->addScript("SwapPane(0);"); + $objResponse->addScript("swapTab(0);"); return $objResponse; } @@ -3192,7 +3193,7 @@ function PasteBlock($sid, $name) $objResponse->addScript("$('dialog-control').setStyle('display', 'block');"); return $objResponse; } - $objResponse->addScript("SwapPane(0);"); + $objResponse->addScript("swapTab(0);"); $objResponse->addScript("$('dialog-control').setStyle('display', 'block');"); $objResponse->addScript("$('dialog-placement').setStyle('display', 'none');"); return $objResponse; diff --git a/web/pages/page.home.php b/web/pages/page.home.php index 19042920e..4b67a2457 100644 --- a/web/pages/page.home.php +++ b/web/pages/page.home.php @@ -51,8 +51,12 @@ $info['auth'] = $res->fields['authid']; $info['ip'] = $res->fields['ip']; $info['server'] = "block_" . $res->fields['sid'] . "_$blcount"; + if ($res->fields['type'] == 1) { - $info['search_link'] = "index.php?p=banlist&advSearch=" . $info['ip'] . "&advType=ip&Submit"; + if ($userbank->is_admin()) + $info['search_link'] = "index.php?p=banlist&advSearch=$info[ip]&advType=ip&Submit"; + else + $info['search_link'] = "index.php?p=banlist&advSearch=$info[name]&advType=name"; } else { $info['search_link'] = "index.php?p=banlist&advSearch=" . $info['auth'] . "&advType=steamid&Submit"; } @@ -94,7 +98,10 @@ $info['authid'] = $res->fields[2]; $info['ip'] = $res->fields[1]; if ($res->fields[15] == 1) { - $info['search_link'] = "index.php?p=banlist&advSearch=" . $info['ip'] . "&advType=ip&Submit"; + if ($userbank->is_admin()) + $info['search_link'] = "index.php?p=banlist&advSearch=$info[ip]&advType=ip&Submit"; + else + $info['search_link'] = "index.php?p=banlist&advSearch=$info[name]&advType=name"; } else { $info['search_link'] = "index.php?p=banlist&advSearch=" . $info['authid'] . "&advType=steamid&Submit"; } diff --git a/web/pages/page.submit.php b/web/pages/page.submit.php index 3033031d3..ddc887727 100644 --- a/web/pages/page.submit.php +++ b/web/pages/page.submit.php @@ -196,15 +196,12 @@ try { $query->Connect($server['ip'], $server['port'], 1, SourceQuery::SOURCE); $info = $query->GetInfo(); + $servers[$key]['hostname'] = $info['HostName']; } catch (Exception $e) { $servers[$key]['hostname'] = "Error Connecting (".$server['ip'].":".$server['port'].")"; } finally { $query->Disconnect(); } - - if (!empty($info['HostName'])) { - $servers[$key]['hostname'] = $info['HostName']; - } } $theme->assign('STEAMID', $SteamID == "" ? "STEAM_0:" : $SteamID); diff --git a/web/scripts/sourcebans.js b/web/scripts/sourcebans.js index 10d755c5c..21ef899fd 100644 --- a/web/scripts/sourcebans.js +++ b/web/scripts/sourcebans.js @@ -73,21 +73,12 @@ function ProcessAdminTabs() var url = window.location.toString(); var pos = url.indexOf('^')+1; var tabNo = url.charAt(pos); - SwapPane(tabNo); + swapTab(tabNo); var upos = url.indexOf('~')+1; var utabNo = url.charAt(upos+1); var utabType = url.charAt(upos) Swap2ndPane(utabNo, utabType); - - if(parseInt(pos) == 0) - { - return -1; - } - else - { - return tabNo; - } } function Swap2ndPane(id, ttype) @@ -115,30 +106,6 @@ function Swap2ndPane(id, ttype) } } -function SwapPane(id) -{ - var i = 0; - var i2 = 0; - if(document.getElementById("tab-" + id)) - { - while($(document.getElementById(i))) - { - $(document.getElementById(i)).setStyle('display', 'none'); - i++; - } - while(i2 < 50) - { - if($("tab-" + i2)) - { - $("tab-" + i2).removeClass('active'); - } - i2++; - } - $(document.getElementById("tab-" + id)).addClass('active'); - $(document.getElementById(id)).setStyle('display', 'block'); - } -} - function InitAccordion(opener, element, container, num) { // IE6 got no window.addEventListener @@ -1539,3 +1506,9 @@ function openTab(event, target) { } } } + +function swapTab(tab) { + let menu = document.getElementById("admin-page-menu").children; + if (Number.isInteger(tab) && tab <= menu.length) + menu[tab].click() +} diff --git a/web/themes/default/core/footer.mustache b/web/themes/default/core/footer.mustache index 2d7b5c145..4ba436516 100644 --- a/web/themes/default/core/footer.mustache +++ b/web/themes/default/core/footer.mustache @@ -8,9 +8,10 @@