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

Selectable album thumbnail #348

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9b27eaf
Allow symlinks to photos outside photos_dir, is enabled in config.php
gboudreau Jan 19, 2017
56b6a1e
Bugfix: user with uppercase letters in its username broke the Groups …
gboudreau Feb 11, 2017
f4e0240
Fixing code validation notices in PHPDoc blocks
gboudreau Feb 11, 2017
0627d3a
Typo in Group::create() method
gboudreau Feb 11, 2017
815653c
Album Cover
Sep 25, 2017
6b973fc
MyConfig File
Sep 25, 2017
fa588ee
Select album cover from album image
Sep 26, 2017
2c09a4d
Merge branch 'master' into myConfig
Sep 27, 2017
24ecf1c
Merge pull request #1 from gboudreau/allow-symlinks-outside-photos-root
alesc Dec 24, 2017
feba79d
FIX : add natsort to directories
alesc Feb 27, 2018
b9095ab
Merge branch 'master' into myConfig
Feb 27, 2018
a9f2e8b
Merge remote-tracking branch 'Official/master'
Feb 27, 2018
c3e9a0e
Merge branch 'master' into myConfig
Feb 27, 2018
266b6b3
FIX : stop video bouncing
Feb 27, 2018
0611d8f
Merge branch 'master' into myConfig
Feb 27, 2018
57b72d1
FIX : Center login page on phone
Feb 27, 2018
1e8a7ef
Merge branch 'master' into myConfig
Feb 27, 2018
403b8be
Merge pull request #3 from gboudreau/276-admin-user-looses-root
alesc Feb 28, 2018
d227e6d
Merge remote-tracking branch 'origin/master' into myConfig
Feb 28, 2018
70919a3
CHANGE : Add Exif filter by year
Jul 28, 2018
572c776
Merge remote-tracking branch 'Official/master'
Jul 28, 2018
01d8ad8
Merge branch 'master' into myConfig
Jul 28, 2018
46fb524
FIX : Zip with // in path
Sep 16, 2018
b12662d
Merge branch 'mine'
Sep 16, 2018
1b546d2
FIX : remove error_log() from debug
alesc Sep 17, 2018
8f4f7cd
FIX : Correct default config
alesc Sep 17, 2018
c8be257
Add DSLR Theme
alesc Sep 26, 2020
42f2d80
Fix exiftran_field in settings
alesc Sep 26, 2020
4702b5c
Add Form and actionner to delete account
alesc Sep 26, 2020
7290c19
Make left menu collapsable
alesc Sep 26, 2020
c387ae2
Improve exif year headers
alesc Sep 26, 2020
8a85729
Merge branch 'DSLR_Theme' into master
alesc Sep 26, 2020
06b382c
Merge branch 'Fix_ffmpeg/exif' into master
alesc Sep 26, 2020
27e05e9
Merge branch 'Add_Delete_account_form' into master
alesc Sep 26, 2020
8121472
Merge branch 'Collasable_left_menu' into master
alesc Sep 26, 2020
f0d9493
Revert "Improve exif year headers" files commited by mistake
alesc Sep 26, 2020
b78eab9
Merge pull request #4 from thibaud-rohmer/master
alesc Oct 5, 2020
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
1 change: 1 addition & 0 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

// Local timezone. Default one is "Europe/Paris".
#$config->timezone = "Europe/Paris";
setlocale(LC_TIME, 'fr_FR.utf8','fra');

// If you want to inject a tracking code (or anything really) in your pages <head>, use this to refer to a file containing that:
#$config->tracking_code_include = '/path/to/something.html';
Expand Down
2 changes: 2 additions & 0 deletions inc/loc/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ numcomments = "Number of comments in Admin Stats"
numcomm = "Comments"
sens = "Max number of images displayed when hovering an album"
thumbs_size = "Thumbnails size (px)"
album_coverfilename = "Album cover filename"
images = "Images"
language = "Language"
user_theme = "Theme"
Expand Down Expand Up @@ -139,6 +140,7 @@ new = "New Folder"
create = "Create"
upload_heading = "Upload"
upload = "Upload images here"
cover = "Set as album cover"

[boardheader]
download = "DOWNLOAD"
Expand Down
2 changes: 2 additions & 0 deletions inc/loc/francais.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ numcomments = "Nombre de commentaires sur la page de stats"
numcomm = "Comms"
sens = "Nombre maximal d'images affich&eacute;es au survol d'album"
thumbs_size = "Taille des miniatures (px)"
album_coverfilename = "Miniatures des albums"
images = "Images"
language = "Langue"
user_theme = "Th&egrave;me"
Expand Down Expand Up @@ -134,6 +135,7 @@ new = "Nouveau dossier"
create = "Cr&eacute;er"
upload_heading = "Ajout"
upload = "Ajouter des images"
cover = "Définir comme miniature de l&apos;album"

[boardheader]
download = "T&Eacute;L&Eacute;CHARGER"
Expand Down
4 changes: 3 additions & 1 deletion inc/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
$(this).parent().children(".button-hidden").toggleClass("hidden");
});


$('#menu').animate({
scrollTop: ($('li.menu_title ul.selected').offset().top-$(window).height()/2)
}, 500);
60 changes: 37 additions & 23 deletions src/classes/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ public function __construct($login=NULL,$key=NULL){
//throw new Exception("Login $login not found");
return false;
}

/**
* Creates a new account in the base
*
* @param string $login
* @param string $password
* @author Thibaud Rohmer
*/

/**
* Creates a new account in the base
*
* @param string $login
* @param string $password
* @author Thibaud Rohmer
* @return bool
*/
public static function create($login, $password, $verif, $groups=array(),$name='',$email=''){

// Check if login already exists
Expand Down Expand Up @@ -162,7 +163,7 @@ public static function create($login, $password, $verif, $groups=array(),$name='
* Encrypt password
*
* @param string $password
* @return void
* @return string
* @author Thibaud Rohmer
*/
public static function password($password){
Expand All @@ -172,7 +173,7 @@ public static function password($password){
/**
* Generate key
*
* @return void
* @return string
* @author Thibaud Rohmer
*/
private function key(){
Expand Down Expand Up @@ -265,24 +266,30 @@ public function save(){
$xml->asXML($xml_infos);
}

/**
* Edit an account
*
* @param string $login
* @param string $old_password
* @param string $password
* @param string $name
* @param string $email
* @author Thibaud Rohmer
*/
/**
* Edit an account
*
* @param string $login
* @param string $old_password
* @param string $password
* @param string $name
* @param string $email
* @param array $groups
* @param string|null $language
* @throws Exception
* @author Thibaud Rohmer
*/
public static function edit($login=NULL, $old_password=NULL, $password=NULL, $name=NULL, $email=NULL, $groups=array(), $language=NULL){
/// Only the admin can modify other accounts
if( !CurrentUser::$admin && $login != CurrentUser::$account->login ){
return;
}

if(isset($login) && (preg_match("/^[A-Z][a-zA-Z -]+$/", $login) === 0) ){
$acc = new Account($login);
if(isset($login)){
$acc = new Account($login);
if(!$acc){
throw new Exception("Error: user with username '$login' not found.");
}
}else{
$acc = CurrentUser::$account;
}
Expand Down Expand Up @@ -415,7 +422,7 @@ public static function findAll(){
* Returns the rights of an account
*
* @param string $login
* @return void
* @return array
* @author Thibaud Rohmer
*/
public static function rights($login){
Expand Down Expand Up @@ -537,6 +544,13 @@ public function toHTML(){
</div>";

echo "</form>\n";
echo "<form class='niceform pure-form pure-form-aligned' method='post' action='#'>\n";
echo "<div class='pure-controls'>
<input type='hidden' name='login' value=\"".htmlentities($this->login, ENT_QUOTES ,'UTF-8')."\">
<input type='hidden' name='delete' value='plop' />
<input type='submit' class='pure-button button-error' value='Delete account'/>
</div>";
echo "</form>\n";
echo "</div>\n";
}

Expand Down
67 changes: 67 additions & 0 deletions src/classes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@ public function __construct(){
Admin::delete();
}
break;

case "Cpy" : if(isset($_POST['pathFrom'])){
try{
CurrentUser::$path = File::r2a(dirname(stripslashes($_POST['pathFrom'])));
}catch(Exception $e){
CurrentUser::$path = Settings::$photos_dir;
}
}
Admin::copyFile();

if(isset($_POST['copy']) && $_POST['copy']=="copy"){
try{
if(is_dir(File::r2a(stripslashes($_POST['pathFrom'])))){
CurrentUser::$path = dirname(File::r2a(stripslashes($_POST['pathFrom'])))."/".stripslashes($_POST['pathTo']);
}
}catch(Exception $e){
CurrentUser::$path = Settings::$photos_dir;
}
}

break;
}
}

Expand All @@ -133,6 +154,11 @@ public function __construct(){
case "Acc" : if(isset($_POST['edit'])){
Account::edit($_POST['login'],$_POST['old_password'],$_POST['password'],$_POST['name'],$_POST['email'],NULL,$_POST['language']);
}
if(isset($_POST['delete'])){
if (CurrentUser::$account != $_POST['login']){
Account::delete($_POST['login']);
}
}
if(isset($_POST['login'])){
$this->page = new Account($_POST['login']);
}else{
Expand Down Expand Up @@ -248,7 +274,48 @@ public static function move(){

return;
}


/**
* Copy files on the server
*
* @author Alesc from Thibaud Rohmer move() function
*/
public static function copyFile(){

/// Just to be really sure...
if( !(CurrentUser::$admin || CurrentUser::$uploader) ){
return;
}

$from = File::r2a(stripslashes($_POST['pathFrom']));
$to = dirname($from)."/".stripslashes($_POST['pathTo']);
$type = $_POST['copy'];

if($from == $to){
return;
}

if($type == "copy"){
/// Metadatas need to be done first: once moved/deleted,
/// we won't be able to compute from the original file
Admin::manage_metadatas(stripslashes($_POST['pathFrom']), stripslashes($_POST['pathTo']));
@copy($from,$to);
return;
}

/// We are moving multiple files
$files = scandir($from);
foreach($files as $file){
if($file != "." && $file!=".."){
Admin::manage_metadatas(stripslashes($_POST['pathFrom'])."/".$file,
stripslashes($_POST['pathTo'])."/".$file);
@copy($from."/".$file,$to."/".$file);
}
}

return;
}

/**
* Delete files on the server
Expand Down
43 changes: 35 additions & 8 deletions src/classes/Board.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private function grid($type="Image"){
continue;
}

$this->boarditems[] = new BoardItem($file);
$this->boarditems[] = new BoardItem($file,0,File::FileDate($file));
}
}

Expand All @@ -176,17 +176,18 @@ private function foldergrid(){
foreach($this->dirs as $d){
if(!Judge::view($d)) //Dir is not accessible (rights) - ignore it for better performance
continue;
$firstImg = Judge::searchDir($d);
if(!$firstImg){

$albumCover = Judge::searchAlbumImage($d);
if(!$albumCover){
if(CurrentUser::$admin){
$firstImg = NULL;
$albumCover = NULL;
}else{
continue;
}
}


$item = new BoardDir($d,$firstImg);
$item = new BoardDir($d,$albumCover);
$this->boardfolders[] = $item;

}
Expand Down Expand Up @@ -226,10 +227,36 @@ public function toHTML(){
$this->grid("Image");
if(sizeof($this->boarditems)>0){
echo "<div class='section sectionimg'>";
echo "<h2>".Settings::_("board","images")."</h2>";
echo "<div class='pure-g line'>";

$years = [];
foreach($this->boarditems as $item){
$item->toHTML();
$year = substr($item->datefile,0,4);
if(!in_array($year,$years) and $year != '') $years[]=$year;
}
//echo "<p>".print_r($years)."</p>";


foreach($years as $year){
echo "<h2>$year</h2>";
echo "<div class='pure-g line'>";
foreach($this->boarditems as $item){
if( $year == substr($item->datefile,0,4)){
$item->toHTML();
}
}
echo "</div>";
}

$hideexif = false;
foreach($this->boarditems as $item){
if (substr($item->datefile,0,4) == ''){
if($hideexif == false) {
echo "<h2>".Settings::_("board","images")." sans dates exif</h2>";
echo "<div class='pure-g line'>";
$hideexif = true;
}
$item->toHTML();
}
}
echo "</div>";
echo "</div>";
Expand Down
6 changes: 5 additions & 1 deletion src/classes/BoardItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,21 @@ class BoardItem implements HTMLObject
/// Item width
public $width;

/// Item date
public $datefile;

/**
* Construct BoardItem
*
* @param string $file
* @param string $ratio
* @author Thibaud Rohmer
*/
public function __construct($file,$ratio=0){
public function __construct($file,$ratio=0,$datefile=''){
$this->path = $file;
$this->file = urlencode(File::a2r($file));
$this->ratio = $ratio;
$this->datefile = $datefile;
}

/**
Expand Down
17 changes: 17 additions & 0 deletions src/classes/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class File
/// File type
public $type;

/// File date
public $filedate;

/**
* Check that file exists, and parse its infos (extension,name,type)
*
Expand All @@ -74,6 +77,7 @@ public function __construct($path){
$this->name = self::Name($path);
$this->type = self::Type($path);
$this->root = self::Root();
$this->filedate = self::FileDate($path);
}

/**
Expand Down Expand Up @@ -161,6 +165,15 @@ public static function Type($file){

}


public static function FileDate($file){
if (!in_array("exif", get_loaded_extensions())) {
return 'exif error';
}else{
return @exif_read_data($file)['DateTimeOriginal'];
}
}

/**
* Absolute path comes in, relative path goes out !
*
Expand All @@ -179,6 +192,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
Loading