Msn inviter problem?

Pozdrav, zanima me zašto mi ovo ne radi ?

<? include 'gore.php'; ?>
<style type="text/css">/* <![CDATA[ */ @import url(/kontakti.css?v=2.0); /* ]]> */</style>
<script src="/pozivnica.js?verzija=2.0" type="text/javascript"></script>
<?
if(!isset($kojipoziv)){
?>
<div id="glavna">
<div id="prvakolona">
<h1>Uveži se sa svojim prijateljima</h1>
<div style="font-size:12px;color:gray">
Bih-Network.com ti omoguæava da vidiš ko je od tvojih msn ili gmail prijatelja èlan vezica.
</div>


   <div class="col1">
<ul id="list_wrap">
<li id="p1" class="on"><a href="javascript:;" onclick="swichajprovider('p1');"><img src="/slike/hotmail.gif" alt=""></a></li>  
<li id="p2"><a href="javascript:;" onclick="swichajprovider('p2');"><img src="/slike/gmail.gif" alt=""></a></li>
</ul>
    </div>



<CENTER><img src="/slike/pozivnica.jpg"></CENTER>
		
</div>

<div id="sporedna">
<h2>Upiši username i passwod</h2>


<div style="background:#FFFCB9;padding:10px">
<form name="pozovi" action="/pozivnica4.php" method="post" onsubmit="document.pozovi.dugmeizabro.disabled=true">
<p><B>E-mail: (klikni lijevo na provajder da promjeniš)</B></p>
<p><input type="text" name="username" id="username" class="in" value="@hotmail.com"></p>
<p><b>Password:</b></p>
<p><input type="password" name="password" id="password" class="in"> <img src="/slike/secure.gif"> Mi ne spamamo</p>
<p>
</p>
<p><input type="hidden" id="kojipoziv" name="kojipoziv" value="hotmail"><input type="submit" value="Vidi ko je od mojih prijatelja na vezicama" class="submitdugme2" onclick="submit.loginformababa()" id="dugmeizabro"></p>
</form>
</div>
<div class="help">
<h2>Proèitaj !</h2>
<b>Ne sekiraj se za privatnost!</b> Nakon što uneseš svoj username i password, te informacije neæe biti nigdje pohranjene niti æemo slati SPAM poruke/pozivnice svim tvojim kontaktima. Samo æe ti se prikazat lista svih tvojih kontakata koji su na derneku.


<span class="blog_naslov">
Ti si jedan od <strong><? echo number_format($membersa-30612); ?></strong> korisnika koji koristi ovu opciju. Ukoliko si i dalje skeptièan/na u vezi sa unošenjem svog passworda ovdje, slobodno ga prvo promjeni (Gmail password klikom na <a href="https://www.google.com/accounts/EditPasswd?service=mail&hl=en" target="_blank">ovaj link</a> ili tvoj msn hotmail password, klikom na <a href="https://accountservices.passport.net/?lc=1033" target="_blank">ovaj link</a>), te nakon korištenja ove opcije ponovo vratiti stari password ukoliko želiš. 

</span>
</div>
<br clear="all"/>
</div>

</div>
<?
}else{
?>
<?
if(!empty($prihvatio)){
// ne treba
}else{
?>

<div id="glavna">
<form name="formazapoziv" action="/pozovi.php" method="post">

<div id="prvakolona">
<div style="margin-left:20px"><h1>Moji <img src='/slike/<? echo $kojipoziv; ?>.gif'> prijatelji na furki</h1></div>
<div style="position:absolute;margin-left:493px;margin-top:10px;"><img src='/slike/arrow-veliki.gif'></div>
  <div class="" id="main">
  			<div id="my-contacts">
          <div id="address-book">
            <div id="contacts-index">
              <h2>Index</h2>
              <ol id="index-alpha" type="disc"><li><a href="#A">A</a></li><li><a href="#B">B</a></li><li><a href="#C">C</a></li><li><a href="#D">D</a></li><li><a href="#E">E</a></li><li><a href="#F">F</a></li><li><a href="#G">G</a></li><li><a href="#H">H</a></li><li><a href="#I">I</a></li><li><a href="#J">J</a></li><li><a href="#K">K</a></li><li><a href="#L">L</a></li><li><a href="#M">M</a></li><li><a href="#N">N</a></li><li><a href="#O">O</a></li><li><a href="#P">P</a></li><li><a href="#Q">Q</a></li><li><a href="#R">R</a></li><li><a href="#S">S</a></li><li><a href="#T">T</a></li><li><a href="#U">U</a></li><li><a href="#V">V</a></li><li><a href="#W">W</a></li><li><a href="#X">X</a></li><li><a href="#Y">Y</a></li><li><a href="#Z">Z</a></li><li><a href="#DRUGI">#</a></li></ol>
            </div>
            <div id="contacts-listing">
              <ol style="display: block;" id="listing-results">
			  <li class="initial-header">
	<?

// Gmail pozivnica

if($kojipoziv=="gmail"){

require_once("libgmailer2.php");

$gmail_acc = $_POST['username'];
$gmail_pwd = $_POST['password'];
$my_timezone = 0;
 
$gmailer = new GMailer();
if ($gmailer->created) {
$gmailer->setLoginInfo($gmail_acc, $gmail_pwd, $my_timezone);

//uncomment if you need it
//$gmailer->setProxy("proxy.company.com");

if ($gmailer->connect()) {
// GMailer connected to Gmail successfully.
// Do something with it.

//Get the contacts
// For "Inbox"

$gmailer->fetchBox(GM_CONTACT, "all", "");

$snapshot = $gmailer->getSnapshot(GM_CONTACT);



?>

 
<?
$brojkontakte=0;
$listadesno="";
for ($slovo=65;$slovo <=90; $slovo++)
{
echo '</ul></li><h2 id="'.strtoupper(chr($slovo)).'">'.strtoupper(chr($slovo)).'</h2><ul id="ltr_cont_'.strtoupper(chr($slovo)).'">';
foreach($snapshot->contacts as $contact){
if (strtoupper(chr($slovo)) == strtoupper($contact['name'][0])){
$imali=mysql_query("select id_member,avatar,username from members where msn='".$contact['email']."' or email='".$contact['email']."' limit 1");
if(mysql_num_rows($imali)!=0){
?>
<li id="dsa<? echo $brojkontakte; ?>" class="vcard"><div class="contact"><h3 class="fn"><? echo $contact['name']; ?></h3><a class="email" href="mailto:<? echo $contact['email']; ?>" title="<? echo $contact['email']; ?>"><? echo $contact['email']; ?></a></div>
<?
$listadesno=$listadesno.'<li id="li'.$brojkontakte.'" style="display:none"><a href="javascript:;" onclick="brisipoziv(\''.$brojkontakte.'\')">'.$contact['name'].' <u>'.$contact['email'].'</u></a></li>';
while ($imaliba = mysql_fetch_array($imali)) 
{
$result7=mysql_query("select id_za from buddy where id_od='$idba' and id_za='".$imaliba['id_member']."'",$db) or die ("ne meRe se selektovat");
if(mysql_num_rows($result7)!=0){
echo "<div ><a href='javascript:;' onmouseover=\"prikazimis('<strong>".$imaliba['username']."</strong> je veæ u listi prijatelja!');\" onmouseout='sakrijmis()'><img src='/slike/prijatelji.gif' border='0'></a></div>";
}
if($imaliba['avatar']!=""){
echo "<p class='title' style='font-size:12px;font-weight:bold;'><img src='/avatari/".$imaliba['avatar']."' width='25' height='25' border='0'> ".$imaliba['username']."</p>";
}else{
echo "<p class='title' style='font-size:12px;font-weight:bold;'>".$imaliba['username']."</p>";
}
}
$brojkontakte++;
?>
</li>
<?
}

}
}
}
echo '</ul></li><h2 id="DRUGI">#</h2><ul id="ltr_cont_DRUGI">';
foreach($snapshot->contacts as $contact){
if ( !( (ord(strtoupper($contact['name'][0]))>=65) && (ord(strtoupper($contact['name'][0]))<=90)) ){
$imali=mysql_query("select id_member,avatar,username from members where msn='".$contact['email']."' or email='".$contact['email']."' limit 1");
if(mysql_num_rows($imali)!=0){
?>
<li id="dsa<? echo $brojkontakte; ?>" class="vcard"><div class="contact"><h3 class="fn"><? echo $contact['name']; ?></h3><a class="email" href="mailto:<? echo $contact['email']; ?>" title="<? echo $contact['email']; ?>"><? echo $contact['email']; ?></a></div>
<?
$listadesno=$listadesno.'<li id="li'.$brojkontakte.'" style="display:none"><a href="javascript:;" onclick="brisipoziv(\''.$brojkontakte.'\')">'.$contact['name'].' <u>'.$contact['email'].'</u></a></li>';
while ($imaliba = mysql_fetch_array($imali)) 
{
$result7=mysql_query("select id_za from buddy where id_od='$idba' and id_za='".$imaliba['id_member']."'",$db) or die ("ne meRe se selektovat");
if(mysql_num_rows($result7)!=0){
echo "<div ><a href='javascript:;' onmouseover=\"prikazimis('<strong>".$imaliba['username']."</strong> je veæ u listi prijatelja!');\" onmouseout='sakrijmis()'><img src='/slike/prijatelji.gif' border='0'></a></div>";
}
if($imaliba['avatar']!=""){
echo "<p class='title' style='font-size:12px;font-weight:bold;'><img src='/avatari/".$imaliba['avatar']."' width='25' height='25' border='0'> ".$imaliba['username']."</p>";
}else{
echo "<p class='title' style='font-size:12px;font-weight:bold;'>".$imaliba['username']."</p>";
}
}
$brojkontakte++;
?>
</li>
<?
}

}
}
?>

<?
} else {
echo("<h6>Konekcija nije uspjela: ".$gmailer->lastActionStatus()."</h6>");
}
} else {
echo("<h6>Konekcija nije uspjela: ".$gmailer->lastActionStatus()."</h6>");
}

// Hotmail msn pozivnica

	}elseif($kojipoziv=="hotmail"){
set_time_limit ( 0 );
if(empty($_POST['username']) || empty($_POST['password']))
{
exit("<h6>Netacan username i password</h6>");
}
elseif(!empty($_POST['username']) && !empty($_POST['password']))
{
include('msn.class.php');

    $msn = new msn;

 $returned_emails = $msn->qGrab($_POST['username'], $_POST['password']);
 
foreach($returned_emails as $contact)
    {
$contact['email'];
$contact['name'];

}
}

$brojkontakte=0;
$listadesno="";
$varij=explode("^",$varijabla);

for ($slovo=65;$slovo <=90; $slovo++)
{
echo '</ul></li><h2 id="'.strtoupper(chr($slovo)).'">'.strtoupper(chr($slovo)).'</h2><ul id="ltr_cont_'.strtoupper(chr($slovo)).'">';
foreach($varij as $zvao){
$zvv=explode("|",$zvao);
$contact['name']=$zvv[0];
$contact['email']=$zvv[1];
if($contact['email']!=""){
if (strtoupper(chr($slovo)) == strtoupper($contact['name'][0])){
	$imali=mysql_query("select id_member,avatar,username from members where msn='".$contact['email']."' or email='".$contact['email']."' limit 1");
if(mysql_num_rows($imali)!=0){
?>
<li id="dsa<? echo $brojkontakte; ?>" class="vcard"><div class="contact"><h3 class="fn"><? echo $contact['name']; ?></h3><a class="email" href="mailto:<? echo $contact['email']; ?>" title="<? echo $contact['email']; ?>"><? echo $contact['email']; ?></a></div>
<?
$listadesno=$listadesno.'<li id="li'.$brojkontakte.'" style="display:none"><a href="javascript:;" onclick="brisipoziv(\''.$brojkontakte.'\')">'.$contact['name'].' <u>'.$contact['email'].'</u></a></li>';

while ($imaliba = mysql_fetch_array($imali)) 
{
$result7=mysql_query("select id_za from buddy where id_od='$idba' and id_za='".$imaliba['id_member']."'",$db) or die ("ne meRe se selektovat");
if(mysql_num_rows($result7)!=0){
echo "<div ><a href='javascript:;' onmouseover=\"prikazimis('<strong>".$imaliba['username']."</strong> je veæ u listi prijatelja!');\" onmouseout='sakrijmis()'><img src='/slike/prijatelji.gif' border='0'></a></div>";
}
if($imaliba['avatar']!=""){
echo "<p class='title' style='font-size:12px;font-weight:bold;'><img src='/avatari/".$imaliba['avatar']."' width='25' height='25' border='0'> ".$imaliba['username']."</p>";
}else{
echo "<p class='title' style='font-size:12px;font-weight:bold;'>".$imaliba['username']."</p>";
}
}
$brojkontakte++;
?>
</li>
<?
}

}
}
}
}

echo '</ul></li><h2 id="DRUGI">#</h2><ul id="ltr_cont_DRUGI">';
foreach($varij as $zvao){
$zvv=explode("|",$zvao);
$contact['name']=$zvv[0];
$contact['email']=$zvv[1];
if($contact['email']!=""){
if ( !( (ord(strtoupper($contact['name'][0]))>=65) && (ord(strtoupper($contact['name'][0]))<=90)) ){
$imali=mysql_query("select id_member,avatar,username from members where msn='".$contact['email']."' or email='".$contact['email']."' limit 1");
if(mysql_num_rows($imali)!=0){
?>
<li id="dsa<? echo $brojkontakte; ?>" class="vcard"><div class="contact"><h3 class="fn"><? echo $contact['name']; ?></h3><a class="email" href="mailto:<? echo $contact['email']; ?>" title="<? echo $contact['email']; ?>"><? echo $contact['email']; ?></a></div>
<?
$listadesno=$listadesno.'<li id="li'.$brojkontakte.'" style="display:none"><a href="javascript:;" onclick="brisipoziv(\''.$brojkontakte.'\')">'.$contact['name'].' <u>'.$contact['email'].'</u></a></li>';

while ($imaliba = mysql_fetch_array($imali)) 
{
$result7=mysql_query("select id_za from buddy where id_od='$idba' and id_za='".$imaliba['id_member']."'",$db) or die ("ne meRe se selektovat");
if(mysql_num_rows($result7)!=0){
echo "<div ><a href='javascript:;' onmouseover=\"prikazimis('<strong>".$imaliba['username']."</strong> je veæ u listi prijatelja!');\" onmouseout='sakrijmis()'><img src='/slike/prijatelji.gif' border='0'></a></div>";
}
if($imaliba['avatar']!=""){
echo "<p class='title' style='font-size:12px;font-weight:bold;'><img src='/avatari/".$imaliba['avatar']."' width='25' height='25' border='0'> ".$imaliba['username']."</p>";
}else{
echo "<p class='title' style='font-size:12px;font-weight:bold;'>".$imaliba['username']."</p>";
}
}
$brojkontakte++;
?>
</li>
<?
}

}
}
}



}elseif($kojipoziv=="dodatno"){


if($_POST['gender']=="male"){
$dodatak="and gender='female'";
}else{
$dodatak="and gender='male'";
}

if($_POST['grad']!=""){
$dodatak.="and grad='".$_POST['grad']."'";
}

$resultba55=mysql_query("SELECT * FROM members where avatar!='' $dodatak and banovan<>'1' order by last_login desc limit 300",$db) or die (mysql_error());
if(mysql_num_rows($resultba55)==0){ echo "<h3>Nema rezultata</h3>"; }

while ($rowba55=mysql_fetch_array($resultba55)) {
$avatar_za=$rowba55["avatar"];
$username_za=$rowba55["username"];
$gender_za=$rowba55["gender"];
$status_za=$rowba55["status"];

$popularnost_za=$rowba55["popularnost_final"];


$finalniprocenat=$popularnost_za;


if($finalniprocenat<0){
$finalniprocenat=0;
}

if($finalniprocenat>48){
$finalniprocenat=48;
}


?>
<span class="friendz"><a href="javascript:alert('Registruj se da vidiš profil od ove osobe :)');" onMouseover="prikazimis('<img src=\'/avatariveliki/<? echo $avatar_za; ?>?a=<? echo time(); ?>\'>',200);" onmouseout="sakrijmis();" onclick="sakrijmis();"><? if($avatar_za!=""){?><img src="/avatari/<? echo $avatar_za; ?>" width="50" height="50" border="0"><?}else{?><img src="/avatari/noavatar.jpg" width="50" height="50" border="0"><?}?><div class="<? if($status_za=="admin"){ echo "popularnost_admin"; }elseif($status_za=="moderator"){ echo "popularnost_moderator"; }elseif(($status_za=="vip")or($status_za=="premium")){ echo "popularnost_vip"; }else{ echo"popularnost"; } ?>"><div class="<? if($status_za=="admin"){ echo "popularnostpostotak_admin"; }elseif($status_za=="moderator"){ echo "popularnostpostotak_moderator"; }elseif(($status_za=="vip")or($status_za=="premium")){ echo "popularnostpostotak_vip"; }else{ echo"popularnostpostotak"; } ?>" style="width:<? echo $finalniprocenat; ?>px"></div></div><div><? echo $username_za ; ?></div></a></span>
<?
}

	}
	?>
			  </ol>
            </div>
            <div class="info">
              <p id="visible-contacts">Prikazano <strong id="count-total"><? echo $brojkontakte; ?></strong> kontakata.</p>
            </div>
 
          </div>      




        </div>      




    </div>

<br clear="all">






</div>
<div id="sporedna">
<?
if($kojipoziv!="dodatno"){
?>
<div class="help">
<?
if(($brojkontakte>0)and($brojkontakte<5)){
?>

<h2>Slabo :(</h2>
Nema puno tvojih <strong><? echo $kojipoziv; ?></strong> prijatelja na furki.




<span style="font-size:12">
A da nam kažeš nešto o sebi ? sigurno ima neko zanimljiv :)





<form action="/kojetu" method="post">
<input type="hidden" value="dodatno" name="kojipoziv">
Ja sam <SELECT class="in" style="width:100px" name="gender" id="gender"><option value="male">Musko</option><option value="female">Zensko</option></SELECT> iz <select name="grad" class="in" style="width:100px" id="grad"><option value="">Odakle si ? </option>
<?
$gradovi=mysql_query("select * from grad",$db) or die (mysql_error());
while ($gradoviba = mysql_fetch_array($gradovi)) { 
?>
<option value="<? echo $gradoviba['grad']; ?>"><? echo $gradoviba['grad']; ?></option>
<?
}
?>
<option value="drugi">Drugi</option>
</select>


</span>
</p>


<p>
<INPUT TYPE="submit" value=" Pogledaj! " class="btn">
</p>
</form>


<?
}elseif($brojkontakte>5){
?>
<h2><strong id="count-total"><? echo $brojkontakte; ?></strong> tvojih prijatlja i prijateljica je na furki!</h2>
Uèlani se na najveæu društvenu mrežu u BiH!






<div class="dugme"><a href="/?ref=rrr">Klikni ovdje za registraciju</a></div>
<?
}else{
?>
<h2>Nemaaa :(</h2>
Nema niko od tvojih <strong><? echo $kojipoziv; ?></strong> prijatelja na furki.




<span style="font-size:12">
A da nam kažeš nešto o sebi ? sigurno ima neko zanimljiv :)





<form action="/kojetu" method="post">
<input type="hidden" value="dodatno" name="kojipoziv">
Ja sam <SELECT class="in" style="width:100px" name="gender" id="gender"><option value="male">Musko</option><option value="female">Zensko</option></SELECT> iz <select name="grad" class="in" style="width:100px" id="grad"><option value="">Odakle si ? </option>
<?
$gradovi=mysql_query("select * from grad",$db) or die (mysql_error());
while ($gradoviba = mysql_fetch_array($gradovi)) { 
?>
<option value="<? echo $gradoviba['grad']; ?>"><? echo $gradoviba['grad']; ?></option>
<?
}
?>
<option value="drugi">Drugi</option>
</select>


</span>
</p>


<p>
<INPUT TYPE="submit" value=" Pogledaj! " class="btn">
</p>
</form>



<?
}
?>
</div>
<?
}else{
?>
<div class="help">
<h2>Pronašli smo <strong id="count-total"><? echo rand(500,20000); ?></strong> aktivnih osoba iz tvog grada!</h2>
Lijevo imaš neke od njih. Uèlani se na najveæu društvenu mrežu u BiH!






<div class="dugme"><a href="/?ref=rrr">Klikni ovdje za registraciju</a></div>
</div>
<?
}
?>
<br clear="all"/>
</div>

</div>
<?
}
}
?>

Na hostingu :

Could not connect to messenger service

Na xampu
Error “Error code not found”

msn_class.php

<?php
/*
Copyright 2007 Jonathan Street jonathan@torrentialwebdev.com

This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

/*
This class connects to the MSNM service and returns
all the email addresses and screen names in the contact
list of the supplied user.

This is a derivation of a more general purpose php class
available at http://flumpcakes.co.uk/php/msn-messenger.

Unlike the more general purpose class, which can handle 
sending and receiving messages, this class solely connects 
and the retrieves the contact list.

USAGE
=====

There are two ways of calling the class.

Verbose
-------
Calling each of the functions involved seperately and 
then getting the emails from a variable in the class

include('msn_contact_grab.class.php');
$msn = new msn;
$msn->connect('username', 'password');
$msn->rx_data();
$msn->process_emails();
$returned_emails = $msn->email_output;

Quick
-----
Handling everything in just one function

include('msn_contact_grab.class.php');
$msn2 = new msn;
$returned_emails = $msn2->qGrab("username", "password");
 

*/

class msn
{
    // messenger.hotmail.com is an exchange server
    // using it will redirect to a server with an open slot
    // using a known server ip will help connect faster

    // commenting out $ssh_login will mean the url to the
    // secure login server will be taken from a secure
    // session.  this will slow down connecting a bit.
    // Note: comment out $ssh_login if you experience auth failures

    var $server    =    'messenger.hotmail.com';
    var $port    =    1863;

    var $nexus    =    'https://nexus.passport.com/rdr/pprdr.asp';
    var $ssh_login    =    'login.live.com/login2.srf';

    var $debug    =    1;


    // curl is used for the secure login, if you don't have
    // the php_curl library installed, you can use a curl binary
    // instead. $use_curl needs to be set to 1 to enable this.
    // set $curl to the path where curl is installed.
    // curl can be downloaded here: http://curl.haxx.se/download.html

    var $curl_bin    =    0;
    var $curl    =    '/usr/local/bin/curl';    // linux
    //var $curl    =    'c:\curl.exe';        // windows

    //Used to prevent the script from hanging
    var $count = 0;
  
    //Used to store the email addresses until all have been collected
    var $email_input = array();
    var $email_processing = array();
    var $email_output = array();

    /**
     *
     * desc    :    Connect to MSN Messenger Network
     *
     * in    :    $passport    =    passport i.e: user@hotmail.com
     *        $password    =    password for passport
     *
     * out    :    true on success else return false
     *
     */

    function connect($passport, $password)
    {
        $this->trID = 1;

        if (!$this->fp = @fsockopen($this->server, $this->port, $errno, $errstr, 2)) {
          
            die("Could not connect to messenger service");
      
        } else {
              stream_set_timeout($this->fp, 2);
            
            $this->_put("VER $this->trID MSNP9 CVR0\r\n");

            while (! feof($this->fp))
            {
                $data = $this->_get();

                switch ($code = substr($data, 0, 3))
                {
                    default:
                        echo $this->_get_error($code);

                        return false;
                    break;
                    case 'VER':
                        $this->_put("CVR $this->trID 0x0409 win 4.10 i386 MSNMSGR 7.0.0816 MSMSGS $passport\r\n");
                    break;
                    case 'CVR':
                        $this->_put("USR $this->trID TWN I $passport\r\n");
                    break;
                    case 'XFR':
                        list(, , , $ip)  = explode (' ', $data);
                        list($ip, $port) = explode (':', $ip);

                        if ($this->fp = @fsockopen($ip, $port, $errno, $errstr, 2))
                        {
                            $this->trID = 1;

                            $this->_put("VER $this->trID MSNP9 CVR0\r\n");
                        }
                        else
                        {
                            if (! empty($this->debug)) echo 'Unable to connect to msn server (transfer)';

                            return false;
                        }
                    break;
                    case 'USR':
                        if (isset($this->authed))
                        {
                            return true;
                        }
                        else
                        {
                            $this->passport = $passport;
                            $this->password = urlencode($password);

                            list(,,,, $code) = explode(' ', trim($data));

                            if ($auth = $this->_ssl_auth($code))
                            {
                                $this->_put("USR $this->trID TWN S $auth\r\n");

                                $this->authed = 1;
                            }
                            else
                            {
                                if (! empty($this->debug)) echo 'auth failed';

                                return false;
                            }
                        }
                    break;
                }
            }
        }
      
    }

    //Collects the raw data containing the email addresses
    function rx_data()
    {
        $this->_put("SYN $this->trID 0\r\n");
      
        //Supplies the second MSG code which stops
        //the script from hanging as it waits for
        //more content
        $this->_put("CHG $this->trID NLN\r\n");
      
        $stream_info = stream_get_meta_data($this->fp);
        $email_total = 100;
        //the count check prevents the script hanging as it waits for more content
        while ((! feof($this->fp)) && (! $stream_info['timed_out']) && ($this->count <= 1) && (count($this->email_input) < $email_total))
        {
            $data = $this->_get();
            $stream_info = stream_get_meta_data($this->fp);
          
            if ($data)
            {
              
                switch($code = substr($data, 0, 3))
                {
                    default:
                        // uncommenting this line here would probably give a load of "error code not found" messages.
                        //echo $this->_get_error($code);
                    break;
                    case 'MSG':
                       //This prevents the script hanging as it waits for more content
                       $this->count++;
                    break;
                    case 'LST':
                       //These are the email addresses
                       //They need to be collected in email_input
                     
                       $this->email_input[] = $data;
                       if ($this->debug) print("<span class='b'>" . count($this->email_input) . "</span>");
                     
                    break;
                    case 'SYN':
                    $syn_explode = explode(" ", $data);
                    $email_total = $syn_explode[3];
                    break;
                    case 'CHL':
                        $bits = explode (' ', trim($data));

                        $return = md5($bits[2].'Q1P7W2E4J9R8U3S5');
                        $this->_put("QRY $this->trID msmsgs@msnmsgr.com 32\r\n$return");
                    break;
                  
                }
            }
        }
      
    }
  
    //This function extracts the emails and screen names from the raw data 
    //collected by rx_data
    function process_emails () {
    
      //Neaten up the emails
    
      //$regex = "|^LST\s(\S+?)\s(\S+?)\s\d+?\s\d+?$|";
      foreach($this->email_input as $email_entry) {
      
        //Seperate out the email from the name and other data
        $this->email_processing[] = explode(" ", $email_entry);
                      
      }
    
      //Get rid of the unnecessary data and clean up the name
      foreach($this->email_processing as $email_entry){
      
        $this->email_output[] = array(0 => $email_entry['1'],
                                        1 => urldecode($email_entry[2]));
    }
  
    //var_dump($this->email_processing);
    //var_dump($this->email_output);
    
    
    
  }

    //This is a quick way of calling all the seperate functions
    //needed to grab the contact list
    function qGrab ($username, $password) {
    
      //Connect to the MSNM service
      $this->connect($username, $password);
    
      //Get data
      $this->rx_data();
    
      //Process emails
      $this->process_emails();
    
      //send the email array
      return $this->email_output;
    
    
    }


    /*====================================*\
        Various private functions
    \*====================================*/

    function _ssl_auth($auth_string)
    {
        if (empty($this->ssh_login))
        {
            if ($this->curl_bin)
            {
                exec("$this->curl -m 60 -LkI $this->nexus", $header);
                $header = implode($header, null);
            }
            else
            {
                $ch = curl_init($this->nexus);

                curl_setopt($ch, CURLOPT_HEADER, 1);
                curl_setopt($ch, CURLOPT_NOBODY, 1);
                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                // curl_setopt($ch, CURLOPT_TIMEOUT, 2);

                $header = curl_exec($ch);

                curl_close($ch);
            }

            preg_match ('/DALogin=(.*?),/', $header, $out);

            if (isset($out[1]))
            {
                $slogin = $out[1];
            }
            else
            {
                return false;
            }
        }
        else
        {
            $slogin = $this->ssh_login;
        }


        if ($this->curl_bin)
        {
            $header1 = '"Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in='.$this->passport.',pwd='.$this->password.','.$auth_string.'"';

            exec("$this->curl -m 60 -LkI -H $header1 https://$slogin", $auth_string);

            $header = null;

            foreach ($auth_string as $key => $value)
            {
                if (strstr($value, 'Unauthorized'))
                {
                    echo 'Unauthorised';
                    return false;
                }
                elseif (strstr($value, 'Authentication-Info'))
                {
                    $header = $value;
                }
            }
        }
        else
        {
            $ch = curl_init('https://'.$slogin);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                            'Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in='.$this->passport.',pwd='.$this->password.','.$auth_string,
                            'Host: login.passport.com'
                            ));

            curl_setopt($ch, CURLOPT_HEADER, 1);
            curl_setopt($ch, CURLOPT_NOBODY, 1);
            //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            // curl_setopt($ch, CURLOPT_TIMEOUT, 2);

            $header = curl_exec($ch);

            curl_close($ch);
        }

        preg_match ("/from-PP='(.*?)'/", $header, $out);

        return (isset($out[1])) ? $out[1] : false;
    }


    function _get()
    {
        if ($data = @fgets($this->fp, 4096))
        {
            
        
            if ($this->debug) echo "<div class=\"r\"><<< $data</div>\n";

            return $data;
        }
        else
        {
            return false;
        }
    }


    function _put($data)
    {
        fwrite($this->fp, $data);

        $this->trID++;

        if ($this->debug) echo "<div class=\"g\">>>> $data</div>";
    }


    function _get_error($code)
    {
        switch ($code)
        {
            case 201:
                return 'Error: 201 Invalid parameter';
            break;
            case 217:
                return 'Error: 217 Principal not on-line';
            break;
            case 500:
                return 'Error: 500 Internal server error';
            break;
            case 540:
                return 'Error: 540 Challenge response failed';
            break;
            case 601:
                return 'Error: 601 Server is unavailable';
            break;
            case 710:
                return 'Error: 710 Bad CVR parameters sent';
            break;
            case 713:
                return 'Error: 713 Calling too rapidly';
            break;
            case 731:
                return 'Error: 731 Not expected';
            break;
            case 800:
                return 'Error: 800 Changing too rapidly';
            break;
            case 910:
            case 921:
                return 'Error: 910/921 Server too busy';
            break;
            case 911:
                return 'Error: 911 Authentication failed';
            break;
            case 923:
                return 'Error: 923 Kids Passport without parental consent';
            break;
            case 928:
                return 'Error: 928 Bad ticket';
            break;
            default:
                return 'Error code '.$code.' not found';
            break;
        }
    }
}
?> 

Copyright © 2020 WM Forum - AboutContact - Sponsored by: Mydataknox & Webmaster.Ninja