Example #1
0
 public function validates()
 {
     if ($this->input->getValue() && !Url::isValid($this->input->getValue())) {
         $this->error = lang('%s is not a valid link', $this->input->getName());
         return false;
     }
     return true;
 }
Example #2
0
 public static function getRemoteMime($url)
 {
     if (Url::isValid($url)) {
         $handle = curl_init($url);
         curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
         curl_setopt($handle, CURLOPT_MAXREDIRS, 5);
         curl_setopt($handle, CURLOPT_HEADER, true);
         curl_setopt($handle, CURLOPT_NOBODY, true);
         curl_exec($handle);
         return curl_getinfo($handle, CURLINFO_CONTENT_TYPE);
     }
     throw new \ErrorException('Failed to parse mime-type');
 }