transfer(s)
function start_transfer(url)
{
url);
this->set_request_headers();
this->follow_location() === false)
{
if (this->set_cookies();
}
this->start_transfer(this->socket = @fsockopen(this->url_segments['port'], &errstr, 5);
if (this->trigger_error("this->url_segments['host']})");
}
}
function set_response()
{
fwrite(this->request_headers);
data = fread(response .= data) != 0);
fclose(response, this->response_headers = this->response_body = this->response_headers, matches[1]) != '')
{
matches[1]);
content_type_array[0]));
}
}
function set_url(this->url = url);
if (strpos(this->url = '' . url_segments = @parse_url(url_segments))
{
url_segments['port']) ? url_segments['path'] = isset(url_segments['path'] : '/';
url_segments['path'], 0, strrpos(url_segments['base'] = url_segments['host'] . url_segments['prev_dir'] = url_segments['base'], 0, strrpos(url_segments['base'] . '/';
url_segments;
/*
URL: username:password@www.example.com:80/dir/dir/page.php?foo=bar&foo2=bar2#bookmark
scheme // http
host // www.example.com
port // 80
user // username
pass // password
path // /dir/dir/page.php
query // ? 'foo=bar&foo2=bar2'
fragment // # 'bookmark'
dir // /dir/dir
base // www.example.com/dir/dir
prev_dir // www.example.com/dir/
*/
if (!empty(this->url_segments['host'], this->trigger_error('You are only allowed to browse these websites: ' . implode(', ', this->trigger_error('Please supply a valid URL');
}
}
function encode_url(url = str_rot13(urlencode(preg_replace('#^([\w+.-]+)://#i', "$1/",
return url;
}
function decode_url(url = preg_replace('#^([\w+.-]+)/#i', "$1://", urldecode(str_rot13(url;
}
function modify_urls()
{
preg_match_all("#\s(href|src|action|codebase|url)=([\"\'])?(.*?)([\"\'])?([\s\>])#i", matches, PREG_SET_ORDER);
foreach (match)
{
match[3]);
hash_pos = strpos(uri, uri))
{
switch (substr(uri = this->url_segments['host'] . uri = uri;
break;
}
}
this->encode_url(replace = ' ' . match[2] . uri . match[4] . this->response_body = str_replace(replace, flags)
{
if (is_numeric(flags, time()+(4*7*24*60*60), '', this->flags['include_form'] = this->flags['remove_scripts'] = this->flags['accept_cookies'] = this->flags['show_images'] = this->flags['show_referer'] = _COOKIE['flags']))
{
_COOKIE['flags']);
}
}
function set_request_headers()
{
_SERVER['REQUEST_METHOD']} {this->url_segments['query']) ? "?{headers .= "Host: {this->url_segments['port']}\r\n";
headers .= "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\r\n";
this->flags['show_referer'] == 1)
{
this->url_segments['base']}\r\n";
}
this->get_cookies();
cookies != '' ? "Cookie:
_SERVER['REQUEST_METHOD'] == 'POST')
{
_POST);
headers .= "Content-Length: " . strlen(
headers .=
headers .= "\r\n";
headers;
}
function set_post_body(
parent_key = null)
{
foreach (
key =>
value))
{
value, isset(
parent_key, urlencode(
key));
}
else
{
this->post_body != '' ? '&' : '';
parent_key) ? sprintf('
\%s[
\%s]',
key)) : urlencode(
this->post_body .=
value));
}
}
}
function follow_location()
{
if (preg_match("#(location|uri):([^\r\n]*)#i",
matches))
{
this->decode_url(trim(
uri))
{
if (substr(
uri =
this->url_segments['host'] .
uri =
uri;
}
}
uri;
return true;
}
return false;
}
function set_cookies()
{
if (preg_match_all("#set-cookie:([^\r\n]*)#i",
matches))
{
foreach (
match)
{
preg_match('#^\s*([^=;,\s]*)=?([^;,\s]*)#',
cookie) ? list(,
value) =
match,
expires) =
match,
path) =
match,
domain) =
match,
secure) =
expires = isset(
expires) : 0;
path) ?
this->url_segments['dir'];
domain) ?
this->url_segments['host'];
domain, '.');
if (!preg_match("#
domain#i",
#i',
domain, '.') < 2)
{
continue;
}
}
else if (substr_count(
name;
path"),
expires, '',
restrict = true)
{
if (!empty(
cookies = '';
foreach (
cookie_name =>
cookie_args = explode(';', urldecode(
cookie_args[0] != 'PHProxy')
{
continue;
}
if (
name,
path) =
domain = str_replace('_', '.',
this->url_segments['host']) && preg_match("#^
this->url_segments['path']))
{
cookies != '' ? '; ' : '';
name=
cookie_args);
cookie_args[1]);
cookie_value;
cookie_args;
}
}
return
hash)
{
this->get_cookies(false);
foreach (
args)
{
if (
hash == md5(
args[1].
args[3]))
{
setcookie(urlencode("PHProxy;
args[1];
send_headers = true)
{
if (strpos(
this->content_type, 'xhtml') !== false)
{
if (
this->remove_scripts();
}
if (
this->remove_images();
}
this->flags['include_form'] == 1)
{
//
headers = explode("\r\n", trim(
headers[] = 'Content-Disposition: '. (strpos(
this->url_segments['path'], strrpos(
headers[] = 'Content-Length: '. strlen(
send_headers)
{
foreach (
header)
{
header(
this->response_body;
}
function remove_scripts()
{
this->response_body); // Remove any scripts enclosed between
<script />
this->response_body); // Remove javascript event handlers
this->response_body); //expose any html between
<noscript />
}
function remove_images()
{
this->response_body);
}
function include_form()
{
ob_start();
include_once 'url_form.inc';
this->response_body = preg_replace("#\
<body(.*?)\>#si", "$0\n
this->response_body, 1);
}
function trigger_error(
this->script_url?error=
tabulate = false,
output = '';
comments['include_form'] = 'Includes a mini URL-form on every HTML page';
comments['accept_cookies'] = 'Accept HTTP cookies';
comments['show_referer'] = 'Show referring website in HTTP headers';
foreach (
flag_code =>
interface = array(ucwords(str_replace('_', ' ',
flag_status == 1 ? ' checked="checked"' : '') . ' /> '
);
interface = array_reverse(
output .= (
interface[0]
. (
interface[1]
. (
comments[
tabulate ? '
</td></tr>' : '');
}
return