Ejemplo n.º 1
0
	/**
	 * Abre a caixa de correio
	 * @throws	ImapException Caso algum erro de conexão ocorra
	 */
	public function open() {
		$this->imap->open( $this->fullname );
	}
Ejemplo n.º 2
0
 /**
  * This function creates or reopens an imap_stream when called.
  */
 protected function setImapStream()
 {
     if (isset($this->imap_stream)) {
         $this->imap->reopen($this->imap_stream, $this->getServerString(), $this->options, 1);
     } else {
         $this->imap_stream = $this->imap->open($this->getServerString(), $this->username, $this->password, $this->options, 1);
     }
 }
Ejemplo n.º 3
0
/**
 * 
 * @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;
}
Ejemplo n.º 4
0
<?php
require 'dso/mail/imap/exception/ImapException.php';
require 'dso/mail/imap/Imap.php';

$username = '******';
$password = '******';

if ( $username == '*****@*****.**' && $password == 'senha' ) {
	throw new Exception( 'Defina o usuário e senha antes de executar o exemplo' );
} else {
	try {
		$imap = new Imap();
		$imap->open( '{imap.gmail.com:993/imap/ssl/novalidate-cert}' , $username , $password );

		for ( $mbi = $imap->getMailboxIterator() ; $mbi->valid() ; $mbi->next() ) {
			$mailbox = $mbi->current();
			$mailbox->open();

			printf( "%s\n" , $mailbox->getName() );

			for ( $mi = $imap->getMessageIterator() ; $mi->valid() ; $mi->next() ) {
				$message = $mi->current();
				$message->fetch();

				printf( "\tID: %s\n" , $message->getMessageId() );
				printf( "\tDe: %s\n" , $message->getFrom() );
				printf( "\tPara: %s\n" , $message->getTo() );
				printf( "\tAssunto: %s\n" , $message->getSubject() );
				printf( "\tData: %s\n\n" , $message->getDate() );
			}