/ derefer.php
derefer.php
1 <?php 2 if (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) 3 && !preg_match('/^https?:\/\/[a-z0-9]+\.(4chan|4channel)\.org/', $_SERVER['HTTP_REFERER'])) { 4 http_response_code(403); 5 die(); 6 } 7 8 if (!isset($_GET['url']) || empty($_GET['url'])) { 9 die(); 10 } 11 12 $url = $_GET['url']; 13 14 $domain = parse_url($url, PHP_URL_HOST); 15 16 if (!$domain) { 17 die(); 18 } 19 20 if (strpos($url, 'http') !== 0) { 21 $url = 'http://' . $url; 22 } 23 24 $domain = htmlspecialchars($domain, ENT_QUOTES); 25 $url = htmlspecialchars(htmlspecialchars_decode($url, ENT_QUOTES), ENT_QUOTES); 26 27 header("Cache-Control: public, immutable"); 28 29 ?><!DOCTYPE html> 30 <html> 31 <head> 32 <meta charset="utf-8"> 33 <title>Redirecting...</title> 34 <meta http-equiv="refresh" content="2; URL=<?php echo $url ?>"> 35 <style type="text/css"> 36 #msg { 37 font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; 38 text-align: center; 39 font-weight: bold; 40 font-size: 36pt; 41 margin-top: 20%; 42 } 43 </style> 44 </head> 45 <body> 46 <div id="msg">Redirecting you to <i><?php echo $domain ?></i>...</div> 47 </body> 48 </html>