<?php
function curl_get_file_contents($URL)
{
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
$url = 'http://my.yahoo.com';
$site = 'https://login.yahoo.com/config/login?.done=http://answers.yahoo.com%2findex&.src=knowsrch&.intl=us';
$sitetext = curl_get_file_contents($site);
//echo $sitetext;
$posturl = 'https://login.yahoo.com/config/login?';
// Get the hidden fields
$pattern = '<input type="hidden" name=".tries" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
//print_r($matches);
$tries = $matches[1];
$pattern = '<input type="hidden" name=".src" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$src = $matches[1];
$pattern = '<input type="hidden" name=".md5" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$md5 = $matches[1];
$pattern = '<input type="hidden" name=".hash" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$hash = $matches[1];
$pattern = '<input type="hidden" name=".js" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$js = $matches[1];
$pattern = '<input type="hidden" name=".last" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$last = $matches[1];
$pattern = '<input type="hidden" name=".promo" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$promo = $matches[1];
$pattern = '<input type="hidden" name=".intl" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$intl = $matches[1];
$pattern = '<input type="hidden" name=".bypass" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$bypass = $matches[1];
$pattern = '<input type="hidden" name=".partner" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$partner = $matches[1];
$pattern = '<input type="hidden" name=".u" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$u = $matches[1];
$pattern = '<input type="hidden" name=".v" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$v = $matches[1];
$pattern = '<input type="hidden" name=".challenge" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$challenge = $matches[1];
$pattern = '<input type="hidden" name=".yplus" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$yplus = $matches[1];
$pattern = '<input type="hidden" name=".emailCode" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$emailcode = $matches[1];
$pattern = '<input type="hidden" name=".pkg" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$pkg = $matches[1];
$pattern = '<input type="hidden" name=".stepid" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$stepid = $matches[1];
$pattern = '<input type="hidden" name=".ev" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$ev = $matches[1];
$pattern = '<input type="hidden" name=".hasMsgr" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$hasmsgt = $matches[1];
$pattern = '<input type="hidden" name=".chkP" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$chkp = $matches[1];
$pattern = '<input type="hidden" name=".done" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$done = $matches[1];
$pattern = '<input type="hidden" name=".pd" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$pd = $matches[1];
$pattern = '<input type="hidden" name=".u" value="(.*)">';
preg_match( $pattern, $sitetext, $matches );
$u = $matches[1];
// Get the Post Data
$post_data = array();
$post_data['login'] = 'usernamehere';
$post_data['passwd'] = 'passwordhere';
$post_data['.tries'] = $tries;
$post_data['.src'] = $src;
$post_data['.md5'] = $md5;
$post_data['.hash'] = $hash;
$post_data['.js'] = $js;
$post_data['.last'] = $last;
$post_data['.promo'] = $promo;
$post_data['.intl'] = $intl;
$post_data['.bypass'] = $bypass;
$post_data['.partner'] = $partner;
$post_data['.u'] = $u;
$post_data['.v'] = $v;
$post_data['.challenge'] = $challenge;
$post_data['.yplus'] = $yplus;
$post_data['.emailCode'] = $emailcode;
$post_data['pkg'] = $pkg;
$post_data['stepid'] = $stepid;
$post_data['.ev'] = $ev;
$post_data['hasMsgr'] = $hasmsgr;
$post_data['.chkP'] = $chkp;
$post_data['.done'] = $done;
$post_data['.pd'] = $pd;
$post_data['.persistent'] = 'n';
foreach ($post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
$post_string = implode ('&', $post_items);
//echo $post_string;
$cookie = MD5($post_data['login']);
$curl_connection = curl_init($posturl);
curl_setopt($curl_connection, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($curl_connection, CURLOPT_COOKIEFILE, $cookie );
curl_setopt($curl_connection, CURLOPT_COOKIE, $cookie);
//curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "YahooSeeker-Testing/v3.9 (compatible; Mozilla 4.0; MSIE 5.5; http://search.yahoo.com/)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_connection, CURLOPT_AUTOREFERER, false);
//curl_setopt($curl_connection, CURLOPT_REFERER, $url);
curl_setopt($curl_connection, CURL_SSL_VERIFYPEER, false);
//curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
$result = curl_exec($curl_connection);
echo $result;
// Set landing page options
curl_setopt( $ch, CURLOPT_REFERER, '' );
curl_setopt($ch, CURLOPT_URL, 'https://login.yahoo.com/config/login?');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt' );
curl_setopt( $ch, CURLOPT_POST, FALSE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, NULL );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
// Retrieve source code
$result = curl_exec( $ch );
curl_close( $ch );
echo $result;
?>