It fetches remote pages and translates all HTML tags of links and images, background image attributes and external style sheet references to use the URLs based on the current script URL.
gonxproxy.class.php
<?php
/**
* gonxproxy class : Just a HTTP Proxy
*
* @package
* @author Ben Yacoub Hatem <hatem@php.net>
* @copyright Copyright (c) 2004
* @version $Id$ - 07/04/2004 13:48:08 - gonxproxy.class.php
* @access public
**/
class gonxproxy{
/**
* Constructor
* @access protected
*/
function gonxproxy(){
}
/**
*
* @access public
* @return void
**/
function version(){
return "1.0.1";
}
/**
* Parse a HTML Page, remove JScript, convert Urls and return it.
*
* @access public
* @return void
**/
function parse_html($_data,$_url){
$matches = preg_match_all( "/(href|src|background|@import) *=? *\"(.*)\"/Ui", $_data, $regs );
foreach($regs[2] as $k=>$v){
$_data = str_replace($v,gonxproxy::chg_url($v,$_url), $_data);
}
return $_data;
}
/**
* Convert an URL to a GONX formatted url
*
* Original function code is taken from GURL v2.1 BETA
* by Bob Matcuk (BMatcuk@Users.SourceForge.Net)
* http://gurl.sourceforge.net
*
* @access public
* @return void
**/
function chg_url($piece,$url){
/**
* gonxproxy Index
*
* @package
* @author Ben Yacoub Hatem <hatem@php.net>
* @copyright Copyright (c) 2004
* @version $Id$ - 09/04/2004 14:45:36 - index.php
* @access public
**/
require_once("gonxproxy.class.php");
@error_reporting(0); // Don't report error
@extract($_GET); // if register globals if off
if (isset($url) and $url!="" and $proxy==1) {
$res = gonxproxy::connect($url);
} elseif(isset($url) and $url!="" and !isset($proxy)){
$res = gonxproxy::connect(base64_decode($url));
}