{ $img = @file_get_contents ($url); if($img === false){ $err = error_get_last(); if(is_array($err) && $err['message']){ $this->lastURLError = $err['message']; } else { $this->lastURLError = $err; } if(preg_match('/404/', $this->lastURLError)){ $this->set404(); } return false; } if(! file_put_contents($tempfile, $img)){ $this->error("Could not write to $tempfile."); return false; } return true; } } protected function serveImg($file){ $s = getimagesize($file); if(! ($s && $s['mime'])){ return false; } header ('Content-Type: ' . $s['mime']); header ('Content-Length: ' . filesize($file) ); header ('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); header ("Pragma: no-cache"); $bytes = @readfile($file); if($bytes > 0){ return true; } $content = @file_get_contents ($file); if ($content != FALSE){ echo $content; return true; } return false; } protected function set404(){ $this->is404 = true; } protected function is404(){ return $this->is404; } }