Advertisement
stuppid_bot

Untitled

Oct 31st, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2.  
  3. $site_path = dirname($_SERVER['SCRIPT_NAME']);
  4. if ($site_path <> '/') {
  5.     $site_path .= '/';
  6. }
  7. $uri = $_SERVER['REQUEST_URI'];
  8. $uri = preg_replace('|/{2,}|', '/', $uri);
  9. $uri = $site_path == $uri ? '' : substr($uri, strlen($site_path));
  10. $cache_enabled = false;
  11. $cache_file = 'cache/' . md5($uri);
  12. if ($cache_enabled && file_exists($cache_file)) {
  13.     echo file_get_contents($cache_file);
  14. }
  15. else {
  16.     $content = @file_get_contents('http://www.tenderhunter.ru/' . $uri);
  17.     $content = preg_replace('~(?<= href=")/([^/].*)~', $site_path . '$1', $content);
  18.     echo $content;
  19.     if ($content && $cache_enabled) {
  20.         file_put_contents($cache_file, $content);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement