Example of PHP simulated login to QQ space

WBOY
Release: 2016-07-25 08:53:10
Original
2109 people have browsed it
  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 ( $pattern,$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."&aid=15004501&u1=http%3A%2F%2Fctc.qzs.qq.com%2Fac%2Fqzone%2Flogin%2Fsucc.html%3Fpara%3Dtoolbar&h=1&ptredirect=0&ptlang=2052&from_ui=1&dumy=&fp=loginerroralert&mibao_css=&t=1&g=1");
  11. function 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. function hex2asc($str) {
  16. $str = join('', explode('x', $str));
  17. for ($i = 0;$i return $data;
  18. }
复制代码

As shown below: Example of PHP simulated login to QQ space

http.class.php file code:

  1. // +----------------------------------------------------------------------
  2. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2009 http://thinkphp.cn All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  7. // +----------------------------------------------------------------------
  8. // | Author: liu21st
  9. // +----------------------------------------------------------------------
  10. // $Id$
  11. /**
  12. +------------------------------------------------ ----------------------------------
  13. * Http tool class
  14. * Provides a series of Http methods
  15. +----- -------------------------------------------------- -----------------------
  16. * @category ORG
  17. * @package ORG
  18. * @subpackage Net
  19. * @author liu21st * @version $Id$
  20. +---------------------------------------- ----------------------------------------
  21. */
  22. class Http
  23. {//类定义开始
  24. /**
  25. +------------------------------------------------ ----------
  26. * Collect remote files
  27. +--------------------------------- --------------------------
  28. * @access public
  29. +------------------ ----------------------------------------
  30. * @param string $remote remote file name
  31. * @param string $local local file name
  32. +---------------------------------------- ---------------------
  33. * @return mixed
  34. +--------------------- ----------------------------------
  35. */
  36. static public function curl_download($remote,$local) {
  37. $cp = curl_init($remote);
  38. $fp = fopen($local,"w");
  39. curl_setopt($cp, CURLOPT_FILE, $fp);
  40. curl_setopt($cp, CURLOPT_HEADER, 0);
  41. curl_exec($cp);
  42. curl_close($cp);
  43. fclose($fp);
  44. }
  45. /**
  46. +------------------------------------------------ ----------
  47. * Download file
  48. * You can specify the file name displayed for download, and automatically send the corresponding Header information
  49. * If the content parameter is specified, download the content of this parameter
  50. +--- -------------------------------------------------- -----
  51. * @static
  52. * @access public
  53. +---------------------------------- --------------------------
  54. * @param string $filename Download file name
  55. * @param string $showname Download displayed file name
  56. * @param string $content downloaded content
  57. * @param integer $expire downloaded content browser cache time
  58. +-------------------------------- --------------------------------
  59. * @return void
  60. +------------- --------------------------------------------------
  61. * @throws ThinkExecption
  62. +------------------------------------------------- ----------
  63. */
  64. static public function download ($filename, $showname='',$content='',$expire=180) {
  65. if(is_file($filename)) {
  66. $length = filesize($filename);
  67. }elseif(is_file(UPLOAD_PATH.$filename)) {
  68. $filename = UPLOAD_PATH.$filename;
  69. $length = filesize($filename);
  70. }elseif($content != '') {
  71. $length = strlen($content);
  72. }else {
  73. throw_exception($filename.L('下载文件不存在!'));
  74. }
  75. if(empty($showname)) {
  76. $showname = $filename;
  77. }
  78. $showname = basename($showname);
  79. if(!empty($filename)) {
  80. $type = mime_content_type($filename);
  81. }else{
  82. $type = "application/octet-stream";
  83. }
  84. //发送Http Header信息 开始下载
  85. header("Pragma: public");
  86. header("Cache-control: max-age=".$expire);
  87. //header('Cache-Control: no-store, no-cache, must-revalidate');
  88. header("Expires: " . gmdate("D, d M Y H:i:s",time()+$expire) . "GMT");
  89. header("Last-Modified: " . gmdate("D, d M Y H:i:s",time()) . "GMT");
  90. header("Content-Disposition: attachment; filename=".$showname);
  91. header("Content-Length: ".$length);
  92. header("Content-type: ".$type);
  93. header('Content-Encoding: none');
  94. header("Content-Transfer-Encoding: binary" );
  95. if($content == '' ) {
  96. readfile($filename);
  97. }else {
  98. echo($content);
  99. }
  100. exit();
  101. }
  102. /**
  103. +------------------------------------------------ ----------
  104. * Display HTTP Header information
  105. +-------------------------------- --------------------------
  106. * @return string
  107. +----------------- ----------------------------------------
  108. */
  109. static function get_header_info($header='',$echo=true)
  110. {
  111. ob_start();
  112. $headers = getallheaders();
  113. if(!empty($header)) {
  114. $info = $headers[$header];
  115. echo($header.':'.$info."n"); ;
  116. }else {
  117. foreach($headers as $key=>$val) {
  118. echo("$key:$valn");
  119. }
  120. }
  121. $output = ob_get_clean();
  122. if ($echo) {
  123. echo (nl2br($output));
  124. }else {
  125. return $output;
  126. }
  127. }
  128. /**
  129. * HTTP Protocol defined status codes
  130. * @param int $num
  131. */
  132. static function send_http_status($code) {
  133. static $_status = array(
  134. // Informational 1xx
  135. 100 => 'Continue',
  136. 101 => 'Switching Protocols',
  137. // Success 2xx
  138. 200 => 'OK',
  139. 201 => 'Created',
  140. 202 => 'Accepted',
  141. 203 => 'Non-Authoritative Information',
  142. 204 => 'No Content',
  143. 205 => 'Reset Content',
  144. 206 => 'Partial Content',
  145. // Redirection 3xx
  146. 300 => 'Multiple Choices',
  147. 301 => 'Moved Permanently',
  148. 302 => 'Found', // 1.1
  149. 303 => 'See Other',
  150. 304 => 'Not Modified',
  151. 305 => 'Use Proxy',
  152. // 306 is deprecated but reserved
  153. 307 => 'Temporary Redirect',
  154. // Client Error 4xx
  155. 400 => 'Bad Request',
  156. 401 => 'Unauthorized',
  157. 402 => 'Payment Required',
  158. 403 => 'Forbidden',
  159. 404 => 'Not Found',
  160. 405 => 'Method Not Allowed',
  161. 406 => 'Not Acceptable',
  162. 407 => 'Proxy Authentication Required',
  163. 408 => 'Request Timeout',
  164. 409 => 'Conflict',
  165. 410 => 'Gone',
  166. 411 => 'Length Required',
  167. 412 => 'Precondition Failed',
  168. 413 => 'Request Entity Too Large',
  169. 414 => 'Request-URI Too Long',
  170. 415 => 'Unsupported Media Type',
  171. 416 => 'Requested Range Not Satisfiable',
  172. 417 => 'Expectation Failed',
  173. // Server Error 5xx
  174. 500 => 'Internal Server Error',
  175. 501 => 'Not Implemented',
  176. 502 => 'Bad Gateway',
  177. 503 => 'Service Unavailable',
  178. 504 => 'Gateway Timeout',
  179. 505 => 'HTTP Version Not Supported',
  180. 509 => 'Bandwidth Limit Exceeded'
  181. );
  182. if(array_key_exists($code,$_status)) {
  183. header('HTTP/1.1 '.$code.' '.$_status[$code]);
  184. }
  185. }
  186. }//类定义结束
  187. if( !function_exists ('mime_content_type')) {
  188. /**
  189. +------------------------------------------------ ----------
  190. * Get the mime_content type of the file
  191. +---------------------------------- --------------------------
  192. * @return string
  193. +---------------- ------------------------------------------
  194. */
  195. function mime_content_type($filename)
  196. {
  197. static $contentType = array(
  198. 'ai' => 'application/postscript',
  199. 'aif' => 'audio/x-aiff',
  200. 'aifc' => 'audio/x-aiff',
  201. 'aiff' => 'audio/x-aiff',
  202. 'asc' => 'application/pgp', //changed by skwashd - was text/plain
  203. 'asf' => 'video/x-ms-asf',
  204. 'asx' => 'video/x-ms-asf',
  205. 'au' => 'audio/basic',
  206. 'avi' => 'video/x-msvideo',
  207. 'bcpio' => 'application/x-bcpio',
  208. 'bin' => 'application/octet-stream',
  209. 'bmp' => 'image/bmp',
  210. 'c' => 'text/plain', // or 'text/x-csrc', //added by skwashd
  211. 'cc' => 'text/plain', // or 'text/x-c++src', //added by skwashd
  212. 'cs' => 'text/plain', //added by skwashd - for C# src
  213. 'cpp' => 'text/x-c++src', //added by skwashd
  214. 'cxx' => 'text/x-c++src', //added by skwashd
  215. 'cdf' => 'application/x-netcdf',
  216. 'class' => 'application/octet-stream',//secure but application/java-class is correct
  217. 'com' => 'application/octet-stream',//added by skwashd
  218. 'cpio' => 'application/x-cpio',
  219. 'cpt' => 'application/mac-compactpro',
  220. 'csh' => 'application/x-csh',
  221. 'css' => 'text/css',
  222. 'csv' => 'text/comma-separated-values',//added by skwashd
  223. 'dcr' => 'application/x-director',
  224. 'diff' => 'text/diff',
  225. 'dir' => 'application/x-director',
  226. 'dll' => 'application/octet-stream',
  227. 'dms' => 'application/octet-stream',
  228. 'doc' => 'application/msword',
  229. 'dot' => 'application/msword',//added by skwashd
  230. 'dvi' => 'application/x-dvi',
  231. 'dxr' => 'application/x-director',
  232. 'eps' => 'application/postscript',
  233. 'etx' => 'text/x-setext',
  234. 'exe' => 'application/octet-stream',
  235. 'ez' => 'application/andrew-inset',
  236. 'gif' => 'image/gif',
  237. 'gtar' => 'application/x-gtar',
  238. 'gz' => 'application/x-gzip',
  239. 'h' => 'text/plain', // or 'text/x-chdr',//added by skwashd
  240. 'h++' => 'text/plain', // or 'text/x-c++hdr', //added by skwashd
  241. 'hh' => 'text/plain', // or 'text/x-c++hdr', //added by skwashd
  242. 'hpp' => 'text/plain', // or 'text/x-c++hdr', //added by skwashd
  243. 'hxx' => 'text/plain', // or 'text/x-c++hdr', //added by skwashd
  244. 'hdf' => 'application/x-hdf',
  245. 'hqx' => 'application/mac-binhex40',
  246. 'htm' => 'text/html',
  247. 'html' => 'text/html',
  248. 'ice' => 'x-conference/x-cooltalk',
  249. 'ics' => 'text/calendar',
  250. 'ief' => 'image/ief',
  251. 'ifb' => 'text/calendar',
  252. 'iges' => 'model/iges',
  253. 'igs' => 'model/iges',
  254. 'jar' => 'application/x-jar', //added by skwashd - alternative mime type
  255. 'java' => 'text/x-java-source', //added by skwashd
  256. 'jpe' => 'image/jpeg',
  257. 'jpeg' => 'image/jpeg',
  258. 'jpg' => 'image/jpeg',
  259. 'js' => 'application/x-javascript',
  260. 'kar' => 'audio/midi',
  261. 'latex' => 'application/x-latex',
  262. 'lha' => 'application/octet-stream',
  263. 'log' => 'text/plain',
  264. 'lzh' => 'application/octet-stream',
  265. 'm3u' => 'audio/x-mpegurl',
  266. 'man' => 'application/x-troff-man',
  267. 'me' => 'application/x-troff-me',
  268. 'mesh' => 'model/mesh',
  269. 'mid' => 'audio/midi',
  270. 'midi' => 'audio/midi',
  271. 'mif' => 'application/vnd.mif',
  272. 'mov' => 'video/quicktime',
  273. 'movie' => 'video/x-sgi-movie',
  274. 'mp2' => 'audio/mpeg',
  275. 'mp3' => 'audio/mpeg',
  276. 'mpe' => 'video/mpeg',
  277. 'mpeg' => 'video/mpeg',
  278. 'mpg' => 'video/mpeg',
  279. 'mpga' => 'audio/mpeg',
  280. 'ms' => 'application/x-troff-ms',
  281. 'msh' => 'model/mesh',
  282. 'mxu' => 'video/vnd.mpegurl',
  283. 'nc' => 'application/x-netcdf',
  284. 'oda' => 'application/oda',
  285. 'patch' => 'text/diff',
  286. 'pbm' => 'image/x-portable-bitmap',
  287. 'pdb' => 'chemical/x-pdb',
  288. 'pdf' => 'application/pdf',
  289. 'pgm' => 'image/x-portable-graymap',
  290. 'pgn' => 'application/x-chess-pgn',
  291. 'pgp' => 'application/pgp',//added by skwashd
  292. 'php' => 'application/x-httpd-php',
  293. 'php3' => 'application/x-httpd-php3',
  294. 'pl' => 'application/x-perl',
  295. 'pm' => 'application/x-perl',
  296. 'png' => 'image/png',
  297. 'pnm' => 'image/x-portable-anymap',
  298. 'po' => 'text/plain',
  299. 'ppm' => 'image/x-portable-pixmap',
  300. 'ppt' => 'application/vnd.ms-powerpoint',
  301. 'ps' => 'application/postscript',
  302. 'qt' => 'video/quicktime',
  303. 'ra' => 'audio/x-realaudio',
  304. 'rar'=>'application/octet-stream',
  305. 'ram' => 'audio/x-pn-realaudio',
  306. 'ras' => 'image/x-cmu-raster',
  307. 'rgb' => 'image/x-rgb',
  308. 'rm' => 'audio/x-pn-realaudio',
  309. 'roff' => 'application/x-troff',
  310. 'rpm' => 'audio/x-pn-realaudio-plugin',
  311. 'rtf' => 'text/rtf',
  312. 'rtx' => 'text/richtext',
  313. 'sgm' => 'text/sgml',
  314. 'sgml' => 'text/sgml',
  315. 'sh' => 'application/x-sh',
  316. 'shar' => 'application/x-shar',
  317. 'shtml' => 'text/html',
  318. 'silo' => 'model/mesh',
  319. 'sit' => 'application/x-stuffit',
  320. 'skd' => 'application/x-koan',
  321. 'skm' => 'application/x-koan',
  322. 'skp' => 'application/x-koan',
  323. 'skt' => 'application/x-koan',
  324. 'smi' => 'application/smil',
  325. 'smil' => 'application/smil',
  326. 'snd' => 'audio/basic',
  327. 'so' => 'application/octet-stream',
  328. 'spl' => 'application/x-futuresplash',
  329. 'src' => 'application/x-wais-source',
  330. 'stc' => 'application/vnd.sun.xml.calc.template',
  331. 'std' => 'application/vnd.sun.xml.draw.template',
  332. 'sti' => 'application/vnd.sun.xml.impress.template',
  333. 'stw' => 'application/vnd.sun.xml.writer.template',
  334. 'sv4cpio' => 'application/x-sv4cpio',
  335. 'sv4crc' => 'application/x-sv4crc',
  336. 'swf' => 'application/x-shockwave-flash',
  337. 'sxc' => 'application/vnd.sun.xml.calc',
  338. 'sxd' => 'application/vnd.sun.xml.draw',
  339. 'sxg' => 'application/vnd.sun.xml.writer.global',
  340. 'sxi' => 'application/vnd.sun.xml.impress',
  341. 'sxm' => 'application/vnd.sun.xml.math',
  342. 'sxw' => 'application/vnd.sun.xml.writer',
  343. 't' => 'application/x-troff',
  344. 'tar' => 'application/x-tar',
  345. 'tcl' => 'application/x-tcl',
  346. 'tex' => 'application/x-tex',
  347. 'texi' => 'application/x-texinfo',
  348. 'texinfo' => 'application/x-texinfo',
  349. 'tgz' => 'application/x-gtar',
  350. 'tif' => 'image/tiff',
  351. 'tiff' => 'image/tiff',
  352. 'tr' => 'application/x-troff',
  353. 'tsv' => 'text/tab-separated-values',
  354. 'txt' => 'text/plain',
  355. 'ustar' => 'application/x-ustar',
  356. 'vbs' => 'text/plain', //added by skwashd - for obvious reasons
  357. 'vcd' => 'application/x-cdlink',
  358. 'vcf' => 'text/x-vcard',
  359. 'vcs' => 'text/calendar',
  360. 'vfb' => 'text/calendar',
  361. 'vrml' => 'model/vrml',
  362. 'vsd' => 'application/vnd.visio',
  363. 'wav' => 'audio/x-wav',
  364. 'wax' => 'audio/x-ms-wax',
  365. 'wbmp' => 'image/vnd.wap.wbmp',
  366. 'wbxml' => 'application/vnd.wap.wbxml',
  367. 'wm' => 'video/x-ms-wm',
  368. 'wma' => 'audio/x-ms-wma',
  369. 'wmd' => 'application/x-ms-wmd',
  370. 'wml' => 'text/vnd.wap.wml',
  371. 'wmlc' => 'application/vnd.wap.wmlc',
  372. 'wmls' => 'text/vnd.wap.wmlscript',
  373. 'wmlsc' => 'application/vnd.wap.wmlscriptc',
  374. 'wmv' => 'video/x-ms-wmv',
  375. 'wmx' => 'video/x-ms-wmx',
  376. 'wmz' => 'application/x-ms-wmz',
  377. 'wrl' => 'model/vrml',
  378. 'wvx' => 'video/x-ms-wvx',
  379. 'xbm' => 'image/x-xbitmap',
  380. 'xht' => 'application/xhtml+xml',
  381. 'xhtml' => 'application/xhtml+xml',
  382. 'xls' => 'application/vnd.ms-excel',
  383. 'xlt' => 'application/vnd.ms-excel',
  384. 'xml' => 'application/xml',
  385. 'xpm' => 'image/x-xpixmap',
  386. 'xsl' => 'text/xml',
  387. 'xwd' => 'image/x-xwindowdump',
  388. 'xyz' => 'chemical/x-xyz',
  389. 'z' => 'application/x-compress',
  390. 'zip' => 'application/zip',
  391. );
  392. $type = strtolower(substr(strrchr($filename, '.'),1));
  393. if(isset($contentType[$type])) {
  394. $mime = $contentType[$type];
  395. }else {
  396. $mime = 'application/octet-stream';
  397. }
  398. return $mime;
  399. }
  400. }
  401. if(!function_exists('image_type_to_extension'))
  402. {
  403. function image_type_to_extension($imagetype)
  404. {
  405. if(empty($imagetype)) return false;
  406. switch($imagetype)
  407. {
  408. case IMAGETYPE_GIF : return '.gif';
  409. case IMAGETYPE_JPEG : return '.jpg';
  410. case IMAGETYPE_PNG : return '.png';
  411. case IMAGETYPE_SWF : return '.swf';
  412. case IMAGETYPE_PSD : return '.psd';
  413. case IMAGETYPE_BMP : return '.bmp';
  414. case IMAGETYPE_TIFF_II : return '.tiff';
  415. case IMAGETYPE_TIFF_MM : return '.tiff';
  416. case IMAGETYPE_JPC : return '.jpc';
  417. case IMAGETYPE_JP2 : return '.jp2';
  418. case IMAGETYPE_JPX : return '.jpf';
  419. case IMAGETYPE_JB2 : return '.jb2';
  420. case IMAGETYPE_SWC : return '.swc';
  421. case IMAGETYPE_IFF : return '.aiff';
  422. case IMAGETYPE_WBMP : return '.wbmp';
  423. case IMAGETYPE_XBM : return '.xbm';
  424. default : return false;
  425. }
  426. }
  427. }
  428. ?>
复制代码

>>> 更多 php模拟登录 文章,专题链接:php模拟登录 php curl模拟登录教程大全



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!