<?phpfunction posttohost($url, $data) { $url = parse_url($url); if (!$url) return "couldn't parse url"; if (!isset($url['port'])) { $url['port'] = ""; } if (!isset($url['query'])) { $url['query'] = ""; } $encoded = ""; while (list($k,$v) = each($data)) { $encoded .= ($encoded ? "&" : ""); $encoded .= rawurlencode($k)."=".rawurlencode($v); } $fp = fsockopen($url['host'], $url['port'] ? $url['port'] : 80); if (!$fp) return "Failed to open socket to $url[host]"; fputs($fp, sprintf("POST %s%s%s HTTP/1.0\n", $url['path'], $url['query'] ? "?" : "", $url['query']));# fputs($fp, "Host: $url[host]\n"); fputs($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE5.0; Windows NT 5.0)\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); fputs($fp, "Accept: text/html\n"); fputs($fp, "Content-length: " . strlen($encoded) . "\n"); fputs($fp, "Connection: close\n\n"); fputs($fp, "$encoded\n"); $line = fgets($fp,1024); if (!eregi("^HTTP/1\.. 200", $line)) return; $results = ""; $inheader = 1; while(!feof($fp)) { $line = fgets($fp,1024); if ($inheader && ($line == "\n" || $line == "\r\n")) { $inheader = 0; } elseif (!$inheader) { $results .= $line; } } fclose($fp); return $results;}function gettohost($url) { $url = parse_url($url); if (!$url) return "couldn't parse url"; if (!isset($url['port'])) { $url['port'] = ""; } if (!isset($url['query'])) { $url['query'] = ""; } $fp = fsockopen($url['host'], $url['port'] ? $url['port'] : 80); if (!$fp) return "Failed to open socket to $url[host]"; fputs($fp, sprintf("GET %s%s%s HTTP/1.0\n", $url['path'], $url['query'] ? "?" : "", $url['query']));# fputs($fp, "Host: $url[host]\n"); fputs($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE5.0; Windows NT 5.0)\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); fputs($fp, "Accept: text/html\n");# fputs($fp, "Content-length: " . strlen($encoded) . "\n"); fputs($fp, "Connection: close\n\n"); $line = fgets($fp,1024); if (!eregi("^HTTP/1\.. 200", $line)) return; $results = ""; $inheader = 1; while(!feof($fp)) { $line = fgets($fp,1024); if ($inheader && ($line == "\n" || $line == "\r\n")) { $inheader = 0; } elseif (!$inheader) { $results .= $line; } } fclose($fp); return $results;}$id = "999999999";$password = "1234";$ip = "172.24.5.28";$url = "[url]http://172.31.130.251/servlet/scpservlet.UserDataReqLoginServlet[/url]";#$url = "[url]http://localhost/test2.php?id=1[/url]";$data = array( 'id' => $id, 'inputpassword' => '', 'servicetype' => '201+', 'ip' => $ip, 'password' => $password, 'languagetype' => '0', 'operatingSystem' => '1', 'httpIp' => '211.95.166.57', 'RadiusVision' => '1', 'Domain' => 'uestc' );$results = posttohost($url, $data);echo $results;$url="[url]http://172.31.130.251/ClientProcess.jspMsgType=100&ISNNO=1000&LocalIP=$ip&UserName=$id&olduserip=$ip&httpIp=211.95.166.57&isPNP=False[/url]";$results = gettohost($url);echo $results;?>
下面是引用零点坐标于2005-06-13 22:50发表的:主要是lt上了外网以后就不能访问内网,不然可以考虑把php登陆客户端放在服务器上,不过这样的话会保持一个窗口不关,不断刷新,和那个html的上网客户端又差不多了。