<?php
- $infoary= array("username"=>"username","password"=>"password");
- $encodestr= encode($infoary);
- $fp= fsockopen("localhost",80,$errno,$errmsg);
- $params.= "POST /admin/index.php?action=login HTTP/1.1/n";
- $params.= "Host: localhost/n";
- $params.= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5/n";
- $params.= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8/n";
- $params.= "Accept-Language: zh-cn,zh;q=0.5/n";
- $params.= "Accept-Encoding: gzip,deflate/n";
- $params.= "Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7/n";
- $params.= "Keep-Alive: 300/n";
- $params.= "Connection: keep-alive/n";
- $params.= "Referer: http:/index.php/n";
- $params.= "Content-Type: application/x-www-form-urlencoded/n";
- $params.= "Content-Length: ".strlen($encodestr)."/n/n";
- $params.= $encodestr;
- fwrite($fp, $params);
- while(!feof($fp)){
- echofgets($fp, 4096);
- }
- fclose($fp);
- functionencode($params)
- {
- $i= 0;
- foreach($paramsas$k=> $v){
- $i++;
- $str.= rawurlencode($k)."=".rawurlencode($v);
- if($i< count($params))$str.= "&";
- }
- return$str;
- }