Esempio n. 1
0
 public static function urlencode_parts($path)
 {
     $ret = "";
     $parts = explode("/", $path);
     foreach ($parts as $part) {
         if ($ret != "") {
             $ret .= "/";
         }
         $ret .= "" . Filebrowser::double_encode_specialcharacters(urlencode($part));
     }
     return $ret;
 }
Esempio n. 2
0
 public function get_thumbnail_url()
 {
     $root = SubfolioTheme::get_site_root();
     if ($this->has_custom_thumbnail()) {
         return $root . "directory/" . format::urlencode_parts($this->parent) . "/-thumbnails-custom/" . Filebrowser::double_encode_specialcharacters($this->get_custom_thumbnail_file_name());
     } else {
         $thumbnail = "-thumbnails/" . $this->name;
         $url = $root . "directory/" . format::urlencode_parts($this->parent) . "/-thumbnails/" . Filebrowser::double_encode_specialcharacters(urlencode($this->name));
         if (!file_exists("-thumbnails")) {
             mkdir("-thumbnails", 0755, true);
         }
         $build_thumbnail = false;
         if (!$this->has_thumbnail()) {
             $build_thumbnail = true;
         }
         if ($build_thumbnail) {
             $max_size = Kohana::config('filebrowser.thumbnail_max_filesize');
             $stats = stat($this->name);
             if ($stats['size'] > $max_size * 1024 * 1024) {
                 return '';
             } else {
                 $thumbnail_width = SubfolioTheme::get_option('thumbnail_width', Kohana::config('filebrowser.thumbnail_width'));
                 $thumbnail_height = SubfolioTheme::get_option('thumbnail_height', Kohana::config('filebrowser.thumbnail_height'));
                 $info = @getimagesize($this->name);
                 if (isset($info[1])) {
                     if ($info[1] <= $thumbnail_height) {
                     } else {
                         $this->image = new Image($this->name);
                         if ($this->image) {
                             $this->image->resize($thumbnail_width, $thumbnail_height, Image::HEIGHT);
                             $this->image->save($thumbnail);
                         }
                     }
                 }
             }
         }
         if (file_exists($thumbnail)) {
             $thumbnail_stats = stat($thumbnail);
             return $url . "?rnd=" . $thumbnail_stats['ctime'];
         } else {
             return '';
         }
     }
 }
Esempio n. 3
0
 public function get_link($name, $directory = false)
 {
     $root = SubfolioTheme::get_site_root();
     if ($directory) {
         $root .= "directory/";
     }
     if ($this->folder == "") {
         $link = $root . urlencode($name);
         $link = str_replace('%2F', '/', $link);
         $link = Filebrowser::double_encode_specialcharacters($link);
     } else {
         $link = $root . urlencode($this->folder) . "/" . urlencode($name);
         // unencode '/'
         $link = str_replace('%2F', '/', $link);
         $link = Filebrowser::double_encode_specialcharacters($link);
     }
     return $link;
 }
Esempio n. 4
0
 public function next_link_or_span($name, $directory_name, $link_id, $class)
 {
     $ff = Subfolio::$filebrowser->get_path();
     if ($ff != '') {
         if (Subfolio::$filebrowser->is_file()) {
             $file = Subfolio::$filebrowser->get_file();
             $items = Subfolio::$filebrowser->get_parent_file_folder_list(null, false);
             $items = Subfolio::$filebrowser->sort($items);
             $items = Subfolio::$filebrowser->prev_next_sort($items);
             $next = Subfolio::$filebrowser->get_next($items, $file->name);
             if ($next != "") {
                 $link = Filebrowser::double_encode_specialcharacters(urlencode($next->name));
                 $link = str_replace('%2F', '/', $link);
                 return "<a id='{$link_id}' href='{$link}'>{$name}</a>";
             } else {
                 return "<span id='{$link_id}' class='" . $class . "'>" . $name . "</span>";
             }
         } else {
             $folder = basename(Subfolio::$filebrowser->get_folder());
             $items = Subfolio::$filebrowser->get_parent_file_folder_list(null, true);
             $items = Subfolio::$filebrowser->sort($items);
             $items = Subfolio::$filebrowser->prev_next_sort($items);
             $next = Subfolio::$filebrowser->get_next($items, $folder);
             if ($next != "") {
                 $link = Filebrowser::double_encode_specialcharacters(urlencode($next->name));
                 $link = str_replace('%2F', '/', $link);
                 return "<a id='{$link_id}' href='{$link}'>{$directory_name}</a>";
             } else {
                 return "<span id='{$link_id}' class='" . $class . "'>" . $directory_name . "</span>";
             }
         }
     }
 }