CopyCode The Code is as follows: <? PHP
/*
* PhP100 Chinese network, provided as a whole, passed the test
*/
$ MSN = new mymsn (php100@php100.com, "123 ");
// Msnv9
Class mymsn {
Private $ Server = "messenger.hotmail.com ";
Private $ Port = 1863;
Private $ nexus = "https://nexus.passport.com/rdr/pprdr.asp ";
Private $ sshlogin = "login.live.com/login2.srf"; // loginnet.passport.com/login2.srf
Private $ getcode = NULL;
Private $ _ IP = NULL;
Private $ _ Port = NULL;
Private $ connect = NULL;
Private $ trid = 1;
Private $ maxmessage = 4096;
Private $ username = NULL;
Private $ Password = NULL;
Private $ DEBUG = true;
Function mymsn ($ username = "", $ Password = ""){
If (! Empty ($ username )&&! Empty ($ password )){
$ This-> username = $ username;
// $ This-> Password = urlencode ($ password );
$ This-> Password = $ password;
$ This-> starttalk ();
}
}
Function put ($ data ){
If ($ this-> isconnect ()){
Fputs ($ this-> connect, $ data );
$ This-> trid;
If ($ this-> Debug)
Print ("<Div style = 'color: green; font-size: 13px; '>>>{$ data} </div> ");
}
}
Function get (){
If ($ DATA = @ fgets ($ this-> connect, $ this-> maxmessage )){
If ($ this-> Debug)
Print ("<Div style = 'color: red; font-size: 13px; '><<{$ data} </div> ");
Return $ data;
} Else {
Return false;
}
}
Function isconnect (){
If (! Is_null ($ this-> Connect ))
Return true;
Else
Return false;
}
Function close (){
@ Fclose ($ this-> Connect );
}
Function starttalk (){
If ($ this-> connect = fsockopen ($ this-> server, $ this-> port, $ errno, $ errstr, 2 ))
$ This-> vertalk ();
}
Function vertalk () // MSN protocol negotiation {
$ This-> put ("ver {$ this-> trid} msnp9 cvr0 RN ");
$ DATA = $ this-> get ();
// Echo $ data;
If (false! = Strripos ($ data, "Ver "))
$ This-> envtalk ();
}
Function envtalk () // Environment Negotiation {
$ This-> put ("CVR {$ this-> trid} 0x0409 winnt 5.0 i386 msnmsgr 7.0.0816 MSMSGS {$ this-> username} RN ");
$ DATA = $ this-> get ();
// Echo $ data;
If (false! = Strripos ($ data, "CVR "))
$ This-> reqtalk ();
}
Function reqtalk () // request confirmation {
$ This-> put ("USR {$ this-> trid} twn I {$ this-> username} RN ");
$ DATA = $ this-> get (); // XFR 3 NS 207.46.107.41: 1863 0 65.54.239.210: 1863 XFR 3 NS 207.46.107.25: 1863 U D
// Echo $ data;
If (false! = Strripos ($ data, "XFR ")){
List (, $ SERV) = explode ("", $ data); // Analysis Server
List ($ IP, $ port) = explode (":", $ SERV); // analyze IP addresses and ports
$ This-> _ IP = $ IP;
$ This-> _ Port = $ port;
$ This-> relink ($ IP, $ port );
} Else {
// Echo $ data; // USR 3 twn s Ct = 1205292058, rver = 5.0.3270.0, WP = fs_40sec_0_compact, lc = 1033, id = 507, Ru = http://messenger.msn.com, Tw = 0, KPP = 1, KV = 4, Ver = 2.1.6000.1, Rn = 1 lgjbfil, TPF = b0735e3a873dfb5e75054213196398e0
List (, $ this-> getcode) = explode ("", trim ($ data ));
// Echo $ data;
If (empty ($ this-> sshlogin ))
$ This-> relogintalk (); // obtain the logon server address again.
Else
$ This-> getlogincode ($ this-> sshlogin );
}
}
Function relink ($ server, $ port) // reset the connection {
$ This-> connect = NULL;
$ This-> Server = $ server;
$ This-> Port = $ port;
$ This-> trid = 1;
$ This-> starttalk ();
}
Function relogintalk () // obtain the server address again {
$ 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 );
$ Header = curl_exec ($ ch );
// Print_r ($ header );
Curl_close ($ ch );
Preg_match ('/dalogin = (.*?), /', $ Header, $ out); // capture Server login matching
// Print_r ($ out );
If (isset ($ out [1]) {
$ This-> getlogincode ($ out [1]);
}
Else {
// Return false;
Exit ("unable to capture the URL of the login server ");
}
}
Function getlogincode ($ slogin) // obtain the login code {
// Echo ($ this-> getcode );
If (! Is_null ($ this-> getcode )){
$ CH = curl_init ("https: //". $ slogin );
$ Logininfo = array (
"Authorization: passport1.4 rgverb = Get, orgurl = http://messenger.msn.com, sign-In = ". $ this-> username. ", Pwd = ". $ this-> password. ",". $ this-> getcode,
"Host: login.passport.com"
);
Curl_setopt ($ ch, curlopt_httpheader, $ logininfo );
// Print_r ($ logininfo );
// $ This-> getcode = NULL;
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 );
$ Header = curl_exec ($ ch );
// Print_r ($ header );
Preg_match ("/from-pp = '(.*?) '/", $ Header, $ out );
// Print_r ($ out );
If (isset ($ out [1]) {
$ This-> loginaction ($ out [1]);
} Else {
// Return false;
Exit ("unable to capture login code information ");
}
} Else {
Return false;
}
}
Function loginaction ($ logincode) // login work {
$ This-> put ("USR {$ this-> trid} TWN s {$ logincode} RN"); // USR | trid | sso s | T = Code |
$ DATA = $ this-> get ();
// Echo $ data;
// Print_r ($ data );
// $ This-> put ("syn {$ this-> trid} 0 RN ");
// $ This-> put ("chg {$ this-> trid} nln rn ");
// Print_r ($ this-> get ());
}
}
?>