我的代理有很多限制,例如:无法访问 youtube、facebook 和许多其他网站,这些是公司政策。
但是在 PHP 中测试代码我发现我可以使用它访问任何站点:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web Proxy</title>
</head>
<body>
<div style="text-align:center;">
<form method="GET" action="<?=$_SERVER['REQUEST_URI']?>">
<input type="url" name="url" placeholder="Type URL of site"/><input type="submit" Value="Load url" />
</form>
</div>
<hr/>
<?php
$url = $_GET['url'];
if (!empty($url))
{
// check we're only getting files served by a website (i.e. not ../../../passwords.txt from this server etc.)
if(preg_match('/^https?:/i', $url))
{
$contents = file_get_contents($url);
if($contents === FALSE)
{
echo "<h2>Sorry <pre>{$url}</pre> cannot be read</h2>\n";
}
//display contents of url
else
{ ?>
<?=$contents?>
<script>for (var i=0; i<document.links.length; i++) document.links[i].href="<?=$_SERVER['PHP_SELF']?>?url="+document.links[i].href;</script>
<?php }
}
else
{
echo "<h2><pre>$url</pre> is an invalid URL</h2>\n";
}
}
?>
</body>
</html>
我只是想了解此代码如何处理忽略代理策略的任何站点?我可以不受限制地访问所有内容。有人可以向我解释“幕后”的概念吗?