| OLD | NEW |
| (Empty) | |
| 1 <?php |
| 2 |
| 3 function getReferrerPath() { |
| 4 if (!isset($_SERVER["HTTP_REFERER"])) |
| 5 return ""; |
| 6 $url = parse_url($_SERVER["HTTP_REFERER"]); |
| 7 return $url['path']; |
| 8 } |
| 9 |
| 10 function putImage() { |
| 11 $image = "../../resources/square100.png"; |
| 12 header("Content-Type: image/png"); |
| 13 header("Content-Length: " . filesize($image)); |
| 14 ob_clean(); |
| 15 flush(); |
| 16 readfile($image); |
| 17 } |
| 18 |
| 19 function putFont() { |
| 20 $font = "../../../../resources/Ahem.ttf"; |
| 21 header("Content-Type: font/truetype"); |
| 22 header("Content-Length: " . filesize($font)); |
| 23 ob_clean(); |
| 24 flush(); |
| 25 readfile($font); |
| 26 } |
| 27 |
| 28 $expectedReferrerPaths = array( |
| 29 "document" => "/css/css-resources-referrer.html", |
| 30 "sheet" => "/css/resources/css-resources-referrer.css", |
| 31 "importedSheet" => "/css/resources/css-resources-referrer-import.css" |
| 32 ); |
| 33 |
| 34 $from = $_GET["from"]; |
| 35 $resource = $_GET["resource"]; |
| 36 $referrerPath = getReferrerPath(); |
| 37 |
| 38 if ($referrerPath === $expectedReferrerPaths[$from]) { |
| 39 if ($resource === "image" || $resource === "image2") |
| 40 putImage(); |
| 41 else if ($resource === "font") |
| 42 putFont(); |
| 43 else |
| 44 header("HTTP/1.1 500 Internal Server Error"); |
| 45 } else { |
| 46 header("HTTP/1.1 500 Internal Server Error"); |
| 47 } |
| 48 |
| 49 ?> |
| OLD | NEW |