📄 index.php
字号:
unset($_response_headers['keep-alive'], $_response_keys['keep-alive']);
}
if ($_response_code == 401 && isset($_response_headers['www-authenticate']) && preg_match('#basic\s+(?:realm="(.*?)")?#i', $_response_headers['www-authenticate'][0], $matches))
{
if (isset($_auth_creds[$matches[1]]) && !$_quit)
{
$_basic_auth_realm = $matches[1];
$_basic_auth_header = '';
$_retry = $_quit = true;
}
else
{
show_report(array('which' => 'index', 'category' => 'auth', 'realm' => $matches[1]));
}
}
}
while ($_retry);
//
// OUTPUT RESPONSE IF NO PROXIFICATION IS NEEDED
//
if (!isset($_proxify[$_content_type]))
{
@set_time_limit(0);
$_response_keys['content-disposition'] = 'Content-Disposition';
$_response_headers['content-disposition'][0] = empty($_content_disp) ? ($_content_type == 'application/octet_stream' ? 'attachment' : 'inline') . '; filename="' . $_url_parts['file'] . '"' : $_content_disp;
if ($_content_length !== false)
{
if ($_config['max_file_size'] != -1 && $_content_length > $_config['max_file_size'])
{
show_report(array('which' => 'index', 'category' => 'error', 'group' => 'resource', 'type' => 'file_size'));
}
$_response_keys['content-length'] = 'Content-Length';
$_response_headers['content-length'][0] = $_content_length;
}
$_response_headers = array_filter($_response_headers);
$_response_keys = array_filter($_response_keys);
header(array_shift($_response_keys));
array_shift($_response_headers);
foreach ($_response_headers as $name => $array)
{
foreach ($array as $value)
{
header($_response_keys[$name] . ': ' . $value, false);
}
}
do
{
$data = fread($_socket, 8192);
echo $data;
}
while (isset($data{0}));
fclose($_socket);
exit(0);
}
do
{
$data = @fread($_socket, 8192); // silenced to avoid the "normal" warning by a faulty SSL connection
$_response_body .= $data;
}
while (isset($data{0}));
unset($data);
fclose($_socket);
//
// MODIFY AND DUMP RESOURCE
//
if ($_content_type == 'text/css')
{
$_response_body = proxify_css($_response_body);
}
else
{
if ($_flags['strip_title'])
{
$_response_body = preg_replace('#(<\s*title[^>]*>)(.*?)(<\s*/title[^>]*>)#is', '$1$3', $_response_body);
}
if ($_flags['remove_scripts'])
{
$_response_body = preg_replace('#<\s*script[^>]*?>.*?<\s*/\s*script\s*>#si', '', $_response_body);
$_response_body = preg_replace("#(\bon[a-z]+)\s*=\s*(?:\"([^\"]*)\"?|'([^']*)'?|([^'\"\s>]*))?#i", '', $_response_body);
$_response_body = preg_replace('#<noscript>(.*?)</noscript>#si', "$1", $_response_body);
}
if (!$_flags['show_images'])
{
$_response_body = preg_replace('#<(img|image)[^>]*?>#si', '', $_response_body);
}
//
// PROXIFY HTML RESOURCE
//
$tags = array
(
'a' => array('href'),
'img' => array('src', 'longdesc'),
'image' => array('src', 'longdesc'),
'body' => array('background'),
'base' => array('href'),
'frame' => array('src', 'longdesc'),
'iframe' => array('src', 'longdesc'),
'head' => array('profile'),
'layer' => array('src'),
'input' => array('src', 'usemap'),
'form' => array('action'),
'area' => array('href'),
'link' => array('href', 'src', 'urn'),
'meta' => array('content'),
'param' => array('value'),
'applet' => array('codebase', 'code', 'object', 'archive'),
'object' => array('usermap', 'codebase', 'classid', 'archive', 'data'),
'script' => array('src'),
'select' => array('src'),
'hr' => array('src'),
'table' => array('background'),
'tr' => array('background'),
'th' => array('background'),
'td' => array('background'),
'bgsound' => array('src'),
'blockquote' => array('cite'),
'del' => array('cite'),
'embed' => array('src'),
'fig' => array('src', 'imagemap'),
'ilayer' => array('src'),
'ins' => array('cite'),
'note' => array('src'),
'overlay' => array('src', 'imagemap'),
'q' => array('cite'),
'ul' => array('src')
);
preg_match_all('#(<\s*style[^>]*>)(.*?)(<\s*/\s*style[^>]*>)#is', $_response_body, $matches, PREG_SET_ORDER);
for ($i = 0, $count_i = count($matches); $i < $count_i; ++$i)
{
$_response_body = str_replace($matches[$i][0], $matches[$i][1]. proxify_css($matches[$i][2]) .$matches[$i][3], $_response_body);
}
preg_match_all("#<\s*([a-zA-Z\?-]+)([^>]+)>#S", $_response_body, $matches);
for ($i = 0, $count_i = count($matches[0]); $i < $count_i; ++$i)
{
if (!preg_match_all("#([a-zA-Z\-\/]+)\s*(?:=\s*(?:\"([^\">]*)\"?|'([^'>]*)'?|([^'\"\s]*)))?#S", $matches[2][$i], $m, PREG_SET_ORDER))
{
continue;
}
$rebuild = false;
$extra_html = $temp = '';
$attrs = array();
for ($j = 0, $count_j = count($m); $j < $count_j; $attrs[strtolower($m[$j][1])] = (isset($m[$j][4]) ? $m[$j][4] : (isset($m[$j][3]) ? $m[$j][3] : (isset($m[$j][2]) ? $m[$j][2] : false))), ++$j);
if (isset($attrs['style']))
{
$rebuild = true;
$attrs['style'] = proxify_inline_css($attrs['style']);
}
$tag = strtolower($matches[1][$i]);
if (isset($tags[$tag]))
{
switch ($tag)
{
case 'a':
if (isset($attrs['href']))
{
$rebuild = true;
$attrs['href'] = complete_url($attrs['href']);
}
break;
case 'img':
if (isset($attrs['src']))
{
$rebuild = true;
$attrs['src'] = complete_url($attrs['src']);
} if (isset($attrs['longdesc']))
{
$rebuild = true;
$attrs['longdesc'] = complete_url($attrs['longdesc']);
}
break;
case 'form':
if (isset($attrs['action']))
{
$rebuild = true;
if (trim($attrs['action']) === '')
{
$attrs['action'] = $_url_parts['path'];
}
if (!isset($attrs['method']) || strtolower(trim($attrs['method'])) === 'get')
{
$extra_html = '<input type="hidden" name="' . $_config['get_form_name'] . '" value="' . encode_url(complete_url($attrs['action'], false)) . '" />';
$attrs['action'] = '';
break;
}
$attrs['action'] = complete_url($attrs['action']);
}
break;
case 'base':
if (isset($attrs['href']))
{
$rebuild = true;
url_parse($attrs['href'], $_base);
$attrs['href'] = complete_url($attrs['href']);
}
break;
case 'meta':
if ($_flags['strip_meta'] && isset($attrs['name']))
{
$_response_body = str_replace($matches[0][$i], '', $_response_body);
}
if (isset($attrs['http-equiv'], $attrs['content']) && preg_match('#\s*refresh\s*#i', $attrs['http-equiv']))
{
if (preg_match('#^(\s*[0-9]*\s*;\s*url=)(.*)#i', $attrs['content'], $content))
{
$rebuild = true;
$attrs['content'] = $content[1] . complete_url(trim($content[2], '"\''));
}
}
break;
case 'head':
if (isset($attrs['profile']))
{
$rebuild = true;
$attrs['profile'] = implode(' ', array_map('complete_url', explode(' ', $attrs['profile'])));
}
break;
case 'applet':
if (isset($attrs['codebase']))
{
$rebuild = true;
$temp = $_base;
url_parse(complete_url(rtrim($attrs['codebase'], '/') . '/', false), $_base);
unset($attrs['codebase']);
}
if (isset($attrs['code']) && strpos($attrs['code'], '/') !== false)
{
$rebuild = true;
$attrs['code'] = complete_url($attrs['code']);
}
if (isset($attrs['object']))
{
$rebuild = true;
$attrs['object'] = complete_url($attrs['object']);
}
if (isset($attrs['archive']))
{
$rebuild = true;
$attrs['archive'] = implode(',', array_map('complete_url', preg_split('#\s*,\s*#', $attrs['archive'])));
}
if (!empty($temp))
{
$_base = $temp;
}
break;
case 'object':
if (isset($attrs['usemap']))
{
$rebuild = true;
$attrs['usemap'] = complete_url($attrs['usemap']);
}
if (isset($attrs['codebase']))
{
$rebuild = true;
$temp = $_base;
url_parse(complete_url(rtrim($attrs['codebase'], '/') . '/', false), $_base);
unset($attrs['codebase']);
}
if (isset($attrs['data']))
{
$rebuild = true;
$attrs['data'] = complete_url($attrs['data']);
}
if (isset($attrs['classid']) && !preg_match('#^clsid:#i', $attrs['classid']))
{
$rebuild = true;
$attrs['classid'] = complete_url($attrs['classid']);
}
if (isset($attrs['archive']))
{
$rebuild = true;
$attrs['archive'] = implode(' ', array_map('complete_url', explode(' ', $attrs['archive'])));
}
if (!empty($temp))
{
$_base = $temp;
}
break;
case 'param':
if (isset($attrs['valuetype'], $attrs['value']) && strtolower($attrs['valuetype']) == 'ref' && preg_match('#^[\w.+-]+://#', $attrs['value']))
{
$rebuild = true;
$attrs['value'] = complete_url($attrs['value']);
}
break;
case 'frame':
case 'iframe':
if (isset($attrs['src']))
{
$rebuild = true;
$attrs['src'] = complete_url($attrs['src']) . '&nf=1';
}
if (isset($attrs['longdesc']))
{
$rebuild = true;
$attrs['longdesc'] = complete_url($attrs['longdesc']);
}
break;
default:
foreach ($tags[$tag] as $attr)
{
if (isset($attrs[$attr]))
{
$rebuild = true;
$attrs[$attr] = complete_url($attrs[$attr]);
}
}
break;
}
}
if ($rebuild)
{
$new_tag = "<$tag";
foreach ($attrs as $name => $value)
{
$delim = strpos($value, '"') && !strpos($value, "'") ? "'" : '"';
$new_tag .= ' ' . $name . ($value !== false ? '=' . $delim . $value . $delim : '');
}
$_response_body = str_replace($matches[0][$i], $new_tag . '>' . $extra_html, $_response_body);
}
}
if ($_flags['include_form'] && !isset($_GET['nf']))
{
$_url_form = '<div style="width:100%;margin:0;text-align:center;border-bottom:1px solid #725554;color:#000000;background-color:#F2FDF3;font-size:12px;font-weight:bold;font-family:Bitstream Vera Sans,arial,sans-serif;padding:4px;">'
. '<form method="post" action="' . $_script_url . '">'
. ' <label for="____' . $_config['url_var_name'] . '"><a href="' . $_url . '">网址</a>:</label> <input id="____' . $_config['url_var_name'] . '" type="text" size="80" name="' . $_config['url_var_name'] . '" value="' . $_url . '" />'
. ' <input type="submit" name="go" value="浏览" />'
. ' [<a href="' . $_script_url . '?' . $_config['url_var_name'] . '=' . encode_url($_url_parts['prev_dir']) .' ">返回</a>, <a href="' . $_script_base . '">首页</a>]'
. '<br /><hr />';
foreach ($_flags as $flag_name => $flag_value)
{
if (!$_frozen_flags[$flag_name])
{
$_url_form .= '<label><input type="checkbox" name="' . $_config['flags_var_name'] . '[' . $flag_name . ']"' . ($flag_value ? ' checked="checked"' : '') . ' /> ' . $_labels[$flag_name][0] . '</label> ';
}
}
$_url_form .= '</form></div>';
$_response_body = preg_replace('#\<\s*body(.*?)\>#si', "$0\n$_url_form" , $_response_body, 1);
}
}
$_response_keys['content-disposition'] = 'Content-Disposition';
$_response_headers['content-disposition'][0] = empty($_content_disp) ? ($_content_type == 'application/octet_stream' ? 'attachment' : 'inline') . '; filename="' . $_url_parts['file'] . '"' : $_content_disp;
$_response_keys['content-length'] = 'Content-Length';
$_response_headers['content-length'][0] = strlen($_response_body);
$_response_headers = array_filter($_response_headers);
$_response_keys = array_filter($_response_keys);
header(array_shift($_response_keys));
array_shift($_response_headers);
foreach ($_response_headers as $name => $array)
{
foreach ($array as $value)
{
header($_response_keys[$name] . ': ' . $value, false);
}
}
echo $_response_body;
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -