<?php
$login = 'skatina@usa.com';
$passwd = 'skatina123456';
header("Content-Type: text/html;charset=cp1251");
define ('DS',DIRECTORY_SEPARATOR);
function GO($url, $post=false, $header=false)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, getcwd().DS.'/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, getcwd().DS.'/cookie.txt');
curl_setopt($ch, CURLOPT_USERAGENT, 'Opera 10.00');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
if ($post!==false)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
if ($header!==false)
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
function curl_redir_exec($ch)
{
static $curl_loops = 0;
static $curl_max_loops = 20;
if ($curl_loops >= $curl_max_loops)
{
$curl_loops = 0;
return FALSE;
}
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
list($header, $data) = explode("\n\n", $data, 2);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($http_code == 301 || $http_code == 302)
{
$matches = array();
preg_match('/Location:(.*?)\n/', $header, $matches);
$url = @parse_url(trim(array_pop($matches)));
if (!$url)
{
//couldn't process the url to redirect to
$curl_loops = 0;
return $data;
}
$last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
if (!$url['scheme'])
$url['scheme'] = $last_url['scheme'];
if (!$url['host'])
$url['host'] = $last_url['host'];
if (!$url['path'])
$url['path'] = $last_url['path'];
$new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . ($url['query']?'?'.$url['query']:'');
curl_setopt($ch, CURLOPT_URL, $new_url);
//debug('Redirecting to', $new_url);
return curl_redir_exec($ch);
} else {
$curl_loops=0;
return $data;
}
}
$res = curl_redir_exec($ch);
curl_close($ch);
return $res;
}
$page=GO('http://service.mail.com/login.html',
array(
'rdirurl' => 'http://www.mail.com/ru/',
'edition' => 'ru',
'lang' => 'ru',
'device' => 'desktop',
'usertype' => 'standard',
'login' => $login,
'password' => $passwd,
'btnLogin' => 'Вход'
)
);
if (preg_match('#<title>.+\((\d+)\).+</title>#smiU', $page, $n))
echo 'В почтовом ящике '.$login.' писем: '.$n[1];
else
echo 'Какието проблемы O_o';
?>