require_once 'lib.php'; require_once 'chance.php'; require_once 'db.php'; require_once 'settings.php'; require_once 'misc/bases.php'; if ($_REQUEST['ajax'] == "random_encounter" && isset($_REQUEST['key']) && isset($_REQUEST['sesc'])) { //Spit out a random poke. //Not being sneaky, are you? if ($_REQUEST['key'] != md5(date('jg') . $context['user']['id']) || $_REQUEST['sesc'] != $context['session_id']) { die('<!-- Bad Data -->'); } //Here we might do some extra checking - if the user is an existing trainer and has a last caught value, we could "cool down" against spammers, making it very difficult to rapidly acquire pokemon. $userdata = userdata($context['user']['id']); //Is this the first time you've encountered a pokemon? Welcome to the trainer club. if (empty($userdata)) { newtrainer($context['user']['id']); sleep(1); $userdata = userdata($context['user']['id']); } //Prevent encounters too soon after recently capturing a pokemon. $lastcapture = time() - $userdata[0]['lastcaught']; //If it's been less than 30 minutes, you can't encounter any more. if ($lastcapture < $pcfg['encounter_cooldown_block']) { die('<!-- Too soon since last capture -->'); } //If it's been under an hour, you have a 50/50 chance to not get this encounter. if ($lastcapture < $pcfg['encounter_cooldown_half']) { $test = mt_rand(0, 10); if ($test < 5) { die('<!-- Too soon since last capture, partially blocked -->'); }
//SLOW DOWN PARDNER. Perhaps we're gifting an egg here? if ($_REQUEST['pokemon_to_give'] == 'EGG') { exit; } //Is the pokemon we're gifting going to be a shiny one? if (isset($_POST['is_shiny']) && $_POST['is_shiny'] == "affirmative") { $_POST['pokemon_to_give'] = $_POST['pokemon_to_give'] . '.3'; } $smf_userdata = ssi_fetchMember($member_ids = $_POST['trainer_list'], $output_method = 'array'); //First thing's first, if you're gifting to a user who does not have a trainer profile yet, we gotta create it for them. foreach ($_POST['trainer_list'] as $recipient) { $recipient = (int) $recipient; $recipientdata = userdata($recipient); if (empty($recipientdata)) { //This user is a virgin! newtrainer($recipient); echo '<br>' . $warning_symbol . ' No trainer profile for ' . $smf_userdata[$recipient]['name'] . ', creating one.<br>'; } //Now we know they have a trainer profile, bypass encounters and chances and just give them the pokemon. see_pokemon($recipient, $_POST['pokemon_to_give']); capture_pokemon($recipient, $_POST['pokemon_to_give']); dex_pokemon($recipient, round($_POST['pokemon_to_give'])); echo '<br>' . (is_shiny($_POST['pokemon_to_give']) ? 'Shiny ' : '') . $pokemon[round($_POST['pokemon_to_give'])] . ' was gifted to User ' . $smf_userdata[$recipient]['name']; admin_log(1, $_POST['pokemon_to_give'], $recipient); //$type, $params(pokemon), $extra(receiving user(s)) } } elseif (isset($_GET['dbbackup'])) { //Just spit out our DB, with a nice timestamp //To help avoid locking, explicitly close our database before proceeding. We're ending execution in a few lines so this is fine. $file_db = null; header('Content-Type: application/octet-stream');