function checkUserDeathTexts($isAssassin, $userID) { if ($isAssassin) { $assassin = getUser($userID); $target = getUser($assassin['target_id']); } else { $target = getUser($userID); $assassin = getAssassinForUserID($userID); } $targetOfKilled = getUser($target['target_id']); $assassinTexted = false; $assassinTextedInTime = false; $targetTexted = false; $targetTextedInTime = false; $assassinTexted = $assassin['text_eliminated'] > 0; $assassinTextedInTime = $assassinTexted && time() - $assassin['text_eliminated'] <= SYSTEM_TIME_BETWEEN_COMMANDS; $targetTexted = $target['text_rip'] > 0; $targetTextedInTime = $targetTexted && time() - $target['text_rip'] <= SYSTEM_TIME_BETWEEN_COMMANDS; if ($assassinTextedInTime && $targetTextedInTime) { DB::update('users', array('text_rip' => -1, 'target_id' => -1), "user_id=%d", $target['user_id']); DB::update('users', array('text_eliminated' => -1, 'target_id' => -1), "user_id=%d", $assassin['user_id']); DB::insert('kills', array('eliminated' => $target['user_id'], 'killer' => $assassin['user_id'], 'date' => time())); DB::insert('xp', array('user_id' => $assassin['user_id'], 'value' => SYSTEM_XP_KILL, 'date' => time())); $personalMessage = 'You earned ' . SYSTEM_XP_KILL . ' XP for killing your target'; log_text('SEND --> ' . $assassin['name'] . ': ' . $personalMessage); $mediaURL = mediaURLForPhone($assassin['phone']); if ($mediaURL) { DB::insert('xp', array('user_id' => $assassin['user_id'], 'value' => SYSTEM_XP_KILLCONFIRMED, 'date' => time())); $personalMessage = 'You earned ' . SYSTEM_XP_KILLCONFIRMED . ' XP for adding a photo!'; log_text('SEND --> ' . $assassin['name'] . ': ' . $personalMessage); if (SYSTEM_STARTED) { singleSMS($assassin['phone'], $personalMessage); } } $message = formatUsername($assassin) . ' has assassinated ' . formatUsername($target) . ($mediaURL ? ' #KillConfirmed' : ''); log_text('TWEET --> ' . $message); if (SYSTEM_STARTED) { postToTwitter($message, $mediaURL); } checkForAchievment($assassin); if ($waitlist = getWaitlistUser()) { DB::update('users', array('target_id' => $waitlist['user_id']), "user_id=%d", $assassin['user_id']); DB::update('users', array('target_id' => $targetOfKilled['user_id'], 'is_waiting' => false), "user_id=%d", $waitlist['user_id']); sendUserMatch($assassin, $waitlist); sendUserMatch($waitlist, $targetOfKilled); } else { if ($match = performMatch($assassin)) { sendUserMatch($assassin, $match); } else { handleVictory($assassin); } } } else { if ($assassinTexted && $targetTexted) { DB::update('users', array('text_rip' => -1), "user_id=%d", $target['user_id']); DB::update('users', array('text_eliminated' => -1), "user_id=%d", $assassin['user_id']); $message = 'Time Between Texts Was Too Long'; log_text('SEND --> ' . $target['name'] . ': ' . $message); log_text('SEND --> ' . $assassin['name'] . ': ' . $message); if (SYSTEM_STARTED) { singleSMS($target['phone'], $message); singleSMS($assassin['phone'], $message); } } else { if ($assassinTexted && !$assassinTextedInTime) { DB::update('users', array('text_rip' => -1), "user_id=%d", $target['user_id']); DB::update('users', array('text_eliminated' => -1), "user_id=%d", $assassin['user_id']); $message = 'Your target did not text in time'; log_text('SEND --> ' . $assassin['name'] . ': ' . $message); if (SYSTEM_STARTED) { singleSMS($assassin['phone'], $message); } } else { if ($targetTexted && !$targetTextedInTime) { DB::update('users', array('text_rip' => -1), "user_id=%d", $target['user_id']); DB::update('users', array('text_eliminated' => -1), "user_id=%d", $assassin['user_id']); $message = 'Your assassin did not text in time'; log_text('SEND --> ' . $target['name'] . ': ' . $message); if (SYSTEM_STARTED) { singleSMS($target['phone'], $message); } } } } } }
<?php set_time_limit(0); require_once substr(getcwd(), 0, strpos(getcwd(), 'public_html')) . 'includes/admin_include.php'; $users = DB::query('SELECT users.*, targetUsers.name as target, COUNT(k.kill_id) AS num_kills FROM users ' . SYSTEM_SQL_STATS_JOIN . ' LEFT JOIN users targetUsers ON users.target_id = targetUsers.user_id ' . SYSTEM_SQL_IS_ALIVE . ' AND ' . SYSTEM_SQL_VALID_USER . ' GROUP BY users.phone'); foreach ($users as $user) { $assassin = getAssassinForUserID($user['user_id']); echo $assassin['phone'] . PHP_EOL; echo $user['phone'] . PHP_EOL; try { sendUserMatch($assassin, $user, true); } catch (Exception $e) { print_r($e); } }