protected function saveImage($url)
 {
     $id = direct::fragment(2, $url);
     $ext = file::getExtension($url);
     $title = md5(uniqid()) . ".{$ext}";
     $i = new image();
     $file = $i->getFile($id);
     if (empty($file)) {
         return '';
     }
     $path = "/images/{$id}/{$title}";
     $save_path = conf::getFullFilesPath($path);
     $web_path = conf::getWebFilesPath($path);
     $dir = dirname($path);
     file::mkdir($dir);
     file_put_contents($save_path, $file['file']);
     return $web_path;
 }
 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;
 }