added code
This commit is contained in:
1 parent
857551a1f9
commit
ffdb3f4705
2 files changed
+41
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
RewriteEngine On
|
||||||
|
Options +FollowSymlinks
|
||||||
|
RewriteBase /
|
||||||
|
DirectoryIndex index.php
|
||||||
|
RewriteRule ^(.*)$ index.php [L]
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Простейщий прокси на PHP. Написан just-for-fun. Практического применения нет.
|
||||||
|
Roman S Grinko <rsgrinko@gmail.com>
|
||||||
|
*/
|
||||||
|
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||||
|
$query = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
|
||||||
|
|
||||||
|
$newPath = ltrim($path, '/');
|
||||||
|
if ($query) {
|
||||||
|
$newPath .= '?' . $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
$base = 'https://it-stories.ru'; // сайт, на котором планируется бродить
|
||||||
|
$local = '//'.$_SERVER['SERVER_NAME'];
|
||||||
|
$proxyUrl = $base .'/'. $newPath;
|
||||||
|
|
||||||
|
$contents = @file_get_contents($proxyUrl);
|
||||||
|
|
||||||
|
$headers = $http_response_header;
|
||||||
|
$firstLine = $headers[0];
|
||||||
|
|
||||||
|
if ($contents === false) {
|
||||||
|
header("HTTP/1.1 503 Proxy error");
|
||||||
|
die("Proxy error - failed to get content from $proxyUrl");
|
||||||
|
}
|
||||||
|
$allowedHeaders = "!^(http/1.1|server:|content-type:|last-modified|access-control-allow-origin|Content-Length:|Accept-Ranges:|Date:|Via:|Connection:|X-|age|cache-control|vary)!i";
|
||||||
|
|
||||||
|
foreach ($headers as $header) {
|
||||||
|
if (preg_match($allowedHeaders, $header)) {
|
||||||
|
header($header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// подменяем ссылки для возможности хождения через прокси и выводим
|
||||||
|
echo str_replace($base, $local, $contents);
|
||||||
Reference in new issue
Block a user