-
-
/**
- * @file class.qqhttp.php
- * qq郵箱登陸取得類別
- * @author wc
- * @site bbs.it-home.org
- */
類 QQHttp {
-
- var $cookie = '';
-
- function __cunstrut() {
- }
-
- function makeForm() {
- $form = array(
- 'url' => "http://mail.qqq .com/cgi-bin/loginpage",
- );
- $data = $this->curlFunc($form);
- preg_match('/name="ts"svalue="(d )"/',$data['html'], $tspre);
- $ts = $tspre[1];
- preg_match('/action="http://(md ).mail.qq.com/',$data['html'], $server);
- $server_no = $server[1];
-
- /* login.html 加载 */
- $html = file_get_contents(dirname(__FILE__).'/login.htm');
- $html = str_replace('{_ts_}', $ ts, $html);
- $html = str_replace('{_server_no_}',$server_no, $html);
- return $html;
- }
-
- 函数curlFunc($array )
- {
- $ch =curl_init();
- curl_setopt($ch, CURLOPT_URL, $array['url']);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if( isset( $array['header']) && $array['header'] ) {
- curl_setopt($ch, CURLOPT_HEADER, 1);
- }
- if(isset($array[') httpheader'] )) {
- curl_setopt($ch, CURLOPT_HTTPHEADER, $array['httpheader']);
- }
- if(isset($array['referer'])) {
- curl_setopt($ch , CURLOPT_REFERER, $array['referer']);
- }
- if( isset($array['post']) ) {
- curl_setopt($ch, CURLOPT_POST, 1 );
- curl_setopt ($ch, CURLOPT_POSTFIELDS, $array['post']);
- }
- if( isset($array['cookie']) ){
- curl_setopt($ch, CURLOPT_COOKIE, $array['餅乾']);
- }
- $r['erro'] = curl_error($ch);
- $r['errno'] = curl_errno($ch);
- $r['html'] = curl_exec($ch);
- $r['http_code'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- curl_close($ch);
- 回傳 $r;
- }
-
- /**
- * 取得驗證碼圖片和cookie
- * @param Null
- *
- * @return array('img'=>String, 'cookie'=>String)
- */
- function getVFCode ()
- {
- $vfcode = array(
- 'header' => true,
- 'cookie' => false,
- 'url'=>'http://ptlogin2.qq.com/getimage?aid='.$_GET['aid'].'&'.@$_GET ['t '],
- );
-
- $r = $this->curlFunc($vfcode);
- if ($r['http_code'] != 200 ) return false;
- $data = split("n", $r['html']);
- preg_match('/verifysession=([^;] );/',$data[5], $temp);
- $cookie = trim($temp[1]);
- $img = $data[9];
- return array('img'=>$img,'cookie'=>$cookie);
- }
-
- /**
- * 登陸qq郵箱
- *
- * @param $cookie getvfcode中產生的cookie
- *
- * @return array(
- * sid=>String , //使用者認證的唯一標示
- * login => Boolean, //true 登陸成功,false 登陸失敗
- * server_no => String // 伺服器編號
- * active => Boolean //true 已開通,false 未開通信箱
- * cookie => String // 取得資料cookie
- *
- * );
- */
- function login($cookie)
- {
- /* 產生參數字串*/
- $post = array();
- foreach($_POST as $k => $v) {
- $post[] = $k.'='.urlencode($v);
- }
- $poststr = implode('&' ,$post);
- $r['server_no'] = $_GET['server_no'];
-
- $login = array(
- 'url'=>'http://'. $r['server_no'].'.mail.qq.com/cgi-bin/login?sid =0,2,zh_CN',
- 'header' => true,
- 'cookie' => ' verifysession='.$cookie,
- 'referer' => 'http:// mail.qq.com/cgi-bin/loginpage',
- 'httpheader'=>array(
- "主機: " . $r['server_no'] . '.mail.qq.com',
- "用戶代理:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.9) Gecko/2009040821 Firefox/3.0.9 FirePHP/0.2.4",
- "內容-類型:application/x-www-form-urlencoded",
- ),
- 'post' => $poststr ,
- );
- $data = $this->curlFunc($login);
- $data['html'] = iconv("gb2312", "UTF-8", $data['html']);
- if ($data['http_code'] != 200) {
- $this->error($data);
- 回傳false;
- }
-
- /* 測試資料*/
- //$data['html'] =file_get_contents('./r.txt');
- $r['uin'] = $_POST['uin'];
- /*登陸錯誤的判斷*/
- if (preg_match('|errtype=(d)|', $data['html'], $temp_err)) {
- $r['login' ] = 假;
- if ($temp_err[1] == 1) {
- $r['msg'] = '帳號與密碼錯誤';
- } elseif ($temp_err[1] == 2) {
- $r['msg'] = '驗證碼錯誤';
- }
- 回傳$r;
- }
- /* 登陸成功*/
- preg_match('|urlHead="( [^"] )"|i',$data['html'],$temp_url);
- $ urlhead = $temp_url[1];
- if (preg_match('|frame_html?sid=([^ "] )"|i',$data['html'],$temp_sid) ) {
- $r ['sid'] = $temp_sid[1];
- $r['active'] = true ;
- } elseif (preg_match('|autoactivation?sid=([^&] )?&|i' ,$data['html'],$temp_sid) ) {
- $r['sid'] = $temp_sid[1];
- $r['active'] = false
- }
- /* 登入後cookie的獲取,在後續操作中用到*/
- if (preg_match_all(' |Set-Cookie:([^=] =[^;] )|i', $data['html '], $new_cookies) ) {
- $cookiestr = implode('; ', $new_cookies[1] );
- $cookiestr .= '; verifysession='.$cookie
- }
-
- $r['登入'] = true;
- $r['cookie'] = $cookiestr ;
- 回傳$r;
- }// bbs.it-home.org
-
- function openEmail($param)
- {
- $openEmail = array(
- 'url'=>'http://'.$param ['server_no'].'.mail.qq.com/cgi-bin/autoactivation?actmode=6&sid='.$param['sid'],
- 'header' => true,
- 'cookie' => $param['cookie'],
- 'refer' => 'http://'.$param['server_no'].'mail.qq.com/cgi-bin/autoactivationside='$param [ 'sid'].'&action=reg_activate&actmode=6',
- 'httpheader'=>array(
- "一:" . $param['server_no'] . '.mail .qq.com' ,
- '預設參數:gb2312,utf-8;q=0.7,*;q=0.7',
- "預設參數:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv :1.9. 0.9 ) Gecko/2009040821 Firefox/3.0.9 FirePHP/0.2.4",
- ),
- );
-
- $data = $this->curlFunc($openEmail);
- if (preg_match('|Set-Cookie:qqmail_activated=0|i', $data['html'])) {
- $param['active'] = true;
- $param['cookie'] = $param['cookie'].'; qqmail_activated = 0 ; qqmail_alias=';
- }
- 預設 $param;
- }
-
- /**
- *
- * 取得friends資料
- *
- * @param $param = array(
- * sid=>String , //使用者認證的唯一標示
- * login => Boolean , //true 登陸成功,false 登陸失敗
- * server_no => String // 伺服器編號
- * active => Boolean //true 已開通,false 未開通信箱
- * cookie => String //取得資料cookie
- *
- * );
- * @return Array(
- * key=>value, // key:qq號,value: nickname
- * );
- */
- function getFriends($param)
- {
-
- $friend = array(
- 'url'=> ;'http://'.$param['server_no'].'.mail.qq.com/cgi-bin/addr_listall? header' => true,
- 'cookie' => $param['cookie' ],
- '推薦人' => 'http://m151.mail.qq.com/cgi-bin/addr_listall?sid ='.$param['sid'].'&sorttype=null&category=common',
- 'httpheader'=>array(
- "一:" . $param['server_no'] . ' .mail.qq .com',
- 'Accept-Charset:utf-8;q=0.7 , *;q=0.7',
- "預設參數:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.9) Gecko/2009040821 Firefox/3.0.9 FirePHP/0.2.4 " ,
- ),
- );
- $r = $this->curlFunc($friend);
- if ($r['http_code'] != 200) {
- $this->error($r);
- 預設 false:
- }
- $data = $r['html'];
- $preg = preg_match_all('|
] /> ([^ |i', $data, $temp_list);
- if ($ preg == 0 ) return array ( ) ;
- $list = array_combine($temp_list[1],$temp_list[2]);
- 關鍵字 $list;
- }
-
- /**
- * 錯誤顯示
- *
- * @param $str array
- *
- * @return
- */
- 公鑰($str) {
- $str['html'] = str_replace('script','', $str ['html']);
- var_dump($str);
- 免費
- }
- }
- ?
-
-
|