$DiscountFinish = 0; } // Определяем следующее действие $NextActionName = 'AddLevelPointDiscount'; // Действие на текстовом поле по клику $OnClickText = ' onClick="javascript:this.value = \'\';"'; // Надпись на кнопке $SaveButtonText = 'Добавить интервал амнистии'; $pLevelPointDiscountId = 0; } else { $pLevelPointDiscountId = mmb_validateInt($_POST, 'LevelPointDiscountId'); if ($pLevelPointDiscountId <= 0) { return; } $sql = "select lpd.levelpointdiscount_id, \n\t lpd.levelpointdiscount_value, \n\t lpd.levelpointdiscount_start, \n\t lpd.levelpointdiscount_finish,\n\t\t lpd.distance_id,\n\t\t lpd.levelpoint_id \n\t\tfrom LevelPointDiscounts lpd\n\t\twhere lpd.levelpointdiscount_id = {$pLevelPointDiscountId}"; $Row = CSql::singleRow($sql); // Если вернулись после ошибки переменные не нужно инициализировать if ($viewsubmode == "ReturnAfterError") { ReverseClearArrays(); $DistanceId = mmb_validateInt($_POST, 'DistanceId'); $LevelPointId = $_POST['LevelPointId']; $DiscountValue = $_POST['DiscountValue']; $DiscountStart = $_POST['DiscountStart']; $DiscountFinish = $_POST['DiscountFinish']; } else { $DiscountValue = $Row['levelpointdiscount_value']; $DiscountStart = $Row['levelpointdiscount_start']; $DiscountFinish = $Row['levelpointdiscount_finish']; $DistanceId = $Row['distance_id']; $LevelPointId = $Row['levelpoint_id']; }
public static function canInviteTeam($userId, $teamId) { // проверяем, что команда не в зачете и узнаем ключ ММБ $sql = "select t.team_outofrange, d.raid_id, t.team_hide\n \t\t\tfrom Teams t \n \t\t\t inner join Distances d\n \t\t\t on t.distance_id = d.distance_id\n\t \t\twhere t.team_id = {$teamId}"; $Row = CSql::singleRow($sql); $outOfRange = $Row['team_outofrange']; $hideTeam = $Row['team_hide']; $raidId = $Row['raid_id']; if (!$outOfRange or $hideTeam) { return false; } $raidStage = CSql::raidStage($raidId); // по идее можно показывать и с 5, но обычно карты загружают позже // до открытия регистрации (до задания даты окончания регистрации) нельяз выдавать if ($raidStage > 2 or $raidStage < 1) { return false; } // проверяем, что пользователь включен в команду, которая не активирована // и пытается активировать другую команду // на этом марш-броске $sql = "select count(*) selfoutofrange\n \t\t\tfrom Teams t \n \t\t\t inner join TeamUsers tu \n \t\t\t on t.team_id = tu.team_id\n \t\t\t inner join Distances d\n \t\t\t on t.distance_id = d.distance_id\n\t \t\twhere tu.user_id = {$userId}\n\t \t\t and t.team_id <> {$teamId}\n\t \t\t and t.team_hide = 0\n\t \t\t and d.raid_id = {$raidId}\n\t \t\t and tu.teamuser_hide = 0\n\t \t\t and t.team_outofrange = 1\n\t \t\t"; $selfoutofrange = CSql::singleValue($sql, 'selfoutofrange', false); if ($selfoutofrange) { return false; } // проверяем, что у пользователя есть приглашение, оо активно и не активировано $sql = "select inv.invitation_id\n \t\t\tfrom Invitations inv\n\t \t\t\tinner join InvitationDeliveries idev\n \t\t\t\ton inv.invitationdelivery_id = idev.invitationdelivery_id\n \t\t\t\tleft outer join Teams t\n \t\t\t\ton inv.invitation_id = t.invitation_id\n\t \t\t\t and t.team_hide = 0\n\t\t \twhere idev.raid_id = {$raidId}\n\t\t \t and inv.user_id = {$userId}\n\t\t\t \tand inv.invitation_begindt <= NOW()\n \t\t\t\tand inv.invitation_enddt >= NOW()\n\t\t\t\t and t.team_id is null\n\t\t\t\torder by inv.invitation_id asc\n\t\t\t\tLIMIT 0,1\n\t\t\t\t"; // echo $sql; $invitationId = CSql::singleValue($sql, 'invitation_id', false); return $invitationId; }
public static function getUserId($login, $pwd) { $qLogin = CSql::quote(trim($login)); // а откуда приходят логин и пароль? они уже заэскейплены или нет? $sql = "select user_id, user_password from Users\n \twhere user_hide = 0 and trim(user_email) = {$qLogin}"; $row = CSql::singleRow($sql); if (!isset($row['user_id'])) { return 0; } // return password_verify($pwd, $row['user_password']) ? $row['user_id'] : 0; // todo uncomment on migration if ($row['user_password'] === md5(trim($pwd))) { return $row['user_id']; } return 0; }
function FindFirstTeamInWaitList($RaidId) { // Получаем информацию о лимите и о зарегистированных командах $sql = "select t.team_id\n\t\t\tfrom Raids r \n\t\t\t\tinner join Distances d\n\t\t\t\ton r.raid_id = d.raid_id\n\t\t\t\tinner join Teams t\n\t\t\t\ton d.distance_id = t.distance_id\n\t\t\twhere r.raid_id={$RaidId}\n\t\t\t\tand t.team_hide = 0\n\t\t\t\tand t.team_outofrange = 1\n\t\t\t\tand t.team_waitdt is not null\n\t\t\torder by t.team_waitdt ASC\n\t\t\tLIMIT 0,1\n\t\t\t"; $Row = CSql::singleRow($sql); return $Row['team_id']; }