Example #1
0
 public function infodirtoHTML($dir)
 {
     $w = File::a2r($dir);
     $ret = "";
     //		$ret .=	"<input type='submit' id='multiselectbutton' value='".Settings::_("adminpanel","multiselect")."'>";
     /// Folder name
     if (strlen($w) > 1 && $this->isfile) {
         $ret .= "<form class='niceform pure-form' action='?a=Mov' method='post'>\r\n\t\t\t\t\t<input type='hidden' name='move' value='rename'>\r\n\t\t\t\t\t<input type='hidden' name='pathFrom' value=\"" . htmlentities($w, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t\t<input type='text' name='pathTo' style='max-width:100%; white-space: normal;' value=\"" . htmlentities(basename($w), ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t\t<input type='submit' class='pure-button pure-button-primary' value='" . Settings::_("adminpanel", "rename") . "'>\r\n\t\t\t\t</form>";
     } else {
         $ret .= "<form class='niceform pure-form' action='?a=Upl' method='post'>\r\n\t\t\t\t\t\t<input type='hidden' name='path' value=\"" . htmlentities($w, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t\t\t<input id='foldername' name='newdir' style='max-width:100%;' type='text' value='" . Settings::_("adminpanel", "new") . "'>\r\n\t\t\t\t\t\t<input type='submit' class='pure-button pure-button-primary' value='" . Settings::_("adminpanel", "create") . "'>\r\n\t\t\t\t\t</form>";
         /// Upload Images form
         /*$ret .= "<div id='files'></div>";
         		$w=File::a2r(CurrentUser::$path);
         		$ret .= "<form class='dropzone' id=\"".htmlentities($w, ENT_QUOTES ,'UTF-8')."\" 
         			action='?a=Upl' method='POST' enctype='multipart/form-data'>
         			<input type='hidden' name='path' value=\"".htmlentities($w, ENT_QUOTES ,'UTF-8')."\">
         			<input type='hidden' name='inherit' value='1' />
         			<input type='file' name='images[]' multiple >
         			<button>Upload</button>
         			<div>".Settings::_("adminpanel","upload")."</div>
         			</form>";
         			*/
     }
     return $ret;
 }
Example #2
0
 /**
  * Create image
  *
  * @param string $file 
  * @author Thibaud Rohmer
  */
 public function __construct($file = NULL, $forcebig = false)
 {
     /// Check file type
     if (!isset($file) || !File::Type($file) || File::Type($file) != "Image") {
         return;
     }
     /// Set relative path (url encoded)
     $this->fileweb = urlencode(File::a2r($file));
     /// Set relative path to parent dir (url encoded)
     $this->dir = urlencode(dirname(File::a2r($file)));
     /// Get image dimensions
     list($this->x, $this->y) = getimagesize($file);
     /// Set big image
     if ($forcebig) {
         $this->t = "Big";
     } else {
         $this->t = "Img";
         if ($this->x >= 1200 || $this->y >= 1200) {
             if ($this->x > $this->y) {
                 $this->x = 1200;
             } else {
                 $this->x = $this->x * 1200 / $this->y;
             }
         }
     }
 }
Example #3
0
 /**
  * Create ImagePanel
  *
  * @param string $file 
  * @author Thibaud Rohmer
  */
 public function __construct($file = NULL)
 {
     if (!isset($file)) {
         return;
     }
     /// Create Image object
     $this->image = new Image($file);
     /// Create Video object
     $this->video = new Video($file);
     /// Create Image object
     $this->imagebar = new ImageBar($file);
     /// Create EXIF object
     $this->exif = new Exif($file);
     if (!Settings::$nocomments) {
         /// Create Comments object
         $this->comments = new Comments($file);
     }
     $pageURL = Settings::$site_address . "/?f=" . urlencode(File::a2r($file));
     // generate the header - opengraph metatags for facebook
     $this->page_header = "<meta property=\"og:url\" content=\"" . $pageURL . "\"/>\n" . "<meta property=\"og:site_name\" content=\"" . Settings::$name . "\"/>\n" . "<meta property=\"og:type\" content=\"website\"/>\n" . "<meta property=\"og:title\" content=\"" . Settings::$name . ": " . File::a2r($file) . "\"/>\n" . "<meta property=\"og:image\" content=\"" . Settings::$site_address . "/?t=Thb&f=" . urlencode(File::a2r($file)) . "\"/>\n";
     if (Settings::$fbappid) {
         $this->page_header .= "<meta property=\"fb:app_id\" content=\"" . Settings::$fbappid . "\"/>\n";
     }
     /// Set the Judge
     $this->judge = new Judge($file);
 }
Example #4
0
 /**
  * Create the ImageBar
  * 
  * @author Thibaud Rohmer
  */
 public function __construct($fs = false)
 {
     $file = urlencode(File::a2r(CurrentUser::$path));
     $this->photosphere = basename(dirname(CurrentUser::$path)) == "PhotoSpheres";
     $this->buttons['prev'] = "?p=p&f=" . $file;
     $this->awesome['prev'] = "<i class='fa fa-chevron-left fa-lg'></i>";
     $this->buttons['back'] = "?f=" . urlencode(File::a2r(dirname(CurrentUser::$path)));
     $this->awesome['back'] = "<i class='fa fa-reply fa-lg'></i>";
     if (!Settings::$nodownload) {
         $this->buttons['img'] = "?t=Big&f=" . $file;
         $this->awesome['img'] = "<i class='fa fa-eye fa-lg'></i>";
         $this->buttons['get'] = "?t=BDl&f=" . $file;
         $this->awesome['get'] = "<i class='fa fa-download fa-lg'></i>";
     }
     $this->buttons['slideshow'] = "?f=" . $file;
     $this->awesome['slideshow'] = "<i class='fa fa-youtube-play fa-lg'></i>";
     if ($this->photosphere) {
         $this->buttons['pshere'] = "#' id='photosphere";
         $this->awesome['pshere'] = "<img height='20px' src='inc/photosphere_logo.png'/>";
     }
     $this->buttons['next'] = "?p=n&f=" . $file;
     $this->awesome['next'] = "<i class='fa fa-chevron-right fa-lg'></i>";
     $this->buttons['pause'] = "?f=" . $file;
     $this->awesome['pause'] = "<i class='fa fa-pause fa-lg'></i>";
     $this->buttons['play'] = "?f=" . $file;
     $this->awesome['play'] = "<i class='fa fa-play fa-lg'></i>";
     $this->buttons['stop'] = "?f=" . $file;
     $this->awesome['stop'] = "<i class='fa fa-stop fa-lg'></i>";
 }
Example #5
0
 public function toHTML()
 {
     if (CurrentUser::$admin) {
         $this->info->toHTML();
     }
     $this->exif->toHTML();
     echo "<div id='comments' class='box'>\n";
     if (!Settings::$nocomments) {
         $this->comments->toHTML();
     }
     echo "</div>\n";
     echo "<div id='share'>\n";
     /*
     		if(Settings::$plusone){	
     			echo "<br/><br/>";
     			echo '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>';
     			
     			echo '<g:plusone></g:plusone>';
     			echo '<br/><br/>';
     		}
     */
     if (Settings::$like) {
         $rootURL = Settings::$site_address;
         $pageURL = $rootURL . "/?f=" . urlencode(File::a2r(CurrentUser::$path));
         echo '<iframe src="//www.facebook.com/plugins/like.php?href=' . $pageURL . '&amp;send=false&amp;layout=button_count&amp;width=100&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>';
     }
     echo "</div>";
 }
Example #6
0
 /**
  * Construct BoardItem
  *
  * @param string $file 
  * @param string $ratio 
  * @author Thibaud Rohmer
  */
 public function __construct($dir, $img)
 {
     $this->path = $dir;
     $this->url = urlencode(File::a2r($dir));
     if ($img == NULL) {
         $this->img = 'inc/folder.png';
     } else {
         $this->img = "?t=Thb&f=" . urlencode(File::a2r($img));
     }
 }
Example #7
0
 /**
  * Display comment on website
  *
  * @return void
  * @author Thibaud Rohmer
  */
 public function toHTML($id = 0)
 {
     $login = stripslashes(htmlentities($this->login, ENT_QUOTES, 'UTF-8'));
     $content = stripslashes(htmlentities($this->content, ENT_QUOTES, 'UTF-8'));
     $date = $this->date;
     echo "<div class='pure-g'>\n";
     echo "<div class='pure-u-1-2 commentauthor'><div>{$login}</div></div>\n";
     echo "<div class='pure-u-1-2 commentcontent'>{$content}\n";
     if (CurrentUser::$admin) {
         echo "<div class='commentdelete'><form action='?t=Adm&a=CDe' method='post'>\r\n\t\t\t\t\t\t\t\t<input type='hidden' name='image' value='" . htmlentities(File::a2r($this->file), ENT_QUOTES, 'UTF-8') . "'>\r\n\t\t\t\t\t\t\t\t<input type='hidden' name='id' value='{$id}'>\r\n\t\t\t\t\t\t\t\t<input type='submit' class='pure-button button-xsmall button-warning' value='x'>\r\n\t\t\t\t\t\t\t</form></div>";
     }
     echo "</div>\n";
     echo "</div>\n";
 }
Example #8
0
 /**
  * Display comment on website
  *
  * @return void
  * @author Thibaud Rohmer
  */
 public function toHTML()
 {
     $login = stripslashes(htmlentities($this->login, ENT_QUOTES, 'UTF-8'));
     $content = stripslashes(htmlentities($this->content, ENT_QUOTES, 'UTF-8'));
     $date = $this->date;
     echo "<div class='comment'>\n";
     // Not implemented yet.
     if (false && (CurrentUser::$admin || $login == CurrentUser::$account->login)) {
         echo "<div class='delete'>\n\t\t\t\t\t\t\t<form action='?t=Adm&a=CDe' method='post'>\n\t\t\t\t\t\t\t\t<input type='hidden' name='image' value='" . htmlentities(File::a2r($this->file), ENT_QUOTES, 'UTF-8') . "'>\n\t\t\t\t\t\t\t\t<input type='hidden' name='date' value='{$date}'>\n\t\t\t\t\t\t\t\t<input type='submit' value='x'>\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t</div>";
     }
     echo "<div class='login name'>{$login}</div>\n";
     echo "<div class='content'>{$content}</div>\n";
     echo "</div>\n";
 }
Example #9
0
 public function infodirtoHTML($dir)
 {
     $w = File::a2r($dir);
     $ret = "";
     /// Folder name
     if (strlen($w) > 1) {
         $ret .= "<form class='rename' action='?a=Mov' method='post'>\n\t\t\t\t\t<input type='hidden' name='move' value='rename'>\n\t\t\t\t\t<input type='hidden' name='pathFrom' value=\"" . htmlentities($w, ENT_QUOTES, 'UTF-8') . "\">\n\t\t\t\t<fieldset>\n\t\t\t\t\t<input type='text' name='pathTo' value=\"" . htmlentities(basename($w), ENT_QUOTES, 'UTF-8') . "\">\n\t\t\t\t\t<input type='submit' value='" . Settings::_("adminpanel", "rename") . "'>\n\t\t\t\t</fieldset>\n\t\t\t\t</form>";
     }
     if (!$this->isfile) {
         $ret .= "<form class='create' action='?a=Upl' method='post'>\n\t\t\t\t\t<fieldset>\n\t\t\t\t\t\t<input type='hidden' name='path' value=\"" . htmlentities($w, ENT_QUOTES, 'UTF-8') . "\">\n\t\t\t\t\t\t<input id='foldername' name='newdir' type='text' value='" . Settings::_("adminpanel", "new") . "'>\n\t\t\t\t\t\t<input type='submit' value='" . Settings::_("adminpanel", "create") . "'>\n\t\t\t\t\t</fieldset>\n\t\t\t\t\t</form>";
         /// Upload Images form
         $ret .= "<div id='files'></div><form class='dropzone' id=\"" . htmlentities($w, ENT_QUOTES, 'UTF-8') . "\" \n\t\t\t\taction='?a=Upl' method='POST' enctype='multipart/form-data'>\n\t\t\t\t<input type='hidden' name='path' value=\"" . htmlentities($w, ENT_QUOTES, 'UTF-8') . "\">\n\t\t\t\t<input type='file' name='images[]' multiple >\n\t\t\t\t<button>Upload</button>\n\t\t\t\t<div>" . Settings::_("adminpanel", "upload") . "</div>\n\t\t\t\t</form>";
     }
     return $ret;
 }
Example #10
0
 /**
  * Create upload page
  * 
  * @author Thibaud Rohmer
  */
 public function __construct()
 {
     /// Get all subdirs
     $list_dirs = Menu::list_dirs(Settings::$photos_dir, true);
     /// Get all subfiles
     $list_files = Menu::list_files(Settings::$photos_dir, true);
     foreach ($list_dirs as $dir) {
         $this->files[] = File::a2r($dir);
     }
     foreach ($list_files as $file) {
         $this->files[] = File::a2r($file);
     }
     if (isset(CurrentUser::$path)) {
         $this->selected = File::a2r(CurrentUser::$path);
     }
 }
Example #11
0
 /**
  * Create the ImageBar
  * 
  * @author Thibaud Rohmer
  */
 public function __construct($fs = false)
 {
     $file = urlencode(File::a2r(CurrentUser::$path));
     //		if($fs){
     //			$t = "?t=Fs&";
     //		}else{
     $t = "?";
     //		}
     $this->buttons['prev'] = $t . "p=p&f=" . $file;
     $this->buttons['back'] = "?f=" . urlencode(File::a2r(dirname(CurrentUser::$path)));
     if (!Settings::$nodownload) {
         $this->buttons['img'] = "?t=Big&f=" . $file;
         $this->buttons['get'] = "?t=BDl&f=" . $file;
     }
     $this->buttons['next'] = $t . "p=n&f=" . $file;
     $this->buttons['slideshow'] = $t . "f=" . $file;
 }
Example #12
0
 public function __construct()
 {
     if (CurrentUser::$admin || CurrentUser::$uploader) {
         $this->info = new AdminPanel();
     }
     $this->exif = new Exif(CurrentUser::$path);
     if (!Settings::$nocomments) {
         $this->comments = new Comments(CurrentUser::$path);
     }
     $this->path = urlencode(File::a2r(CurrentUser::$path));
     $this->title = basename(CurrentUser::$path);
     $this->w = File::a2r(CurrentUser::$path);
     if (is_file(CurrentUser::$path)) {
         $this->thumb = "<img src=\"?t=Thb&f=" . urlencode(File::a2r(CurrentUser::$path)) . "\" />";
         $this->dl = "?t=BDl&f={$this->path}";
     } else {
         $this->thumb = "<img src='inc/folder.png' />";
         $this->dl = "?t=Zip&f={$this->path}";
     }
     if (CurrentUser::$admin) {
         $this->deleteform = "<div id='deleteform'><form class='pure-form' action='?a=Del' method='post'>\r\n\t\t\t\t<input type='hidden' name='del' value=\"" . htmlentities($this->w, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t\t\t<button class='button-round button-error' type='submit'><i class='fa fa-trash-o'></i></button>\r\n\t\t\t\t</form>\r\n\t\t\t\t</div>";
     }
 }
Example #13
0
 /**
  * Create Menu
  *
  * @param string $dir 
  * @param int $level
  * @author Thibaud Rohmer
  */
 public function __construct($dir = null, $level = 0)
 {
     /// Init Menu
     if ($dir == null) {
         $dir = Settings::$photos_dir;
     }
     /// Check rights
     if (!Judge::view($dir) || Judge::searchDir($dir) == NULL) {
         return;
     }
     if (!CurrentUser::$admin && !CurrentUser::$uploader && sizeof($this->list_files($dir, true, false, true)) == 0) {
         return;
     }
     /// Set variables
     $this->title = end(explode('/', $dir));
     $this->webdir = urlencode(File::a2r($dir));
     $this->path = File::a2r($dir);
     try {
         /// Check if selected dir is in $dir
         File::a2r(CurrentUser::$path, $dir);
         $this->selected = true;
         $this->class = "level-{$level} selected";
     } catch (Exception $e) {
         /// Selected dir not in $dir, or nothing is selected
         $this->selected = false;
         $this->class = "level-{$level}";
     }
     /// Create Menu for each directory
     $subdirs = $this->list_dirs($dir);
     if (Settings::$reverse_menu) {
         $subdirs = array_reverse($subdirs);
     }
     foreach ($subdirs as $d) {
         $this->items[] = new Menu($d, $level + 1);
     }
 }
Example #14
0
 /**
  * Provide an image to the user, if he is allowed to
  * see it. If $thumb is true, provide the thumb associated
  * to the image.
  *
  * @param string $file 
  * @param string $thumb 
  * @return void
  * @author Thibaud Rohmer
  */
 public static function Image($file, $thumb = false, $large = false, $output = true, $dl = false)
 {
     if (!Judge::view($file)) {
         return;
     }
     if (function_exists("error_reporting")) {
         error_reporting(0);
     }
     /// Check item
     $file_type = File::Type($file);
     switch ($file_type) {
         case "Image":
             $is_video = false;
             break;
         case "Video":
             $is_video = true;
             break;
         default:
             return;
     }
     //error_log('DEBUG/Provider::image: '.$file.' '.($is_video?'is_video':''));
     if (!$large) {
         try {
             if ($is_video) {
                 //TODO: fix so when opening the folder the first time no need to do F5 to see
                 //the freshly created thumbnail
                 Video::FastEncodeVideo($file);
                 $basefile = new File($file);
                 $basepath = File::a2r($file);
                 $path = Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . ".jpg";
             } elseif ($thumb) {
                 // Img called on a video, return the thumbnail
                 $path = Provider::thumb($file);
             } else {
                 $path = Provider::small($file);
             }
         } catch (Exception $e) {
             // do nothing
         }
     }
     if (!isset($path) || !file_exists($path)) {
         error_log('ERROR/Provider::image path:' . $path . ' does not exist, using ' . $file);
         $path = $file;
     }
     if ($output) {
         if ($dl) {
             header('Content-Disposition: attachment; filename="' . basename($file) . '"');
         } else {
             $expires = 60 * 60 * 24 * 14;
             $last_modified_time = filemtime($path);
             $last_modified_time = 0;
             $etag = md5_file($file);
             header("Last-Modified: " . 0 . " GMT");
             header("Pragma: public");
             header("Cache-Control: max-age=360000");
             header("Etag: {$etag}");
             header("Cache-Control: maxage=" . $expires);
             header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
         }
         header('Content-type: image/jpeg');
         if (File::Type($path) == "Image") {
             readfile($path);
             return;
             try {
                 imagejpeg(Provider::autorotate_jpeg($path));
             } catch (Exception $e) {
                 error_log('ERROR/Provider.php: cannot rotate ' . $path . ': ' . $e);
                 readfile($path);
             }
         } else {
             readfile($path);
         }
     }
 }
Example #15
0
 /**
  * Provide an image to the user, if he is allowed to
  * see it. If $thumb is true, provide the thumb associated
  * to the image.
  *
  * @param string $file 
  * @param string $thumb 
  * @return void
  * @author Thibaud Rohmer
  */
 public static function image($file, $thumb = false, $large = false, $output = true, $dl = false)
 {
     if (!Judge::view($file)) {
         return;
     }
     if (function_exists("error_reporting")) {
         error_reporting(0);
     }
     /// Check item
     //~ if(!File::Type($file) || File::Type($file) != "Image"){
     //~ return;
     //~ }
     if (File::Type($file) == "Video") {
         $basefile = new File($file);
         $basepath = File::a2r($file);
         /// Build relative path to webimg
         $path = Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . ".jpg";
         Video::FastEncodeVideo($file, $basefile->extension);
         $large = true;
     }
     if (!$large) {
         try {
             if ($thumb) {
                 $path = File::r2a(File::a2r($file), Settings::$thumbs_dir);
                 if (!file_exists($path) || filectime($file) > filectime($path)) {
                     require_once dirname(__FILE__) . '/../phpthumb/ThumbLib.inc.php';
                     /// Create directories
                     if (!file_exists(dirname($path))) {
                         @mkdir(dirname($path), 0750, true);
                     }
                     /// Create thumbnail
                     $thumb = PhpThumbFactory::create($file);
                     $thumb->resize(200, 200);
                     $thumb->save($path);
                 }
             } else {
                 list($x, $y) = getimagesize($file);
                 if ($x > 800 || $y > 600) {
                     require_once dirname(__FILE__) . '/../phpthumb/ThumbLib.inc.php';
                     $basefile = new File($file);
                     $basepath = File::a2r($file);
                     /// Build relative path to webimg
                     $webimg = dirname($basepath) . "/" . $basefile->name . "_small." . $basefile->extension;
                     /// Set absolute path to comments file
                     $path = File::r2a($webimg, Settings::$thumbs_dir);
                     if (!file_exists($path) || filectime($file) > filectime($path)) {
                         /// Create smaller image
                         if (!file_exists(dirname($path))) {
                             @mkdir(dirname($path), 0755, true);
                         }
                         $thumb = PhpThumbFactory::create($file);
                         $thumb->resize(800, 600);
                         $thumb->save($path);
                     }
                 } else {
                     $path = $file;
                 }
             }
         } catch (Exception $e) {
             // do nothing
         }
     }
     if (!isset($path) || !file_exists($path)) {
         $path = $file;
     }
     if ($output) {
         if ($dl) {
             header('Content-Disposition: attachment; filename="' . basename($file) . '"');
             header('Content-type: image/jpeg');
         } else {
             $expires = 60 * 60 * 24 * 14;
             $last_modified_time = filemtime($path);
             $last_modified_time = 0;
             $etag = md5_file($file);
             header("Last-Modified: " . 0 . " GMT");
             header("Pragma: public");
             header("Cache-Control: max-age=360000");
             header("Etag: {$etag}");
             header("Cache-Control: maxage=" . $expires);
             header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
             header('Content-type: image/jpeg');
         }
         readfile($path);
     }
 }
Example #16
0
 /**
  * Board constructor
  *
  * @param string $path 
  * @author Thibaud Rohmer
  */
 public function __construct($path = NULL)
 {
     if (!isset($path)) {
         $path = CurrentUser::$path;
     }
     $this->analyzed = array();
     $this->path = $path;
     // If $path is a file, list directory containing the file
     if (is_file($path)) {
         $this->path = dirname($path);
     }
     $this->title = basename($this->path);
     $this->header = new BoardHeader($this->title, $this->path);
     $this->files = Menu::list_files($this->path);
     $this->dirs = Menu::list_dirs($this->path);
     $pageURL = Settings::$site_address . "/?f=" . urlencode(File::a2r($this->path));
     // generate the header - opengraph metatags for facebook
     $this->page_header = "<meta property=\"og:url\" content=\"" . $pageURL . "\"/>\n" . "<meta property=\"og:site_name\" content=\"" . Settings::$name . "\"/>\n" . "<meta property=\"og:type\" content=\"article\"/>\n" . "<meta property=\"og:title\" content=\"" . Settings::$name . ": " . File::a2r($this->path) . "\"/>\n";
     if (Settings::$fbappid) {
         $this->page_header .= "<meta property=\"fb:app_id\" content=\"" . Settings::$fbappid . "\"/>\n";
     }
     if (!empty($this->files)) {
         $i = 0;
         foreach ($this->files as $file) {
             if ($i > 9) {
                 break;
             }
             if (Judge::is_public($file)) {
                 $this->page_header .= "<meta property=\"og:image\" content=\"" . Settings::$site_address . "/?t=Thb&f=" . urlencode(File::a2r($file)) . "\"/>\n";
                 $i++;
             }
         }
     } else {
         // No files in the directory, getting thumbnails from sub-directories
         $i = 0;
         foreach ($this->dirs as $d) {
             if ($i > 9) {
                 break;
             }
             $img = Judge::searchDir($d, true);
             if ($img) {
                 $this->page_header .= "<meta property=\"og:image\" content=\"" . Settings::$site_address . "/?t=Thb&f=" . urlencode(File::a2r($img)) . "\"/>\n";
                 $i++;
             }
         }
     }
     // Generate the grid
     $this->grid();
     $this->foldergrid();
 }
 /**
  * test get_path function
  * @test
  * @depends test_create
  * @depends test_generate_key
  */
 public function test_get_path()
 {
     self::login_as_admin();
     $key = Guesttoken::generate_key();
     $path = Settings::$photos_dir . "/tokenfolder";
     GuestToken::create($path, $key);
     $tpath = GuestToken::get_path($key);
     $this->assertEquals(File::a2r($path), $tpath);
 }
Example #18
0
 private function toMainCommentsFile($comment)
 {
     $maincomm = Settings::$conf_dir . "/comments.xml";
     if (!file_exists($maincomm)) {
         $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><comments></comments>');
     } else {
         $xml = simplexml_load_file($maincomm);
     }
     $c = $xml->addChild("comment");
     $c->addChild("login", $comment->login);
     $c->addChild("date", $comment->date);
     $c->addChild("content", $comment->content);
     $c->addChild("webfile", $this->webfile);
     $c->addChild("path", File::a2r($this->file));
     while ($xml->count() > Settings::$max_comments) {
         unset($xml->comment[0]);
     }
     $xml->asXML($maincomm);
 }
Example #19
0
 public function infodirtoHTML($dir)
 {
     $w = File::a2r($dir);
     $ret = "";
     if (strlen($w) > 1) {
         $ret .= "<form class='pure-form' action='?a=Mov' method='post'>\r\n\t\t\t\t\t<input type='hidden' name='move' value='rename'>\r\n\t\t\t\t\t<input type='hidden' name='pathFrom' value=\"" . htmlentities($w, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t\t<div class='pure-g'>\r\n\t\t\t\t\t\t<div class=' pure-u-1-2'>\r\n\t\t\t\t\t\t\t<input type='text' class='toto' name='pathTo' value=\"" . htmlentities(basename($w), ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class='pure-u-1-2'>\r\n\t\t\t\t\t\t\t<input class='pure-button pure-button-primary' type='submit' value='" . Settings::_("adminpanel", "rename") . "'>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</form>";
     }
     /// Folder name
     if (is_dir($dir)) {
         $ret .= "<form class='niceform pure-form' action='?a=Upl' method='post'>\r\n\t\t\t\t\t\t<input type='hidden' name='path' value=\"" . htmlentities($w, ENT_QUOTES, 'UTF-8') . "\">\r\n\r\n\t\t\t\t\t\t<div class='pure-g'>\r\n\t\t\t\t\t\t\t<div class=' pure-u-1-2'>\r\n\t\t\t\t\t\t\t\t<input id='foldername' name='newdir' style='max-width:100%;' type='text' value='" . Settings::_("adminpanel", "new") . "'>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t<div class='pure-u-1-2'>\r\n\t\t\t\t\t\t\t\t<input type='submit' class='pure-button pure-button-primary' value='" . Settings::_("adminpanel", "create") . "'>\r\n\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</form>";
     }
     return $ret;
 }
Example #20
0
 public static function Video($file, $width = '100%', $height = '100%', $control = false)
 {
     if (!Judge::view($file)) {
         return;
     }
     if (function_exists("error_reporting")) {
         error_reporting(0);
     }
     /// Check item
     if (!File::Type($file) || File::Type($file) != "Video") {
         return;
     }
     $basefile = new File($file);
     $basepath = File::a2r($file);
     $path_webm = Settings::$thumbs_dir . dirname($basepath) . "/" . $basefile->name . '.webm';
     $c = null;
     Video::FastEncodeVideo($file);
     $wh = ' height="' . $height . '" width="' . $width . '"';
     if ($control) {
         $c = ' controls="controls"';
     }
     echo '<video' . $wh . $c . '><source src="' . $path_webm . '" type="video/webm" /></video>';
     //echo 'Webm Video Codec not found.Plaese up to date the brower or Download the codec <a href="http://tools.google.com/dlpage/webmmf">Download</a>';
 }
Example #21
0
 /**
  * Display settings page
  */
 public function toHTML()
 {
     echo "<div class='header'>";
     echo "<h1>Settings</h1>";
     echo "</div>";
     /// Site Title
     echo "<form class='niceform pure-form pure-form-aligned' action='?t=Adm&a=Set' method='post'>\n";
     echo "<h2>Global</h2>\r\n\t\t\t\t<div class='pure-control-group'>\r\n\t\t\t\t\t<label for='name'>" . Settings::_("settings", "title") . "</label>\r\n\t\t\t\t\t<input type='text' name='name' value=\"" . htmlentities(Settings::$name, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t</div>";
     /// Site Address
     echo "<div class='pure-control-group'>\r\n\t\t\t\t\t<label>" . Settings::_("settings", "site_address") . "</label>\r\n\t\t\t\t\t<input type='text' name='site_address' value=\"" . htmlentities(Settings::$site_address, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t</div>";
     /// Language
     echo "<div class='pure-control-group'>\r\n\t\t\t\t\t<label>" . Settings::_("settings", "language") . "</label>\r\n\t\t\t\t\t<select name='loc'>";
     foreach (Settings::$ava_loc as $l) {
         $p = htmlentities($l, ENT_QUOTES, 'UTF-8');
         echo "<option value=\"" . addslashes($p) . "\"";
         if ($p == Settings::$loc) {
             echo " selected ";
         }
         echo ">" . substr($p, 0, -4) . "</option>";
     }
     echo "</select>";
     echo "</div>";
     /// User Theme
     echo "<div class='pure-control-group'>\r\n\t\t\t\t\t<label>" . Settings::_("settings", "user_theme") . "</label>\r\n\t\t\t\t\t<select name='user_theme'>";
     foreach (Settings::$ava_themes as $l) {
         $p = htmlentities($l, ENT_QUOTES, 'UTF-8');
         echo "<option value=\"" . addslashes($p) . "\"";
         if ($p == Settings::$user_theme) {
             echo " selected ";
         }
         echo ">{$p}</option>";
     }
     echo "</select>";
     echo "</div>";
     echo "<h2>Options</h2>";
     $options = array("noregister", "forcehttps", "nocomments", "nodownload", "reverse_menu", "l33t", "rss");
     foreach ($options as $val) {
         $c = Settings::${$val} ? "checked" : "";
         echo "<div class='pure-controls'><label><input type='checkbox' name='{$val}' {$c}> " . Settings::_("settings", $val) . "</label></div>\n";
     }
     /// Max Comments
     echo "<div class='pure-control-group'>\r\n\t\t\t\t\t<label>" . Settings::_("settings", "numcomments") . "</label>\r\n\t\t\t\t\t<input type='text' name='max_comments' value=\"" . htmlentities(Settings::$max_comments, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t</div>\n";
     /// Thumbs size
     echo "<div class='pure-control-group'>\r\n\t\t\t\t\t<label>" . Settings::_("settings", "thumbs_size") . "</label>\r\n\t\t\t\t\t<input type='text' name='max_img_dir' value=\"" . htmlentities(Settings::$thumbs_size, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t</div>\n";
     echo "<h2>Social Networks</h2>";
     /// Facebook Button
     $c = Settings::$like ? "checked" : "";
     echo "<div class='pure-controls'>\r\n\t\t\t\t<label><input type='checkbox' name='like' {$c}>" . Settings::_("settings", "fb") . "</label>\r\n\t\t\t</div>\n";
     /// Facebook App ID
     echo "<div class='pure-control-group'>\r\n\t\t\t\t\t<label>" . Settings::_("settings", "facebook_appid") . "</label>\r\n\t\t\t\t\t<input type='text' name='fbappid' value=\"" . htmlentities(Settings::$fbappid, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t</div>";
     echo "<h2>Video</h2>";
     /// Encode Video
     echo "<span>" . Settings::_("settings", "video_comment") . "</span>";
     echo "<div class='pure-controls'>";
     $c = Settings::$encode_video ? "checked" : "";
     echo "<label><input type='checkbox' name='encode_video' {$c}>Encode Video</label>\n";
     echo "</div>";
     /// FFmpeg Path
     echo "<div class='pure-control-group'>\r\n\t\t\t\t\t<label>" . Settings::_("settings", "ffmpeg_path") . "</label>\r\n\t\t\t\t\t<input type='text' name='ffmpeg_path' value=\"" . htmlentities(Settings::$ffmpeg_path, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t</div>\n";
     /// FFmpeg command line
     echo "<div class='pure-control-group'>\r\n\t\t\t\t\t<label>" . Settings::_("settings", "ffmpeg_option") . "</label>\r\n\t\t\t\t\t<input type='text' name='ffmpeg_option' value=\"" . htmlentities(Settings::$ffmpeg_option, ENT_QUOTES, 'UTF-8') . "\">\r\n\t\t\t\t</div>";
     echo "<div class='pure-controls'><input type='submit' class='pure-button pure-button-primary' value='" . Settings::_("settings", "submit") . "'/></div>\n";
     echo "</form>\n";
     echo "<div class='section'><h2>" . Settings::_("settings", "generate") . "</h2>";
     echo "<form class='niceform pure-form' action='?t=Adm&a=GAl' method='post'>\n";
     echo "<fieldset>\r\n\t\t\t\t\t<label>" . Settings::_("settings", "folder") . "</label>\r\n\t\t\t\t\t<select name='path'>";
     echo "<option value='.'>" . Settings::_("settings", "all") . "</option>";
     foreach ($this->folders as $f) {
         $p = htmlentities(File::a2r($f), ENT_QUOTES, 'UTF-8');
         echo "<option value=\"" . addslashes($p) . "\">" . basename($p) . "</option>";
     }
     echo "</select>";
     echo "<input type='submit' class='pure-button pure-button-primary' value='" . Settings::_("settings", "submit") . "'/>\n";
     echo "</fieldset>";
     echo "</form>";
     echo "</div>";
 }
Example #22
0
 /**
  * Returns true if the token is allowed to view the file
  * in the given path
  *
  * @param string $key
  * @param string $path
  * $return bool
  * @author Franck Royer
  */
 public static function view($key, $path)
 {
     $rpath = File::a2r($path) . "/";
     $apath = self::get_path($key) . "/";
     // Remove double slashes
     preg_replace('/\\/\\/+/', '/', $rpath);
     preg_replace('/\\/\\/+/', '/', $apath);
     // Check if the tokens file exists
     if (!file_exists(CurrentUser::$tokens_file)) {
         return false;
     }
     if (!$apath || !$rpath) {
         return false;
     }
     if (preg_match("/^" . preg_quote($apath, '/') . "/", $rpath)) {
         return true;
     }
     return false;
 }
Example #23
0
 /**
  * Path comes in, relative and absolute path come out
  *
  * @param string $path 
  * @return void
  * @author Thibaud Rohmer
  */
 public static function paths($path, $dir = NULL)
 {
     if (!isset($dir)) {
         $dir = Settings::$photos_dir;
     }
     try {
         $rel = File::a2r($path, $dir);
         $abs = $path;
     } catch (Exception $e) {
         // This path is already relative
         $rel = $path;
         $abs = File::r2a($path, $dir);
     }
     return array($rel, $abs);
 }
Example #24
0
 /**
  * Create BoardHeader
  *
  * @param string $title 
  * @author Thibaud Rohmer
  */
 public function __construct($title, $path)
 {
     $this->path = urlencode(File::a2r($path));
     $this->title = $title;
 }
Example #25
0
 /**
  * Create a job file
  *   
  * @return void
  * @author Franck Royer
  */
 public static function CreateJob($file, $pid)
 {
     if (!self::NoJob($file)) {
         error_log('ERROR/Video: job for ' . $file . ' already exists, not creating second job file');
         return;
     }
     if (!$pid || $pid == '' || $pid == '0') {
         error_log('ERROR/Video: pid for ' . $file . ' is invalid, not creating job file');
         return;
     }
     // Open file
     $file_file = new File($file);
     $job_filename = Settings::$thumbs_dir . dirname(File::a2r($file)) . "/" . $file_file->name . '.job';
     $job_file = fopen($job_filename, "w");
     if (!$job_file) {
         error_log('ERROR/Video: Cannot write on ' . $job_filename . '.');
         return;
     }
     //error_log('DEBUG/Video: store PID '.$pid.' in '.$job_filename);
     fwrite($job_file, $pid);
     fclose($job_file);
 }
Example #26
0
 public function dir2div($dir)
 {
     $subdirs = Menu::list_dirs($dir);
     $res = "<li class=' ";
     if (sizeof($subdirs) > 0) {
         $res .= " has_sub ";
     }
     try {
         File::a2r(CurrentUser::$path, $dir);
         $res .= " selected ";
     } catch (Exception $e) {
         // Do nothing
     }
     $res .= " dir'>";
     $res .= "\n\t\t<div class='title {$class}'>\t<span id='" . urlencode(File::a2r($dir)) . "' class='" . addslashes(htmlentities(File::a2r($dir), ENT_QUOTES, 'UTF-8')) . "'>" . htmlentities(basename($dir), ENT_QUOTES, 'UTF-8') . "</span></div>\n\t\t\t<ul class='subdirs'>\n\t\t\t";
     foreach ($subdirs as $d) {
         $res .= $this->dir2div($d);
     }
     $res .= "</ul></li>";
     return $res;
 }
Example #27
0
 /**
  * create a token and give you the ouput
  * actually it's a bit of cheating
  * if a token already exist for the given path we return it
  * otherwise, we create a new one
  */
 public function create_token($path = NULL)
 {
     // default path is the token folder
     if (!isset($path)) {
         $path = Settings::$photos_dir . "/tokenfolder";
     }
     // do we already have a token ?
     $tokens = GuestToken::find_for_path(File::a2r($path), true);
     if (!empty($tokens)) {
         return $tokens[0]['key'];
     }
     // No token found, Creating a token to allow guest view for the given path
     $key = Guesttoken::generate_key();
     if (!GuestToken::create($path, $key)) {
         throw new Exception("Cannot create token for path " . $path . "\n");
     }
     return $key;
 }
Example #28
0
 /**
  * Check if a file is viewable in a folder, and returns path to that file.
  */
 public static function searchDir($dir, $public_search = false)
 {
     $rightsdir = File::r2a(File::a2r($dir), Settings::$thumbs_dir);
     $rightsfiles = glob($rightsdir . "/.*ights.xml");
     // Check files
     foreach ($rightsfiles as $rf) {
         $f = Judge::associated_file($rf);
         if ($public_search and Judge::is_public($f) or !$public_search and Judge::view($f)) {
             if (is_file($f)) {
                 return $f;
             } else {
                 foreach (Menu::list_files($f, true) as $p) {
                     if ($public_search and Judge::is_public($p) or !$public_search and Judge::view($p)) {
                         return $p;
                     }
                 }
             }
         }
     }
     // Check subdirs
     foreach (Menu::list_dirs($dir) as $d) {
         if ($f = Judge::searchDir($d, $public_search)) {
             return $f;
         }
     }
     return false;
 }
Example #29
0
 /**
  * Construct BoardItem
  *
  * @param string $file 
  * @param string $ratio 
  * @author Thibaud Rohmer
  */
 public function __construct($file, $ratio = 0)
 {
     $this->path = $file;
     $this->file = urlencode(File::a2r($file));
     $this->ratio = $ratio;
 }
Example #30
0
 /**
  * Display BoardItem on Website
  *
  * @return void
  * @author Thibaud Rohmer
  */
 public function toHTML()
 {
     /// If item is small, display its thumb. Else, display the item
     $getfile = $this->width > 25 ? "t=Img&f={$this->file}" : "t=Thb&f={$this->file}";
     /// We display the image as a background
     echo "<div class='item";
     if (CurrentUser::$path == $this->path) {
         echo " selected ";
     }
     echo " '";
     echo " style='";
     echo " width: \t\t\t{$this->width}%;";
     echo " background: \t\turl(\"?{$getfile}\") no-repeat center center;";
     echo " -webkit-background-size: cover;";
     echo " -moz-background-size: cover;";
     echo " -o-background-size: cover;";
     echo " background-size: \tcover;";
     echo "'>\n";
     echo "<span class='name hidden'>" . htmlentities(basename($this->path), ENT_QUOTES, 'UTF-8') . "</span>";
     echo "<span class='path hidden'>" . htmlentities(File::a2r($this->path), ENT_QUOTES, 'UTF-8') . "</span>";
     echo "<a href='?f={$this->file}'>";
     echo "<img src='./inc/img.png' width='100%' height='100%'>";
     echo "</a>\n";
     echo "</div>\n";
 }