search
HomeBackend DevelopmentPHP Tutorial简略的php代理 Simple PHP Proxy

简单的php代理 Simple PHP Proxy

实例:http://www.ikeepstudying.com/tools/proxy/

?

index.php

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><script type="text/javascript" language="javascript">// I want to use json2.js because it allows me to format stringified JSON with// pretty indents, so let's nuke any existing browser-specific JSON parser.window.JSON = null;</script><script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script><script type="text/javascript" src="http://benalman.com/code/projects/php-simple-proxy/shared/json2.js"></script><script>	(function($){$(document).ready(function(e)	{		// Handle form submit.		$('#params').submit(function(){			var proxy = 'proxy.php', url = proxy + '?' + $('#params').serialize();						// Update some stuff.			$('#request').html( $('<a/>').attr( 'href', url ).text( url ) );			$('#response').html( 'Loading...' );						// Test to see if HTML mode.			if ( /mode=native/.test( url ) ) 			{			  	// Make GET request.			  	$.get( url, function(data)			  	{			  		$('#response')			  		.html( '<pre class='brush:php;toolbar:false;'>' )			  		.find( 'pre' )			  		.text( data );			  	});			} 			else 			{			  	// Make JSON request.				$.getJSON( url, function(data)				{			  		$('#response')			  		.html( '<pre class="brush:js"/>' )			  		.find( 'pre' )					.text( JSON.stringify( data, null, 2 ) );			  	});			}						// Prevent default form submit action.			return false;		});	  	  	// Submit the form on page load if ?url= is passed into the example page.	  	if ( $('#url').val() !== '' ) $('#params').submit();	  	  	// Disable AJAX caching.	  	$.ajaxSetup({ cache: false });	  	  	// Disable dependent checkboxes as necessary.	  	$('input:radio').click(function(){			var that = $(this),	  		c1 = 'dependent-' + that.attr('name'),	  		c2 = c1 + '-' + that.val();				that.closest('form')		  	.find( '.' + c1 + ' input' )			.attr( 'disabled', 'disabled' )		    .end()		  	.find( '.' + c2 + ' input' )			.removeAttr( 'disabled' );	 	});	  	  	// Clicking sample remote urls should populate the "Remote URL" box.	  	$('#sample a').click(function(){			$('#url').val( $(this).attr( 'href' ) );	    	return false;	  	});			});})($staff)</script> <form action="" method="get" id="params">  <div>    <label>      <b>Remote URL</b>      <input type="text" value="" name="url" class="text" id="url" style="width:90%" />    </label>  </div>  <p id="sample">    ..or try these sample Remote URLs:    <a href="http://github.com/">GitHub</a>,    <a href="http://github.com/cowboy/php-simple-proxy/raw/master/examples/simple/json_sample.js">a sample JSON (not JSONP) request</a>,    <a href="http://github.com/omg404errorpage">a 404 error page</a>  </p>  <div>    <label>      <input type="radio" disabled="disabled" value="native" name="mode">      Native <i>(disabled by default)</i>    </label>  </div>  <div>    <label>      <input type="radio" disabled="disabled" checked="checked" value="json" name="mode">      JSON    </label>  </div>  <div class="dependent-mode dependent-mode-json indent">    <div>      <label>        <input type="checkbox" checked="checked" value="1" name="full_headers">        Full Headers      </label>    </div>    <div>      <label>        <input type="checkbox" checked="checked" value="1" name="full_status">        Full Status      </label>    </div>  </div>  <input type="submit" value="Submit" name="submit" class="submit"></form><h3 id="Request-URL">Request URL</h3><p id="request">N/A, click Submit!</p><h3 id="Simple-PHP-Proxy-response">Simple PHP Proxy response</h3><div id="response">N/A, click Submit!</div>

?

proxy.php

<?PHP// Script: Simple PHP Proxy: Get external HTML, JSON and more!//// *Version: 1.6, Last updated: 1/24/2009*// // Project Home - http://benalman.com/projects/php-simple-proxy/// GitHub       - http://github.com/cowboy/php-simple-proxy/// Source       - http://github.com/cowboy/php-simple-proxy/raw/master/ba-simple-proxy.php// // About: License// // Copyright (c) 2010 "Cowboy" Ben Alman,// Dual licensed under the MIT and GPL licenses.// http://benalman.com/about/license/// // About: Examples// // This working example, complete with fully commented code, illustrates one way// in which this PHP script can be used.// // Simple - http://benalman.com/code/projects/php-simple-proxy/examples/simple/// // About: Release History// // 1.6 - (1/24/2009) Now defaults to JSON mode, which can now be changed to//       native mode by specifying ?mode=native. Native and JSONP modes are//       disabled by default because of possible XSS vulnerability issues, but//       are configurable in the PHP script along with a url validation regex.// 1.5 - (12/27/2009) Initial release// // Topic: GET Parameters// // Certain GET (query string) parameters may be passed into ba-simple-proxy.php// to control its behavior, this is a list of these parameters. // //   url - The remote URL resource to fetch. Any GET parameters to be passed//     through to the remote URL resource must be urlencoded in this parameter.//   mode - If mode=native, the response will be sent using the same content//     type and headers that the remote URL resource returned. If omitted, the//     response will be JSON (or JSONP). <Native requests> and <JSONP requests>//     are disabled by default, see <Configuration Options> for more information.//   callback - If specified, the response JSON will be wrapped in this named//     function call. This parameter and <JSONP requests> are disabled by//     default, see <Configuration Options> for more information.//   user_agent - This value will be sent to the remote URL request as the//     `User-Agent:` HTTP request header. If omitted, the browser user agent//     will be passed through.//   send_cookies - If send_cookies=1, all cookies will be forwarded through to//     the remote URL request.//   send_session - If send_session=1 and send_cookies=1, the SID cookie will be//     forwarded through to the remote URL request.//   full_headers - If a JSON request and full_headers=1, the JSON response will//     contain detailed header information.//   full_status - If a JSON request and full_status=1, the JSON response will//     contain detailed cURL status information, otherwise it will just contain//     the `http_code` property.// // Topic: POST Parameters// // All POST parameters are automatically passed through to the remote URL// request.// // Topic: JSON requests// // This request will return the contents of the specified url in JSON format.// // Request:// // > ba-simple-proxy.php?url=http://example.com/// // Response:// // > { "contents": "<html>...</script>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
华为GT3 Pro和GT4的差异是什么?华为GT3 Pro和GT4的差异是什么?Dec 29, 2023 pm 02:27 PM

许多用户在选择智能手表的时候都会选择的华为的品牌,其中华为GT3pro和GT4都是非常热门的选择,不少用户都很好奇华为GT3pro和GT4有什么区别,下面就就给大家介绍一下二者。华为GT3pro和GT4有什么区别一、外观GT4:46mm和41mm,材质是玻璃表镜+不锈钢机身+高分纤维后壳。GT3pro:46.6mm和42.9mm,材质是蓝宝石玻璃表镜+钛金属机身/陶瓷机身+陶瓷后壳二、健康GT4:采用最新的华为Truseen5.5+算法,结果会更加的精准。GT3pro:多了ECG心电图和血管及安

VUE3怎么使用JSON编辑器VUE3怎么使用JSON编辑器May 12, 2023 pm 05:34 PM

1、先看看效果图,可以自行选择展示效果2、这是我在vue3项目中使用的JSON编辑器,首先引入第三方插件npminstalljson-editor-vue3yarnaddjson-editor-vue33、引入到项目中//导入模块importJsonEditorVuefrom&#39;json-editor-vue3&#39;//注册组件components:{JsonEditorVue},4、一般后端返回的是会将JSON转为String形式我们传给后端也是通过这种形式,就可以通

SpringBoot之Json的序列化和反序列化问题怎么解决SpringBoot之Json的序列化和反序列化问题怎么解决May 12, 2023 pm 04:07 PM

控制json序列化/反序列化1.@JsonIgnoreProperties的用法@JsonIgnoreProperties(value={"prop1","prop2"})用来修饰Pojo类,在序列化和反序列化的时候忽略指定的属性,可以忽略一个或多个属性.@JsonIgnoreProperties(ignoreUnknown=true)用来修饰Pojo类,在反序列化的时候忽略那些无法被设置的属性,包括无法在构造子设置和没有对应的setter方法.2.@Js

修复:截图工具在 Windows 11 中不起作用修复:截图工具在 Windows 11 中不起作用Aug 24, 2023 am 09:48 AM

为什么截图工具在Windows11上不起作用了解问题的根本原因有助于找到正确的解决方案。以下是截图工具可能无法正常工作的主要原因:对焦助手已打开:这可以防止截图工具打开。应用程序损坏:如果截图工具在启动时崩溃,则可能已损坏。过时的图形驱动程序:不兼容的驱动程序可能会干扰截图工具。来自其他应用程序的干扰:其他正在运行的应用程序可能与截图工具冲突。证书已过期:升级过程中的错误可能会导致此issu简单的解决方案这些适合大多数用户,不需要任何特殊的技术知识。1.更新窗口和Microsoft应用商店应用程

Java怎么调用接口获取json数据解析后保存到数据库Java怎么调用接口获取json数据解析后保存到数据库May 14, 2023 am 10:58 AM

Java调用接口获取json数据保存到数据库1.在yml文件中配置自己定义的接口URL//自己定义的JSON接口URLblacklist_data_url:接口URL2.在Controller中添加请求方法和路径/***@Title:查询*@Description:查询车辆的记录*@Author:半度纳*@Date:2022/9/2717:33*/@GetMapping("/Blacklist")publicvoidselectBlacklist(){booleana=imB

深入解析JWT(JSON Web Token)的原理及用法深入解析JWT(JSON Web Token)的原理及用法Jan 10, 2023 am 10:55 AM

本篇文章给大家带来了关于JWT的相关知识,其中主要介绍了什么是JWT?JWT的原理以及用法是什么?感兴趣的朋友,下面一起来看一下吧,希望对大家有帮助。

php输出json无法解析的原因和解决方法【总结】php输出json无法解析的原因和解决方法【总结】Mar 23, 2023 pm 04:35 PM

PHP作为一种常见的编程语言,在web开发中使用广泛,其与前端交互的方式也多种多样。其中,输出Json数据是一种常见的交互方式,但有时候会碰到Json无法解析的问题。为什么会出现无法解析的情况呢?下面列举了几个可能的原因。

php如何将xml转为json格式?3种方法分享php如何将xml转为json格式?3种方法分享Mar 22, 2023 am 10:38 AM

当我们处理数据时经常会遇到将XML格式转换为JSON格式的需求。PHP有许多内置函数可以帮助我们执行这个操作。在本文中,我们将讨论将XML格式转换为JSON格式的不同方法。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!