예제 #1
0
 /**
  * Sets a controller and a action
  */
 private function setControllerAction()
 {
     // Parse url. 2 cases:
     // a) Default controller
     // b) Module controller
     // Get all modules
     $mod_path = conf::pathBase() . "/" . $this->modules;
     $mods = file::getDirsGlob($mod_path, array('basename' => true));
     $base = direct::fragment(0);
     if (!in_array($base, $mods)) {
         // Could not find a controller / module
         $this->controller = $this->default;
         $action = direct::fragment(0);
         if ($action) {
             $this->action = $action;
         }
     } else {
         // Found a controller / module
         $this->controller = $base;
         $action = direct::fragment(1);
         if ($action) {
             $this->action = $action;
         }
     }
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 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;
 }
 /**
  * Check to see if a image is a figure.
  * @param string $type (mp4 or image type)
  * @param string $url
  * @return false|string $res
  */
 public function isFigure($type, $url)
 {
     // Movie is always a reference.
     if ($type == 'mp4') {
         return $url;
     }
     // Image.
     if ($type != 'mp4') {
         // Check if image is a figure.
         $a = parse_url($url);
         //Off-site image. Not a figure
         if (isset($a['scheme'])) {
             return false;
         }
         $mod = direct::fragment(0, $url);
         if ($mod == 'image') {
             $id = direct::fragment(2, $url);
             $i = new imageModule();
             $row = $i->getSingleFileInfo($id);
             if ($row['figure'] == 1) {
                 return $row;
             }
         }
         return false;
     }
 }