Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow symlinks to photos outside photos_dir, if enabled in config.php #327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/classes/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ public static function a2r($file,$dir=NULL){

if($rf==$rd) return "";

if(Settings::$allow_symlinks_outside_photos_dir && substr($rf,0,strlen($rd)) != $rd && is_file($rf) ){
return substr($file,strlen($dir) + 1 );
}

if( substr($rf,0,strlen($rd)) != $rd ){
throw new Exception("This file is not inside the photos folder !<br/>");
}
Expand Down
3 changes: 2 additions & 1 deletion src/classes/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ public static function list_files($dir,$rec = false, $hidden = false, $stopatfir

/// Content isn't hidden and is a file
if($content[0] != '.' || $hidden){
if(is_file($path=$dir."/".$content)){
$path = $dir."/".$content;
if(is_file($path) || is_link($path)){
if((File::Type($path) && (File::Type($path) == "Image" || File::Type($path)=="Video")) || $all_file_type){
/// Add content to list
$list[]=$path;
Expand Down
7 changes: 7 additions & 0 deletions src/classes/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class Settings extends Page
/// Quality of mini thumbnails in overview, scala: 0-100
static public $quality_mini = 90;

/// The user can enable this to allow symlinks in his photos_dir to point to files outside his photos_dir
static public $allow_symlinks_outside_photos_dir = false;


/**** Admin Settings ****/

Expand Down Expand Up @@ -201,6 +204,10 @@ static public function init($forced = false, $config_file = NULL){
Settings::$conf_dir = $config->ps_generated."/Conf/";
Settings::$admin_settings_file = $config->ps_generated."/Conf/admin_settings.ini";

if (isset($config->allow_symlinks_outside_photos_dir)) {
Settings::$allow_symlinks_outside_photos_dir = (bool) $config->allow_symlinks_outside_photos_dir;
}

if (isset($config->cache_max_age)) {
Settings::$cache_max_age = (int) $config->cache_max_age;
}
Expand Down