Proxy.php-梧桐雨的遨游内网漫游
来源:互联网 发布:centos系统备份 编辑:程序博客网 时间:2024/05/01 01:14
<?php//@KaiyiZhang Github//////////////////////////////////////////////////////////////////////////////////// Description:// Script to redirect the request http://host/proxy.php?url=http://someUrl// to http://someUrl .//// This script can be used to circumvent javascript's security requirements// which prevent a URL from an external web site being called.//// Author: Nedjo Rogers////////////////////////////////////////////////////////////////////////////////// read in the variablesif(array_key_exists('HTTP_SERVERURL', $_SERVER)){ $onlineresource=$_SERVER['HTTP_SERVERURL']; }else{ $onlineresource=$_REQUEST['url']; }$parsed = parse_url($onlineresource);$host = @$parsed["host"];$path = @$parsed["path"] . "?" . @$parsed["query"];if(empty($host)) { $host = "localhost";}$port = @$parsed['port'];if(empty($port)){ $port="80";}$contenttype = @$_REQUEST['contenttype'];if(empty($contenttype)) { $contenttype = "text/html";}$data = @$GLOBALS["HTTP_RAW_POST_DATA"];// define content typeheader("Content-type: " . $contenttype);if(empty($data)) { $result = send_request();}else { // post XML $posting = new HTTP_Client($host, $port, $data); $posting->set_path($path); $result = $posting->send_request();}// strip leading text from result and output result$len=strlen($result);$pos = strpos($result, "<");if($pos > 1) { $result = substr($result, $pos, $len);}//$result = str_replace("xlink:","",$result);echo $result;// define class with functions to open socket and post XML// from http://www.phpbuilder.com/annotate/message.php3?id=1013274 by Richard Hundtclass HTTP_Client { var $host; var $path; var $port; var $data; var $socket; var $errno; var $errstr; var $timeout; var $buf; var $result; var $agent_name = "MyAgent"; //Constructor, timeout 30s function HTTP_Client($host, $port, $data, $timeout = 30) { $this->host = $host; $this->port = $port; $this->data = $data; $this->timeout = $timeout; } //Opens a connection function connect() { $this->socket = fsockopen($this->host, $this->port, $this->errno, $this->errstr, $this->timeout ); if(!$this->socket) return false; else return true; } //Set the path function set_path($path) { $this->path = $path; } //Send request and clean up function send_request() { if(!$this->connect()) { return false; } else { $this->result = $this->request($this->data); return $this->result; } } function request($data) { $this->buf = ""; fwrite($this->socket, "POST $this->path HTTP/1.0\r\n". "Host:$this->host\r\n". "User-Agent: $this->agent_name\r\n". "Content-Type: application/html\r\n". "Content-Length: ".strlen($data). "\r\n". "\r\n".$data. "\r\n" ); while(!feof($this->socket)) $this->buf .= fgets($this->socket, 2048); $this->close(); return $this->buf; } function close() { fclose($this->socket); } } function send_request() { global $onlineresource; $ch = curl_init(); $timeout = 5; // set to zero for no timeout // fix to allow HTTPS connections with incorrect certificates curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt ($ch, CURLOPT_URL,$onlineresource); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt ($ch, CURLOPT_ENCODING , "gzip, deflate"); $file_contents = curl_exec($ch); curl_close($ch); $lines = array(); $lines = explode("\n", $file_contents); if(!($response = $lines)) { echo "Unable to retrieve file '$service_request'"; } $response = implode("",$response); return $response;}?>
0 0
- Proxy.php-梧桐雨的遨游内网漫游
- 疯子求助-梧桐雨解答的jsp proxy
- 遨游
- PHP的代理Proxy模式
- PHP.INI配置文件漫游
- 遨游浏览器的操作技巧
- 大数据时代的遨游
- Ubuntu安装squid作为内网的代理服务器(Proxy)的简单配制
- Proxy模式及Java内建的动态代理机制
- 如何使用遨游的viewpage插件工具
- IE 8的发布 促使遨游升级
- 遨游浏览器2与Google的chrome
- 这是遨游的BUG吗?
- eWebEditor不支持IE8IE7火狐遨游的解决方法
- mysql-proxy解决只能内网访问线上数据库问题
- Linux局域网内配置使用proxy连接外网
- 图片的漫游
- OpenGL漫游的实现
- 深入理解JVM(五)-Java类加载器
- 前端头部标签汇总
- 趣写算法系列之--匈牙利算法
- JDK 动态代理的简单理解
- js Eventutil内容
- Proxy.php-梧桐雨的遨游内网漫游
- Jenkins的分布式构建及部署——节点
- 图像插值
- 【BZOJ3049】Island Travels,SPFA预处理+状态压缩DP
- 设置view的颜色渐变的方法
- 干货文章整理(建议有时间多看几遍)
- PL/SQL developer 使用技巧
- Eclipse编译apk提示Unable to execute dex: Multiple dex files define 解决方法
- 35 虚函数与多态(二)