From Seeks
<?
/* Copyright Camille Harang
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see http://www.fsf.org/licensing/licenses/agpl-3.0.html. */
if($_SERVER['HTTPS']) $scheme = 'https://';
else $scheme= 'http://';
$seeks_uri = 'http://s.s';
$proxy = 'localhost:8118';
$base_script = $_SERVER['SCRIPT_NAME'];
$base_url = $scheme.$_SERVER['HTTP_HOST'].$base_script;
if ($_SERVER['REQUEST_URI'] == '/') { header('Location: '.$base_url.'/websearch-hp'); }
else $url = $seeks_uri.str_replace($base_script, '', $_SERVER['REQUEST_URI']);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_PROXY, $proxy);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1) ;
$result = curl_exec($curl);
$result_info = curl_getinfo($curl);
curl_close($curl);
if(substr($result_info['content_type'], 0, 5) == 'text/' && $result_info['content_type'] != 'text/javascript') {
$result = str_replace($seeks_uri, $base_url, $result);
$result = str_replace('"/', '"'.$base_url.'/', $result);
$result = str_replace("'/", "'".$base_url.'/', $result);
$result = str_replace("url(/", "url(".$base_url.'/', $result);
}
header('Content-Type: '.$result_info['content_type']);
echo $result;
?>