isAllowed($_GET['url'])) { header("HTTP/1.0 404 Not Found"); die('404 - 3'); } } public function output() { $ext = pathinfo($this->url, PATHINFO_EXTENSION); switch ($ext) { case "gif": header('Content-Type: image/gif'); readfile($this->url); break; case "png": header('Content-Type: image/png'); readfile($this->url); break; case "jpg": default: header('Content-Type: image/jpeg'); readfile($this->url); break; } } protected function getHost() { $result = parse_url($this->url); return $result['host']; } protected function isAllowed($url) { return in_array($this->getHost($url), $this->allowed); } } (new Proxy)->output();