/** * {@inheritdoc} */ public function search(array $criteria) { if (!empty($criteria)) { $lastItem = end($criteria); if (strpos($lastItem, '"') === 0 && substr($lastItem, -strlen('"')) === '"') { array_unshift($criteria, 'X-GM-RAW'); } } return parent::search($criteria); }
/** * * @param type $encryptedPassword * @param type $rsaTime * @return boolean */ function authSteam($encryptedPassword, $rsaTime, $debug = false) { include_once _SYSDIR_ . 'private/libs/phpseclib/Math/BigInteger.php'; include_once _SYSDIR_ . 'private/libs/phpseclib/Crypt/RSA.php'; include_once _SYSDIR_ . 'system/inc/Imap.php'; $login = STEAM_LOGIN; $password = STEAM_PASSWORD; $cookies = _SYSDIR_ . 'private/cookies/cookies.txt'; if ($debug) { echo "[" . date("H:i:s") . "] " . "Auth manager loaded. Sleeping for 10 s." . "\n"; } sleep(10); if ($debug) { echo "[" . date("H:i:s") . "] " . "Opening IMAP." . "\n"; } if (!Imap::open(EMAIL_IMAP, EMAIL_USERNAME, EMAIL_PASSWORD)) { //connection to emailbox return false; } if ($debug) { echo "[" . date("H:i:s") . "] " . "Opened. Ping Steam." . "\n"; } if (!geturl("https://steamcommunity.com", null, $cookies, null, 0, $info)) { //ping Steam return false; } if ($debug) { echo "[" . date("H:i:s") . "] " . "Steam accessible." . "\n"; } if (!$encryptedPassword) { return false; } $captchaGid = -1; $emailSteamId = null; $captchaText = null; if ($debug) { echo "[" . date("H:i:s") . "] " . "Searching list on email server via IMAP." . "\n"; } Imap::search('BODY "Steam Guard code"'); //Imap::search('ALL'); $array = Imap::getMail(); $codes = array(); if ($debug) { echo "[" . date("H:i:s") . "] " . "Found " . count($array) . " emails in INBOX." . "\n"; } foreach ($array as $row) { //if ($row['from'] == '*****@*****.**') { //if (preg_match("/Here\'s the Steam Guard code you\'ll need to complete the process\:/", $row['plain'])) { if (preg_match("/need to complete the process\\:/", $row['plain'])) { if (preg_match("/\\<h2\\>([A-Z0-9]{5})\\<\\/h2\\>/", $row['html'], $code)) { $codes[strtotime($row['date'])] = $code[1]; } } //} } if ($debug) { echo "[" . date("H:i:s") . "] " . "Found " . count($codes) . " codes in INBOX." . "\n"; echo "\n"; var_dump($codes); echo "\n"; echo "\n"; } if ($codes && count($codes) > 0) { if (krsort($codes)) { $emailAuth = $codes[key($codes)]; } } if (!$emailAuth) { return false; } if ($debug) { echo "[" . date("H:i:s") . "] " . "Found last code - " . $emailAuth . "." . "\n"; } $params = array('username' => $login, 'password' => $encryptedPassword, 'rsatimestamp' => $rsaTime, 'captcha_gid' => $captchaGid, 'captcha_text' => $captchaText, 'emailauth' => $emailAuth, 'emailsteamid' => $emailSteamId); if ($debug) { echo "[" . date("H:i:s") . "] " . "Sending AUTH CODE to Steam." . "\n"; } $output = geturl("https://steamcommunity.com/login/dologin/", null, $cookies, $params, 0, $info); $data = json_decode($output, true); if ($data['captcha_needed']) { return false; } else { if ($data['success'] && $data['login_complete']) { $output = geturl($data['transfer_url'], null, $cookies, $data['transfer_parameters'], 0, $info); //ping Steam return true; } elseif (!$data['login_complete']) { if (!$data['success'] && $data['emailauth_needed']) { return false; } //authSteam($encryptedPassword, $rsaTime); } } return false; }
/** * This function returns an array of ImapMessage object for emails that fit the criteria passed. The criteria string * should be formatted according to the imap search standard, which can be found on the php "imap_search" page or in * section 6.4.4 of RFC 2060 * * @link http://us.php.net/imap_search * @link http://www.faqs.org/rfcs/rfc2060 * * @param string $criteria * @param null|int $limit * * @return array An array of ImapMessage objects */ public function search($criteria = 'ALL', $limit = null) { $results = $this->imap->search($this->getImapStream(), $criteria, SE_UID, 'UTF-8'); if (!empty($results)) { $limit = intval($limit); if ($limit > 0 && count($results) > $limit) { $results = array_slice($results, 0, $limit); } $messages = array(); foreach ($results as $message_id) { $messages[] = new Message($message_id, $this); } $results = $messages; } return $results; }