コード例 #1
0
function AddBlock($nickname, $type, $steam, $length, $reason)
{
    $objResponse = new xajaxResponse();
    global $userbank, $username;
    if (!$userbank->HasAccess(ADMIN_OWNER | ADMIN_ADD_BAN)) {
        $objResponse->redirect("index.php?p=login&m=no_access", 0);
        $log = new CSystemLog("w", "Hacking Attempt", $username . " tried to add a block, but doesnt have access.");
        return $objResponse;
    }
    $steam = trim($steam);
    $error = 0;
    // If they didnt type a steamid
    if (empty($steam)) {
        $error++;
        $objResponse->addAssign("steam.msg", "innerHTML", "You must type a Steam ID or Community ID");
        $objResponse->addScript("\$('steam.msg').setStyle('display', 'block');");
    } else {
        if (!is_numeric($steam) && !validate_steam($steam) || is_numeric($steam) && (strlen($steam) < 15 || !validate_steam($steam = FriendIDToSteamID($steam)))) {
            $error++;
            $objResponse->addAssign("steam.msg", "innerHTML", "Please enter a valid Steam ID or Community ID");
            $objResponse->addScript("\$('steam.msg').setStyle('display', 'block');");
        } else {
            $objResponse->addAssign("steam.msg", "innerHTML", "");
            $objResponse->addScript("\$('steam.msg').setStyle('display', 'none');");
        }
    }
    if ($error > 0) {
        return $objResponse;
    }
    $nickname = RemoveCode($nickname);
    $reason = RemoveCode($reason);
    if (!$length) {
        $len = 0;
    } else {
        $len = $length * 60;
    }
    // prune any old bans
    PruneComms();
    $typeW = "";
    switch ((int) $type) {
        case 1:
            $typeW = "type = 1";
            break;
        case 2:
            $typeW = "type = 2";
            break;
        case 3:
            $typeW = "(type = 1 OR type = 2)";
            break;
        default:
            $typeW = "";
            break;
    }
    // Check if the new steamid is already banned
    $chk = $GLOBALS['db']->GetRow("SELECT count(bid) AS count FROM " . DB_PREFIX . "_comms WHERE authid = ? AND (length = 0 OR ends > UNIX_TIMESTAMP()) AND RemovedBy IS NULL AND " . $typeW, array($steam));
    if (intval($chk[0]) > 0) {
        $objResponse->addScript("ShowBox('Error', 'SteamID: {$steam} is already blocked.', 'red', '');");
        return $objResponse;
    }
    // Check if player is immune
    $admchk = $userbank->GetAllAdmins();
    foreach ($admchk as $admin) {
        if ($admin['authid'] == $steam && $userbank->GetProperty('srv_immunity') < $admin['srv_immunity']) {
            $objResponse->addScript("ShowBox('Error', 'SteamID: Admin " . $admin['user'] . " ({$steam}) is immune.', 'red', '');");
            return $objResponse;
        }
    }
    if ((int) $type == 1 || (int) $type == 3) {
        $pre = $GLOBALS['db']->Prepare("INSERT INTO " . DB_PREFIX . "_comms(created,type,authid,name,ends,length,reason,aid,adminIp ) VALUES\r\n\t\t\t\t\t\t\t\t\t  (UNIX_TIMESTAMP(),1,?,?,(UNIX_TIMESTAMP() + ?),?,?,?,?)");
        $GLOBALS['db']->Execute($pre, array($steam, $nickname, $length * 60, $len, $reason, $userbank->GetAid(), $_SERVER['REMOTE_ADDR']));
    }
    if ((int) $type == 2 || (int) $type == 3) {
        $pre = $GLOBALS['db']->Prepare("INSERT INTO " . DB_PREFIX . "_comms(created,type,authid,name,ends,length,reason,aid,adminIp ) VALUES\r\n\t\t\t\t\t\t\t\t\t  (UNIX_TIMESTAMP(),2,?,?,(UNIX_TIMESTAMP() + ?),?,?,?,?)");
        $GLOBALS['db']->Execute($pre, array($steam, $nickname, $length * 60, $len, $reason, $userbank->GetAid(), $_SERVER['REMOTE_ADDR']));
    }
    $objResponse->addScript("ShowBlockBox('" . $steam . "', '" . (int) $type . "', '" . (int) $len . "');");
    $objResponse->addScript("TabToReload();");
    $log = new CSystemLog("m", "Block Added", "Block against (" . $steam . ") has been added, reason: {$reason}, length: {$length}", true, $kickit);
    return $objResponse;
}
コード例 #2
0
     $errorScript .= "\$('steam.msg').setStyle('display', 'block');";
 } else {
     if (!is_numeric($_POST['steam']) && !validate_steam($_POST['steam']) || is_numeric($_POST['steam']) && (strlen($_POST['steam']) < 15 || !validate_steam($_POST['steam'] = FriendIDToSteamID($_POST['steam'])))) {
         $error++;
         $errorScript .= "\$('steam.msg').innerHTML = 'Please enter a valid Steam ID or Community ID';";
         $errorScript .= "\$('steam.msg').setStyle('display', 'block');";
     }
 }
 // Didn't type a custom reason
 if ($_POST['listReason'] == "other" && empty($_POST['txtReason'])) {
     $error++;
     $errorScript .= "\$('reason.msg').innerHTML = 'You must type a reason';";
     $errorScript .= "\$('reason.msg').setStyle('display', 'block');";
 }
 // prune any old bans
 PruneComms();
 if ($error == 0) {
     // Check if the new steamid is already banned
     $chk = $GLOBALS['db']->GetRow("SELECT count(bid) AS count FROM " . DB_PREFIX . "_comms WHERE authid = ? AND RemovedBy IS NULL AND type = ? AND bid != ? AND (length = 0 OR ends > UNIX_TIMESTAMP())", array($_POST['steam'], (int) $_POST['type'], (int) $_GET['id']));
     if ((int) $chk[0] > 0) {
         $error++;
         $errorScript .= "\$('steam.msg').innerHTML = 'This SteamID is already blocked';";
         $errorScript .= "\$('steam.msg').setStyle('display', 'block');";
     } else {
         // Check if player is immune
         $admchk = $userbank->GetAllAdmins();
         foreach ($admchk as $admin) {
             if ($admin['authid'] == $_POST['steam'] && $userbank->GetProperty('srv_immunity') < $admin['srv_immunity']) {
                 $error++;
                 $errorScript .= "\$('steam.msg').innerHTML = 'Admin " . $admin['user'] . " is immune';";
                 $errorScript .= "\$('steam.msg').setStyle('display', 'block');";