Hi i have an Hotmail, Gmail and Yahoo grabber to my site so ppl can grabb thir contacts and easy invite their friends. But the script dont work so well :/ when i enter my details and klick import the hotmail.php load but it wont import eny contacts, same with yahoo and gmail. It just load the page blank with no contact then i click at invite buttom and no contacts get the invation. What could the error be?
Heres the code for hotmail:
<?
//---------**** Functions required to run index.php****------------//
mt_srand((double)microtime()*100000);
$test=mt_rand(65,90);
$test3=mt_rand(97,122);
$test1=mt_rand(65,90);
$test4=mt_rand(48,57);
$test5=mt_rand(48,57);
$test6=mt_rand(65,90);
$test7=mt_rand(97,122);
$test8=mt_rand(97,122);
$ram1=chr($test);
$ram2=chr($test3);
$ram3=chr($test4);
$ram4=chr($test1);
$ram5=chr($test5);
$ram6=chr($test6);
$ram7=chr($test7);
$ram8=chr($test8);
$fname="$ram1$ram2$ram3$ram4$ram5"; ///Random string for unique file name
function login($hotmail_user_id,$hotmail_user_password)
{
global $cookie_file_path,$acurmbox,$str,$fname,$live,$sid;
$file="./$fname".".txt";
@unlink($file);
$live=false;
// 1-Get First Login Page http://www.hotmail.com
// This page will set some cookies and later we will use these cookies to access inside pages .
$cookie_file_path ="./temp/".$fname.".txt"; // Please set your cookie domain
$LOGINURL = "http://www.hotmail.com";
$result = get_curl($LOGINURL,$cookie_file_path,"","");
$action=substr($result,strpos($result,'action="')+strlen("action=\""));
$action1=substr($action,0,strpos($action,'"'));
$value=substr($result,strpos($result,'value="')+strlen("value=\""));
$value=substr($value,0,strpos($value,'"'));
$POSTFIELDS = 'PPStateXfer='.urlencode($value);
$result= get_curl($action1,$cookie_file_path,$POSTFIELDS,"http://www.hotmail.com");
$action=substr($result,strpos($result,'action="')+strlen("action=\""));
$action=substr($action,0,strpos($action,'"'));
$value=substr($result,strpos($result,'id="i0327" value="')+strlen("id=\"i0327\" value=\""));
$value=substr($value,0,strpos($value,'"'));
$RsPass = (get_magic_quotes_gpc()) ? stripslashes($hotmail_user_password) : $hotmail_user_password;
$RsLogin = (get_magic_quotes_gpc()) ? stripslashes($hotmail_user_id) : $hotmail_user_id;
$POSTFIELDS = "PPFT=$value&PPSX=Passport&PwdPad=&LoginOptions=3¬inframe=1&SI= Sign In &passwd=".urlencode($RsPass)."&login=".$RsLogin;
$reffer = $action1;
// 2- Post Login Data to Page https://login.passport.com/ppsecure/post.srf.... to login to hotmail
$str= get_curl($action,$cookie_file_path,$POSTFIELDS,$reffer);
if(strpos($str,'<input name="login"')>0)
return false;
$str1=substr($str,strpos($str,"http://"));
$str2=substr($str1,0,strpos($str1,"\");"));
$result = get_curl($str2,$cookie_file_path,"","");
$action=substr($result,strpos($result,'action="')+strlen("action=\""));
$action1=substr($action,0,strpos($action,'"'));
if(strpos($action1,"https://login.live.com")===false)
{
$str1=substr($result,strpos($result,"curmbox"));
$str1=$acurmbox=substr($str1,0,strpos($str1,"\n"));
}
else
{
$live=true;
$value=substr($result,strpos($result,'value="')+strlen("value=\""));
$value=substr($value,0,strpos($value,'"'));
$POSTFIELDS = 'PPStateXfer='.urlencode($value);
$result= get_curl($action1,$cookie_file_path,$POSTFIELDS,"");
$str1=substr($result,strpos($result,"http://"));
$str2=substr($str1,0,strpos($str1,"\");"));
$result= get_curl($str2,$cookie_file_path,"","","true");
$mailtoken=substr($result,strpos($result,"MailToken=")+strlen("MailToken="));
$acurmbox=$mailtoken=substr($mailtoken,0,strpos($mailtoken,";"));
$str1=substr($result,strpos($result,"main\" src=\"")+strlen("main\" src=\""));
$str2="http://by116w.bay116.mail.live.com/mail/".substr($str1,0,strpos($str1,"\""));
$result= get_curl($str2,$cookie_file_path,"","");
$sid=substr($result,strpos($result,"SessionIdHash\" value=\"")+strlen("SessionIdHash\" value=\""));
$sid=substr($sid,0,strpos($sid,"\""));
}
//write_to_file($str);
//Get 'curmbox' and 'a' variable's value from a page's source code
///and embed those value at the end of a url
return true;
}
function get_address_page()
{
global $cookie_file_path,$acurmbox,$prarray,$emarray,$live,$sid;
if($live)
{
$action="http://by116w.bay116.mail.live.com/mail/mail.fpp?cnmn=Microsoft.Msn.Hotmail.MailBox.Bootstrap&ptid=0&a=";
$postfileds="cn=Microsoft.Msn.Hotmail.MailBox&mn=Bootstrap&d=&MailToken=$acurmbox";
$str= get_curl($action,$cookie_file_path,$postfileds,"");
}
else
{
$additional_parameter=$acurmbox;
///Address page url
$str="http://by16fd.bay16.hotmail.msn.com/cgi-bin/addresses?&$additional_parameter";
//Address page's print preview page url
$prview="http://by16fd.bay16.hotmail.msn.com/cgi-bin/addresses?&$additional_parameter&strUsrFltr=&strUsrView=&strAlphNav=&PrintView=1";
///Get the print preview page and save Name and password in temp array
$prvstr=get_curl($prview,$cookie_file_path,"","");
$tbst='<table border=0 cellpadding=0 cellspacing=0 width=100% class="Contact">';
$table=substr($prvstr,strpos($prvstr,$tbst));
$table=substr($table,0,strpos($table,"</table>"));
//echo $table;
$rows=explode("<tr>",$table);
//echo sizeof($rows);
$emarray=array();
$nmarray=array();
for($i=2;$i<sizeof($rows);$i++)
{
$colums=explode("</td>",$rows[$i]);
$emarray[]=strip_tags(substr($colums[1],0,strpos($colums[1],'</span>')));
}
//Get the address page and return contents of address page
$str=get_curl($str,$cookie_file_path,"","");
}
return $str;
}
function get_curl($url,$cookie_path="",$postfileds="",$referrer="",$header="")
{
$agent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
if($referrer!="")
curl_setopt($ch, CURLOPT_REFERER, $referrer);
if($cookie_path!="")
{
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_path);
}
if($postfileds!="")
{
curl_setopt($ch, CURLOPT_POST, 1.1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postfileds);
}
if($header!="")
curl_setopt($ch, CURLOPT_HEADER, 1);
$result = curl_exec ($ch);
curl_close ($ch);
//echo ("url=$url<hr>PostFields=$postfileds<hr>".nl2br(htmlspecialchars($result))."<hr>");
return $result;
}
function parser($str)
{
global $id_str,$id_array,$name_array,$email_array,$phone_array,$call_more,$call_array,$cookie_file_path,$live;
if($live)
{
$str=substr($str,strpos($str,"new HM.ABContact"));
$str=substr($str,0,strpos($str,"new HM.__"));
$lines=explode("new HM.ABContact",$str);
foreach($lines as $key=>$val)
{
$data=explode(", \"",$val);
$name_array[]=substr($data[0],2,strlen($data[0])-3);
$email=$data[1];
$email_array[]=substr($email,0,strpos($email,"\""));
}
}
else
{
///get the table body which containing email address and names
$a='<table border=0 cellpadding=0 cellspacing=0 width=100% class="EE" id="ListTable">';
$b="<td colspan=5> </td>";
$str=substr($str,strpos($str,$a));
$str=substr($str,0,strpos($str,$b)+strlen($b));
///Parse the html data and bring out name and addresses
$rows=explode("</tr>",$str);
for($i=2;$i<sizeof($rows);$i++)
{
$tr_name=substr($rows[$i],strlen("<tr name='"));
$tr_name=substr($tr_name,0,strpos($tr_name,"'"));
$rows[$i]=substr($rows[$i],strpos("$rows[$i]","<td")-1);
$colums=explode("</td>",$rows[$i]);
$call_more=false;
for($j=0;$j<sizeof($colums);$j++)
{
if(sizeof($colums)==6)
{
switch($j)
{
case 0:
$id_str=substr($colums[$j],strpos($colums[$j],"name=")+6);
$id_str=$id_array[]=substr($id_str,0,strpos($id_str,"\""));
break;
case 2:
$name_str=substr($colums[$j],strpos($colums[$j],"return false;\">")+strlen("return false;\">"));
$name_str=$name_array[]=substr($name_str,0,strpos($name_str,"</a>"));
break;
case 3:
$email_str=substr($colums[$j],strpos($colums[$j],"return false;\">")+strlen("return false;\">"));
$email_str=substr($email_str,0,strpos($email_str,"</a>"));
if(!ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$",$email_str))
$email_array[]=$tr_name;
else
$email_array[]=$email_str;
if(strpos($colums[$j],"more"))
$call_more=true;
break;
default:
break;
}
}
else
{
switch($j)
{
case 0:
$id_str=substr($colums[$j],strpos($colums[$j],"name=")+6);
$id_str=$id_array[]=substr($id_str,0,strpos($id_str,"\""));
break;
case 3:
$name_str=substr($colums[$j],strpos($colums[$j],"return false;\">")+strlen("return false;\">"));
$name_str=$name_array[]=substr($name_str,0,strpos($name_str,"</a>"));
break;
case 4:
$email_str=substr($colums[$j],strpos($colums[$j],"return false;\">")+strlen("return false;\">"));
$email_str=substr($email_str,0,strpos($email_str,"</a>"));
if(!ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$",$email_str))
$email_array[]=$tr_name;
else
$email_array[]=$email_str;
if(strpos($colums[$j],"more"))
$call_more=true;
break;
default:
break;
}
}
}
}
}
@unlink($cookie_file_path);
}
?>