- \r
- $data = $this->ns_readln();\r
- if($data === false) {\r
- // There was no data / an error when reading from the socket so reconnect\r
- $this->callHandler('Reconnect', NULL);\r
- $this->signon();\r
- } else {\r
- switch (substr($data,0,3))\r
- {\r
- case 'SBS':\r
- // after 'USR {id} OK {user} {verify} 0' response, the server will send SBS and profile to us\r
- // NS: <<< SBS 0 null\r
- break;\r
- \r
- case 'RFS':\r
- // FIXME:\r
- // NS: <<< RFS ???\r
- // refresh ADL, so we re-send it again\r
- if (is_array($this->aADL)) {\r
- foreach ($this->aADL as $str) {\r
- $len = strlen($str);\r
- // NS: >>> ADL {id} {size}\r
- $this->ns_writeln("ADL $this->id $len");\r
- $this->ns_writedata($str);\r
- }\r
- }\r
- break;\r
- \r
- case 'LST':\r
- // NS: <<< LST {email} {alias} 11 0\r
- @list(/* LST */, $email, /* alias */, ) = @explode(' ', $data);\r
- @list($u_name, $u_domain) = @explode('@', $email);\r
- if (!isset($this->aContactList[$u_domain][$u_name][1])) {\r
- $this->aContactList[$u_domain][$u_name][1]['Allow'] = 'Allow';\r
- $this->log_message("*** add to our contact list: $u_name@$u_domain");\r
- }\r
- break;\r
- \r
- case 'ADL':\r
- // randomly, we get ADL command, someome add us to their contact list for MSNP15\r
- // NS: <<< ADL 0 {size}\r
- @list(/* ADL */, /* 0 */, $size,) = @explode(' ', $data);\r
- if (is_numeric($size) && $size > 0)\r
- {\r
- $data = $this->ns_readdata($size);\r
- preg_match('#<ml><d n="([^"]+)"><c n="([^"]+)"(.*) t="(\d*)"(.*) /></d></ml>#', $data, $matches);\r
- if (is_array($matches) && count($matches) > 0)\r
- {\r
- $u_domain = $matches[1];\r
- $u_name = $matches[2];\r
- $network = $matches[4];\r
- if (isset($this->aContactList[$u_domain][$u_name][$network]))\r
- $this->log_message("*** someone (network: $network) add us to their list (but already in our list): $u_name@$u_domain");\r
- else\r
- {\r
- $re_login = false;\r
- $cnt = 0;\r
- foreach (array('Allow', 'Reverse') as $list)\r
- {\r
- if (!$this->addMemberToList($u_name.'@'.$u_domain, $network, $list))\r
- {\r
- if ($re_login) {\r
- $this->log_message("*** can't add $u_name@$u_domain (network: $network) to $list");\r
- continue;\r
- }\r
- $aTickets = $this->get_passport_ticket();\r
- if (!$aTickets || !is_array($aTickets)) {\r
- // failed to login? ignore it\r
- $this->log_message("*** can't re-login, something wrong here");\r
- $this->log_message("*** can't add $u_name@$u_domain (network: $network) to $list");\r
- continue;\r
- }\r
- $re_login = true;\r
- $this->ticket = $aTickets;\r
- $this->log_message("**** get new ticket, try it again");\r
- if (!$this->addMemberToList($u_name.'@'.$u_domain, $network, $list))\r
- {\r
- $this->log_message("*** can't add $u_name@$u_domain (network: $network) to $list");\r
- continue;\r
- }\r
- }\r
- $this->aContactList[$u_domain][$u_name][$network][$list] = false;\r
- $cnt++;\r
- }\r
- $this->log_message("*** someone (network: $network) add us to their list: $u_name@$u_domain");\r
- }\r
- $str = '<ml l="1"><d n="'.$u_domain.'"><c n="'.$u_name.'" l="3" t="'.$network.'" /></d></ml>';\r
- $len = strlen($str);\r
- }\r
- else\r
- $this->log_message("*** someone add us to their list: $data");\r
- $this->AddUsToMemberList($u_name.'@'.$u_domain, $network);\r
- }\r
- break;\r
- \r
- case 'RML':\r
- // randomly, we get RML command, someome remove us to their contact list for MSNP15\r
- // NS: <<< RML 0 {size}\r
- @list(/* RML */, /* 0 */, $size,) = @explode(' ', $data);\r
- if (is_numeric($size) && $size > 0)\r
- {\r
- $data = $this->ns_readdata($size);\r
- preg_match('#<ml><d n="([^"]+)"><c n="([^"]+)"(.*) t="(\d*)"(.*) /></d></ml>#', $data, $matches);\r
- if (is_array($matches) && count($matches) > 0)\r
- {\r
- $u_domain = $matches[1];\r
- $u_name = $matches[2];\r
- $network = $matches[4];\r
- if (isset($this->aContactList[$u_domain][$u_name][$network]))\r
- {\r
- $aData = $this->aContactList[$u_domain][$u_name][$network];\r
- foreach ($aData as $list => $id)\r
- $this->delMemberFromList($id, $u_name.'@'.$u_domain, $network, $list);\r
- unset($this->aContactList[$u_domain][$u_name][$network]);\r
- $this->log_message("*** someone (network: $network) remove us from their list: $u_name@$u_domain");\r
- }\r
- else\r
- $this->log_message("*** someone (network: $network) remove us from their list (but not in our list): $u_name@$u_domain");\r
- $this->RemoveUsFromMemberList($u_name.'@'.$u_domain, $network);\r
- }\r
- else\r
- $this->log_message("*** someone remove us from their list: $data");\r
- }\r
- break;\r
- \r
- case 'MSG':\r
- // randomly, we get MSG notification from server\r
- // NS: <<< MSG Hotmail Hotmail {size}\r
- @list(/* MSG */, /* Hotmail */, /* Hotmail */, $size,) = @explode(' ', $data);\r
- if (is_numeric($size) && $size > 0) {\r
- $data = $this->ns_readdata($size);\r
- $aLines = @explode("\n", $data);\r
- $header = true;\r
- $ignore = false;\r
- $maildata = '';\r
- foreach ($aLines as $line) {\r
- $line = rtrim($line);\r
- if ($header) {\r
- if ($line === '') {\r
- $header = false;\r
- continue;\r
- }\r
- if (strncasecmp($line, 'Content-Type:', 13) == 0) {\r
- if (strpos($line, 'text/x-msmsgsinitialmdatanotification') === false &&\r
- strpos($line, 'text/x-msmsgsoimnotification') === false) {\r
- // we just need text/x-msmsgsinitialmdatanotification\r
- // or text/x-msmsgsoimnotification\r
- $ignore = true;\r
- break;\r
- }\r
- }\r
- continue;\r
- }\r
- if (strncasecmp($line, 'Mail-Data:', 10) == 0) {\r
- $maildata = trim(substr($line, 10));\r
- break;\r
- }\r
- }\r
- if ($ignore) {\r
- $this->log_message("*** ingnore MSG for: $line");\r
- break;\r
- }\r
- if ($maildata == '') {\r
- $this->log_message("*** ingnore MSG not for OIM");\r
- break;\r
- }\r
- $re_login = false;\r
- if (strcasecmp($maildata, 'too-large') == 0) {\r
- $this->log_message("*** large mail-data, need to get the data via SOAP");\r
- $maildata = $this->getOIM_maildata();\r
- if ($maildata === false) {\r
- $this->log_message("*** can't get mail-data via SOAP");\r
- // maybe we need to re-login again\r
- $aTickets = $this->get_passport_ticket();\r
- if (!$aTickets || !is_array($aTickets)) {\r
- // failed to login? ignore it\r
- $this->log_message("*** can't re-login, something wrong here, ignore this OIM");\r
- break;\r
- }\r
- $re_login = true;\r
- $this->ticket = $aTickets;\r
- $this->log_message("**** get new ticket, try it again");\r
- $maildata = $this->getOIM_maildata();\r
- if ($maildata === false) {\r
- $this->log_message("*** can't get mail-data via SOAP, and we already re-login again, so ignore this OIM");\r
- break;\r
- }\r
- }\r
- }\r
- // could be a lots of <M>...</M>, so we can't use preg_match here\r
- $p = $maildata;\r
- $aOIMs = array();\r
- while (1) {\r
- $start = strpos($p, '<M>');\r
- $end = strpos($p, '</M>');\r
- if ($start === false || $end === false || $start > $end) break;\r
- $end += 4;\r
- $sOIM = substr($p, $start, $end - $start);\r
- $aOIMs[] = $sOIM;\r
- $p = substr($p, $end);\r
- }\r
- if (count($aOIMs) == 0) {\r
- $this->log_message("*** ingnore empty OIM");\r
- break;\r
- }\r
- foreach ($aOIMs as $maildata) {\r
- // T: 11 for MSN, 13 for Yahoo\r
- // S: 6 for MSN, 7 for Yahoo\r
- // RT: the datetime received by server\r
- // RS: already read or not\r
- // SZ: size of message\r
- // E: sender\r
- // I: msgid\r
- // F: always 00000000-0000-0000-0000-000000000009\r
- // N: sender alias\r
- preg_match('#<T>(.*)</T>#', $maildata, $matches);\r
- if (count($matches) == 0) {\r
- $this->log_message("*** ingnore OIM maildata without <T>type</T>");\r
- continue;\r
- }\r
- $oim_type = $matches[1];\r
- if ($oim_type = 13)\r
- $network = 32;\r
- else\r
- $network = 1;\r
- preg_match('#<E>(.*)</E>#', $maildata, $matches);\r
- if (count($matches) == 0) {\r
- $this->log_message("*** ingnore OIM maildata without <E>sender</E>");\r
- continue;\r
- }\r
- $oim_sender = $matches[1];\r
- preg_match('#<I>(.*)</I>#', $maildata, $matches);\r
- if (count($matches) == 0) {\r
- $this->log_message("*** ingnore OIM maildata without <I>msgid</I>");\r
- continue;\r
- }\r
- $oim_msgid = $matches[1];\r
- preg_match('#<SZ>(.*)</SZ>#', $maildata, $matches);\r
- $oim_size = (count($matches) == 0) ? 0 : $matches[1];\r
- preg_match('#<RT>(.*)</RT>#', $maildata, $matches);\r
- $oim_time = (count($matches) == 0) ? 0 : $matches[1];\r
- $this->log_message("*** You've OIM sent by $oim_sender, Time: $oim_time, MSGID: $oim_msgid, size: $oim_size");\r
- $sMsg = $this->getOIM_message($oim_msgid);\r
- if ($sMsg === false) {\r
- $this->log_message("*** can't get OIM, msgid = $oim_msgid");\r
- if ($re_login) {\r
- $this->log_message("*** can't get OIM via SOAP, and we already re-login again, so ignore this OIM");\r
- continue;\r
- }\r
- $aTickets = $this->get_passport_ticket();\r
- if (!$aTickets || !is_array($aTickets)) {\r
- // failed to login? ignore it\r
- $this->log_message("*** can't re-login, something wrong here, ignore this OIM");\r
- continue;\r
- }\r
- $re_login = true;\r
- $this->ticket = $aTickets;\r
- $this->log_message("**** get new ticket, try it again");\r
- $sMsg = $this->getOIM_message($oim_msgid);\r
- if ($sMsg === false) {\r
- $this->log_message("*** can't get OIM via SOAP, and we already re-login again, so ignore this OIM");\r
- continue;\r
- }\r
- }\r
- $this->log_message("*** MSG (Offline) from $oim_sender (network: $network): $sMsg");\r
- \r
- //$this->ReceivedMessage($oim_sender,$sMsg,$network,true);\r
- $this->callHandler('IMin', array('sender' => $oim_sender, 'message' => $sMsg, 'network' => $network, 'offline' => true));\r
- }\r
- }\r
- break;\r
- \r
- case 'UBM':\r
- // randomly, we get UBM, this is the message from other network, like Yahoo!\r
- // NS: <<< UBM {email} $network $type {size}\r
- @list(/* UBM */, $from_email, $network, $type, $size,) = @explode(' ', $data);\r
- if (is_numeric($size) && $size > 0)\r
- {\r
- $data = $this->ns_readdata($size);\r
- $aLines = @explode("\n", $data);\r
- $header = true;\r
- $ignore = false;\r
- $sMsg = '';\r
- foreach ($aLines as $line) {\r
- $line = rtrim($line);\r
- if ($header) {\r
- if ($line === '') {\r
- $header = false;\r
- continue;\r
- }\r
- if (strncasecmp($line, 'TypingUser:', 11) == 0) {\r
- $ignore = true;\r
- break;\r
- }\r
- continue;\r
- }\r
- $aSubLines = @explode("\r", $line);\r
- foreach ($aSubLines as $str) {\r
- if ($sMsg !== '')\r
- $sMsg .= "\n";\r
- $sMsg .= $str;\r
- }\r
- }\r
- if($ignore)\r
- {\r
- $this->log_message("*** ingnore from $from_email: $line");\r
- break;\r
- }\r
- $this->log_message("*** MSG from $from_email (network: $network): $sMsg");\r
- //$this->ReceivedMessage($from_email,$sMsg,$network,false);\r
- $this->callHandler('IMin', array('sender' => $from_email, 'message' => $sMsg, 'network' => $network, 'offline' => false));\r
- }\r
- break;\r
- \r
- case 'UBX':\r
- // randomly, we get UBX notification from server\r
- // NS: <<< UBX email {network} {size}\r
- @list(/* UBX */, /* email */, /* network */, $size,) = @explode(' ', $data);\r
- // we don't need the notification data, so just ignore it\r
- if (is_numeric($size) && $size > 0)\r
- $this->ns_readdata($size);\r
- break;\r
- \r
- case 'CHL':\r
- // randomly, we'll get challenge from server\r
- // NS: <<< CHL 0 {code}\r
- @list(/* CHL */, /* 0 */, $chl_code,) = @explode(' ', $data);\r
- $fingerprint = $this->getChallenge($chl_code);\r
- // NS: >>> QRY {id} {product_id} 32\r
- // NS: >>> fingerprint\r
- $this->ns_writeln("QRY $this->id $this->prod_id 32");\r
- $this->ns_writedata($fingerprint);\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid"); \r
- if($this->PhotoStickerFile!==false)\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
- break;\r
- case 'CHG':\r
- // NS: <<< CHG {id} {status} {code}\r
- // ignore it\r
- // change our status to online first\r
- break;\r
- \r
- case 'XFR':\r
- // sometimes, NS will redirect to another NS\r
- // MSNP9\r
- // NS: <<< XFR {id} NS {server} 0 {server}\r
- // MSNP15\r
- // NS: <<< XFR {id} NS {server} U D\r
- // for normal switchboard XFR\r
- // NS: <<< XFR {id} SB {server} CKI {cki} U messenger.msn.com 0\r
- @list(/* XFR */, /* {id} */, $server_type, $server, /* CKI */, $cki_code, /* ... */) = @explode(' ', $data);\r
- @list($ip, $port) = @explode(':', $server);\r
- if ($server_type != 'SB') {\r
- // maybe exit?\r
- // this connection will close after XFR\r
- $this->NSLogout();\r
- continue;\r
- }\r
- if(count($this->MessageQueue))\r
- {\r
- foreach($this->MessageQueue as $User => $Message)\r
- {\r
- //$this->ChildProcess[$ChildPid]\r
- $this->log_message("*** XFR SB $User");\r
- $pid=pcntl_fork();\r
- if($pid)\r
- {\r
- //Parrent Process\r
- $this->ChildProcess[$pid]=$User;\r
- break;\r
- }\r
- elseif($pid==-1)\r
- {\r
- $this->log_message("*** Fork Error $User");\r
- break;\r
- }\r
- else\r
- {\r
- //Child Process\r
- $this->log_message("*** Child Process Start for $User");\r
- unset($Message['XFRSent']);\r
- unset($Message['ReqTime']);\r
- $bSBresult = $this->switchboard_control($ip, $port, $cki_code, $User, $Message);\r
- if ($bSBresult === false)\r
- {\r
- // error for switchboard\r
- $this->log_message("!!! error for sending message to ".$User);\r
- }\r
- die;\r
- }\r
- }\r
- unset($this->MessageQueue[$User]);\r
- }\r
- /*\r
- $bSBresult = $this->switchboard_control($ip, $port, $cki_code, $aMSNUsers[$nCurrentUser], $sMessage);\r
- if ($bSBresult === false) {\r
- // error for switchboard\r
- $this->log_message("!!! error for sending message to ".$aMSNUsers[$nCurrentUser]);\r
- $aOfflineUsers[] = $aMSNUsers[$nCurrentUser];\r
- }*/\r
- break;\r
- case 'QNG':\r
- // NS: <<< QNG {time}\r
- @list(/* QNG */, $ping_wait) = @explode(' ', $data);\r
- //if ($this->ping_wait == 0) $this->ping_wait = 50;\r
- //if (is_int($use_ping) && $use_ping > 0) $ping_wait = $use_ping;\r
- //Mod by Ricky Set Online\r
- \r
- $this->callHandler('Pong', $ping_wait);\r
- break;\r
- \r
- case 'RNG':\r
- if($this->PhotoStickerFile!==false)\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid ".rawurlencode($this->MsnObj($this->PhotoStickerFile)));\r
- else\r
- $this->ns_writeln("CHG $this->id NLN $this->clientid");\r
- // someone is trying to talk to us\r
- // NS: <<< RNG {session_id} {server} {auth_type} {ticket} {email} {alias} U {client} 0\r
- $this->log_message("NS: <<< RNG $data");\r
- @list(/* RNG */, $sid, $server, /* auth_type */, $ticket, $email, $name, ) = @explode(' ', $data);\r
- @list($sb_ip, $sb_port) = @explode(':', $server);\r
- if($this->IsIgnoreMail($email))\r
- {\r
- $this->log_message("*** Ignore RNG from $email");\r
- break;\r
- }\r
- $this->log_message("*** RING from $email, $sb_ip:$sb_port");\r
- $this->addContact($email,1,$email, true);\r
- $pid=pcntl_fork();\r
- if($pid)\r
- {\r
- //Parrent Process\r
- $this->ChildProcess[$pid]='RNG';\r
- break;\r
- }\r
- elseif($pid==-1)\r
- {\r
- $this->log_message("*** Fork Error $User");\r
- break;\r
- }\r
- else\r
- {\r
- //Child Process\r
- $this->log_message("*** Ring Child Process Start for $User");\r
- $this->switchboard_ring($sb_ip, $sb_port, $sid, $ticket,$email);\r
- die;\r
- }\r
- break;\r
- case 'OUT':\r
- // force logout from NS\r
- // NS: <<< OUT xxx\r
- $this->log_message("*** LOGOUT from NS");\r
- return $this->NsLogout();\r
- \r
- default:\r
- $code = substr($data,0,3);\r
- if (is_numeric($code)) {\r
- $this->error = "Error code: $code, please check the detail information from: http://msnpiki.msnfanatic.com/index.php/Reference:Error_List";\r
- $this->debug_message("*** NS: $this->error");\r
- \r
- return $this->NsLogout();\r
- }\r
- break;\r
+ return $Data;\r
+ }\r
+\r
+ /**\r
+ * Get Passport ticket\r
+ *\r
+ * @param string $url URL string (Optional)\r
+ * @return mixed Array of tickets or false on failure\r
+ */\r
+ private function get_passport_ticket($url = '') {\r
+ $user = $this->user;\r
+ $password = htmlspecialchars($this->password);\r
+\r
+ if ($url === '')\r
+ $passport_url = self::PASSPORT_URL;\r
+ else\r
+ $passport_url = $url;\r
+\r
+ $XML = '<?xml version="1.0" encoding="UTF-8"?>\r
+<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"\r
+ xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext"\r
+ xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"\r
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy"\r
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"\r
+ xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"\r
+ xmlns:wssc="http://schemas.xmlsoap.org/ws/2004/04/sc"\r
+ xmlns:wst="http://schemas.xmlsoap.org/ws/2004/04/trust">\r
+<Header>\r
+ <ps:AuthInfo xmlns:ps="http://schemas.microsoft.com/Passport/SoapServices/PPCRL" Id="PPAuthInfo">\r
+ <ps:HostingApp>{7108E71A-9926-4FCB-BCC9-9A9D3F32E423}</ps:HostingApp>\r
+ <ps:BinaryVersion>4</ps:BinaryVersion>\r
+ <ps:UIVersion>1</ps:UIVersion>\r
+ <ps:Cookies></ps:Cookies>\r
+ <ps:RequestParams>AQAAAAIAAABsYwQAAAAxMDMz</ps:RequestParams>\r
+ </ps:AuthInfo>\r
+ <wsse:Security>\r
+ <wsse:UsernameToken Id="user">\r
+ <wsse:Username>'.$user.'</wsse:Username>\r
+ <wsse:Password>'.$password.'</wsse:Password>\r
+ </wsse:UsernameToken>\r
+ </wsse:Security>\r
+</Header>\r
+<Body>\r
+ <ps:RequestMultipleSecurityTokens xmlns:ps="http://schemas.microsoft.com/Passport/SoapServices/PPCRL" Id="RSTS">\r
+ <wst:RequestSecurityToken Id="RST0">\r
+ <wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>\r
+ <wsp:AppliesTo>\r
+ <wsa:EndpointReference>\r
+ <wsa:Address>http://Passport.NET/tb</wsa:Address>\r
+ </wsa:EndpointReference>\r
+ </wsp:AppliesTo>\r
+ </wst:RequestSecurityToken>\r
+ <wst:RequestSecurityToken Id="RST1">\r
+ <wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>\r
+ <wsp:AppliesTo>\r
+ <wsa:EndpointReference>\r
+ <wsa:Address>messengerclear.live.com</wsa:Address>\r
+ </wsa:EndpointReference>\r
+ </wsp:AppliesTo>\r
+ <wsse:PolicyReference URI="'.$this->passport_policy.'"></wsse:PolicyReference>\r
+ </wst:RequestSecurityToken>\r
+ <wst:RequestSecurityToken Id="RST2">\r
+ <wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>\r
+ <wsp:AppliesTo>\r
+ <wsa:EndpointReference>\r
+ <wsa:Address>messenger.msn.com</wsa:Address>\r
+ </wsa:EndpointReference>\r
+ </wsp:AppliesTo>\r
+ <wsse:PolicyReference URI="?id=507"></wsse:PolicyReference>\r
+ </wst:RequestSecurityToken>\r
+ <wst:RequestSecurityToken Id="RST3">\r
+ <wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>\r
+ <wsp:AppliesTo>\r
+ <wsa:EndpointReference>\r
+ <wsa:Address>contacts.msn.com</wsa:Address>\r
+ </wsa:EndpointReference>\r
+ </wsp:AppliesTo>\r
+ <wsse:PolicyReference URI="MBI"></wsse:PolicyReference>\r
+ </wst:RequestSecurityToken>\r
+ <wst:RequestSecurityToken Id="RST4">\r
+ <wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>\r
+ <wsp:AppliesTo>\r
+ <wsa:EndpointReference>\r
+ <wsa:Address>messengersecure.live.com</wsa:Address>\r
+ </wsa:EndpointReference>\r
+ </wsp:AppliesTo>\r
+ <wsse:PolicyReference URI="MBI_SSL"></wsse:PolicyReference>\r
+ </wst:RequestSecurityToken>\r
+ <wst:RequestSecurityToken Id="RST5">\r
+ <wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>\r
+ <wsp:AppliesTo>\r
+ <wsa:EndpointReference>\r
+ <wsa:Address>spaces.live.com</wsa:Address>\r
+ </wsa:EndpointReference>\r
+ </wsp:AppliesTo>\r
+ <wsse:PolicyReference URI="MBI"></wsse:PolicyReference>\r
+ </wst:RequestSecurityToken>\r
+ <wst:RequestSecurityToken Id="RST6">\r
+ <wst:RequestType>http://schemas.xmlsoap.org/ws/2004/04/security/trust/Issue</wst:RequestType>\r
+ <wsp:AppliesTo>\r
+ <wsa:EndpointReference>\r
+ <wsa:Address>storage.msn.com</wsa:Address>\r
+ </wsa:EndpointReference>\r
+ </wsp:AppliesTo>\r
+ <wsse:PolicyReference URI="MBI"></wsse:PolicyReference>\r
+ </wst:RequestSecurityToken>\r
+ </ps:RequestMultipleSecurityTokens>\r
+</Body>\r
+</Envelope>';\r
+\r
+ $this->debug_message("*** URL: $passport_url");\r
+ $this->debug_message("*** Sending SOAP:\n$XML");\r
+ $curl = curl_init();\r
+ curl_setopt($curl, CURLOPT_URL, $passport_url);\r
+ if ($this->debug) curl_setopt($curl, CURLOPT_HEADER, 1);\r
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);\r
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);\r
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);\r
+ curl_setopt($curl, CURLOPT_POST, 1);\r
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $XML);\r
+ $data = curl_exec($curl);\r
+ $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);\r
+ curl_close($curl);\r
+ $this->debug_message("*** Get Result:\n$data");\r
+\r
+ if ($http_code != 200) {\r
+ // sometimes, redirect to another URL\r
+ // MSNP15\r
+ //<faultcode>psf:Redirect</faultcode>\r
+ //<psf:redirectUrl>https://msnia.login.live.com/pp450/RST.srf</psf:redirectUrl>\r
+ //<faultstring>Authentication Failure</faultstring>\r
+ if (strpos($data, '<faultcode>psf:Redirect</faultcode>') === false) {\r
+ $this->debug_message("*** Could not get passport ticket! http code = $http_code");\r
+ return false;\r