Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smaller UI Bugfixes #611

Merged
merged 7 commits into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions web/includes/SteamID/SteamID.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}
Expand Down
43 changes: 22 additions & 21 deletions web/includes/sb-callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = ''");
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions web/pages/page.home.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down Expand Up @@ -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";
}
Expand Down
5 changes: 1 addition & 4 deletions web/pages/page.submit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 7 additions & 34 deletions web/scripts/sourcebans.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
3 changes: 2 additions & 1 deletion web/themes/default/core/footer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
</div>
</div>
<script>
var settab = ProcessAdminTabs();
window.addEvent('domready', function(){
{{{query}}}

ProcessAdminTabs();

var Tips2 = new Tips($$('.tip'), {
initialize:function(){
Expand Down
10 changes: 8 additions & 2 deletions web/themes/default/page_bans.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,14 @@
</tr>
{if $ban.type == 0}
<tr align="left">
<td width="20%" height="16" class="listtable_1">Steam Community</td>
<td height="16" class="listtable_1"><a href="http://steamcommunity.com/profiles/{$ban.communityid}" target="_blank">{$ban.communityid}</a></td>
<td width="20%" height="16" class="listtable_1">Steam Community</td>
<td height="16" class="listtable_1">
{if empty($ban.steamid)}
<i><font color="#677882">No Steam Community ID present</font></i>
{else}
<a href="http://steamcommunity.com/profiles/{$ban.communityid}" target="_blank">{$ban.communityid}</a>
{/if}
</td>
</tr>
{/if}
{if !$hideplayerips}
Expand Down
7 changes: 6 additions & 1 deletion web/themes/default/page_comms.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@
</tr>
<tr align="left">
<td width="20%" height="16" class="listtable_1">Steam Community</td>
<td height="16" class="listtable_1"><a href="http://steamcommunity.com/profiles/{$ban.communityid}" target="_blank">{$ban.communityid}</a>
<td height="16" class="listtable_1">
{if empty($ban.steamid)}
<i><font color="#677882">No Steam Community ID present</font></i>
{else}
<a href="http://steamcommunity.com/profiles/{$ban.communityid}" target="_blank">{$ban.communityid}</a>
{/if}
</td>
</tr>
<tr align="left">
Expand Down