function proccessAdminMessage($phone, $message, $name = "Not Registered", $media = null) { global $SYSTEM_ADMIN_PHONES; $message = trim(substr($message, strpos($message, ':') + 1)); $media = mediaURLForPhone($phone); foreach ($SYSTEM_ADMIN_PHONES as $adminPhone) { singleSMS($adminPhone, $phone . ' (' . $name . ')' . ":\n\n" . $message, $media); } }
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); } } } } } }