PHP模擬登入QQ空間的例子

WBOY
發布: 2016-07-25 08:53:10
原創
2118 人瀏覽過
  1. include "include/http.class.php";
  2. $http = new http(1);
  3. $html = $http->get('http://check.ptlogin2.qq.com/check?uin=QQ帳號&appid=15004501&r='.Math.rand(),1);
  4. $pattern = '/ '. preg_quote("ptui_checkVC('0','",'/').'(.*?)'.preg_quote("',",'/').'/i';
  5. preg_match ( $模式, $html, $matches);
  6. $yzm = $matches[1];
  7. $pattern = '/'.preg_quote("'x",'/').'(.*?)' .preg_quote ("');",'/').'/i';
  8. preg_match ( $pattern,$html, $matches);
  9. $yzmt = 'x'.$matches[1];
  10. $http -> get("http://ptlogin2.qq.com/login?u=QQ帳號&p=".jspassword("QQ密碼",$yzm,$yzmt)."&verifycode=".$ yzm。 ");
  11. 函數jspassword($p, $vc, $vt) {
  12. $p = strtoupper(md5($p));
  13. for ($i = 0; $i return strtoupper(md5(strtoupper(md5(hex2asc($temp) . hex2asc($ vt))) . $vc));
  14. }
  15. 函數hex2asc($str) {
  16. $str = join('',explode('x', $str));
  17. for ($i = 0;$i return $data;
  18. }
複製程式碼

如下圖: PHP模擬登入QQ空間的例子

http.class.php檔案程式碼:

  1. // -------------------------- - -------------------------------------------------- -----
  2. // | ThinkPHP [ 只要想就可以做到]
  3. // ------------------------- ---------- -----------------------------------
  4. // | Copyright (c) 2009 http://thinkphp.cn 版權所有
  5. // ----------------------------- - -------------------------------------------------- ---
  6. // |授權( http://www.apache.org/licenses/LICENSE-2.0 )
  7. // ---------------- ----------- --------------------------------------- ----------------
  8. // |作者:liu21st
  9. // ------------- --------------------- ----------------------------- -------------------
  10. // $Id$
  11. /**
  12. ----------------------------------------------- -------------------------------
  13. * Http 工具類別
  14. * 提供一系列的Http方法
  15. ------------------------------------------------- -----------------------------
  16. * @category ORG
  17. * @package ORG
  18. * @subpackage Net
  19. * @author liu21st
  20. * @version $Id$
  21. ------------------------ -------------------------------------------------- ----
  22. */
  23. class Http
  24. { //類別定義開始
  25. /**
  26. ----------------------------------------------- -----------
  27. * 擷取遠端檔案
  28. ----------------------------- -----------------------------
  29. * @access public
  30. ----------- -----------------------------------------------
  31. * @param string $remote 遠端檔案名稱
  32. * @param string $local 本機儲存檔案名稱
  33. ------------------------- ---------------------------------
  34. * @return mixed
  35. ------- -------------------------------------------------- -
  36. */
  37. static public function curl_download($remote,$local) {
  38. $cp =curl_init($remote);
  39. $ fp = fopen($local,"w");
  40. curl_setopt($cp, CURLOPT_FILE, $fp);
  41. curl_setopt($cp) , CURLOPT_HEADER, 0);
  42. curl_exec($cp);
  43. curl_close($cp);
  44. fclose($fp);
  45. }
  46. /**
  47. ----------------------------------------------- -----------
  48. * 下載檔案
  49. * 可以指定下載顯示的檔案名,並自動傳送對應的Header資訊
  50. * 如果指定了content參數,則下載該參數的內容
  51. --------------------------------------------- -------------
  52. * @static
  53. * @access public
  54. --------------------- -------------------------------------
  55. * @param string $filename 下載檔名
  56. * @param string $showname 下載顯示的檔案名稱
  57. * @param string $content 下載的內容
  58. * @param integer $expire 下載內容瀏覽器快取時間
  59. ------- -------------------------------------------------- -
  60. * @return void
  61. --------------------------------------- -------------------
  62. * @throws ThinkExecption
  63. --------------------- -------------------------------------
  64. * /
  65. 靜態公用函數download ($filename, $showname=' ',$content='',$expire=180) {
  66. if(is_file($filename)) {
  67. $length = filesize( $filename);
  68. }elseif(is_file(UPLOAD_PATH.$filename )) {
  69. $filename = UPLOAD_PATH.$filename;
  70. $length = filesize($filename);
  71. }elseif($content != '') {
  72. $length = strlen($content );
  73. }else {
  74. throw_exception($filename.L('下載檔案不存在!'));
  75. }
  76. if(empty($showname)) {
  77. $showname = $filename;
  78. }
  79. $showname = basename($showname);
  80. if( !empty($filename)) {
  81. $type = mime_content_type($filename);
  82. }else{
  83. $type = "application/octet-stream";
  84. }
  85. // 發送Http 標頭資訊開始下載
  86. header("Pragma: public");
  87. header("Cache-control: max-age=".$expire);
  88. //header('Cache-Control: no -store, no-cache, Must-revalidate');
  89. header("過期: " .gmdate("D, d M Y H:i:s",time() $expire) . "GMT");
  90. header("最後修改時間: " .gmdate("D, d M Y H:i:s",time()) . "GMT");
  91. header("內容處置: 附件; filename=".$ showname);
  92. header("內容長度:".$length);
  93. header("內容類型:".$type);
  94. header('內容編碼:無');
  95. header ("內容傳輸編碼:二進位" );
  96. if($content == '' ) {
  97. readfile($filename);
  98. }else {
  99. echo($content );
  100. }
  101. exit();
  102. }
  103. /**
  104. ----------------------------------------------- -----------
  105. * 顯示HTTP Header 資訊
  106. ---------------------------- ------------------------------
  107. * @return string
  108. ---------- ------------------------------------------------
  109. */
  110. 靜態函數get_header_info($header='',$echo=true)
  111. {
  112. ob_start();
  113. $headers = getallheaders();
  114. if(!empty($header)) {
  115. $info = $headers[$header];
  116. echo ($header.' :'.$info."n"); ;
  117. }else {
  118. foreach($headers as $key=>$val) {
  119. echo("$key:$valn");
  120. }
  121. }
  122. $輸出= ob_get_clean();
  123. if ($echo) {
  124. echo (nl2br($output));
  125. }else {
  126. return $output;
  127. }
  128. }
  129. /**
  130. * HTTP 協定定義的狀態碼
  131. * @param int $num
  132. */
  133. static function send_http_status($code) {
  134. static $_status = array(
  135. //訊息1xx
  136. 100 => '繼續',
  137. 101 => '切換協定',
  138. // 成功2xx
  139. 200 => '確定',
  140. 201 => '已建立',
  141. 202 => '已接受',
  142. '非權威資訊',
  143. 204 => '無內容',
  144. '重設內容',
  145. 206 => '部分內容',
  146. // 重定向3xx
  147. 300 => '多重選擇',
  148. 301 => '永久移動',
  149. 302 => '找到', / / 1.1
  150. 303 => '查看其他',
  151. 304 => '未修改',
  152. 305 => '使用代理',
  153. // 306 已棄用但保留
  154. 307 =>; '暫時重新導向',
  155. // 客戶端錯誤4xx
  156. 400 => '錯誤的請求',
  157. 401 => '未經授權',
  158. 402 = > “需要付款”,
  159. 403 => '禁止',
  160. 404 => '未找到',
  161. 405 => '方法不允許',
  162. 406 => '不可接受',
  163. 407 => '需要代理身份驗證',
  164. 408 => '請求超時',
  165. 409 => '衝突',
  166. 410 => '走了',
  167. 411 = > '需要長度',
  168. 412 => '前提條件失敗',
  169. 413 => '請求實體太大',
  170. 414 => '請求URI 太長',
  171. 415 => '不支援的媒體類型',
  172. 416 => '請求的範圍無法滿足',
  173. 417 => '期望失敗',
  174. // 伺服器錯誤5xx
  175. 500 => ; '內部伺服器錯誤',
  176. 501 => '未實作',
  177. 502 => '錯誤網關',
  178. 503 => '服務不可用',
  179. 504 => '網關逾時',
  180. 505 => 'HTTP 版本不支援',
  181. 509 => '超出頻寬限制'
  182. );
  183. if(array_key_exists($code,$_status)) {
  184. header ('HTTP/1.1 '.$code.' '.$_status[$code]);
  185. }
  186. }
  187. }//類別定義結束
  188. if( !function_exists ('mime_content_type')) {
  189. /**
  190. ----------------------------------------------- -----------
  191. * 取得檔案的mime_content類型
  192. --------------------------- -------------------------------
  193. * @return string
  194. --------- -------------------------------------------------
  195. */
  196. function mime_content_type($filename)
  197. {
  198. function mime_content_type($filename)
  199. {
  200. static 藍色> array(
  201. 'ai' => '應用程式/postscript',
  202. 'aif' => '音訊/x-aiff',
  203. 'aifc' => '音訊/x-aiff' ,
  204. 'aiff' => 'audio/x-aiff',
  205. 'asc' => 'application/pgp', //由skwashd 更改- was text/plain
  206. 'asf' = > '視頻/ x-ms-asf',
  207. 'asx' => '視訊/x-ms-asf',
  208. 'au' => '音訊/基本',
  209. ' avi' => 'video/ x-msvideo',
  210. 'bcpio' => 'application/x-bcpio',
  211. 'bin' => 'application/octet-stream',
  212. 'bmp' => 'image/bmp' ,
  213. 'c' => 'text/plain', // 或'text/x-csrc', //由skwashd 加
  214. 'cc' = > 'text/plain', // 或'text /x-c src', //由skwashd 加
  215. 'cs' =>; 'text/plain', //由skwashd 加- 對於C# src
  216. 'cpp' =>; 'text/x-c src', //由skwashd
  217. 加'cxx' =>; 'text/x-c src', //由skwashd
  218. 加'cdf' =>; 'application/x-netcdf',
  219. 'class' = >; 'application/octet-stream',//安全,但application/java-class 是正確的
  220. 'com' =>; 'application/octet-stream',//由skwashd
  221. 添加'cpio ' =>; 'application/x-cpio',
  222. 'cpt' =>; 'application/mac-compactpro',
  223. 'csh' =>; 'application/x-csh',
  224. ' css' =>; 'text/css',
  225. 'csv' =>; 'text/comma-separated-values',//由skwashd
  226. 加'dcr' =>; 'application/x-director ',
  227. 'diff' =>; 'text/diff',
  228. 'dir' =>; 'application/x-director',
  229. 'dll' =>; 'application/octet-stream' ,
  230. 'dms' =>; 'application/octet-stream',
  231. 'doc' =>; 'application/msword',
  232. '點' => 'application/msword',//由skwashd 加
  233. 'dvi' =>; 'application/x-dvi',
  234. 'dxr' =>; 'application/x-director',
  235. 'eps' =>; 'application/postscript' ,
  236. 'etx' =>; 'text/x-setext',
  237. 'exe' =>; 'application/octet-stream',
  238. 'ez' =>; 'application/andrew-inset ',
  239. 'gif' =>; '圖像/gif',
  240. 'gtar' =>; 'application/x-gtar',
  241. 'gz' =>; 'application/x-gzip' ,
  242. 'h' =>; 'text/plain', // 或'text/x-chdr',//由skwashd 加
  243. 'h ' =>; 'text/plain', // 或'text/x-c hdr', //由skwashd
  244. 加'hh' =>; 'text/plain', // 或'text/x-c hdr', //由skwashd
  245. 加'hpp' => ; 'text/plain', // 或'text/x-c hdr', //由skwashd
  246. 加'hxx' =>; 'text/plain', // 或'text/x-c hdr', //由skwashd
  247. 加'hdf' =>; 'application/x-hdf',
  248. 'hqx' =>; 'application/mac-binhex40',
  249. 'htm' =>; 'text/html' ,
  250. 'html' =>; 'text/html',
  251. 'ice' =>; 'x-conference/x-cooltalk',
  252. 'ics' =>; '文字/日曆',
  253. 'ief' => 'image/ief',
  254. 'ifb' =>; '文字/日曆',
  255. 'iges' =>; '模型/iges',
  256. 'igs' =>; 'model/iges',
  257. 'jar' =>; 'application/x-jar', //由skwashd 新增- 替代mime 類型
  258. 'java' =>; 'text/x-java -source', //由skwashd
  259. 加'jpe' =>; 'image/jpeg',
  260. 'jpeg' =>; 'image/jpeg',
  261. 'jpg' =>; 'image /jpeg',
  262. 'js' =>; 'application/x-javascript',
  263. 'kar' =>; '音頻/midi',
  264. '乳膠' => 'application/x-latex ',
  265. 'lha' =>; 'application/octet-stream',
  266. 'log' =>; 'text/plain',
  267. 'lzh' =>; 'application/octet-stream' ,
  268. 'm3u' =>; 'audio/x-mpegurl', 'man' =>; '應用程式/x-troff-man','我' => 'application/x-troff-me',
  269. 'mesh' =>; '模型/網格',
  270. 'mid' => '音訊/midi',
  271. 'midi ' => '音頻/midi',
  272. 'mif' =>; 'application/vnd.mif',
  273. 'mov' =>; '視頻/quicktime',
  274. '電影' =>; 'video/x-sgi-movie',
  275. 'mp2' =>; '音訊/mpeg',
  276. 'mp3' => '音訊/mpeg',
  277. 'mpe' => '影片/ mpeg',
  278. 'mpeg' =>; '視訊/mpeg',
  279. 'mpg' =>; '視訊/mpeg',
  280. 'mpga' =>; '音訊/mpeg',
  281. 'ms' => 'application/x-troff-ms',
  282. 'msh' =>; '模型/網格',
  283. 'mxu' =>; 'video/vnd.mpegurl',
  284. 'nc' =>; 'application/x-netcdf',
  285. 'oda' =>; 'application/oda',
  286. '補丁' =>; 'text/diff',
  287. ' pbm' =>; 'image/x-portable-bitmap',
  288. 'pdb' =>; 'chemical/x-pdb',
  289. 'pdf' =>; 'application/pdf',
  290. 'pgm' =>; 'image/x-portable-graymap',
  291. 'pgn' =>; 'application/x-chess-pgn',
  292. 'pgp' =>; 'application/pgp', //由skwashd 加入
  293. 'php' =>; 'application/x-httpd-php',
  294. 'php3' =>; 'application/x-httpd-php3',
  295. 'pl' = >; 'application/x-perl',
  296. 'pm' =>; 'application/x-perl',
  297. 'png' =>; 'image/png',
  298. 'pnm' => ; 'image/x-portable-anymap',
  299. 'po' =>; '文字/純文字',
  300. 'ppm' => 'image/x-portable-pixmap',
  301. 'ppt ' =>; 'application/vnd.ms-powerpoint',
  302. 'ps' =>; 'application/postscript',
  303. 'qt' =>; '影片/quicktime',
  304. 'ra' =>; 'audio/x-realaudio',
  305. 'rar'=>'application/octet-stream',
  306. 'ram' =>; 'audio/x-pn-realaudio',
  307. ' ras' =>; 'image/x-cmu-raster',
  308. 'rgb' =>; 'image/x-rgb',
  309. 'rm' =>; 'audio/x-pn-realaudio' ,
  310. 'roff' =>; 'application/x-troff',
  311. 'rpm' =>; 'audio/x-pn-realaudio-plugin',
  312. 'rtf' =>; 'text /rtf',
  313. 'rtx' =>; 'text/richtext',
  314. 'sgm' =>; 'text/sgml',
  315. 'sgml' =>; 'text/sgml',
  316. 'sh' =>; 'application/x-sh',
  317. 'shar' =>; 'application/x-shar',
  318. 'shtml' =>; 'text/html',
  319. '筒倉' => '模型/網格',
  320. '坐' => 'application/x-stuffit',
  321. 'skd' =>; 'application/x-koan',
  322. 'skm' =>; 'application/x-koan',
  323. 'skp' =>; 'application/x-koan',
  324. 'skt' =>; 'application/x-koan',
  325. 'smi' =>; 'application/smil',
  326. 'smil' =>; 'application/smil',
  327. 'snd' =>; '音頻/基本',
  328. '所以' = > 'application/octet-stream',
  329. 'spl' =>; 'application/x-futuresplash',
  330. 'src' =>; 'application/x-wais-source',
  331. 'stc ' =>; 'application/vnd.sun.xml.calc.template',
  332. 'std' =>; 'application/vnd.sun.xml.draw.template',
  333. 'sti' =>; 'application/vnd.sun.xml.impress.template',
  334. 'stw' =>; 'application/vnd.sun.xml.writer.template',
  335. 'sv4cpio' =>; 'application/x -sv4cpio',
  336. 'sv4crc' =>; 'application/x-sv4crc',
  337. 'swf' =>; 'application/x-shockwave-flash',
  338. 'sxc' =>; ' application/vnd.sun.xml.calc',
  339. 'sxd' =>; 'application/vnd.sun.xml.draw',
  340. 'sxg' =>; 'application/vnd.sun.xml. writer.global',
  341. 'sxi' =>; 'application/vnd.sun.xml.impress',
  342. 'sxm' =>; 'application/vnd.sun.xml.math',
  343. 'sxw' =>; 'application/vnd.sun.xml.writer',
  344. 't' =>; 'application/x-troff',
  345. 'tar' =>; 'application/x-tar ',
  346. 'tcl' =>; 'application/x-tcl',
  347. 'tex' =>; 'application/x-tex',
  348. 'texi' =>; 'application/x- texinfo',
  349. 'texinfo' =>; '應用程式/x-texinfo',
  350. 'tgz'=> 'application/x-gtar',
  351. 'tif' =>; '圖片/tiff',
  352. 'tiff' => 'image/tiff',
  353. 'tr' => ; 'application/x-troff',
  354. 'tsv' =>; '文字/製表符分隔值',
  355. 'txt' =>; 'text/plain',
  356. 'ustar' = >; 'application/x-ustar',
  357. 'vbs' =>; 'text/plain', //由skwashd 添加- 出於明顯的原因
  358. 'vcd' =>; 'application/x- cdlink',
  359. 'vcf' =>; 'text/x-vcard',
  360. 'vcs' =>; '文字/日曆',
  361. 'vfb' =>; '文字/日曆',
  362. 'vrml' =>; '模型/vrml',
  363. 'vsd' => 'application/vnd.visio',
  364. 'wav' =>; '音訊/x-wav',
  365. '蠟' => 'audio/x-ms-wax',
  366. 'wbmp' =>; 'image/vnd.wap.wbmp',
  367. 'wbxml' =>; 'application/vnd.wap .wbxml',
  368. 'wm' =>; 'video/x-ms-wm',
  369. 'wma' =>; 'audio/x-ms-wma',
  370. 'wmd' => ; 'application/x-ms-wmd',
  371. 'wml' =>; 'text/vnd.wap.wml',
  372. 'wmlc' =>; 'application/vnd.wap.wmlc',
  373. 'wmls' =>; 'text/vnd.wap.wmlscript',
  374. 'wmlsc' =>; 'application/vnd.wap.wmlscriptc',
  375. 'wmv' =>; 'video/x -ms-wmv',
  376. 'wmx' =>; 'video/x-ms-wmx',
  377. 'wmz' =>; 'application/x-ms-wmz',
  378. 'wrl' =>; '模型/vrml',
  379. 'wvx' => 'video/x-ms-wvx',
  380. 'xbm' =>; 'image/x-xbitmap',
  381. 'xht' =>; 'application/xhtml xml',
  382. 'xhtml' =>; 'application/xhtml xml',
  383. 'xls' =>; 'application/vnd.ms-excel',
  384. 'xlt ' =>; 'application/vnd.ms-excel',
  385. 'xml' =>; 'application/xml',
  386. 'xpm' =>; 'image/x-xpixmap',
  387. ' xsl' =>; 'text/xml',
  388. 'xwd' =>; 'image/x-xwindowdump',
  389. 'xyz' =>; 'chemical/x-xyz',
  390. 'z ' =>; 'application/x-compress',
  391. 'zip' =>; 'application/zip',
  392. );
  393. $type = strtolower(substr(strrchr($filename, '.' ),1));
  394. if(isset($contentType[$type])) {
  395. $mime = $contentType[$type];
  396. }else {
  397. $mime = 'application/ octet-stream';
  398. }
  399. return $mime;
  400. }
  401. }
  402. if(!function_exists('image_type_to_extension'))
  403. { {
  404. if(empty($imagetype)) return false;
  405. switch($imagetype)
  406. {
  407. case IMAGETYPE_GIF : 回傳'.gif';
  408. case IMAGETYPE_GIF : 回傳'.gif'; case IMAGETYPE_PNG : 回傳'.png';
  409. case IMAGETYPE_SWF : 回傳'.swf';
  410. case IMAGETYPE_PSD : 回傳'.swf';
  411. case IMAGETYPE_PSD : 回傳'.swf';
  412. case IMAGETYPE_PSD : 回傳'.ps '.bmp';
  413. case IMAGETYPE_TIFF_II : 返回'.tiff';
  414. case IMAGETYPE_TIFF_MM : 返回'.tiff';
  415. 案例IMAGETYPE_JPC : 返回'.jpc'; 案例IMAGETYPE_JPX : 返回'.jpf';
  416. 案例IMAGETYPE_JB2 : return '.jb2';
  417. case IMAGETYPE_SWC : 返回'.swase';
  418. case IMAGETYPE_SWC : 返回'.swasec';
  419. case IMAGETY ;
  420. case IMAGETYPE_WBMP : 回傳'.wbmp';
  421. case IMAGETYPE_XBM : 回傳'.wbmp';
  422. case IMAGETYPE_XBM : 回傳'.wbmp';
  423. case IMAGETYPE_XBM : 回傳'.wbmp';
  424. case IMAGETYPE_XBM : 回傳' .xbm';
  425. 預設:回傳false;
  426. }
  427. }
  428. }
?>
複製程式碼

>>> 更多php 模擬登入文章,專題連結:php 模擬登入php curl 模擬登入教學大全


來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板