| 
 
 
class vs_fetion{ 
 private $mobile_no=''; 
 private $password=''; 
 private $login_received=''; 
 private $sock_handle=null; 
 private $i=0; 
 private $sipc_ip='';//各地手机服务器不同 
 private $sipc_port='8080'; 
 var $domain='fetion.com.cn'; 
 var $login_keys=array(); 
 var $c_ver='3.1.0480';//client version 
 function __construct($mobile_no,$password){ 
  $this->mobile_no=$mobile_no; 
  $this->password=$password; 
 } 
  
 //获得系统信息 
 function get_sipc(){ 
  $sid=''; 
  if(preg_match('/[0-9]{11}/m',$this->mobile_no)){ 
   $sid="mobile-no="{$this->mobile_no}""; 
  } 
  else{ 
   $sid="sid="{$this->mobile_no}""; 
  } 
  $data=''; 
  $data_len=strlen($data); 
  ); 
  if(!$fp){ 
   $this->error('get sipc failed.'); 
  } 
  else{ 
   $headers=
post /nav/getsystemconfig.asp教程x http/1.0 
user-agent: iic2.0/pc 3.1.0480 
accept-encoding: deflate, gzip 
host: nav.fetion.com.cn:80 
content-length: {$data_len} 
{$data} 
eot; 
   fwrite($fp,$headers); 
   $received=fread($fp,1024); 
   fclose($fp); 
   if(preg_match('/([^]+)
    list($this->sipc_ip,$this->sipc_port)=explode(':',$matchs[1]); 
   } 
   else{ 
    $this->error('pregmatch sipc received info failed.'); 
   } 
  } 
 } 
  
 //向ssi服务器登录 
 function login(){ 
  ); 
  if(!$fp){ 
   $this->error("fsockopen error,".$errstr.":({$errno})"); 
  } 
  else{ 
   if(preg_match('/[0-9]{11}/m',$this->mobile_no)){ 
    $sid="mobileno={$this->mobile_no}"; 
   } 
   else{ 
    $sid="sid={$this->mobile_no}"; 
   } 
   $headers="get /ssiportal/ssiapps教程ignin.aspx?{$sid}&pwd={$this->password} http/1.1 "; 
   $headers.="host: nav.fetion.com.cn "; 
   $headers.="connection: close "; 
   flock($fp,lock_ex); 
   @fwrite($fp,$headers); 
   $this->login_received=fread($fp,1024); 
   flock($fp,lock_un); 
   fclose($fp); 
   $this->get_login_keys(); 
  } 
 } 
 //向服务器注册 
 function register(){ 
  $this->sock_handle=fsockopen($this->sipc_ip,$this->sipc_port,$errno,$errstr,90); 
  if(!$this->sock_handle){ 
   $this->error('create fsocket failed,'.$errstr.'('.$errno.')'); 
  } 
  else{ 
   $this->i++; 
   $send_data=
r fetion.com.cn sip-c/2.0 
f: {$this->login_keys['sid']} 
i: {$this->i} 
q: 1 r 
l: 251 
 
eot; 
   $received=$this->sipp($send_data); 
   if(preg_match('/nonce="(.+)"/',$received,$matchs)){ 
    $nonce=$matchs[1]; 
   } 
   else{ 
    $this->error('no received nonce.');     
   } 
   $cnonce=$this->cnonce_maker(); 
   $response=$this->calc_response($this->login_keys['sid'],$this->domain,$this->password,$nonce,$cnonce); 
   $send_data=
r fetion.com.cn sip-c/2.0 
f: {$this->login_keys['sid']} 
i: {$this->i} 
q: 1 r 
l: 251 
a: digest response="{$response}",cnonce="{$cnonce}" 
 
eot; 
   $received=$this->sipp($send_data); 
   if(!preg_match('/200 ok/',$received)){ 
    $r_array=explode(" ",$received); 
    $this->error('register failed.code('.$r_array[0].')'); 
   } 
   //preg_match('/([^]+)/',$received,$matchs); 
   return true; 
  } 
 } 
 |