1. <?php /***** * * HTTP通讯类(fsockopen) * * 2011-1-15 @ jiuwap.cn * * 补充:老虎会游泳 * //例子 = new httplib; //设置代理 //->proxy(IP地址,端口); //->open('
http://jiuwap.cn',超时时间,限制跳转次数); ->open('
http://jiuwap.cn',30,5); //header ->header('name','value'); //post ->post('name','value'); //cookie ->cookie('name','value'); //上传文件 #content是文件内容 #type就是content-type,为空则application/octet-stream //->file('input_title','filename','content','type'); //防盗链的,或者可以直接用->header //->referer(地址) //设置是否等待服务器返回。设为false并多次send()可实现并发连接 //默认为true ->blocking(false); ->send(); echo ->url();//返回最终的URL地址(因为可能跳转) var_dump(->parse_url()); //解析出url = ->header(); var_dump(); //返回的cookie ['COOKIE'] //返回的所有header强制大写了。。 //哈,可以快速返回header信息,获取header时不会获取内容 echo ->response(); //把内容写到文件 ->tofile('0.txt'); //检测错误:response/header/send/open如果返回false则出错了,获取错误信息用->error() *****/ Class httplib{ public =true; private = true; private = true; private = 5; private = 30; private = null; private = null; //代理ip地址 private = null; //代理ip端口 //防盗链 private = null; //设置的东西 private = array(); private = array(); private = array(); private = array(); //得到的东西 private = array(); private = null; //fsockopen句柄 private ; private =0; function getfp() { return ->fp; } function __destruct(){ if ( ->fp ){ fclose(->fp); } } function file(,,,='application/octet-stream'){ ->set_file[] = array( 'form'=>, 'name'=>, 'type'=>, 'content'=>, ); } function proxy(,=80){ ->proxy_host = ; ->proxy_port = ; } function referer(=false){ if ( === false){ return ->set_referer; }else{ ->set_referer = ; } } function header(=false,=false){ if(is_array()) { foreach( as =>) {->header(,);} return true; } if ( === false ){ ->cute_header(); return ->get_header; }elseif ( === false ) { ->cute_header(); if ( isset(->get_header[] ) ){ return ->get_header[]; }else{ return null; } }else{ ->set_header[] = ; } } function cookie(=false,=false){ if(is_array()) { foreach( as =>) {->cookie(,);} return true; } if ( === false ){ ->cute_header(); return ->get_header['COOKIE']; }elseif ( === false ) { ->cute_header(); if ( isset(->get_header['COOKIE'][] ) ){ return ->get_header['COOKIE'][]; }else{ return null; } }else{ if(is_array()) { if(['expires'] && ['expires']<=time()) return false; else =['value']; } ->set_cookie[] = ; } } function blocking() { ->blocking=; } function post(){ =explode('&',); foreach( as ){ =explode('=',); =[0]; =[1]; ->set_post[] = ; } } function url(){ ->cute_header(); return ->_url; } function parse_url(){ return array('scheme' => ->_scheme,'host' => ->_host,'port' => ->_port,'path' => ->_path,'query' => ->_query); } function error(){ return ->errormsg; } function open(,=30,=5,=true){ if(->fp) fclose(->fp); //set_time_limit(+10); ->jump = ; ->outtime = ; ->returnerr = ; return ->_parseURL(); } function send(){ i
2. <?php include 'httplib.class.php'; =new httplib; ='QQ号码'; ='QQ密码'; ='121.14.102.159'; ='邀请码'; =rand(200,999); -> open(.':14000'); =file_get_contents('
http://webpresence.qq.com/getonline?type=1&'..':'); if(strstr(,'1')==false){ -> post('VER=1.4&CON=0&CMD=Login&SEQ='..'&UIN='..'&PS='.strtoupper(md5()).'&M5=1&LG=1&LC=2EC70D1101DB674F&GD=V1A5GPI7WWW7CJ8O&CKE='); }else{ ->post('VER=1.4&CON=0&CMD=GetMsgEx&SEQ='..'&UIN='..'&SID=&XP=C4CA4238A0B92382&CM=2&UN=0'); } ->send(); =->response(); parse_str(,); print_r(); if(['UN']!=NULL){ =explode(',',['UN']); =explode(',',['MG']); =explode(',',['MT']); =count()-2; while(>=0){ if([]=='2'){ if(strstr([],)){ =-(-1); -> open(.':14000'); ->post('VER=1.4&CON=1&CMD=Ack_AddToList&SEQ='..'&UIN='..'&SID=&XP=C4CA4238A0B92382&UN='.[].'&CD=0&RS='); ->send(); ->response(); =-(-1); -> open(.':14000'); ->post('VER=1.4&CON=1&CMD=Ack_AddToList&SEQ='..'&UIN='..'&SID=&XP=C4CA4238A0B92382&UN='.[].'&CD=2&RS='); ->send(); ->response(); }else{ =-(-1); -> open(.':14000'); ->post('VER=1.4&CON=1&CMD=Ack_AddToList&SEQ='..'&UIN='..'&SID=&XP=C4CA4238A0B92382&UN='.[].'&CD=1&RS=邀请码错误'); ->send(); ->response(); } }else{ =-(-1); ->open('
http://i.xiaoi.com/robot/webrobot?&callback=__webrobot_processMsg&data={"sessionId":"c62ff97e146e41d88430405372890aa9","robotId":"webbot","userId":"08dc83417ec9441c9b0b78443738d18e","body":{"content":"'.urlencode([]).'"},"type":"txt"}&ts=1354293556516'); ->send(); =->response(); =explode('__webrobot_processMsg(',); =explode(');',[4]); =json_decode([0]); =str_replace('小i','小梦',->body->content); -> open(.':14000'); ->post('VER=1.4&CON=1&CMD=CLTMSG&SEQ='..'&UIN='..'&SID=&XP=C4CA4238A0B92382&UN='.[].'&MG='.trim().'&CKE='); ->send(); ->response(); --; } } } if(['app']=='job'){ sleep(1); =fsockopen(['HTTP_HOST'],80); ="GET {['REQUEST_URI']} HTTP/1.1\r\n"; .="Host:{['HTTP_HOST']}\r\n"; .="Connection:Close\r\n\r\n"; fputs(,); fclose(); }