/**
  * Images are stored in database. 
  * @param type $url
  * @return boolean
  */
 public function saveImage($url)
 {
     $id = direct::fragment(2, $url);
     $title = direct::fragment(3, $url);
     $title = rawurlencode($title);
     $path = "/images/{$id}/{$title}";
     $save_path = conf::getFullFilesPath($path);
     $web_path = conf::getSchemeWithServerName() . conf::getWebFilesPath($path);
     $code = headers::getReturnCode($web_path);
     if ($code != '200') {
         log::error("Could not get file content (image). Got: {$code} " . $web_path . ' in ' . __CLASS__);
         return false;
     }
     return $save_path;
 }
 /**
  * Images are stored in database. 
  * @param type $url
  * @return boolean
  */
 public function checkImage($url)
 {
     $id = direct::fragment(2, $url);
     $title = direct::fragment(3, $url);
     $path = "/images/{$id}/{$title}";
     $save_path = conf::getFullFilesPath($path);
     $web_path = conf::getWebFilesPath($path);
     $image_url = conf::getSchemeWithServerName() . $url;
     $code = headers::getReturnCode($image_url);
     if ($code != 200) {
         log::error("Could not get file content (image). Got: {$code} " . $image_url);
         return false;
     }
     return $url;
 }
 protected function saveImage($url)
 {
     $id = direct::fragment(2, $url);
     $title = direct::fragment(3, $url);
     $path = "/images/{$id}/{$title}";
     $save_path = conf::getFullFilesPath($path);
     $web_path = conf::getWebFilesPath($path);
     $image_url = conf::getSchemeWithServerName() . $url;
     $code = headers::getReturnCode($image_url);
     if ($code != 200) {
         log::error("Could not get file content (image). Got: {$code} " . $image_url);
         return '';
     } else {
         $file = file_get_contents($image_url);
     }
     // make dir
     $dir = dirname($path);
     file::mkdir($dir);
     file_put_contents($save_path, $file);
     return $web_path;
 }