PHP + Socket sends http requests so that the website can be filled with water. in essence, the request line, header information, and topic information can be assembled for reference to the it self-learning network.
The cookie information has a lot to do with the http request header. Be sure to pass the http request header information to the function.
01-msg.php
SetHeader ('accept: text/html, application/xhtml + xml, application/xml; q = 0.9, */*; q = 100 '); $ http-> setHeader ('Accept-Encoding: gzip, deflate'); $ http-> setHeader ('Accept-Language: zh-cn, zh; q = 0.8, en-us; q = 0.5, en; q = 0.3 '); $ http-> setHeader ('connection: keep-alive'); $ http-> setHeader ('cookie: hm_lvt_c7849bb40e146a37d411700cb7696e46 = 1371132935,1371551596, 1371552570; CNZZDATA1479 = cnzz_eid % hour % 253A % 252F % hour % 26 ntime % 3D1371559611% 26cnzz_a % 3D27% 26 retime % hour % 26sin % 3 Dhttp % 253A % 252F % hour % 252Fi % Hour % 252F % 26 ltime % 3D1371559611556% 26 rtime % 3D1; _ utma = response; _ utmz = 248211998.1371552579.2.2.utmcsr = verycd.com | utmccn = (referral) | utmcmd = referral | utmcct =/; response = 1371554752; post_action = repost; BAIDU_CLB_REFER = http % 3A % 2F % 2Fcwebmail.mail.163.com % 2Fjs5% 2 Fread % 2Freadhtml. jsp % 3 Fssid % %%253d % 26mid % 3D45% 3A1tbiLRFAhFEFoLvtCAAAsS % 26 color % 3D003399% 26 preventSetRead % 3Don % 26 font % 3D15; uchome_loginuser = http % E5 % 8D % 8F % E8 % AE; uchome _ refer = % 2Fspace. php % 3Fdo % 3Dpm % 26 filter % 3 Dnewpm; _ utmc = 248211998; sid = 9a48b201fb4d176a7188ef2a3560789651eb4766; member_id = 17822047; member_name = http % E5 % 8D % 8F % E8 % AE; mgroupId = 93; pass_hash = signature; rememberme = false; uchome_auth = signature % signature; uchome_sendmail = 1; uchome_checkpm = 1; _ utmb = 248211998.1.10.1371559612; dcm = 1 '); $ http-> setHeader ('referer: http://home.verycd.com/cp.php?ac=pm '); $ Http-> setHeader ('User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv: 21.0) Gecko/20100101 Firefox/123 '); $ msg = array ('formhash' => '4f23e777', 'message' => 'I am not filling the water, please allow', 'pmsubmit '=> 'true ', 'pmsubmit _ btn '=> 'put', 'refer' =>' http://home.verycd.com/space.php?do=pm&filter=privatepm ', 'Username' => 'http receiver'); file_put_contents ('./res.html ', $ http-> post ($ msg); echo' OK ';
Http. class. php
Conn ($ url); $ this-> setHeader ('host :'. $ this-> url ['host']);} // this method writes the request line protected function setLine ($ method) {$ this-> line [0] = $ method. ''. $ this-> url ['path']. '? '. $ This-> url ['query']. ''. $ this-> version;} // this method writes the header information public function setHeader ($ headerline) {$ this-> header [] = $ headerline ;} // this method writes the subject information protected function setBody ($ body) {$ this-> body [] = http_build_query ($ body );} // Connect url public function conn ($ url) {$ this-> url = parse_url ($ url); // judge port if (! Isset ($ this-> url ['port']) {$ this-> url ['port'] = 80;} // judge query if (! Isset ($ this-> url ['query']) {$ this-> url ['query'] = '';} $ this-> fh = fsockopen ($ this-> url ['host'], $ this-> url ['port'], $ this-> errno, $ this-> errstr, 3);} // Construct the public function get () {$ this-> setLine ('get') of the get request '); $ this-> request (); return $ this-> response;} // Construct The post query data public function post ($ body = array ()) {$ this-> setLine ('post'); // Design content-type $ this-> setHeader ('content-type: application/x-www -Form-urlencoded '); // design the subject information, which is different from GET. $ this-> setBody ($ body ); // calculate content-length $ this-> setHeader ('content-length :'. strlen ($ this-> body [0]); $ this-> request (); return $ this-> response ;}// the public function request () is actually requested () {// put the request line, header information, and object information in an array to facilitate splicing $ req = array_merge ($ this-> line, $ this-> header, array (''), $ this-> body, array (''); // print_r ($ req); $ req = implode (self: CRLF, $ req); // echo $ req; e Xit; fwrite ($ this-> fh, $ req); while (! Feof ($ this-> fh) {$ this-> response. = fread ($ this-> fh, 1024) ;}$ this-> close (); // close the connection} // close the connection public function close () {fclose ($ this-> fh) ;}/ * $ url =' http://news.163.com/13/0613/09/9187CJ4C00014JB6.html '; $ Http = new Http ($ url); echo $ http-> get (); * // * set_time_limit (0); $ url =' http://liangyue.net.cn/0523/ ? '; For ($ I = 1; $ I <100; $ I ++) {$ str = str_shuffle ('abcdefghijklmnopqrst0776656'); $ tit = substr ($ str, 0, 5); $ con = substr ($ str, 6, 8); $ http = new Http ($ url); $ http-> post (array ('tit' => $ tit, 'con '=> $ con, 'submit' => 'login'); echo $ tit, '----------- ', $ con ,'
'; Usleep (2000 );}*/