国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Maison développement back-end tutoriel php 簡略的php代理 Simple PHP Proxy

簡略的php代理 Simple PHP Proxy

Jun 13, 2016 am 11:57 AM
gt json lt the url

簡單的php代理 Simple PHP Proxy

實(shí)例: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>Request URL</h3><p id="request">N/A, click Submit!</p><h3>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>...</html>", "headers": {...}, "status": {...} }// // JSON object properties:// //   contents - (String) The contents of the remote URL resource.//   headers - (Object) A hash of HTTP headers returned by the remote URL//     resource.//   status - (Object) A hash of status codes returned by cURL.// // Topic: JSONP requests// // This request will return the contents of the specified url in JSONP format// (but only if $enable_jsonp is enabled in the PHP script).// // Request:// // > ba-simple-proxy.php?url=http://example.com/&callback=foo// // Response:// // > foo({ "contents": "<html>...</html>", "headers": {...}, "status": {...} })// // JSON object properties:// //   contents - (String) The contents of the remote URL resource.//   headers - (Object) A hash of HTTP headers returned by the remote URL//     resource.//   status - (Object) A hash of status codes returned by cURL.// // Topic: Native requests// // This request will return the contents of the specified url in the format it// was received in, including the same content-type and other headers (but only// if $enable_native is enabled in the PHP script).// // Request:// // > ba-simple-proxy.php?url=http://example.com/&mode=native// // Response:// // > <html>...</html>// // Topic: Notes// // * Assumes magic_quotes_gpc = Off in php.ini// // Topic: Configuration Options// // These variables can be manually edited in the PHP file if necessary.// //   $enable_jsonp - Only enable <JSONP requests> if you really need to. If you//     install this script on the same server as the page you're calling it//     from, plain JSON will work. Defaults to false.//   $enable_native - You can enable <Native requests>, but you should only do//     this if you also whitelist specific URLs using $valid_url_regex, to avoid//     possible XSS vulnerabilities. Defaults to false.//   $valid_url_regex - This regex is matched against the url parameter to//     ensure that it is valid. This setting only needs to be used if either//     $enable_jsonp or $enable_native are enabled. Defaults to '/.*/' which//     validates all URLs.// // ############################################################################// Change these configuration options if needed, see above descriptions for info.$enable_jsonp    = false;$enable_native   = false;$valid_url_regex = '/.*/';// ############################################################################$url = $_GET['url'];if ( !$url ) {    // Passed url not specified.  $contents = 'ERROR: url not specified';  $status = array( 'http_code' => 'ERROR' );  } else if ( !preg_match( $valid_url_regex, $url ) ) {    // Passed url doesn't match $valid_url_regex.  $contents = 'ERROR: invalid url';  $status = array( 'http_code' => 'ERROR' );  } else {  $ch = curl_init( $url );    if ( strtolower($_SERVER['REQUEST_METHOD']) == 'post' ) {    curl_setopt( $ch, CURLOPT_POST, true );    curl_setopt( $ch, CURLOPT_POSTFIELDS, $_POST );  }    if ( $_GET['send_cookies'] ) {    $cookie = array();    foreach ( $_COOKIE as $key => $value ) {      $cookie[] = $key . '=' . $value;    }    if ( $_GET['send_session'] ) {      $cookie[] = SID;    }    $cookie = implode( '; ', $cookie );        curl_setopt( $ch, CURLOPT_COOKIE, $cookie );  }    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );  curl_setopt( $ch, CURLOPT_HEADER, true );  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );    curl_setopt( $ch, CURLOPT_USERAGENT, $_GET['user_agent'] ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] );    list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 );    $status = curl_getinfo( $ch );    curl_close( $ch );}// Split header text into an array.$header_text = preg_split( '/[\r\n]+/', $header );if ( $_GET['mode'] == 'native' ) {  if ( !$enable_native ) {    $contents = 'ERROR: invalid mode';    $status = array( 'http_code' => 'ERROR' );  }    // Propagate headers to response.  foreach ( $header_text as $header ) {    if ( preg_match( '/^(?:Content-Type|Content-Language|Set-Cookie):/i', $header ) ) {      header( $header );    }  }    print $contents;  } else {    // $data will be serialized into JSON data.  $data = array();    // Propagate all HTTP headers into the JSON data object.  if ( $_GET['full_headers'] ) {    $data['headers'] = array();        foreach ( $header_text as $header ) {      preg_match( '/^(.+?):\s+(.*)$/', $header, $matches );      if ( $matches ) {        $data['headers'][ $matches[1] ] = $matches[2];      }    }  }    // Propagate all cURL request / response info to the JSON data object.  if ( $_GET['full_status'] ) {    $data['status'] = $status;  } else {    $data['status'] = array();    $data['status']['http_code'] = $status['http_code'];  }    // Set the JSON data object contents, decoding it from JSON if possible.  $decoded_json = json_decode( $contents );  $data['contents'] = $decoded_json ? $decoded_json : $contents;    // Generate appropriate content-type header.  $is_xhr = strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';  header( 'Content-type: application/' . ( $is_xhr ? 'json' : 'x-javascript' ) );    // Get JSONP callback.  $jsonp_callback = $enable_jsonp && isset($_GET['callback']) ? $_GET['callback'] : null;    // Generate JSON/JSONP string  $json = json_encode( $data );    print $jsonp_callback ? "$jsonp_callback($json)" : $json;  }

?

實(shí)例:http://www.ikeepstudying.com/tools/proxy/

原文:http://benalman.com/projects/php-simple-proxy/

?

?

?

Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefa?on, veuillez contacter admin@php.cn

Outils d'IA chauds

Undress AI Tool

Undress AI Tool

Images de déshabillage gratuites

Undresser.AI Undress

Undresser.AI Undress

Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover

AI Clothes Remover

Outil d'IA en ligne pour supprimer les vêtements des photos.

Clothoff.io

Clothoff.io

Dissolvant de vêtements AI

Video Face Swap

Video Face Swap

échangez les visages dans n'importe quelle vidéo sans effort grace à notre outil d'échange de visage AI entièrement gratuit?!

Outils chauds

Bloc-notes++7.3.1

Bloc-notes++7.3.1

éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise

SublimeText3 version chinoise

Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1

Envoyer Studio 13.0.1

Puissant environnement de développement intégré PHP

Dreamweaver CS6

Dreamweaver CS6

Outils de développement Web visuel

SublimeText3 version Mac

SublimeText3 version Mac

Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Sujets chauds

Tutoriel PHP
1502
276
Après 2 mois, le robot humano?de Walker S peut plier les vêtements Après 2 mois, le robot humano?de Walker S peut plier les vêtements Apr 03, 2024 am 08:01 AM

Rédacteur en chef du Machine Power Report : Wu Xin La version domestique de l'équipe robot humano?de + grand modèle a accompli pour la première fois la tache d'exploitation de matériaux flexibles complexes tels que le pliage de vêtements. Avec le dévoilement de Figure01, qui intègre le grand modèle multimodal d'OpenAI, les progrès connexes des pairs nationaux ont attiré l'attention. Hier encore, UBTECH, le ? stock numéro un de robots humano?des ? en Chine, a publié la première démo du robot humano?de WalkerS, profondément intégré au grand modèle de Baidu Wenxin, présentant de nouvelles fonctionnalités intéressantes. Maintenant, WalkerS, bénéficiant des capacités de grands modèles de Baidu Wenxin, ressemble à ceci. Comme la figure 01, WalkerS ne se déplace pas, mais se tient derrière un bureau pour accomplir une série de taches. Il peut suivre les commandes humaines et plier les vêtements

Conseils d'optimisation des performances pour la conversion de tableaux PHP en JSON Conseils d'optimisation des performances pour la conversion de tableaux PHP en JSON May 04, 2024 pm 06:15 PM

Les méthodes d'optimisation des performances pour la conversion des tableaux PHP en JSON incluent?: l'utilisation d'extensions JSON et de la fonction json_encode()?; l'ajout de l'option JSON_UNESCAPED_UNICODE pour éviter l'échappement de caractères?; l'utilisation de tampons pour améliorer les performances d'encodage de boucle et l'utilisation d'un tiers?; Bibliothèque d'encodage JSON.

Comment enregistrer les données JSON dans la base de données dans Golang ? Comment enregistrer les données JSON dans la base de données dans Golang ? Jun 06, 2024 am 11:24 AM

Les données JSON peuvent être enregistrées dans une base de données MySQL à l'aide de la bibliothèque gjson ou de la fonction json.Unmarshal. La bibliothèque gjson fournit des méthodes pratiques pour analyser les champs JSON, et la fonction json.Unmarshal nécessite un pointeur de type cible pour désorganiser les données JSON. Les deux méthodes nécessitent la préparation d'instructions SQL et l'exécution d'opérations d'insertion pour conserver les données dans la base de données.

Comment les annotations de la bibliothèque Jackson contr?lent-elles la sérialisation et la désérialisation JSON?? Comment les annotations de la bibliothèque Jackson contr?lent-elles la sérialisation et la désérialisation JSON?? May 06, 2024 pm 10:09 PM

Les annotations dans la bibliothèque Jackson contr?lent la sérialisation et la désérialisation JSON : Sérialisation : @JsonIgnore : Ignorer la propriété @JsonProperty : Spécifiez le nom @JsonGetter : Utilisez la méthode get @JsonSetter : Utilisez la méthode set Désérialisation : @JsonIgnoreProperties : Ignorez la propriété @ JsonProperty : Spécifiez le nom @JsonCreator?: utilisez le constructeur @JsonDeserialize?: logique personnalisée

Comment utiliser les fonctions PHP pour traiter les données JSON ? Comment utiliser les fonctions PHP pour traiter les données JSON ? May 04, 2024 pm 03:21 PM

PHP fournit les fonctions suivantes pour traiter les données JSON : Analyser les données JSON : utilisez json_decode() pour convertir une cha?ne JSON en un tableau PHP. Créer des données JSON?: utilisez json_encode() pour convertir un tableau ou un objet PHP en cha?ne JSON. Obtenez des valeurs spécifiques des données JSON?: utilisez les fonctions de tableau PHP pour accéder à des valeurs spécifiques, telles que des paires clé-valeur ou des éléments de tableau.

Conseils rapides pour convertir des tableaux PHP en JSON Conseils rapides pour convertir des tableaux PHP en JSON May 03, 2024 pm 06:33 PM

Les tableaux PHP peuvent être convertis en cha?nes JSON via la fonction json_encode() (par exemple : $json=json_encode($array);), et inversement, la fonction json_decode() peut être utilisée pour convertir du JSON en tableaux ($array= json_decode($json);) . D'autres conseils incluent d'éviter les conversions profondes, de spécifier des options personnalisées et d'utiliser des bibliothèques tierces.

Comment détecter une URL avec une expression régulière dans Golang ? Comment détecter une URL avec une expression régulière dans Golang ? May 31, 2024 am 10:32 AM

Les étapes pour détecter les URL dans Golang à l'aide d'expressions régulières sont les suivantes : Compilez le modèle d'expression régulière à l'aide de regexp.MustCompile(pattern). Le modèle doit correspondre aux paramètres de protocole, de nom d'h?te, de port (facultatif), de chemin (facultatif) et de requête (facultatif). Utilisez regexp.MatchString(pattern,url) pour détecter si l'URL correspond au modèle.

Implémentation PHP des techniques de nettoyage du suffixe du chemin d'adresse URL Implémentation PHP des techniques de nettoyage du suffixe du chemin d'adresse URL Mar 24, 2024 pm 05:48 PM

Implémentation PHP des techniques de nettoyage du suffixe du chemin d'adresse URL Dans le processus de développement Web, le nettoyage du suffixe du chemin d'adresse URL est une étape très importante. Nettoyer le suffixe du chemin de l'adresse URL peut améliorer l'optimisation du référencement du site Web, améliorer l'expérience utilisateur et est également bénéfique pour la sécurité du site Web. Dans le développement PHP, comment nettoyer le suffixe du chemin de l'adresse URL?? Voici quelques conseils pratiques et exemples de code spécifiques. 1. Concepts de base Dans les URL, le suffixe du chemin d'adresse fait généralement référence au type de fichier ou à l'identifiant dans l'URL, par exemple

See all articles