mirror of
https://github.com/YunoHost-Apps/piwigo_ynh.git
synced 2024-09-03 20:06:03 +02:00
initial commit
This commit is contained in:
commit
677d1bffff
2916 changed files with 310166 additions and 0 deletions
2
README.md
Normal file
2
README.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ynh_piwigo
|
||||||
|
==========
|
66
conf/config.sql~
Normal file
66
conf/config.sql~
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
-- initial configuration for Piwigo
|
||||||
|
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('activate_comments','true','Global parameter for usage of comments system');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('nb_comment_page','10','number of comments to display on each page');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('log','true','keep an history of visits on your website');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('comments_validation','false','administrators validate users comments before becoming visible');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('comments_forall','false','even guest not registered can post comments');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('comments_order','ASC','comments order on picture page and cie');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('comments_author_mandatory','false','Comment author is mandatory');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('comments_email_mandatory','false','Comment email is mandatory');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('user_can_delete_comment','false','administrators can allow user delete their own comments');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('user_can_edit_comment','false','administrators can allow user edit their own comments');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('email_admin_on_comment_edition','false','Send an email to the administrators when a comment is modified');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('email_admin_on_comment_deletion','false','Send an email to the administrators when a comment is deleted');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('gallery_locked','false','Lock your gallery temporary for non admin users');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('gallery_title','','Title at top of each page and for RSS feed');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('rate','true','Rating pictures feature is enabled');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('rate_anonymous','true','Rating pictures feature is also enabled for visitors');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('page_banner','','html displayed on the top each page of your gallery');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('history_admin','false','keep a history of administrator visits on your website');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_registration','true','allow visitors to register?');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_customization','true','allow users to customize their gallery?');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('nb_categories_page','12','Param for categories pagination');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_complementary_mail_content','','Complementary mail content for notification by mail');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_recent_post_dates','true','Send recent post by dates for notification by mail');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('email_admin_on_new_user','false','Send an email to theadministrators when a user registers');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('email_admin_on_comment','false','Send an email to the administrators when a valid comment is entered');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('email_admin_on_comment_validation','true','Send an email to the administrators when a comment requires validation');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('obligatory_user_mail_address','false','Mail address is obligatory for users');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('c13y_ignore',null,'List of ignored anomalies');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('extents_for_templates','a:0:{}','Actived template-extension(s)');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('blk_menubar','','Menubar options');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('menubar_filter_icon','false','Display filter icon');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('index_sort_order_input','true','Display image order selection list');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('index_flat_icon','false','Display flat icon');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('index_posted_date_icon','true','Display calendar by posted date');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('index_created_date_icon','true','Display calendar by creation date icon');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('index_slideshow_icon','true','Display slideshow icon');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('index_new_icon','true','Display new icons next albums and pictures');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('picture_metadata_icon','true','Display metadata icon on picture page');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('picture_slideshow_icon','true','Display slideshow icon on picture page');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('picture_favorite_icon','true','Display favorite icon on picture page');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('picture_download_icon','true','Display download icon on picture page');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('picture_navigation_icons','true','Display navigation icons on picture page');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('picture_navigation_thumb','true','Display navigation thumbnails on picture page');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('picture_menu','false','Show menubar on picture page');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment)
|
||||||
|
VALUES (
|
||||||
|
'picture_informations',
|
||||||
|
'a:11:{s:6:"author";b:1;s:10:"created_on";b:1;s:9:"posted_on";b:1;s:10:"dimensions";b:0;s:4:"file";b:0;s:8:"filesize";b:0;s:4:"tags";b:1;s:10:"categories";b:1;s:6:"visits";b:1;s:12:"rating_score";b:1;s:13:"privacy_level";b:1;}',
|
||||||
|
'Information displayed on picture page'
|
||||||
|
);
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('week_starts_on','monday','Monday may not be the first day of the week');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('updates_ignored','a:3:{s:7:"plugins";a:0:{}s:6:"themes";a:0:{}s:9:"languages";a:0:{}}','Extensions ignored for update');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('order_by','ORDER BY date_available DESC, file ASC, id ASC','default photo order');
|
||||||
|
INSERT INTO piwigo_config (param,value,comment) VALUES ('order_by_inside_category','ORDER BY date_available DESC, file ASC, id ASC','default photo order inside category');
|
||||||
|
INSERT INTO piwigo_config (param,value) VALUES ('original_resize','false');
|
||||||
|
INSERT INTO piwigo_config (param,value) VALUES ('original_resize_maxwidth','2016');
|
||||||
|
INSERT INTO piwigo_config (param,value) VALUES ('original_resize_maxheight','2016');
|
||||||
|
INSERT INTO piwigo_config (param,value) VALUES ('original_resize_quality','95');
|
||||||
|
INSERT INTO piwigo_config (param,value) VALUES ('mobile_theme',null);
|
||||||
|
INSERT INTO piwigo_config (param,value) VALUES ('mail_theme','clear');
|
15
conf/database.inc.php
Normal file
15
conf/database.inc.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
$conf['dblayer'] = 'mysqli';
|
||||||
|
$conf['db_base'] = 'DBTOCHANGE';
|
||||||
|
$conf['db_user'] = 'USERTOCHANGE';
|
||||||
|
$conf['db_password'] = 'PASSTOCHANGE';
|
||||||
|
$conf['db_host'] = 'localhost';
|
||||||
|
|
||||||
|
$prefixeTable = '';
|
||||||
|
|
||||||
|
define('PHPWG_INSTALLED', true);
|
||||||
|
define('PWG_CHARSET', 'utf-8');
|
||||||
|
define('DB_CHARSET', 'utf8');
|
||||||
|
define('DB_COLLATE', '');
|
||||||
|
|
||||||
|
?>
|
15
conf/database.inc.php~
Normal file
15
conf/database.inc.php~
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
$conf['dblayer'] = 'mysqli';
|
||||||
|
$conf['db_base'] = 'DBTOCHANGE';
|
||||||
|
$conf['db_user'] = 'USERTOCHANGE';
|
||||||
|
$conf['db_password'] = 'PASSTOCHANGE';
|
||||||
|
$conf['db_host'] = 'localhost';
|
||||||
|
|
||||||
|
$prefixeTable = 'piwigo_';
|
||||||
|
|
||||||
|
define('PHPWG_INSTALLED', true);
|
||||||
|
define('PWG_CHARSET', 'utf-8');
|
||||||
|
define('DB_CHARSET', 'utf8');
|
||||||
|
define('DB_COLLATE', '');
|
||||||
|
|
||||||
|
?>
|
30
conf/index.php
Normal file
30
conf/index.php
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Recursive call
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
18
conf/nginx.conf
Normal file
18
conf/nginx.conf
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
location PATHTOCHANGE {
|
||||||
|
alias ALIASTOCHANGE;
|
||||||
|
client_max_body_size 10G;
|
||||||
|
index index.php;
|
||||||
|
default_type text/html;
|
||||||
|
location ~ [^/]\.php(/|$) {
|
||||||
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
|
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Include SSOWAT user panel.
|
||||||
|
#include conf.d/yunohost_panel.conf.inc;
|
||||||
|
}
|
17
conf/nginx.conf~
Normal file
17
conf/nginx.conf~
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
location PATHTOCHANGE {
|
||||||
|
alias ALIASTOCHANGE;
|
||||||
|
index index.php index.html index.htm;
|
||||||
|
default_type text/html;
|
||||||
|
location ~ [^/]\.php(/|$) {
|
||||||
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
|
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Include SSOWAT user panel.
|
||||||
|
#include conf.d/yunohost_panel.conf.inc;
|
||||||
|
}
|
239
conf/php-fpm.conf
Normal file
239
conf/php-fpm.conf
Normal file
|
@ -0,0 +1,239 @@
|
||||||
|
; Start a new pool named 'www'.
|
||||||
|
; the variable $pool can we used in any directive and will be replaced by the
|
||||||
|
; pool name ('www' here)
|
||||||
|
[NAMETOCHANGE]
|
||||||
|
|
||||||
|
; Per pool prefix
|
||||||
|
; It only applies on the following directives:
|
||||||
|
; - 'slowlog'
|
||||||
|
; - 'listen' (unixsocket)
|
||||||
|
; - 'chroot'
|
||||||
|
; - 'chdir'
|
||||||
|
; - 'php_values'
|
||||||
|
; - 'php_admin_values'
|
||||||
|
; When not set, the global prefix (or /usr) applies instead.
|
||||||
|
; Note: This directive can also be relative to the global prefix.
|
||||||
|
; Default Value: none
|
||||||
|
;prefix = /path/to/pools/$pool
|
||||||
|
|
||||||
|
; The address on which to accept FastCGI requests.
|
||||||
|
; Valid syntaxes are:
|
||||||
|
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
|
||||||
|
; a specific port;
|
||||||
|
; 'port' - to listen on a TCP socket to all addresses on a
|
||||||
|
; specific port;
|
||||||
|
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||||
|
; Note: This value is mandatory.
|
||||||
|
listen = /var/run/php5-fpm-NAMETOCHANGE.sock
|
||||||
|
|
||||||
|
; Set listen(2) backlog. A value of '-1' means unlimited.
|
||||||
|
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
|
||||||
|
;listen.backlog = -1
|
||||||
|
|
||||||
|
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
|
||||||
|
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
||||||
|
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
||||||
|
; must be separated by a comma. If this value is left blank, connections will be
|
||||||
|
; accepted from any ip address.
|
||||||
|
; Default Value: any
|
||||||
|
;listen.allowed_clients = 127.0.0.1
|
||||||
|
|
||||||
|
; Set permissions for unix socket, if one is used. In Linux, read/write
|
||||||
|
; permissions must be set in order to allow connections from a web server. Many
|
||||||
|
; BSD-derived systems allow connections regardless of permissions.
|
||||||
|
; Default Values: user and group are set as the running user
|
||||||
|
; mode is set to 0666
|
||||||
|
listen.owner = www-data
|
||||||
|
listen.group = www-data
|
||||||
|
listen.mode = 0600
|
||||||
|
|
||||||
|
; Unix user/group of processes
|
||||||
|
; Note: The user is mandatory. If the group is not set, the default user's group
|
||||||
|
; will be used.
|
||||||
|
user = NAMETOCHANGE
|
||||||
|
group = NAMETOCHANGE
|
||||||
|
|
||||||
|
; Choose how the process manager will control the number of child processes.
|
||||||
|
; Possible Values:
|
||||||
|
; static - a fixed number (pm.max_children) of child processes;
|
||||||
|
; dynamic - the number of child processes are set dynamically based on the
|
||||||
|
; following directives:
|
||||||
|
; pm.max_children - the maximum number of children that can
|
||||||
|
; be alive at the same time.
|
||||||
|
; pm.start_servers - the number of children created on startup.
|
||||||
|
; pm.min_spare_servers - the minimum number of children in 'idle'
|
||||||
|
; state (waiting to process). If the number
|
||||||
|
; of 'idle' processes is less than this
|
||||||
|
; number then some children will be created.
|
||||||
|
; pm.max_spare_servers - the maximum number of children in 'idle'
|
||||||
|
; state (waiting to process). If the number
|
||||||
|
; of 'idle' processes is greater than this
|
||||||
|
; number then some children will be killed.
|
||||||
|
; Note: This value is mandatory.
|
||||||
|
pm = dynamic
|
||||||
|
|
||||||
|
; The number of child processes to be created when pm is set to 'static' and the
|
||||||
|
; maximum number of child processes to be created when pm is set to 'dynamic'.
|
||||||
|
; This value sets the limit on the number of simultaneous requests that will be
|
||||||
|
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
|
||||||
|
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
|
||||||
|
; CGI.
|
||||||
|
; Note: Used when pm is set to either 'static' or 'dynamic'
|
||||||
|
; Note: This value is mandatory.
|
||||||
|
pm.max_children = 6
|
||||||
|
|
||||||
|
; The number of child processes created on startup.
|
||||||
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
|
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
|
||||||
|
pm.start_servers = 3
|
||||||
|
|
||||||
|
; The desired minimum number of idle server processes.
|
||||||
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
|
pm.min_spare_servers = 3
|
||||||
|
|
||||||
|
; The desired maximum number of idle server processes.
|
||||||
|
; Note: Used only when pm is set to 'dynamic'
|
||||||
|
; Note: Mandatory when pm is set to 'dynamic'
|
||||||
|
pm.max_spare_servers = 5
|
||||||
|
|
||||||
|
; The number of requests each child process should execute before respawning.
|
||||||
|
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||||
|
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||||
|
; Default Value: 0
|
||||||
|
pm.max_requests = 500
|
||||||
|
|
||||||
|
; The URI to view the FPM status page. If this value is not set, no URI will be
|
||||||
|
; recognized as a status page. By default, the status page shows the following
|
||||||
|
; information:
|
||||||
|
; accepted conn - the number of request accepted by the pool;
|
||||||
|
; pool - the name of the pool;
|
||||||
|
; process manager - static or dynamic;
|
||||||
|
; idle processes - the number of idle processes;
|
||||||
|
; active processes - the number of active processes;
|
||||||
|
; total processes - the number of idle + active processes.
|
||||||
|
; max children reached - number of times, the process limit has been reached,
|
||||||
|
; when pm tries to start more children (works only for
|
||||||
|
; pm 'dynamic')
|
||||||
|
; The values of 'idle processes', 'active processes' and 'total processes' are
|
||||||
|
; updated each second. The value of 'accepted conn' is updated in real time.
|
||||||
|
; Example output:
|
||||||
|
; accepted conn: 12073
|
||||||
|
; pool: www
|
||||||
|
; process manager: static
|
||||||
|
; idle processes: 35
|
||||||
|
; active processes: 65
|
||||||
|
; total processes: 100
|
||||||
|
; max children reached: 1
|
||||||
|
; By default the status page output is formatted as text/plain. Passing either
|
||||||
|
; 'html' or 'json' as a query string will return the corresponding output
|
||||||
|
; syntax. Example:
|
||||||
|
; http://www.foo.bar/status
|
||||||
|
; http://www.foo.bar/status?json
|
||||||
|
; http://www.foo.bar/status?html
|
||||||
|
; Note: The value must start with a leading slash (/). The value can be
|
||||||
|
; anything, but it may not be a good idea to use the .php extension or it
|
||||||
|
; may conflict with a real PHP file.
|
||||||
|
; Default Value: not set
|
||||||
|
pm.status_path = /fpm-status
|
||||||
|
|
||||||
|
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||||
|
; URI will be recognized as a ping page. This could be used to test from outside
|
||||||
|
; that FPM is alive and responding, or to
|
||||||
|
; - create a graph of FPM availability (rrd or such);
|
||||||
|
; - remove a server from a group if it is not responding (load balancing);
|
||||||
|
; - trigger alerts for the operating team (24/7).
|
||||||
|
; Note: The value must start with a leading slash (/). The value can be
|
||||||
|
; anything, but it may not be a good idea to use the .php extension or it
|
||||||
|
; may conflict with a real PHP file.
|
||||||
|
; Default Value: not set
|
||||||
|
ping.path = /ping
|
||||||
|
|
||||||
|
; This directive may be used to customize the response of a ping request. The
|
||||||
|
; response is formatted as text/plain with a 200 response code.
|
||||||
|
; Default Value: pong
|
||||||
|
;ping.response = pong
|
||||||
|
|
||||||
|
; The timeout for serving a single request after which the worker process will
|
||||||
|
; be killed. This option should be used when the 'max_execution_time' ini option
|
||||||
|
; does not stop script execution for some reason. A value of '0' means 'off'.
|
||||||
|
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||||
|
; Default Value: 0
|
||||||
|
request_terminate_timeout = 120s
|
||||||
|
|
||||||
|
; The timeout for serving a single request after which a PHP backtrace will be
|
||||||
|
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||||
|
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||||
|
; Default Value: 0
|
||||||
|
request_slowlog_timeout = 5s
|
||||||
|
|
||||||
|
; The log file for slow requests
|
||||||
|
; Default Value: not set
|
||||||
|
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||||
|
slowlog = /var/log/nginx/NAMETOCHANGE.slow.log
|
||||||
|
|
||||||
|
; Set open file descriptor rlimit.
|
||||||
|
; Default Value: system defined value
|
||||||
|
rlimit_files = 4096
|
||||||
|
|
||||||
|
; Set max core size rlimit.
|
||||||
|
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
||||||
|
; Default Value: system defined value
|
||||||
|
rlimit_core = 0
|
||||||
|
|
||||||
|
; Chroot to this directory at the start. This value must be defined as an
|
||||||
|
; absolute path. When this value is not set, chroot is not used.
|
||||||
|
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
|
||||||
|
; of its subdirectories. If the pool prefix is not set, the global prefix
|
||||||
|
; will be used instead.
|
||||||
|
; Note: chrooting is a great security feature and should be used whenever
|
||||||
|
; possible. However, all PHP paths will be relative to the chroot
|
||||||
|
; (error_log, sessions.save_path, ...).
|
||||||
|
; Default Value: not set
|
||||||
|
;chroot =
|
||||||
|
|
||||||
|
; Chdir to this directory at the start.
|
||||||
|
; Note: relative path can be used.
|
||||||
|
; Default Value: current directory or / when chroot
|
||||||
|
chdir = /var/www/NAMETOCHANGE
|
||||||
|
|
||||||
|
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
||||||
|
; stderr will be redirected to /dev/null according to FastCGI specs.
|
||||||
|
; Note: on highloaded environement, this can cause some delay in the page
|
||||||
|
; process time (several ms).
|
||||||
|
; Default Value: no
|
||||||
|
catch_workers_output = yes
|
||||||
|
|
||||||
|
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
||||||
|
; the current environment.
|
||||||
|
; Default Value: clean env
|
||||||
|
;env[HOSTNAME] = $HOSTNAME
|
||||||
|
;env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||||
|
;env[TMP] = /tmp
|
||||||
|
;env[TMPDIR] = /tmp
|
||||||
|
;env[TEMP] = /tmp
|
||||||
|
|
||||||
|
; Additional php.ini defines, specific to this pool of workers. These settings
|
||||||
|
; overwrite the values previously defined in the php.ini. The directives are the
|
||||||
|
; same as the PHP SAPI:
|
||||||
|
; php_value/php_flag - you can set classic ini defines which can
|
||||||
|
; be overwritten from PHP call 'ini_set'.
|
||||||
|
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
||||||
|
; PHP call 'ini_set'
|
||||||
|
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
||||||
|
|
||||||
|
; Defining 'extension' will load the corresponding shared extension from
|
||||||
|
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
|
||||||
|
; overwrite previously defined php.ini values, but will append the new value
|
||||||
|
; instead.
|
||||||
|
|
||||||
|
; Note: path INI options can be relative and will be expanded with the prefix
|
||||||
|
; (pool, global or /usr)
|
||||||
|
|
||||||
|
; Default Value: nothing is defined by default except the values in php.ini and
|
||||||
|
; specified at startup with the -d argument
|
||||||
|
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
|
||||||
|
;php_flag[display_errors] = off
|
||||||
|
;php_admin_value[error_log] = /var/log/fpm-php.www.log
|
||||||
|
;php_admin_flag[log_errors] = on
|
||||||
|
;php_admin_value[memory_limit] = 32M
|
0
conf/php-fpm.conf~
Normal file
0
conf/php-fpm.conf~
Normal file
2
conf/php-fpm.ini
Normal file
2
conf/php-fpm.ini
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
upload_max_filesize=10G
|
||||||
|
post_max_size=10G
|
0
conf/php-fpm.ini~
Normal file
0
conf/php-fpm.ini~
Normal file
977
conf/piwigo.sql~
Normal file
977
conf/piwigo.sql~
Normal file
|
@ -0,0 +1,977 @@
|
||||||
|
-- phpMyAdmin SQL Dump
|
||||||
|
-- version 4.2.0
|
||||||
|
-- http://www.phpmyadmin.net
|
||||||
|
--
|
||||||
|
-- Client : localhost
|
||||||
|
-- Généré le : Sam 28 Juin 2014 à 23:02
|
||||||
|
-- Version du serveur : 5.5.37-0+wheezy1
|
||||||
|
-- Version de PHP : 5.4.4-14+deb7u11
|
||||||
|
USE piwigo;
|
||||||
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||||
|
SET time_zone = "+00:00";
|
||||||
|
|
||||||
|
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||||
|
/*!40101 SET NAMES utf8 */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Base de données : `piwigo`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_caddie`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_caddie` (
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`element_id` mediumint(8) NOT NULL DEFAULT '0'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_categories`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_categories` (
|
||||||
|
`id` smallint(5) unsigned NOT NULL,
|
||||||
|
`name` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
`id_uppercat` smallint(5) unsigned DEFAULT NULL,
|
||||||
|
`comment` text,
|
||||||
|
`dir` varchar(255) DEFAULT NULL,
|
||||||
|
`rank` smallint(5) unsigned DEFAULT NULL,
|
||||||
|
`status` enum('public','private') NOT NULL DEFAULT 'public',
|
||||||
|
`site_id` tinyint(4) unsigned DEFAULT NULL,
|
||||||
|
`visible` enum('true','false') NOT NULL DEFAULT 'true',
|
||||||
|
`representative_picture_id` mediumint(8) unsigned DEFAULT NULL,
|
||||||
|
`uppercats` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
`commentable` enum('true','false') NOT NULL DEFAULT 'true',
|
||||||
|
`global_rank` varchar(255) DEFAULT NULL,
|
||||||
|
`image_order` varchar(128) DEFAULT NULL,
|
||||||
|
`permalink` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_comments`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_comments` (
|
||||||
|
`id` int(11) unsigned NOT NULL,
|
||||||
|
`image_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`author` varchar(255) DEFAULT NULL,
|
||||||
|
`email` varchar(255) DEFAULT NULL,
|
||||||
|
`author_id` smallint(5) DEFAULT NULL,
|
||||||
|
`anonymous_id` varchar(45) NOT NULL,
|
||||||
|
`website_url` varchar(255) DEFAULT NULL,
|
||||||
|
`content` longtext,
|
||||||
|
`validated` enum('true','false') NOT NULL DEFAULT 'false',
|
||||||
|
`validation_date` datetime DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_config`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_config` (
|
||||||
|
`param` varchar(40) NOT NULL DEFAULT '',
|
||||||
|
`value` text,
|
||||||
|
`comment` varchar(255) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='configuration table';
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Contenu de la table `piwigo_config`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `piwigo_config` (`param`, `value`, `comment`) VALUES
|
||||||
|
('activate_comments', 'true', 'Global parameter for usage of comments system'),
|
||||||
|
('nb_comment_page', '10', 'number of comments to display on each page'),
|
||||||
|
('log', 'true', 'keep an history of visits on your website'),
|
||||||
|
('comments_validation', 'false', 'administrators validate users comments before becoming visible'),
|
||||||
|
('comments_forall', 'false', 'even guest not registered can post comments'),
|
||||||
|
('comments_order', 'ASC', 'comments order on picture page and cie'),
|
||||||
|
('comments_author_mandatory', 'false', 'Comment author is mandatory'),
|
||||||
|
('comments_email_mandatory', 'false', 'Comment email is mandatory'),
|
||||||
|
('user_can_delete_comment', 'false', 'administrators can allow user delete their own comments'),
|
||||||
|
('user_can_edit_comment', 'false', 'administrators can allow user edit their own comments'),
|
||||||
|
('email_admin_on_comment_edition', 'false', 'Send an email to the administrators when a comment is modified'),
|
||||||
|
('email_admin_on_comment_deletion', 'false', 'Send an email to the administrators when a comment is deleted'),
|
||||||
|
('gallery_locked', 'false', 'Lock your gallery temporary for non admin users'),
|
||||||
|
('gallery_title', 'Une galerie Piwigo de plus', 'Title at top of each page and for RSS feed'),
|
||||||
|
('rate', 'true', 'Rating pictures feature is enabled'),
|
||||||
|
('rate_anonymous', 'true', 'Rating pictures feature is also enabled for visitors'),
|
||||||
|
('page_banner', '<h1>%gallery_title%</h1>\n\n<p>Bienvenue sur ma galerie photo</p>', 'html displayed on the top each page of your gallery'),
|
||||||
|
('history_admin', 'false', 'keep a history of administrator visits on your website'),
|
||||||
|
('history_guest', 'true', 'keep a history of guest visits on your website'),
|
||||||
|
('allow_user_registration', 'true', 'allow visitors to register?'),
|
||||||
|
('allow_user_customization', 'true', 'allow users to customize their gallery?'),
|
||||||
|
('nb_categories_page', '12', 'Param for categories pagination'),
|
||||||
|
('nbm_send_html_mail', 'true', 'Send mail on HTML format for notification by mail'),
|
||||||
|
('nbm_send_mail_as', '', 'Send mail as param value for notification by mail'),
|
||||||
|
('nbm_send_detailed_content', 'true', 'Send detailed content for notification by mail'),
|
||||||
|
('nbm_complementary_mail_content', '', 'Complementary mail content for notification by mail'),
|
||||||
|
('nbm_send_recent_post_dates', 'true', 'Send recent post by dates for notification by mail'),
|
||||||
|
('email_admin_on_new_user', 'false', 'Send an email to theadministrators when a user registers'),
|
||||||
|
('email_admin_on_comment', 'false', 'Send an email to the administrators when a valid comment is entered'),
|
||||||
|
('email_admin_on_comment_validation', 'true', 'Send an email to the administrators when a comment requires validation'),
|
||||||
|
('obligatory_user_mail_address', 'false', 'Mail address is obligatory for users'),
|
||||||
|
('c13y_ignore', 'a:2:{s:7:"version";s:5:"2.6.3";s:4:"list";a:0:{}}', 'List of ignored anomalies'),
|
||||||
|
('extents_for_templates', 'a:0:{}', 'Actived template-extension(s)'),
|
||||||
|
('blk_menubar', '', 'Menubar options'),
|
||||||
|
('menubar_filter_icon', 'false', 'Display filter icon'),
|
||||||
|
('index_sort_order_input', 'true', 'Display image order selection list'),
|
||||||
|
('index_flat_icon', 'false', 'Display flat icon'),
|
||||||
|
('index_posted_date_icon', 'true', 'Display calendar by posted date'),
|
||||||
|
('index_created_date_icon', 'true', 'Display calendar by creation date icon'),
|
||||||
|
('index_slideshow_icon', 'true', 'Display slideshow icon'),
|
||||||
|
('index_new_icon', 'true', 'Display new icons next albums and pictures'),
|
||||||
|
('picture_metadata_icon', 'true', 'Display metadata icon on picture page'),
|
||||||
|
('picture_slideshow_icon', 'true', 'Display slideshow icon on picture page'),
|
||||||
|
('picture_favorite_icon', 'true', 'Display favorite icon on picture page'),
|
||||||
|
('picture_download_icon', 'true', 'Display download icon on picture page'),
|
||||||
|
('picture_navigation_icons', 'true', 'Display navigation icons on picture page'),
|
||||||
|
('picture_navigation_thumb', 'true', 'Display navigation thumbnails on picture page'),
|
||||||
|
('picture_menu', 'false', 'Show menubar on picture page'),
|
||||||
|
('picture_informations', 'a:11:{s:6:"author";b:1;s:10:"created_on";b:1;s:9:"posted_on";b:1;s:10:"dimensions";b:0;s:4:"file";b:0;s:8:"filesize";b:0;s:4:"tags";b:1;s:10:"categories";b:1;s:6:"visits";b:1;s:12:"rating_score";b:1;s:13:"privacy_level";b:1;}', 'Information displayed on picture page'),
|
||||||
|
('week_starts_on', 'monday', 'Monday may not be the first day of the week'),
|
||||||
|
('updates_ignored', 'a:3:{s:7:"plugins";a:0:{}s:6:"themes";a:0:{}s:9:"languages";a:0:{}}', 'Extensions ignored for update'),
|
||||||
|
('order_by', 'ORDER BY date_available DESC, file ASC, id ASC', 'default photo order'),
|
||||||
|
('order_by_inside_category', 'ORDER BY date_available DESC, file ASC, id ASC', 'default photo order inside category'),
|
||||||
|
('original_resize', 'false', NULL),
|
||||||
|
('original_resize_maxwidth', '2016', NULL),
|
||||||
|
('original_resize_maxheight', '2016', NULL),
|
||||||
|
('original_resize_quality', '95', NULL),
|
||||||
|
('mobile_theme', 'smartpocket', NULL),
|
||||||
|
('mail_theme', 'clear', NULL),
|
||||||
|
('secret_key', '8c52ac66f4b2bb51a8e2a850990e900d', 'a secret key specific to the gallery for internal use'),
|
||||||
|
('piwigo_db_version', '2.6', NULL),
|
||||||
|
('smartpocket', 'a:2:{s:4:"loop";b:1;s:8:"autohide";i:5000;}', 'loop#autohide'),
|
||||||
|
('derivatives', 'a:4:{s:1:"d";a:9:{s:6:"square";O:16:"DerivativeParams":3:{s:13:"last_mod_time";i:1403987679;s:6:"sizing";O:12:"SizingParams":3:{s:10:"ideal_size";a:2:{i:0;i:120;i:1;i:120;}s:8:"max_crop";i:1;s:8:"min_size";a:2:{i:0;i:120;i:1;i:120;}}s:7:"sharpen";i:0;}s:5:"thumb";O:16:"DerivativeParams":3:{s:13:"last_mod_time";i:1403987679;s:6:"sizing";O:12:"SizingParams":3:{s:10:"ideal_size";a:2:{i:0;i:144;i:1;i:144;}s:8:"max_crop";i:0;s:8:"min_size";N;}s:7:"sharpen";i:0;}s:6:"2small";O:16:"DerivativeParams":3:{s:13:"last_mod_time";i:1403987679;s:6:"sizing";O:12:"SizingParams":3:{s:10:"ideal_size";a:2:{i:0;i:240;i:1;i:240;}s:8:"max_crop";i:0;s:8:"min_size";N;}s:7:"sharpen";i:0;}s:6:"xsmall";O:16:"DerivativeParams":3:{s:13:"last_mod_time";i:1403987679;s:6:"sizing";O:12:"SizingParams":3:{s:10:"ideal_size";a:2:{i:0;i:432;i:1;i:324;}s:8:"max_crop";i:0;s:8:"min_size";N;}s:7:"sharpen";i:0;}s:5:"small";O:16:"DerivativeParams":3:{s:13:"last_mod_time";i:1403987679;s:6:"sizing";O:12:"SizingParams":3:{s:10:"ideal_size";a:2:{i:0;i:576;i:1;i:432;}s:8:"max_crop";i:0;s:8:"min_size";N;}s:7:"sharpen";i:0;}s:6:"medium";O:16:"DerivativeParams":3:{s:13:"last_mod_time";i:1403987679;s:6:"sizing";O:12:"SizingParams":3:{s:10:"ideal_size";a:2:{i:0;i:792;i:1;i:594;}s:8:"max_crop";i:0;s:8:"min_size";N;}s:7:"sharpen";i:0;}s:5:"large";O:16:"DerivativeParams":3:{s:13:"last_mod_time";i:1403987679;s:6:"sizing";O:12:"SizingParams":3:{s:10:"ideal_size";a:2:{i:0;i:1008;i:1;i:756;}s:8:"max_crop";i:0;s:8:"min_size";N;}s:7:"sharpen";i:0;}s:6:"xlarge";O:16:"DerivativeParams":3:{s:13:"last_mod_time";i:1403987679;s:6:"sizing";O:12:"SizingParams":3:{s:10:"ideal_size";a:2:{i:0;i:1224;i:1;i:918;}s:8:"max_crop";i:0;s:8:"min_size";N;}s:7:"sharpen";i:0;}s:7:"xxlarge";O:16:"DerivativeParams":3:{s:13:"last_mod_time";i:1403987679;s:6:"sizing";O:12:"SizingParams":3:{s:10:"ideal_size";a:2:{i:0;i:1656;i:1;i:1242;}s:8:"max_crop";i:0;s:8:"min_size";N;}s:7:"sharpen";i:0;}}s:1:"q";i:95;s:1:"w";O:15:"WatermarkParams":6:{s:4:"file";s:0:"";s:8:"min_size";a:2:{i:0;i:500;i:1;i:500;}s:4:"xpos";i:50;s:4:"ypos";i:50;s:7:"xrepeat";i:0;s:7:"opacity";i:100;}s:1:"c";a:0:{}}', NULL),
|
||||||
|
('data_dir_checked', '1', NULL),
|
||||||
|
('elegant', 'a:3:{s:11:"p_main_menu";s:2:"on";s:12:"p_pict_descr";s:2:"on";s:14:"p_pict_comment";s:3:"off";}', 'p_main_menu#'),
|
||||||
|
('no_photo_yet', 'false', NULL);
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_favorites`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_favorites` (
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`image_id` mediumint(8) unsigned NOT NULL DEFAULT '0'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_groups`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_groups` (
|
||||||
|
`id` smallint(5) unsigned NOT NULL,
|
||||||
|
`name` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
`is_default` enum('true','false') NOT NULL DEFAULT 'false'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_group_access`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_group_access` (
|
||||||
|
`group_id` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`cat_id` smallint(5) unsigned NOT NULL DEFAULT '0'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_history`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_history` (
|
||||||
|
`id` int(10) unsigned NOT NULL,
|
||||||
|
`date` date NOT NULL DEFAULT '0000-00-00',
|
||||||
|
`time` time NOT NULL DEFAULT '00:00:00',
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`IP` varchar(15) NOT NULL DEFAULT '',
|
||||||
|
`section` enum('categories','tags','search','list','favorites','most_visited','best_rated','recent_pics','recent_cats') DEFAULT NULL,
|
||||||
|
`category_id` smallint(5) DEFAULT NULL,
|
||||||
|
`tag_ids` varchar(50) DEFAULT NULL,
|
||||||
|
`image_id` mediumint(8) DEFAULT NULL,
|
||||||
|
`summarized` enum('true','false') DEFAULT 'false',
|
||||||
|
`image_type` enum('picture','high','other') DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Contenu de la table `piwigo_history`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `piwigo_history` (`id`, `date`, `time`, `user_id`, `IP`, `section`, `category_id`, `tag_ids`, `image_id`, `summarized`, `image_type`) VALUES
|
||||||
|
(1, '2014-06-28', '22:50:57', 2, '192.168.0.13', 'categories', NULL, NULL, NULL, 'false', NULL),
|
||||||
|
(2, '2014-06-28', '22:54:12', 2, '192.168.0.13', 'categories', NULL, NULL, NULL, 'false', NULL),
|
||||||
|
(3, '2014-06-28', '22:56:13', 2, '192.168.0.13', 'categories', NULL, NULL, NULL, 'false', NULL),
|
||||||
|
(4, '2014-06-28', '22:57:03', 2, '192.168.0.13', 'categories', NULL, NULL, NULL, 'false', NULL),
|
||||||
|
(5, '2014-06-28', '22:57:35', 2, '192.168.0.13', 'categories', NULL, NULL, NULL, 'false', NULL),
|
||||||
|
(6, '2014-06-28', '22:58:24', 2, '192.168.0.13', 'categories', NULL, NULL, NULL, 'false', NULL),
|
||||||
|
(7, '2014-06-28', '22:58:59', 3, '192.168.0.13', 'categories', NULL, NULL, NULL, 'false', NULL),
|
||||||
|
(8, '2014-06-28', '22:59:07', 2, '192.168.0.13', 'categories', NULL, NULL, NULL, 'false', NULL);
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_history_summary`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_history_summary` (
|
||||||
|
`year` smallint(4) NOT NULL DEFAULT '0',
|
||||||
|
`month` tinyint(2) DEFAULT NULL,
|
||||||
|
`day` tinyint(2) DEFAULT NULL,
|
||||||
|
`hour` tinyint(2) DEFAULT NULL,
|
||||||
|
`nb_pages` int(11) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_images`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_images` (
|
||||||
|
`id` mediumint(8) unsigned NOT NULL,
|
||||||
|
`file` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||||
|
`date_available` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`date_creation` datetime DEFAULT NULL,
|
||||||
|
`name` varchar(255) DEFAULT NULL,
|
||||||
|
`comment` text,
|
||||||
|
`author` varchar(255) DEFAULT NULL,
|
||||||
|
`hit` int(10) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`filesize` mediumint(9) unsigned DEFAULT NULL,
|
||||||
|
`width` smallint(9) unsigned DEFAULT NULL,
|
||||||
|
`height` smallint(9) unsigned DEFAULT NULL,
|
||||||
|
`coi` char(4) DEFAULT NULL COMMENT 'center of interest',
|
||||||
|
`representative_ext` varchar(4) DEFAULT NULL,
|
||||||
|
`date_metadata_update` date DEFAULT NULL,
|
||||||
|
`rating_score` float(5,2) unsigned DEFAULT NULL,
|
||||||
|
`path` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
`storage_category_id` smallint(5) unsigned DEFAULT NULL,
|
||||||
|
`level` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`md5sum` char(32) DEFAULT NULL,
|
||||||
|
`added_by` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`rotation` tinyint(3) unsigned DEFAULT NULL,
|
||||||
|
`latitude` double(8,6) DEFAULT NULL,
|
||||||
|
`longitude` double(9,6) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_image_category`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_image_category` (
|
||||||
|
`image_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`category_id` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`rank` mediumint(8) unsigned DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_image_tag`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_image_tag` (
|
||||||
|
`image_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`tag_id` smallint(5) unsigned NOT NULL DEFAULT '0'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_languages`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_languages` (
|
||||||
|
`id` varchar(64) NOT NULL DEFAULT '',
|
||||||
|
`version` varchar(64) NOT NULL DEFAULT '0',
|
||||||
|
`name` varchar(64) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Contenu de la table `piwigo_languages`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `piwigo_languages` (`id`, `version`, `name`) VALUES
|
||||||
|
('af_ZA', '2.6.0', 'Afrikaans [ZA]'),
|
||||||
|
('es_AR', '2.6.0', 'Argentina [AR]'),
|
||||||
|
('az_AZ', '2.5.0', 'Azərbaycanca [AZ]'),
|
||||||
|
('id_ID', '2.6.0', 'Bahasa Indonesia [ID]'),
|
||||||
|
('pt_BR', '2.6.1', 'Brasil [BR]'),
|
||||||
|
('br_FR', '2.6.2', 'Brezhoneg [FR]'),
|
||||||
|
('ca_ES', '2.6.1', 'Català [CA]'),
|
||||||
|
('da_DK', '2.6.0', 'Dansk [DK]'),
|
||||||
|
('de_DE', '2.6.0', 'Deutsch [DE]'),
|
||||||
|
('dv_MV', '2.5.0', 'Dhivehi [MV]'),
|
||||||
|
('en_GB', '2.6.1', 'English [GB]'),
|
||||||
|
('en_UK', '2.6.0', 'English [UK]'),
|
||||||
|
('en_US', '2.6.0', 'English [US]'),
|
||||||
|
('es_ES', '2.6.0', 'Español [ES]'),
|
||||||
|
('eo_EO', '2.6.0', 'Esperanto [EO]'),
|
||||||
|
('et_EE', '2.6.0', 'Estonian [EE]'),
|
||||||
|
('fi_FI', '2.6.0', 'Finnish [FI]'),
|
||||||
|
('fr_FR', '2.6.0', 'Français [FR]'),
|
||||||
|
('fr_CA', '2.6.0', 'Français [QC]'),
|
||||||
|
('ga_IE', '2.5.0', 'Gaeilge [IE]'),
|
||||||
|
('gl_ES', '2.6.1', 'Galego [ES]'),
|
||||||
|
('hr_HR', '2.6.0', 'Hrvatski [HR]'),
|
||||||
|
('it_IT', '2.6.0', 'Italiano [IT]'),
|
||||||
|
('lv_LV', '2.6.0', 'Latviešu [LV]'),
|
||||||
|
('lt_LT', '2.6.0', 'Lietuviu [LT]'),
|
||||||
|
('lb_LU', '2.5.0', 'Lëtzebuergesch [LU]'),
|
||||||
|
('hu_HU', '2.6.0', 'Magyar [HU]'),
|
||||||
|
('ms_MY', '2.5.0', 'Malay [MY]'),
|
||||||
|
('nl_NL', '2.6.0', 'Nederlands [NL]'),
|
||||||
|
('nb_NO', '2.6.0', 'Norwegian [NO]'),
|
||||||
|
('nn_NO', '2.6.0', 'Norwegian nynorsk [NO]'),
|
||||||
|
('pl_PL', '2.6.1', 'Polski [PL]'),
|
||||||
|
('pt_PT', '2.6.0', 'Português [PT]'),
|
||||||
|
('ro_RO', '2.6.0', 'Română [RO]'),
|
||||||
|
('sk_SK', '2.6.0', 'Slovensky [SK]'),
|
||||||
|
('sl_SI', '2.6.1', 'Slovenšcina [SI]'),
|
||||||
|
('sh_RS', '2.6.1', 'Srpski [SR]'),
|
||||||
|
('sv_SE', '2.6.0', 'Svenska [SE]'),
|
||||||
|
('vi_VN', '2.6.0', 'Tiếng Việt [VN]'),
|
||||||
|
('tr_TR', '2.6.0', 'Türkçe [TR]'),
|
||||||
|
('is_IS', '2.6.0', 'Íslenska [IS]'),
|
||||||
|
('cs_CZ', '2.6.0', 'Česky [CZ]'),
|
||||||
|
('el_GR', '2.6.0', 'Ελληνικά [GR]'),
|
||||||
|
('bg_BG', '2.6.0', 'Български [BG]'),
|
||||||
|
('mk_MK', '2.6.0', 'Македонски [MK]'),
|
||||||
|
('mn_MN', '2.6.2', 'Монгол [MN]'),
|
||||||
|
('ru_RU', '2.6.0', 'Русский [RU]'),
|
||||||
|
('sr_RS', '2.6.1', 'Српски [SR]'),
|
||||||
|
('uk_UA', '2.6.0', 'Українська [UA]'),
|
||||||
|
('he_IL', '2.6.2', 'עברית [IL]'),
|
||||||
|
('ar_SA', '2.6.0', 'العربية [AR]'),
|
||||||
|
('ar_MA', '2.5.0', 'العربية [MA]'),
|
||||||
|
('fa_IR', '2.6.0', 'پارسی [IR]'),
|
||||||
|
('kok_IN', '2.5.0', 'कोंकणी [IN]'),
|
||||||
|
('bn_IN', '2.5.0', 'বাংলা[IN]'),
|
||||||
|
('ta_IN', '2.6.1', 'தமிழ் [IN]'),
|
||||||
|
('kn_IN', '2.6.0', 'ಕನ್ನಡ [IN]'),
|
||||||
|
('th_TH', '2.6.0', 'ภาษาไทย [TH]'),
|
||||||
|
('ka_GE', '2.6.0', 'ქართული [GE]'),
|
||||||
|
('km_KH', '2.6.2', 'ខ្មែរ [KH]'),
|
||||||
|
('zh_TW', '2.6.0', '中文 (繁體) [TW]'),
|
||||||
|
('zh_HK', '2.6.0', '中文 (香港) [HK]'),
|
||||||
|
('ja_JP', '2.6.0', '日本語 [JP]'),
|
||||||
|
('zh_CN', '2.6.0', '简体中文 [CN]'),
|
||||||
|
('ko_KR', '2.6.0', '한국어 [KR]');
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_old_permalinks`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_old_permalinks` (
|
||||||
|
`cat_id` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`permalink` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||||
|
`date_deleted` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`last_hit` datetime DEFAULT NULL,
|
||||||
|
`hit` int(10) unsigned NOT NULL DEFAULT '0'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_plugins`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_plugins` (
|
||||||
|
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||||
|
`state` enum('inactive','active') NOT NULL DEFAULT 'inactive',
|
||||||
|
`version` varchar(64) NOT NULL DEFAULT '0'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Contenu de la table `piwigo_plugins`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `piwigo_plugins` (`id`, `state`, `version`) VALUES
|
||||||
|
('Ldap_Login', 'active', '1.1');
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_rate`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_rate` (
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`element_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`anonymous_id` varchar(45) NOT NULL DEFAULT '',
|
||||||
|
`rate` tinyint(2) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`date` date NOT NULL DEFAULT '0000-00-00'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_search`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_search` (
|
||||||
|
`id` int(10) unsigned NOT NULL,
|
||||||
|
`last_seen` date DEFAULT NULL,
|
||||||
|
`rules` text
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_sessions`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_sessions` (
|
||||||
|
`id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||||
|
`data` mediumtext NOT NULL,
|
||||||
|
`expiration` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Contenu de la table `piwigo_sessions`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `piwigo_sessions` (`id`, `data`, `expiration`) VALUES
|
||||||
|
('C0A8q02887miht1f856vh8u19emb13', 'pwg_device|s:7:"desktop";pwg_mobile_theme|b:0;', '2014-06-28 22:59:15');
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_sites`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_sites` (
|
||||||
|
`id` tinyint(4) NOT NULL,
|
||||||
|
`galleries_url` varchar(255) NOT NULL DEFAULT ''
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Contenu de la table `piwigo_sites`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `piwigo_sites` (`id`, `galleries_url`) VALUES
|
||||||
|
(1, './galleries/');
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_tags`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_tags` (
|
||||||
|
`id` smallint(5) unsigned NOT NULL,
|
||||||
|
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||||
|
`url_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT ''
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_themes`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_themes` (
|
||||||
|
`id` varchar(64) NOT NULL DEFAULT '',
|
||||||
|
`version` varchar(64) NOT NULL DEFAULT '0',
|
||||||
|
`name` varchar(64) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Contenu de la table `piwigo_themes`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `piwigo_themes` (`id`, `version`, `name`) VALUES
|
||||||
|
('smartpocket', '2.6.2', 'Smart Pocket'),
|
||||||
|
('elegant', '2.6.2', 'elegant');
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_upgrade`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_upgrade` (
|
||||||
|
`id` varchar(20) NOT NULL DEFAULT '',
|
||||||
|
`applied` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`description` varchar(255) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Contenu de la table `piwigo_upgrade`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `piwigo_upgrade` (`id`, `applied`, `description`) VALUES
|
||||||
|
('61', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('62', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('63', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('64', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('65', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('66', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('67', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('68', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('69', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('70', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('71', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('72', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('73', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('74', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('75', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('76', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('77', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('78', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('79', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('80', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('81', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('82', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('83', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('84', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('85', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('86', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('87', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('88', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('89', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('90', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('91', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('92', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('93', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('94', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('95', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('96', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('97', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('98', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('99', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('100', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('101', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('102', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('103', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('104', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('105', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('106', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('107', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('108', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('109', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('110', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('111', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('112', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('113', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('114', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('115', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('116', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('117', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('118', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('119', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('120', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('121', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('122', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('123', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('124', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('125', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('126', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('127', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('128', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('129', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('130', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('131', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('132', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('133', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('134', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('135', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('136', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('137', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('138', '2014-06-28 22:33:36', 'upgrade included in installation'),
|
||||||
|
('139', '2014-06-28 22:33:36', 'upgrade included in installation');
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_users`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_users` (
|
||||||
|
`id` smallint(5) NOT NULL,
|
||||||
|
`username` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||||
|
`password` varchar(255) DEFAULT NULL,
|
||||||
|
`mail_address` varchar(255) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Contenu de la table `piwigo_users`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `piwigo_users` (`id`, `username`, `password`, `mail_address`) VALUES
|
||||||
|
(1, 'ADMINUSER', '', 'webmaster@monsieur-a.com'),
|
||||||
|
(2, 'guest', NULL, NULL);
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_user_access`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_user_access` (
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`cat_id` smallint(5) unsigned NOT NULL DEFAULT '0'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_user_cache`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_user_cache` (
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`need_update` enum('true','false') NOT NULL DEFAULT 'true',
|
||||||
|
`cache_update_time` int(10) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`forbidden_categories` mediumtext,
|
||||||
|
`nb_total_images` mediumint(8) unsigned DEFAULT NULL,
|
||||||
|
`last_photo_date` datetime DEFAULT NULL,
|
||||||
|
`nb_available_tags` int(5) DEFAULT NULL,
|
||||||
|
`nb_available_comments` int(5) DEFAULT NULL,
|
||||||
|
`image_access_type` enum('NOT IN','IN') NOT NULL DEFAULT 'NOT IN',
|
||||||
|
`image_access_list` mediumtext
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_user_cache_categories`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_user_cache_categories` (
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`cat_id` smallint(5) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`date_last` datetime DEFAULT NULL,
|
||||||
|
`max_date_last` datetime DEFAULT NULL,
|
||||||
|
`nb_images` mediumint(8) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`count_images` mediumint(8) unsigned DEFAULT '0',
|
||||||
|
`nb_categories` mediumint(8) unsigned DEFAULT '0',
|
||||||
|
`count_categories` mediumint(8) unsigned DEFAULT '0',
|
||||||
|
`user_representative_picture_id` mediumint(8) unsigned DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_user_feed`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_user_feed` (
|
||||||
|
`id` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`last_check` datetime DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_user_group`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_user_group` (
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`group_id` smallint(5) unsigned NOT NULL DEFAULT '0'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_user_infos`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_user_infos` (
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`nb_image_page` smallint(3) unsigned NOT NULL DEFAULT '15',
|
||||||
|
`status` enum('webmaster','admin','normal','generic','guest') NOT NULL DEFAULT 'guest',
|
||||||
|
`language` varchar(50) NOT NULL DEFAULT 'en_UK',
|
||||||
|
`expand` enum('true','false') NOT NULL DEFAULT 'false',
|
||||||
|
`show_nb_comments` enum('true','false') NOT NULL DEFAULT 'false',
|
||||||
|
`show_nb_hits` enum('true','false') NOT NULL DEFAULT 'false',
|
||||||
|
`recent_period` tinyint(3) unsigned NOT NULL DEFAULT '7',
|
||||||
|
`theme` varchar(255) NOT NULL DEFAULT 'elegant',
|
||||||
|
`registration_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`enabled_high` enum('true','false') NOT NULL DEFAULT 'true',
|
||||||
|
`level` tinyint(3) unsigned NOT NULL DEFAULT '0',
|
||||||
|
`activation_key` char(20) DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Contenu de la table `piwigo_user_infos`
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `piwigo_user_infos` (`user_id`, `nb_image_page`, `status`, `language`, `expand`, `show_nb_comments`, `show_nb_hits`, `recent_period`, `theme`, `registration_date`, `enabled_high`, `level`, `activation_key`) VALUES
|
||||||
|
(1, 15, 'webmaster', 'fr_FR', 'false', 'false', 'false', 7, 'elegant', '2014-06-28 22:33:36', 'true', 8, NULL),
|
||||||
|
(2, 15, 'guest', 'fr_FR', 'false', 'false', 'false', 7, 'elegant', '2014-06-28 22:33:36', 'true', 0, NULL);
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `piwigo_user_mail_notification`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `piwigo_user_mail_notification` (
|
||||||
|
`user_id` smallint(5) NOT NULL DEFAULT '0',
|
||||||
|
`check_key` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||||
|
`enabled` enum('true','false') NOT NULL DEFAULT 'false',
|
||||||
|
`last_send` datetime DEFAULT NULL
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour les tables exportées
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_caddie`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_caddie`
|
||||||
|
ADD PRIMARY KEY (`user_id`,`element_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_categories`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_categories`
|
||||||
|
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `categories_i3` (`permalink`), ADD KEY `categories_i2` (`id_uppercat`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_comments`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_comments`
|
||||||
|
ADD PRIMARY KEY (`id`), ADD KEY `comments_i2` (`validation_date`), ADD KEY `comments_i1` (`image_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_config`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_config`
|
||||||
|
ADD PRIMARY KEY (`param`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_favorites`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_favorites`
|
||||||
|
ADD PRIMARY KEY (`user_id`,`image_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_groups`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_groups`
|
||||||
|
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `groups_ui1` (`name`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_group_access`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_group_access`
|
||||||
|
ADD PRIMARY KEY (`group_id`,`cat_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_history`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_history`
|
||||||
|
ADD PRIMARY KEY (`id`), ADD KEY `history_i1` (`summarized`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_history_summary`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_history_summary`
|
||||||
|
ADD UNIQUE KEY `history_summary_ymdh` (`year`,`month`,`day`,`hour`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_images`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_images`
|
||||||
|
ADD PRIMARY KEY (`id`), ADD KEY `images_i2` (`date_available`), ADD KEY `images_i3` (`rating_score`), ADD KEY `images_i4` (`hit`), ADD KEY `images_i5` (`date_creation`), ADD KEY `images_i1` (`storage_category_id`), ADD KEY `images_i6` (`latitude`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_image_category`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_image_category`
|
||||||
|
ADD PRIMARY KEY (`image_id`,`category_id`), ADD KEY `image_category_i1` (`category_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_image_tag`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_image_tag`
|
||||||
|
ADD PRIMARY KEY (`image_id`,`tag_id`), ADD KEY `image_tag_i1` (`tag_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_languages`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_languages`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_old_permalinks`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_old_permalinks`
|
||||||
|
ADD PRIMARY KEY (`permalink`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_plugins`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_plugins`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_rate`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_rate`
|
||||||
|
ADD PRIMARY KEY (`element_id`,`user_id`,`anonymous_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_search`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_search`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_sessions`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_sessions`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_sites`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_sites`
|
||||||
|
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `sites_ui1` (`galleries_url`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_tags`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_tags`
|
||||||
|
ADD PRIMARY KEY (`id`), ADD KEY `tags_i1` (`url_name`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_themes`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_themes`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_upgrade`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_upgrade`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_users`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_users`
|
||||||
|
ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `users_ui1` (`username`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_user_access`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_user_access`
|
||||||
|
ADD PRIMARY KEY (`user_id`,`cat_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_user_cache`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_user_cache`
|
||||||
|
ADD PRIMARY KEY (`user_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_user_cache_categories`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_user_cache_categories`
|
||||||
|
ADD PRIMARY KEY (`user_id`,`cat_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_user_feed`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_user_feed`
|
||||||
|
ADD PRIMARY KEY (`id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_user_group`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_user_group`
|
||||||
|
ADD PRIMARY KEY (`group_id`,`user_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_user_infos`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_user_infos`
|
||||||
|
ADD PRIMARY KEY (`user_id`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Index pour la table `piwigo_user_mail_notification`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_user_mail_notification`
|
||||||
|
ADD PRIMARY KEY (`user_id`), ADD UNIQUE KEY `user_mail_notification_ui1` (`check_key`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT pour les tables exportées
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT pour la table `piwigo_categories`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_categories`
|
||||||
|
MODIFY `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT;
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT pour la table `piwigo_comments`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_comments`
|
||||||
|
MODIFY `id` int(11) unsigned NOT NULL AUTO_INCREMENT;
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT pour la table `piwigo_groups`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_groups`
|
||||||
|
MODIFY `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT;
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT pour la table `piwigo_history`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_history`
|
||||||
|
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=9;
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT pour la table `piwigo_images`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_images`
|
||||||
|
MODIFY `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT;
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT pour la table `piwigo_search`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_search`
|
||||||
|
MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT pour la table `piwigo_sites`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_sites`
|
||||||
|
MODIFY `id` tinyint(4) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT pour la table `piwigo_tags`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_tags`
|
||||||
|
MODIFY `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT;
|
||||||
|
--
|
||||||
|
-- AUTO_INCREMENT pour la table `piwigo_users`
|
||||||
|
--
|
||||||
|
ALTER TABLE `piwigo_users`
|
||||||
|
MODIFY `id` smallint(5) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4;
|
||||||
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
455
conf/piwigo_structure-mysql.sql~
Normal file
455
conf/piwigo_structure-mysql.sql~
Normal file
|
@ -0,0 +1,455 @@
|
||||||
|
-- MySQL dump 9.11
|
||||||
|
--
|
||||||
|
-- Host: localhost Database: pwg-bsf
|
||||||
|
-- ------------------------------------------------------
|
||||||
|
-- Server version 4.0.24_Debian-10-log
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_caddie`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_caddie`;
|
||||||
|
CREATE TABLE `piwigo_caddie` (
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`element_id` mediumint(8) NOT NULL default '0',
|
||||||
|
PRIMARY KEY (`user_id`,`element_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_categories`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_categories`;
|
||||||
|
CREATE TABLE `piwigo_categories` (
|
||||||
|
`id` smallint(5) unsigned NOT NULL auto_increment,
|
||||||
|
`name` varchar(255) NOT NULL default '',
|
||||||
|
`id_uppercat` smallint(5) unsigned default NULL,
|
||||||
|
`comment` text,
|
||||||
|
`dir` varchar(255) default NULL,
|
||||||
|
`rank` smallint(5) unsigned default NULL,
|
||||||
|
`status` enum('public','private') NOT NULL default 'public',
|
||||||
|
`site_id` tinyint(4) unsigned default NULL,
|
||||||
|
`visible` enum('true','false') NOT NULL default 'true',
|
||||||
|
`representative_picture_id` mediumint(8) unsigned default NULL,
|
||||||
|
`uppercats` varchar(255) NOT NULL default '',
|
||||||
|
`commentable` enum('true','false') NOT NULL default 'true',
|
||||||
|
`global_rank` varchar(255) default NULL,
|
||||||
|
`image_order` varchar(128) default NULL,
|
||||||
|
`permalink` varchar(64) binary default NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `categories_i3` (`permalink`),
|
||||||
|
KEY `categories_i2` (`id_uppercat`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_comments`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_comments`;
|
||||||
|
CREATE TABLE `piwigo_comments` (
|
||||||
|
`id` int(11) unsigned NOT NULL auto_increment,
|
||||||
|
`image_id` mediumint(8) unsigned NOT NULL default '0',
|
||||||
|
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`author` varchar(255) default NULL,
|
||||||
|
`email` varchar(255) default NULL,
|
||||||
|
`author_id` smallint(5) DEFAULT NULL,
|
||||||
|
`anonymous_id` varchar(45) NOT NULL,
|
||||||
|
`website_url` varchar(255) DEFAULT NULL,
|
||||||
|
`content` longtext,
|
||||||
|
`validated` enum('true','false') NOT NULL default 'false',
|
||||||
|
`validation_date` datetime default NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `comments_i2` (`validation_date`),
|
||||||
|
KEY `comments_i1` (`image_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_config`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_config`;
|
||||||
|
CREATE TABLE `piwigo_config` (
|
||||||
|
`param` varchar(40) NOT NULL default '',
|
||||||
|
`value` text,
|
||||||
|
`comment` varchar(255) default NULL,
|
||||||
|
PRIMARY KEY (`param`)
|
||||||
|
) ENGINE=MyISAM COMMENT='configuration table';
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_favorites`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_favorites`;
|
||||||
|
CREATE TABLE `piwigo_favorites` (
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`image_id` mediumint(8) unsigned NOT NULL default '0',
|
||||||
|
PRIMARY KEY (`user_id`,`image_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_group_access`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_group_access`;
|
||||||
|
CREATE TABLE `piwigo_group_access` (
|
||||||
|
`group_id` smallint(5) unsigned NOT NULL default '0',
|
||||||
|
`cat_id` smallint(5) unsigned NOT NULL default '0',
|
||||||
|
PRIMARY KEY (`group_id`,`cat_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_groups`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_groups`;
|
||||||
|
CREATE TABLE `piwigo_groups` (
|
||||||
|
`id` smallint(5) unsigned NOT NULL auto_increment,
|
||||||
|
`name` varchar(255) NOT NULL default '',
|
||||||
|
`is_default` enum('true','false') NOT NULL default 'false',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `groups_ui1` (`name`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_history`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_history`;
|
||||||
|
CREATE TABLE `piwigo_history` (
|
||||||
|
`id` int(10) unsigned NOT NULL auto_increment,
|
||||||
|
`date` date NOT NULL default '0000-00-00',
|
||||||
|
`time` time NOT NULL default '00:00:00',
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`IP` varchar(15) NOT NULL default '',
|
||||||
|
`section` enum('categories','tags','search','list','favorites','most_visited','best_rated','recent_pics','recent_cats') default NULL,
|
||||||
|
`category_id` smallint(5) default NULL,
|
||||||
|
`tag_ids` varchar(50) default NULL,
|
||||||
|
`image_id` mediumint(8) default NULL,
|
||||||
|
`summarized` enum('true','false') default 'false',
|
||||||
|
`image_type` enum('picture','high','other') default NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `history_i1` (`summarized`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_history_summary`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_history_summary`;
|
||||||
|
CREATE TABLE `piwigo_history_summary` (
|
||||||
|
`year` smallint(4) NOT NULL default '0',
|
||||||
|
`month` tinyint(2) default NULL,
|
||||||
|
`day` tinyint(2) default NULL,
|
||||||
|
`hour` tinyint(2) default NULL,
|
||||||
|
`nb_pages` int(11) default NULL,
|
||||||
|
UNIQUE KEY history_summary_ymdh (`year`,`month`,`day`,`hour`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_image_category`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_image_category`;
|
||||||
|
CREATE TABLE `piwigo_image_category` (
|
||||||
|
`image_id` mediumint(8) unsigned NOT NULL default '0',
|
||||||
|
`category_id` smallint(5) unsigned NOT NULL default '0',
|
||||||
|
`rank` mediumint(8) unsigned default NULL,
|
||||||
|
PRIMARY KEY (`image_id`,`category_id`),
|
||||||
|
KEY `image_category_i1` (`category_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_image_tag`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_image_tag`;
|
||||||
|
CREATE TABLE `piwigo_image_tag` (
|
||||||
|
`image_id` mediumint(8) unsigned NOT NULL default '0',
|
||||||
|
`tag_id` smallint(5) unsigned NOT NULL default '0',
|
||||||
|
PRIMARY KEY (`image_id`,`tag_id`),
|
||||||
|
KEY `image_tag_i1` (`tag_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_images`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_images`;
|
||||||
|
CREATE TABLE `piwigo_images` (
|
||||||
|
`id` mediumint(8) unsigned NOT NULL auto_increment,
|
||||||
|
`file` varchar(255) binary NOT NULL default '',
|
||||||
|
`date_available` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`date_creation` datetime default NULL,
|
||||||
|
`name` varchar(255) default NULL,
|
||||||
|
`comment` text,
|
||||||
|
`author` varchar(255) default NULL,
|
||||||
|
`hit` int(10) unsigned NOT NULL default '0',
|
||||||
|
`filesize` mediumint(9) unsigned default NULL,
|
||||||
|
`width` smallint(9) unsigned default NULL,
|
||||||
|
`height` smallint(9) unsigned default NULL,
|
||||||
|
`coi` char(4) default NULL COMMENT 'center of interest',
|
||||||
|
`representative_ext` varchar(4) default NULL,
|
||||||
|
`date_metadata_update` date default NULL,
|
||||||
|
`rating_score` float(5,2) unsigned default NULL,
|
||||||
|
`path` varchar(255) NOT NULL default '',
|
||||||
|
`storage_category_id` smallint(5) unsigned default NULL,
|
||||||
|
`level` tinyint unsigned NOT NULL default '0',
|
||||||
|
`md5sum` char(32) default NULL,
|
||||||
|
`added_by` smallint(5) NOT NULL default '0',
|
||||||
|
`rotation` tinyint unsigned default NULL,
|
||||||
|
`latitude` double(8, 6) default NULL,
|
||||||
|
`longitude` double(9, 6) default NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `images_i2` (`date_available`),
|
||||||
|
KEY `images_i3` (`rating_score`),
|
||||||
|
KEY `images_i4` (`hit`),
|
||||||
|
KEY `images_i5` (`date_creation`),
|
||||||
|
KEY `images_i1` (`storage_category_id`),
|
||||||
|
KEY `images_i6` (`latitude`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_languages`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_languages`;
|
||||||
|
CREATE TABLE `piwigo_languages` (
|
||||||
|
`id` varchar(64) NOT NULL default '',
|
||||||
|
`version` varchar(64) NOT NULL default '0',
|
||||||
|
`name` varchar(64) default NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_old_permalinks`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_old_permalinks`;
|
||||||
|
CREATE TABLE `piwigo_old_permalinks` (
|
||||||
|
`cat_id` smallint(5) unsigned NOT NULL default '0',
|
||||||
|
`permalink` varchar(64) binary NOT NULL default '',
|
||||||
|
`date_deleted` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`last_hit` datetime default NULL,
|
||||||
|
`hit` int(10) unsigned NOT NULL default '0',
|
||||||
|
PRIMARY KEY (`permalink`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_plugins`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_plugins`;
|
||||||
|
CREATE TABLE `piwigo_plugins` (
|
||||||
|
`id` varchar(64) binary NOT NULL default '',
|
||||||
|
`state` enum('inactive','active') NOT NULL default 'inactive',
|
||||||
|
`version` varchar(64) NOT NULL default '0',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_rate`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_rate`;
|
||||||
|
CREATE TABLE `piwigo_rate` (
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`element_id` mediumint(8) unsigned NOT NULL default '0',
|
||||||
|
`anonymous_id` varchar(45) NOT NULL default '',
|
||||||
|
`rate` tinyint(2) unsigned NOT NULL default '0',
|
||||||
|
`date` date NOT NULL default '0000-00-00',
|
||||||
|
PRIMARY KEY (`element_id`,`user_id`,`anonymous_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_search`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_search`;
|
||||||
|
CREATE TABLE `piwigo_search` (
|
||||||
|
`id` int(10) unsigned NOT NULL auto_increment,
|
||||||
|
`last_seen` date default NULL,
|
||||||
|
`rules` text,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_sessions`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_sessions`;
|
||||||
|
CREATE TABLE `piwigo_sessions` (
|
||||||
|
`id` varchar(255) binary NOT NULL default '',
|
||||||
|
`data` mediumtext NOT NULL,
|
||||||
|
`expiration` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_sites`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_sites`;
|
||||||
|
CREATE TABLE `piwigo_sites` (
|
||||||
|
`id` tinyint(4) NOT NULL auto_increment,
|
||||||
|
`galleries_url` varchar(255) NOT NULL default '',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `sites_ui1` (`galleries_url`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_tags`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_tags`;
|
||||||
|
CREATE TABLE `piwigo_tags` (
|
||||||
|
`id` smallint(5) unsigned NOT NULL auto_increment,
|
||||||
|
`name` varchar(255) binary NOT NULL default '',
|
||||||
|
`url_name` varchar(255) binary NOT NULL default '',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `tags_i1` (`url_name`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_themes`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_themes`;
|
||||||
|
CREATE TABLE `piwigo_themes` (
|
||||||
|
`id` varchar(64) NOT NULL default '',
|
||||||
|
`version` varchar(64) NOT NULL default '0',
|
||||||
|
`name` varchar(64) default NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_upgrade`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_upgrade`;
|
||||||
|
CREATE TABLE `piwigo_upgrade` (
|
||||||
|
`id` varchar(20) NOT NULL default '',
|
||||||
|
`applied` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`description` varchar(255) default NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_user_access`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_user_access`;
|
||||||
|
CREATE TABLE `piwigo_user_access` (
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`cat_id` smallint(5) unsigned NOT NULL default '0',
|
||||||
|
PRIMARY KEY (`user_id`,`cat_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_user_cache`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_user_cache`;
|
||||||
|
CREATE TABLE `piwigo_user_cache` (
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`need_update` enum('true','false') NOT NULL default 'true',
|
||||||
|
`cache_update_time` integer unsigned NOT NULL default 0,
|
||||||
|
`forbidden_categories` mediumtext,
|
||||||
|
`nb_total_images` mediumint(8) unsigned default NULL,
|
||||||
|
`last_photo_date` datetime DEFAULT NULL,
|
||||||
|
`nb_available_tags` INT(5) DEFAULT NULL,
|
||||||
|
`nb_available_comments` INT(5) DEFAULT NULL,
|
||||||
|
`image_access_type` enum('NOT IN','IN') NOT NULL default 'NOT IN',
|
||||||
|
`image_access_list` mediumtext default NULL,
|
||||||
|
PRIMARY KEY (`user_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_user_cache_categories`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_user_cache_categories`;
|
||||||
|
CREATE TABLE `piwigo_user_cache_categories` (
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`cat_id` smallint(5) unsigned NOT NULL default '0',
|
||||||
|
`date_last` datetime default NULL,
|
||||||
|
`max_date_last` datetime default NULL,
|
||||||
|
`nb_images` mediumint(8) unsigned NOT NULL default '0',
|
||||||
|
`count_images` mediumint(8) unsigned default '0',
|
||||||
|
`nb_categories` mediumint(8) unsigned default '0',
|
||||||
|
`count_categories` mediumint(8) unsigned default '0',
|
||||||
|
`user_representative_picture_id` mediumint(8) unsigned default NULL,
|
||||||
|
PRIMARY KEY (`user_id`,`cat_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_user_feed`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_user_feed`;
|
||||||
|
CREATE TABLE `piwigo_user_feed` (
|
||||||
|
`id` varchar(50) binary NOT NULL default '',
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`last_check` datetime default NULL,
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_user_group`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_user_group`;
|
||||||
|
CREATE TABLE `piwigo_user_group` (
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`group_id` smallint(5) unsigned NOT NULL default '0',
|
||||||
|
PRIMARY KEY (`group_id`,`user_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_user_infos`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_user_infos`;
|
||||||
|
CREATE TABLE `piwigo_user_infos` (
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`nb_image_page` smallint(3) unsigned NOT NULL default '15',
|
||||||
|
`status` enum('webmaster','admin','normal','generic','guest') NOT NULL default 'guest',
|
||||||
|
`language` varchar(50) NOT NULL default 'en_UK',
|
||||||
|
`expand` enum('true','false') NOT NULL default 'false',
|
||||||
|
`show_nb_comments` enum('true','false') NOT NULL default 'false',
|
||||||
|
`show_nb_hits` enum('true','false') NOT NULL default 'false',
|
||||||
|
`recent_period` tinyint(3) unsigned NOT NULL default '7',
|
||||||
|
`theme` varchar(255) NOT NULL default 'elegant',
|
||||||
|
`registration_date` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||||
|
`enabled_high` enum('true','false') NOT NULL default 'true',
|
||||||
|
`level` tinyint unsigned NOT NULL default '0',
|
||||||
|
`activation_key` char(20) default NULL,
|
||||||
|
PRIMARY KEY (`user_id`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_user_mail_notification`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_user_mail_notification`;
|
||||||
|
CREATE TABLE `piwigo_user_mail_notification` (
|
||||||
|
`user_id` smallint(5) NOT NULL default '0',
|
||||||
|
`check_key` varchar(16) binary NOT NULL default '',
|
||||||
|
`enabled` enum('true','false') NOT NULL default 'false',
|
||||||
|
`last_send` datetime default NULL,
|
||||||
|
PRIMARY KEY (`user_id`),
|
||||||
|
UNIQUE KEY `user_mail_notification_ui1` (`check_key`)
|
||||||
|
) ENGINE=MyISAM;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `piwigo_users`
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `piwigo_users`;
|
||||||
|
CREATE TABLE `piwigo_users` (
|
||||||
|
`id` smallint(5) NOT NULL auto_increment,
|
||||||
|
`username` varchar(100) binary NOT NULL default '',
|
||||||
|
`password` varchar(255) default NULL,
|
||||||
|
`mail_address` varchar(255) default NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `users_ui1` (`username`)
|
||||||
|
) ENGINE=MyISAM;
|
1
conf/plug.sql~
Normal file
1
conf/plug.sql~
Normal file
|
@ -0,0 +1 @@
|
||||||
|
INSERT INTO plugins
|
49
manifest.json
Normal file
49
manifest.json
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{
|
||||||
|
"name": "Piwigo",
|
||||||
|
"id": "piwigo",
|
||||||
|
"description": {
|
||||||
|
"en": "photo gallery",
|
||||||
|
"fr": "Gallerie photo"
|
||||||
|
},
|
||||||
|
"developer": {
|
||||||
|
"name": "monsieur-a",
|
||||||
|
"email": "simon@monsieur-a.fr",
|
||||||
|
"url": "http://piwigo.org"
|
||||||
|
},
|
||||||
|
"multi_instance": "true",
|
||||||
|
"arguments": {
|
||||||
|
"install" : [
|
||||||
|
{
|
||||||
|
"name": "domain",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose a domain for Piwigo"
|
||||||
|
},
|
||||||
|
"example": "domain.org"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "path",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose a path for Piwigo"
|
||||||
|
},
|
||||||
|
"example": "/piwigo",
|
||||||
|
"default": "/piwigo"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "admin",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose the Piwigo administrator (must be an existing YunoHost user)"
|
||||||
|
},
|
||||||
|
"example": "homer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "public_site",
|
||||||
|
"ask": {
|
||||||
|
"en": "Is it a public Piwigo site ?",
|
||||||
|
"fr": "Est-ce un site public ?"
|
||||||
|
},
|
||||||
|
"choices": ["Yes", "No"],
|
||||||
|
"default": "Yes"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
30
plugins/Ldap_Login/TODO
Normal file
30
plugins/Ldap_Login/TODO
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
TODO :
|
||||||
|
auto config (may use ajax): fill in the settings, then the page guess the next settings.
|
||||||
|
Ex : after filled the host address, the page guess the base dn. The last to guess is the users OU.
|
||||||
|
Users OU can come with a select field, as the ld_attr.
|
||||||
|
|
||||||
|
correct init plugin
|
||||||
|
if mail isn't furnished ?
|
||||||
|
create common piwigo users upon successfull ldap connection when piwigo user doesn't exist => done !
|
||||||
|
Groups : users may belong to ldap group to allow connection
|
||||||
|
Groups : users belonging to «sudo» or «admin» ldap group become piwigo admin when created this way
|
||||||
|
fetching attributes from ldap (mail…).
|
||||||
|
|
||||||
|
config of the previous one (need tabs)
|
||||||
|
config page to render better
|
||||||
|
|
||||||
|
########
|
||||||
|
|
||||||
|
à faire :
|
||||||
|
initialisation du plugin correcte
|
||||||
|
qu'est-ce qu'on fait si le mail est pas fourni ?
|
||||||
|
configuration automatique (javascript/ajax probable): entrée des paramètres et la page recherche le paramètre suivant si possible.
|
||||||
|
Ex : adresse du serveur -> la page trouve toute seule la racine ldap, reste plus que la OU des utilisateurs (qu'on peut selectionner via une liste déroulante).
|
||||||
|
l'attribut d'identification peut être selectionné par une liste déroulante.
|
||||||
|
|
||||||
|
creation d'un utilisateur piwigo suite à une authentification ldap quand l'utilisateur n'existe pas. => fait !
|
||||||
|
question de groups : les utilisateurs membres du groupe ldap «sudo» ou autre pourraient automatiquement être admins piwigo
|
||||||
|
question de groupe : les utilisateurs devraient appartenir à un groupe ldap pour se connecter…
|
||||||
|
récuperer les attributs dans le ldap (mail…).
|
||||||
|
|
||||||
|
page de config à peaufiner, option précédente à intégrer dans un onglet.
|
25
plugins/Ldap_Login/admin.php
Normal file
25
plugins/Ldap_Login/admin.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
defined('LDAP_LOGIN_PATH') or die('Hacking attempt!');
|
||||||
|
|
||||||
|
global $template, $page, $conf;
|
||||||
|
|
||||||
|
// get current tab
|
||||||
|
$page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : $page['tab'] = 'configuration';
|
||||||
|
|
||||||
|
// tabsheet
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||||
|
$tabsheet = new tabsheet();
|
||||||
|
$tabsheet->set_id('ldap_login');
|
||||||
|
|
||||||
|
$tabsheet->add('configuration', l10n('Configuration'), LDAP_LOGIN_ADMIN . '-configuration');
|
||||||
|
$tabsheet->add('newusers', l10n('New users when ldap auth is successfull'), LDAP_LOGIN_ADMIN . '-newusers');
|
||||||
|
$tabsheet->select($page['tab']);
|
||||||
|
$tabsheet->assign();
|
||||||
|
|
||||||
|
// include page
|
||||||
|
include(LDAP_LOGIN_PATH . 'admin/' . $page['tab'] . '.php');
|
||||||
|
|
||||||
|
// template vars
|
||||||
|
$template->assign('LDAP_LOGIN_PATH', get_root_url() . LDAP_LOGIN_PATH );
|
||||||
|
|
||||||
|
?>
|
58
plugins/Ldap_Login/admin/configuration.php
Normal file
58
plugins/Ldap_Login/admin/configuration.php
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
|
||||||
|
|
||||||
|
global $template;
|
||||||
|
$template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/configuration.tpl') );
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'PLUGIN_ACTION' => get_root_url().'admin.php?page=plugin-Ldap_Login-configuration',
|
||||||
|
'PLUGIN_CHECK' => get_root_url().'admin.php?page=plugin-Ldap_Login-configuration',
|
||||||
|
));
|
||||||
|
|
||||||
|
$me = new Ldap();
|
||||||
|
$me->load_config();
|
||||||
|
//$me = get_plugin_data($plugin_id);
|
||||||
|
|
||||||
|
$template->assign('HOST', $me->config['host']);
|
||||||
|
$template->assign('BASEDN', $me->config['basedn']); // racine !
|
||||||
|
$template->assign('PORT', $me->config['port']);
|
||||||
|
$template->assign('LD_ATTR', $me->config['ld_attr']);
|
||||||
|
$template->assign('LD_USE_SSL', $me->config['ld_use_ssl']);
|
||||||
|
$template->assign('LD_BINDPW', $me->config['ld_bindpw']);
|
||||||
|
$template->assign('LD_BINDDN', $me->config['ld_binddn']);
|
||||||
|
|
||||||
|
if (isset($_POST['save'])){
|
||||||
|
$me->config['host'] = $_POST['HOST'];
|
||||||
|
$me->config['basedn'] = $_POST['BASEDN'];
|
||||||
|
$me->config['port'] = $_POST['PORT'];
|
||||||
|
$me->config['ld_attr'] = $_POST['LD_ATTR'];
|
||||||
|
$me->config['ld_binddn'] = $_POST['LD_BINDDN'];
|
||||||
|
$me->config['ld_bindpw'] = $_POST['LD_BINDPW'];
|
||||||
|
|
||||||
|
if (isset($_POST['LD_USE_SSL'])){
|
||||||
|
$me->config['ld_use_ssl'] = True;
|
||||||
|
} else {
|
||||||
|
$me->config['ld_use_ssl'] = False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save LDAP configuration
|
||||||
|
if (isset($_POST['save'])){
|
||||||
|
$me->save_config();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check LDAP configuration
|
||||||
|
if (isset($_POST['check_ldap'])){
|
||||||
|
$check = $me->ldap_name($_POST['USERNAME']);
|
||||||
|
$error = $me->check_ldap();
|
||||||
|
|
||||||
|
if ($me->ldap_bind_as($_POST['USERNAME'],$_POST['PASSWORD'])){
|
||||||
|
$template->assign('LD_CHECK_LDAP','<p style="color:green;">Configuration LDAP OK : '.$check.'</p>');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$template->assign('LD_CHECK_LDAP','<p style="color:red;">Error :'.$error.' test '.$me->config['uri'].' '.$check.'</p>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
|
||||||
|
?>
|
109
plugins/Ldap_Login/admin/configuration.tpl
Normal file
109
plugins/Ldap_Login/admin/configuration.tpl
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
<h2>{'Ldap_Login Plugin'|@translate}</h2>
|
||||||
|
|
||||||
|
<div id="configContent">
|
||||||
|
|
||||||
|
<p>{'All LDAP users can use their ldap password everywhere on piwigo if needed.'|@translate}</p>
|
||||||
|
|
||||||
|
<form method="post" action="{$PLUGIN_ACTION}" class="general">
|
||||||
|
|
||||||
|
{if (!extension_loaded('ldap'))}
|
||||||
|
<p style="color:red;">{'Warning: LDAP Extension missing.'|@translate}</p>
|
||||||
|
<br />
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<fieldset class="mainConf">
|
||||||
|
<legend>{'Ldap server host connection'|@translate}</legend>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<label for="host">{'Ldap server host'|@translate}</label>
|
||||||
|
<br>
|
||||||
|
<input size="70" type="text" id="host" name="HOST" value="{$HOST}" />
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<label for="ld_use_ssl">
|
||||||
|
{if $LD_USE_SSL }
|
||||||
|
<input type="checkbox" id="ld_use_ssl" name="LD_USE_SSL" value="{$LD_USE_SSL}" checked />
|
||||||
|
{else}
|
||||||
|
<input type="checkbox" id="ld_use_ssl" name="LD_USE_SSL" value="{$LD_USE_SSL}" />
|
||||||
|
{/if}
|
||||||
|
{'Secure connexion'|@translate}</label>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<label for="port">{'Ldap port'|@translate}</label>
|
||||||
|
<br>
|
||||||
|
<input type="text" id="port" name="PORT" value="{$PORT}" />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<i>{'If empty, localhost and standard protocol ports will be used in configuration.'|@translate}</i>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="mainConf">
|
||||||
|
<legend>{'Ldap attributes'|@translate}</legend>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<label for="basedn">{'Base DN'|@translate}</label>
|
||||||
|
<br>
|
||||||
|
<input size="70" type="text" id="basedn" name="BASEDN" value="{$BASEDN}" />
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<label for="ld_attr">{'Attribute corresponding to the user name'|@translate}</label>
|
||||||
|
<br>
|
||||||
|
<input type="text" id="ld_attr" name="LD_ATTR" value="{$LD_ATTR}" />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="mainConf">
|
||||||
|
<legend>{'Ldap connection credentials'|@translate}</legend>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<label for="ld_binddn">{'Bind DN, field in full ldap style'|@translate}</label>
|
||||||
|
<br>
|
||||||
|
<input size="70" type="text" id="ld_binddn" name="LD_BINDDN" value="{$LD_BINDDN}" />
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<label for="ld_bindpw">{'Bind password'|@translate}</label>
|
||||||
|
<br>
|
||||||
|
<input type="password" id="ld_bindpw" name="LD_BINDPW" />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<i>{'Let the fields blank if the ldap accept anonymous connections.'|@translate}</i>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<input type="submit" value="{'Save'|@translate}" name="save" />
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form method="post" action="{$PLUGIN_CHECK}" class="general">
|
||||||
|
<fieldset class="mainConf">
|
||||||
|
<legend>{'Ldap_Login Test'|@translate}</legend>
|
||||||
|
<i>{'You must save the settings with the Save button just up there before testing here.'|@translate}</i>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<label for="username">{'Username'|@translate}</label>
|
||||||
|
<br>
|
||||||
|
<input type="text" id="username" name="USERNAME" value="{$USERNAME}" />
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<label for="ld_attr">{'Your password'|@translate}</label>
|
||||||
|
<br>
|
||||||
|
<input type="password" id="password" name="PASSWORD" value="{$PASSWORD}" />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{if (!empty($LD_CHECK_LDAP))}
|
||||||
|
{$LD_CHECK_LDAP}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
<p><input type="submit" value="{'Test Settings'|@translate}" name="check_ldap" /></p>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
30
plugins/Ldap_Login/admin/index.php
Normal file
30
plugins/Ldap_Login/admin/index.php
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Recursive call
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
22
plugins/Ldap_Login/admin/ldap_login_plugin_admin.php
Normal file
22
plugins/Ldap_Login/admin/ldap_login_plugin_admin.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
|
||||||
|
|
||||||
|
$me = get_plugin_data($plugin_id);
|
||||||
|
|
||||||
|
if (isset($_POST['submit']))
|
||||||
|
{
|
||||||
|
$me->config['host'] = $_POST['HOST'];
|
||||||
|
$me->config['basedn'] = $_POST['BASEDN'];
|
||||||
|
$me->config['pref'] = $_POST['PREF'];
|
||||||
|
$me->save_config();
|
||||||
|
}
|
||||||
|
|
||||||
|
global $template;
|
||||||
|
$template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/ldap_login_plugin_admin.tpl') );
|
||||||
|
|
||||||
|
$template->assign('HOST', $me->config['host']);
|
||||||
|
$template->assign('BASEDN', $me->config['basedn']);
|
||||||
|
$template->assign('PREF', $me->config['pref']);
|
||||||
|
|
||||||
|
$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
|
||||||
|
?>
|
24
plugins/Ldap_Login/admin/ldap_login_plugin_admin.tpl
Normal file
24
plugins/Ldap_Login/admin/ldap_login_plugin_admin.tpl
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<div class="titrePage">
|
||||||
|
<h2>Ldap_Login PlugIn</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>Configuration du plugin Ldap_Login</p>
|
||||||
|
|
||||||
|
<form method="post" action="{$TESTPLUGIN_F_ACTION}" class="general">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Ldap_Login PlugIn</legend>
|
||||||
|
<label>Hote du serveur Ldap
|
||||||
|
<input type="text" name="HOST" value="{$HOST}" />
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
|
<label>Arbre ldap à explorer : basedn = ",ou=utilisateurs,dc=22decembre,dc=eu". L'arbre doit commencer par une virgule !
|
||||||
|
<input type="text" name="BASEDN" value="{$BASEDN}" />
|
||||||
|
</label>
|
||||||
|
<br />
|
||||||
|
<label>prefixe à utiliser. Les plus communs sont "uid=".
|
||||||
|
<input type="text" name="PREF" value="{$PREF}" />
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p><input type="submit" value="Enregistrer" name="submit" /></p>
|
||||||
|
</form>
|
52
plugins/Ldap_Login/admin/newusers.php
Normal file
52
plugins/Ldap_Login/admin/newusers.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
|
||||||
|
|
||||||
|
global $template;
|
||||||
|
$template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/newusers.tpl') );
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'PLUGIN_NEWUSERS' => get_root_url().'admin.php?page=plugin-Ldap_Login-newusers',
|
||||||
|
));
|
||||||
|
|
||||||
|
$me = new Ldap();
|
||||||
|
$me->load_config();
|
||||||
|
//$me = get_plugin_data($plugin_id);
|
||||||
|
|
||||||
|
$template->assign('ALLOW_NEWUSERS', $me->config['allow_newusers']);
|
||||||
|
$template->assign('ADVERTISE_ADMINS', $me->config['advertise_admin_new_ldapuser']);
|
||||||
|
$template->assign('SEND_CASUAL_MAIL', $me->config['send_password_by_mail_ldap']);
|
||||||
|
|
||||||
|
if (isset($_POST['save'])){
|
||||||
|
|
||||||
|
if (isset($_POST['ALLOW_NEWUSERS'])){
|
||||||
|
$me->config['allow_newusers'] = True;
|
||||||
|
} else {
|
||||||
|
$me->config['allow_newusers'] = False;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['ADVERTISE_ADMINS'])){
|
||||||
|
$me->config['advertise_admin_new_ldapuser'] = True;
|
||||||
|
} else {
|
||||||
|
$me->config['advertise_admin_new_ldapuser'] = False;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['SEND_CASUAL_MAIL'])){
|
||||||
|
$me->config['send_password_by_mail_ldap'] = True;
|
||||||
|
} else {
|
||||||
|
$me->config['send_password_by_mail_ldap'] = False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save LDAP configuration
|
||||||
|
if (isset($_POST['save'])){
|
||||||
|
$me->save_config();
|
||||||
|
}
|
||||||
|
|
||||||
|
// do we allow to create new piwigo users in case of auth along the ldap ?
|
||||||
|
// does he have to belong an ldap group ?
|
||||||
|
// does ldap groups give some power ?
|
||||||
|
// what do we do when there's no mail in the ldap ?
|
||||||
|
// do we send mail to admins ?
|
||||||
|
|
||||||
|
$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
|
||||||
|
?>
|
54
plugins/Ldap_Login/admin/newusers.tpl
Normal file
54
plugins/Ldap_Login/admin/newusers.tpl
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{literal}
|
||||||
|
<style>
|
||||||
|
label
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
width: 250px;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{/literal}
|
||||||
|
|
||||||
|
<div class="titrePage">
|
||||||
|
<h2>{'Ldap_Login Plugin'|@translate}</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<i>{"If the LDAP doesn't furnish the mail address, users can set it up in the profile page."|@translate}</i>
|
||||||
|
<form method="post" action="{$PLUGIN_NEWUSERS}" class="general">
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>{'Ldap_Login configuration'|@translate}</legend>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{if $ALLOW_NEWUSERS}
|
||||||
|
<input type="checkbox" id="allow_newusers" name="ALLOW_NEWUSERS" value="{$ALLOW_NEWUSERS}" checked />
|
||||||
|
{else}
|
||||||
|
<input type="checkbox" id="allow_newusers" name="ALLOW_NEWUSERS" value="{$ALLOW_NEWUSERS}" />
|
||||||
|
{/if}
|
||||||
|
{'Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'|@translate}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{if $ADVERTISE_ADMINS}
|
||||||
|
<input type="checkbox" id="advertise_admin_new_ldapuser" name="ADVERTISE_ADMINS" value="{$ADVERTISE_ADMINS}" checked />
|
||||||
|
{else}
|
||||||
|
<input type="checkbox" id="advertise_admin_new_ldapuser" name="ADVERTISE_ADMINS" value="{$ADVERTISE_ADMINS}" />
|
||||||
|
{/if}
|
||||||
|
{'Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'|@translate}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{if $SEND_CASUAL_MAIL}
|
||||||
|
<input type="checkbox" id="send_password_by_mail_ldap" name="SEND_CASUAL_MAIL" value="{$SEND_CASUAL_MAIL}" checked />
|
||||||
|
{else}
|
||||||
|
<input type="checkbox" id="send_password_by_mail_ldap" name="SEND_CASUAL_MAIL" value="{$SEND_CASUAL_MAIL}" />
|
||||||
|
{/if}
|
||||||
|
{'Do you want to send mail to the new users, like casual piwigo users receive ?'|@translate}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<input type="submit" value="{'Save'|@translate}" name="save" />
|
||||||
|
</p>
|
||||||
|
</form>
|
192
plugins/Ldap_Login/class.ldap.php
Normal file
192
plugins/Ldap_Login/class.ldap.php
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
<?php
|
||||||
|
global $conf;
|
||||||
|
class Ldap {
|
||||||
|
var $cnx;
|
||||||
|
var $config;
|
||||||
|
|
||||||
|
// for debug
|
||||||
|
public function write_log($message){
|
||||||
|
@file_put_contents('/var/log/ldap_login.log',$message."\n",FILE_APPEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check ldap configuration
|
||||||
|
*
|
||||||
|
* Dans le cas ou l'acces au ldap est anonyme il faut impérativement faire une recherche
|
||||||
|
* pour tester la connection.
|
||||||
|
*
|
||||||
|
* When OpenLDAP 2.x.x is used, ldap_connect() will always return a resource as it does not actually connect
|
||||||
|
* but just initializes the connecting parameters. The actual connect happens with the next calls
|
||||||
|
* to ldap_* funcs, usually with ldap_bind().
|
||||||
|
*/
|
||||||
|
public function check_ldap(){
|
||||||
|
|
||||||
|
if (!$this->ldap_conn()) {
|
||||||
|
return $this->getErrorString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// test du compte root si renseigné
|
||||||
|
if (!empty($this->config['ld_binddn']) && !empty($this->config['ld_bindpw'])){ // if empty ld_binddn, anonymous search
|
||||||
|
// authentication with rootdn and rootpw for search
|
||||||
|
if (!$this->ldap_bind_as($this->config['ld_binddn'],$this->config['ld_bindpw'])){
|
||||||
|
return $this->getErrorString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// sinon recherche du basedn (cf comportement ldap_connect avec OpenLDAP)
|
||||||
|
if (!$this->ldap_check_basedn()){ // search userdn
|
||||||
|
return $this->getErrorString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function load_default_config()
|
||||||
|
{
|
||||||
|
$this->config['host'] = 'localhost';
|
||||||
|
$this->config['basedn'] = 'ou=people,dc=example,dc=com'; // racine !
|
||||||
|
$this->config['port'] = ''; // if port is empty, I count on the software to care of it !
|
||||||
|
$this->config['ld_attr'] = 'uid';
|
||||||
|
$this->config['ld_use_ssl'] = False;
|
||||||
|
$this->config['ld_bindpw'] ='';
|
||||||
|
$this->config['ld_binddn'] ='';
|
||||||
|
|
||||||
|
$this->config['allow_newusers'] = False;
|
||||||
|
$this->config['advertise_admin_new_ldapuser'] = False;
|
||||||
|
$this->config['send_password_by_mail_ldap'] = False;
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_config() {
|
||||||
|
// first we load the base config
|
||||||
|
$conf_file = @file_get_contents( LDAP_LOGIN_PATH.'data.dat' );
|
||||||
|
if ($conf_file!==false)
|
||||||
|
{
|
||||||
|
$this->config = unserialize($conf_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function save_config()
|
||||||
|
{
|
||||||
|
$file = fopen( LDAP_LOGIN_PATH.'/data.dat', 'w' );
|
||||||
|
fwrite($file, serialize($this->config) );
|
||||||
|
fclose( $file );
|
||||||
|
}
|
||||||
|
|
||||||
|
function ldap_admin_menu($menu)
|
||||||
|
{
|
||||||
|
array_push($menu,
|
||||||
|
array(
|
||||||
|
'NAME' => 'Ldap Login',
|
||||||
|
'URL' => get_admin_plugin_menu_link(LDAP_LOGIN_PATH.'/admin.php') )
|
||||||
|
);
|
||||||
|
return $menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ldap_conn(){
|
||||||
|
if ($this->config['ld_use_ssl'] == 1){
|
||||||
|
if (empty($this->config['port'])){
|
||||||
|
$this->config['uri'] = 'ldaps://'.$this->config['host'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->config['uri'] = 'ldaps://'.$this->config['host'].':'.$this->config['port'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// now, it's without ssl
|
||||||
|
else {
|
||||||
|
if (empty($this->config['port'])){
|
||||||
|
$this->config['uri'] = 'ldap://'.$this->config['host'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->config['uri'] = 'ldap://'.$this->config['host'].':'.$this->config['port'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->cnx = @ldap_connect($this->config['uri'])){
|
||||||
|
@ldap_set_option($this->cnx, LDAP_OPT_PROTOCOL_VERSION, 3); // LDAPv3 if possible
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// connect with rootdn in case not anonymous.
|
||||||
|
if (!empty($obj->config['ld_binddn']) && !empty($obj->config['ld_bindpw'])){ // if empty ld_binddn, anonymous work
|
||||||
|
|
||||||
|
// authentication with rootdn and rootpw for dn search
|
||||||
|
// carefull ! rootdn should be in full ldap style ! Nothing is supposed (to be one of the users the plugin auth…).
|
||||||
|
if (@ldap_bind($obj->config['ld_binddn'],$obj->config['ld_bindpw'])){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return ldap error
|
||||||
|
public function getErrorString(){
|
||||||
|
return ldap_err2str(ldap_errno($this->cnx));
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the name ldap understand
|
||||||
|
public function ldap_name($name){
|
||||||
|
return $this->config['ld_attr'].'='.$name.','.$this->config['basedn'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// authentication
|
||||||
|
public function ldap_bind_as($user,$user_passwd){
|
||||||
|
if (@ldap_bind($this->cnx,$this->ldap_name($user),$user_passwd)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ldap_mail($name){
|
||||||
|
|
||||||
|
//echo $this->cnx;
|
||||||
|
//echo $this->ldap_name($name);
|
||||||
|
$sr=@ldap_read($this->cnx, $this->ldap_name($name), "(objectclass=*)", array('mail'));
|
||||||
|
$entry = @ldap_get_entries($this->cnx, $sr);
|
||||||
|
|
||||||
|
if (!empty($entry[0]['mail'])) {
|
||||||
|
return $entry[0]['mail'][0];
|
||||||
|
}
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return userdn (and username) for authentication
|
||||||
|
/* public function ldap_search_dn($to_search){
|
||||||
|
$filter = str_replace('%s',$to_search,$this->config['ld_filter']);
|
||||||
|
//$this->write_log('$filter '.$filter);
|
||||||
|
|
||||||
|
if ($search = @ldap_search($this->cnx,$this->config['basedn'],$filter,array('dn',$this->config['ld_attr']),0,1)){
|
||||||
|
$entry = @ldap_get_entries($this->cnx, $search);
|
||||||
|
if (!empty($entry[0][strtolower($this->config['ld_attr'])][0])) {
|
||||||
|
return $entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
public function getAttr() {
|
||||||
|
$search = @ldap_read($this->cnx, "cn=subschema", "(objectClass=*)", array('*', 'subschemasubentry'));
|
||||||
|
$entries = @ldap_get_entries($this->cnx, $search);
|
||||||
|
echo count($entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRootDse() {
|
||||||
|
|
||||||
|
$search = @ldap_read($this->cnx, NULL, 'objectClass=*', array("*", "+"));
|
||||||
|
$entries = @ldap_get_entries($this->cnx, $search);
|
||||||
|
return $entries[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function ldap_check_basedn(){
|
||||||
|
if ($read = @ldap_read($this->cnx,$this->config['basedn'],'(objectClass=*)',array('dn'))){
|
||||||
|
$entry = @ldap_get_entries($this->cnx, $read);
|
||||||
|
if (!empty($entry[0]['dn'])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
1
plugins/Ldap_Login/data.dat
Normal file
1
plugins/Ldap_Login/data.dat
Normal file
|
@ -0,0 +1 @@
|
||||||
|
a:10:{s:4:"host";s:0:"";s:6:"basedn";s:27:"ou=users,dc=yunohost,dc=org";s:4:"port";s:0:"";s:7:"ld_attr";s:3:"uid";s:9:"ld_binddn";s:0:"";s:9:"ld_bindpw";s:0:"";s:10:"ld_use_ssl";b:0;s:14:"allow_newusers";b:1;s:28:"advertise_admin_new_ldapuser";b:0;s:26:"send_password_by_mail_ldap";b:0;}
|
30
plugins/Ldap_Login/index.php
Normal file
30
plugins/Ldap_Login/index.php
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Recursive call
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
56
plugins/Ldap_Login/language/da_DK/plugin.lang.php
Normal file
56
plugins/Ldap_Login/language/da_DK/plugin.lang.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: Ldap_Login
|
||||||
|
Version: 1.0.1
|
||||||
|
Description: Permet de se logger via une authentification ldap
|
||||||
|
Plugin URI: http://www.22decembre.eu
|
||||||
|
Author: 22decembre
|
||||||
|
Author URI:http://www.22decembre.eu
|
||||||
|
___________________________________
|
||||||
|
|
||||||
|
Language Name: Dansk [DK]
|
||||||
|
*/
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Alle LDAP-brugere kan om nødvendigt benytte deres LDAP-adgangskode over alt i Piwigo.';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Nye bruger ved vellykket LDAP-autentifikation';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Ldap_Login Plugin';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Opsætning af Ldap_Login';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Advarsel: LDAP-udvidelse mangler.';
|
||||||
|
|
||||||
|
// ldap server connection
|
||||||
|
|
||||||
|
$lang['Ldap server host connection'] = 'LDAP-server';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Hvis tomt benyttes standard-protokolporte af programmellet.';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Hvis tomt benyttes localhost og standard-protokolporte i opsætningen.';
|
||||||
|
$lang['Ldap server host'] = 'LDAP-værtsadresse';
|
||||||
|
$lang['Secure connexion'] = 'Sikker forbindelse (ldaps)';
|
||||||
|
$lang['Ldap port'] = 'LDAP-port';
|
||||||
|
|
||||||
|
// ldap attributes
|
||||||
|
|
||||||
|
$lang['Ldap attributes'] = 'LDAP-attributer';
|
||||||
|
$lang['Base DN'] = 'Base DN hvor LDAP-brugerne findes (f.eks.: ou=users,dc=example,dc=com):';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Attribut der svarer til brugernavnet';
|
||||||
|
|
||||||
|
// ldap connection credentials
|
||||||
|
$lang['Ldap connection credentials'] = 'LDAP-loginoplysninger';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Hvis LDAP accepterer anonyme logins, skal felterne være tomme.';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Bind DN på LDAP-form (f.eks.: cn=admin,dc=example,dc=com).';
|
||||||
|
$lang['Bind password'] = 'Bind-adgangskode';
|
||||||
|
|
||||||
|
// test and save
|
||||||
|
|
||||||
|
$lang['Username'] = 'Dit LDAP-brugernavn';
|
||||||
|
$lang['Your password'] = 'Din LDAP-adgangskode.';
|
||||||
|
$lang['Ldap_Login Test'] = 'Test af Ldap_Login';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Du skal gemme indstillingerne med knappen Gem herover, før du kan afprøve dem.';
|
||||||
|
$lang['Save'] = 'Gem';
|
||||||
|
$lang['Test Settings'] = 'Afprøv indstillingerne';
|
||||||
|
|
||||||
|
// new piwigo users
|
||||||
|
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Skal nye brugere modtage en mail på samme måde som tilfældige brugere?';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Må Piwigo oprette nye brugere, når de med succes autentificeres i LDAP?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Skal administratorerne have besked pr. mail i tilfælde af at nye brugere oprettes ved login via LDAP?';
|
||||||
|
|
||||||
|
$lang['Ldap filter :'] = 'LDAP-filter';
|
||||||
|
?>
|
7
plugins/Ldap_Login/language/de_DE/index.php
Normal file
7
plugins/Ldap_Login/language/de_DE/index.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
51
plugins/Ldap_Login/language/de_DE/plugin.lang.php
Normal file
51
plugins/Ldap_Login/language/de_DE/plugin.lang.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Attribute entsprechend des Benutzernamens';
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Alle LDAP-Benutzer können ihr LDAP-Passwort falls es notwendig ist auch für Piwigo benutzen.';
|
||||||
|
$lang['Base DN'] = 'Base DN wo LDAP-Benutzer gefunden werden sollen (zB.: ou=users,dc=example,dc=com):';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Bind DN im LDAP-Style (z.B.: cn=admin,dc=example,dc=com).';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Möchtest du das die Admins per Mail benachrichtigt werden, wenn neue Nutzer über das LDAP Login angelegt werden.';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Möchtest du die Mails so an die neuen Nutzern senden, wie sie normale Piwigo Benutzer bekommen?';
|
||||||
|
$lang['Ldap connection credentials'] = 'LDAP-Verbindungsreferenzen';
|
||||||
|
$lang['Username'] = 'Bitte LDAP Benutzername';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Neuer Benutzer, wenn LDAP Auth erfolgreich war';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Warnung: LDAP Erweiterung fehlt.';
|
||||||
|
$lang['Ldap attributes'] = 'LDAP Attribute';
|
||||||
|
$lang['Secure connexion'] = 'Sichere Verbindung (ldaps)';
|
||||||
|
$lang['Ldap filter :'] = 'LDAP-Filter:';
|
||||||
|
$lang['Ldap port'] = 'LDAP-Port';
|
||||||
|
$lang['Ldap server host'] = 'LDAP-Server';
|
||||||
|
$lang['Bind password'] = 'Bind passwort';
|
||||||
|
$lang['Ldap server host connection'] = 'LDAP Serververbindung';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'LDAP-Login Plugin';
|
||||||
|
$lang['Ldap_Login Test'] = 'LDAP-Login Test';
|
||||||
|
$lang['Ldap_Login configuration'] = 'LDAP-Login Konfiguration';
|
||||||
|
$lang['Save'] = 'Speichern';
|
||||||
|
$lang['Test Settings'] = 'Test-Einstellungen';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Du musst die Einstellungen erst speichern, bevor du sie testen kannst.';
|
||||||
|
$lang['Your password'] = 'Dein LDAP Passwort.';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Erlauben Sie, dass neue Piwigo-Benutzer angelegt werden, wenn sie erfolgreich bei LDAP authentifiziert wurden?';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Wenn leer werden die Standard-Protokoll-Ports von der Software benutzt.';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Wenn leer werden localhost und die Standard-Protokoll-Ports in der Konfiguration benutzt.';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Das Feld leer lassen, wenn LDAP auch anonyme Verbindungen erlauben soll.';
|
||||||
|
?>
|
7
plugins/Ldap_Login/language/el_GR/index.php
Normal file
7
plugins/Ldap_Login/language/el_GR/index.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
51
plugins/Ldap_Login/language/el_GR/plugin.lang.php
Normal file
51
plugins/Ldap_Login/language/el_GR/plugin.lang.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$lang['Base DN'] = 'Base DN, που θα πρέπει να βρίσκονται οι χρήστες ldap (ex : ou=users,dc=example,dc=com) :';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Χαρακτηριστικό που αντιστοιχεί στο όνομα χρήστη';
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Όλοι οι χρήστες LDAP μπορούν να χρησιμοποιήσουν τον κωδικό ldap τους παντού στο piwigo αν χρειαστεί.';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Πρέπει να αποθηκεύσετε τις ρυθμίσεις χρησιμοποιώντας το κουμπί Αποθήκευση παραπάνω, πριν τις δοκιμάσετε.';
|
||||||
|
$lang['Your password'] = 'Ο κωδικός σας για το LDAP';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Προειδοποίηση:Απουσία Πρόσθετου του LDAP';
|
||||||
|
$lang['Username'] = 'Το όνομά σας χρήστη LDAP';
|
||||||
|
$lang['Test Settings'] = 'Δοκιμή ρυθμίσεων';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Εάν μείνει κενό, το λογισμικό θα χρησιμοποιεί τις συνήθεις θύρες πρωτοκόλλου.';
|
||||||
|
$lang['Ldap server host connection'] = 'Σύνδεση με εξυπηρετητή LDAP';
|
||||||
|
$lang['Ldap server host'] = 'LDAP server host';
|
||||||
|
$lang['Ldap attributes'] = 'Χαρακτηριστικά του LDAP';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Εάν μείνει κενό, θα χρησιμοποιηθούν στη ρύθμιση ο localhost και οι συνήθεις θύρες πρωτοκόλλου.';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Πρέπει να λαμβάνουν οι νέοι χρήστες μήνυματα όπως και οι κλασικοί χρήστες Piwigo;';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Θέλετε να ενημερώνονται οι διαχειριστές με ηλεκτρονικό μήνυμα σε περίπτωση δημιουργίας νέων χρηστών με σύνδεση ldap;';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Συνδεθείτε με DN σε μορφή LDAP (π.χ.:admin, dc=example,dc=com). ';
|
||||||
|
$lang['Bind password'] = 'Κωδικός σύνδεσης';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Μπορούν να δημιουργούνται νέοι χρήστες Piwigo όταν πιστοποιούνται επιτυχώς μέσω LDAP;';
|
||||||
|
$lang['Ldap connection credentials'] = 'Διαπιστευτήρια σύνδεσης LDAP';
|
||||||
|
$lang['Ldap filter :'] = 'Φίλτρο LDAP';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Ldap_Πρόσθετο σύνδεσης';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Ldap_Ρύθμιση σύνδεσης';
|
||||||
|
$lang['Secure connexion'] = 'Ασφαλής σύνδεση(ldaps)';
|
||||||
|
$lang['Save'] = 'Αποθήκευση';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Νέοι χρήστες όταν η πιστοποίηση LDAP είναι επιτυχής';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Αφήστε τα πεδία κενά εάν το LDAP αποδέχεται ανώνυμες συνδέσεις';
|
||||||
|
$lang['Ldap_Login Test'] = 'Ldap_Δοκιμή σύνδεσης';
|
||||||
|
$lang['Ldap port'] = 'θύρα LDAP';
|
||||||
|
?>
|
1
plugins/Ldap_Login/language/en_UK/description.txt
Normal file
1
plugins/Ldap_Login/language/en_UK/description.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
allow to login piwigo users with their ldap credentials (login, mail, or another attribute specified by piwigo admins + ldap password).
|
59
plugins/Ldap_Login/language/en_UK/plugin.lang.php
Normal file
59
plugins/Ldap_Login/language/en_UK/plugin.lang.php
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: Ldap_Login
|
||||||
|
Version: 1.0.1
|
||||||
|
Description: Permet de se logger via une authentification ldap
|
||||||
|
Plugin URI: http://www.22decembre.eu
|
||||||
|
Author: 22decembre
|
||||||
|
Author URI:http://www.22decembre.eu
|
||||||
|
___________________________________
|
||||||
|
|
||||||
|
Language Name: English [UK]
|
||||||
|
*/
|
||||||
|
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'All LDAP users can use their LDAP password everywhere in Piwigo if needed.';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'New users when LDAP auth is successful';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Ldap_Login Plugin';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Ldap_Login configuration';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Warning: LDAP Extension missing.';
|
||||||
|
|
||||||
|
// ldap server connection
|
||||||
|
|
||||||
|
$lang['Ldap server host connection'] = 'LDAP server connection';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'If empty, standard protocol ports will be used by the software.';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'If empty, localhost and standard protocol ports will be used in configuration.';
|
||||||
|
$lang['Ldap server host'] = 'LDAP server host';
|
||||||
|
$lang['Secure connexion'] = 'Secure connection (ldaps)';
|
||||||
|
$lang['Ldap port'] = 'LDAP port';
|
||||||
|
|
||||||
|
// ldap attributes
|
||||||
|
|
||||||
|
$lang['Ldap attributes'] = 'LDAP attributes';
|
||||||
|
$lang['Base DN'] = 'Base DN where LDAP users should be found (e.g.: ou=users,dc=example,dc=com):';
|
||||||
|
$lang['Ldap filter :'] = 'LDAP filter';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Attribute corresponding to the user name';
|
||||||
|
|
||||||
|
// ldap connection credentials
|
||||||
|
|
||||||
|
$lang['Ldap connection credentials'] = 'LDAP connection credentials';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Leave the fields empty if LDAP accepts anonymous connections.';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Bind DN in LDAP style (e.g.: cn=admin,dc=example,dc=com).';
|
||||||
|
$lang['Bind password'] = 'Bind password';
|
||||||
|
|
||||||
|
// test and save
|
||||||
|
|
||||||
|
$lang['Username'] = 'Your LDAP username';
|
||||||
|
$lang['Your password'] = 'Your LDAP password';
|
||||||
|
$lang['Ldap_Login Test'] = 'Ldap_Login Test';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'You need to save settings using the Save button above, before testing them.';
|
||||||
|
$lang['Save'] = 'Save';
|
||||||
|
$lang['Test Settings'] = 'Test settings';
|
||||||
|
|
||||||
|
// new piwigo users
|
||||||
|
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Should admins be notified by mail in case of creation of new users upon LDAP login?';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Should new users receive mail similar to casual Piwigo users?';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Should new Piwigo users be created when users authenticate succesfully via LDAP?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Do you want admins to be advertised by mail in case of new users creation upon ldap login ?';
|
||||||
|
|
||||||
|
?>
|
7
plugins/Ldap_Login/language/es_ES/index.php
Normal file
7
plugins/Ldap_Login/language/es_ES/index.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
52
plugins/Ldap_Login/language/es_ES/plugin.lang.php
Normal file
52
plugins/Ldap_Login/language/es_ES/plugin.lang.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Nuevos usuarios cuando la autentificación LDAP es exitosa';
|
||||||
|
$lang['Save'] = 'Guardar';
|
||||||
|
$lang['Secure connexion'] = 'Conexión segura (ldap)';
|
||||||
|
$lang['Test Settings'] = 'Test de la configuración';
|
||||||
|
$lang['Username'] = 'Su nombre de usuario Ldap';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Atención: falta la extensión LDAP';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Tiene que guardar la configuración usando en botón de arriba antes de iniciar un test';
|
||||||
|
$lang['Your password'] = 'Su contraseña LDAP';
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Todos los usuarios de LDAP pueden utilizar su contraseña en todas las partes de piwigo si es necesario.';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Atributo que corresponde al nombre de usuario';
|
||||||
|
$lang['Base DN'] = 'La base DN es donde deben encontrarse los usuarios de LDAP (por ejemplo: ou = usuarios, dc = ejemplo, dc = com):';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Enlace DN en el estilo de LDAP (por ejemplo: cn = admin, dc = ejemplo, dc = com).';
|
||||||
|
$lang['Bind password'] = 'Contraseña Bind';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = '¿Permite que los nuevos usuarios de Piwigo que se crean cuando los usuarios se autentican con éxito en el ldap?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Desea ser advertido por mail en caso de creacion de una nueva cuenta ldap ?';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Desea mandar mail a los nuevos usuarios, como la mayoria de los usuarios de Piwigo ?';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'En caso de estar libre. el localhost y los protocolos de los puertos se utilizaran para la configuracion. ';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'En caso de estar libre, los protocolos de los puertos se utilizaran para los programas.';
|
||||||
|
$lang['Ldap attributes'] = 'Atributos LDAP';
|
||||||
|
$lang['Ldap connection credentials'] = 'Credenciales de conexion ldap';
|
||||||
|
$lang['Ldap filter :'] = 'Filtros ldap';
|
||||||
|
$lang['Ldap port'] = 'Puerto ldap';
|
||||||
|
$lang['Ldap server host'] = 'Servidor host de ldap';
|
||||||
|
$lang['Ldap server host connection'] = 'Conexion del servidor ldap';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Plugin de autentificacion de ldap';
|
||||||
|
$lang['Ldap_Login Test'] = 'Test de autentificacion de ldap';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Configuracion de autentificacion de ldap
|
||||||
|
';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Deje los campos en blanco si el ldap acepte a conexiones anónimas.';
|
||||||
|
?>
|
59
plugins/Ldap_Login/language/fr_CA/plugin.lang.php
Normal file
59
plugins/Ldap_Login/language/fr_CA/plugin.lang.php
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: Ldap_Login
|
||||||
|
Version: 1.0.1
|
||||||
|
Description: Permet de se logger via une authentification ldap
|
||||||
|
Plugin URI: http://www.22decembre.eu
|
||||||
|
Author: 22decembre
|
||||||
|
Author URI:http://www.22decembre.eu
|
||||||
|
___________________________________
|
||||||
|
|
||||||
|
Language Name: Français [FR]
|
||||||
|
*/
|
||||||
|
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Les utilisateurs ldap peuvent utiler leur mot de passe ldap partout où necessaire dans cette galerie piwigo.';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Nouveaux utilisateurs piwigo en cas de connection LDAP';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Ldap_Login Plugin';
|
||||||
|
$lang['Ldap_Login Plugin configuration'] = 'Configuration du plugin Ldap_Login';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Attention: Extension LDAP manquante.';
|
||||||
|
|
||||||
|
// ldap server connection
|
||||||
|
|
||||||
|
$lang['Ldap server host connection'] = 'Connection au serveur Ldap';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Les ports standarts seront utilisés si ce champs est laissé vide.';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Localhost et les ports standard du protocol seront utilisés si ces champs sont laissés vides.';
|
||||||
|
$lang['Ldap server host'] = 'Hote du serveur Ldap';
|
||||||
|
$lang['Secure connexion'] = 'Connexion sécurisée (ldaps)';
|
||||||
|
$lang['Ldap port'] = 'Port a utiliser';
|
||||||
|
|
||||||
|
// ldap attributes
|
||||||
|
|
||||||
|
$lang['Ldap attributes'] = 'Attributs ldap';
|
||||||
|
$lang['Base DN'] = 'Arbre ldap à explorer où rechercher les utilisateurs (ex : ou=users,dc=exemple,dc=com)';
|
||||||
|
$lang['Ldap filter'] = 'Filtre de recherche';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Attribut correspondant au nom d\'utilisateur';
|
||||||
|
|
||||||
|
// ldap connection credentials
|
||||||
|
|
||||||
|
$lang['Ldap connection credentials'] = 'Identifiants de connection LDAP';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Laissez les champs vides si le ldap accepte les connexions anonymes.';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Identifiant de connection, avec syntaxe LDAP complète (par ex : cn=admin,dc=example,dc=com).';
|
||||||
|
$lang['Bind password'] = 'Mot de passe de connection';
|
||||||
|
|
||||||
|
// test and save
|
||||||
|
|
||||||
|
$lang['Username'] = 'Votre nom d\'utilisateur LDAP';
|
||||||
|
$lang['Your password'] = 'Votre mot de passe LDAP.';
|
||||||
|
$lang['Ldap_Login Test'] = 'Test du plugin Ldap_Login';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Vous devez sauvegarder les paramètres avec le bouton Enregistrer juste au dessus avant de faire ce test.';
|
||||||
|
$lang['Test Settings'] = 'Tester les paramètres';
|
||||||
|
$lang['Save'] = 'Enregistrer';
|
||||||
|
|
||||||
|
// new piwigo users
|
||||||
|
|
||||||
|
$lang['If the LDAP doesn\'t furnish the mail address, users can set it up in the profile page.'] = 'Si le ldap ne fournit pas l\'adresse courriel, les utilisateurs peuvent l\'enregistrer dans la page de profil.';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Voulez-vous envoyer le courriel habituel aux nouveaux utilisateurs de Piwigo crées par le plugin ?';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Voulez-vous créer des utilisateurs piwigo lorsque quelqu\'un se connecte avec des identifiants ldap valides ?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Voulez-vous que les administrateurs du site soient prévenus lors de ces créations d\'utilisateurs ?';
|
||||||
|
|
||||||
|
?>
|
59
plugins/Ldap_Login/language/fr_FR/plugin.lang.php
Normal file
59
plugins/Ldap_Login/language/fr_FR/plugin.lang.php
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: Ldap_Login
|
||||||
|
Version: 1.0.1
|
||||||
|
Description: Permet de se logger via une authentification ldap
|
||||||
|
Plugin URI: http://www.22decembre.eu
|
||||||
|
Author: 22decembre
|
||||||
|
Author URI:http://www.22decembre.eu
|
||||||
|
___________________________________
|
||||||
|
|
||||||
|
Language Name: Français [FR]
|
||||||
|
*/
|
||||||
|
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Les utilisateurs ldap peuvent utiler leur mot de passe ldap partout où necessaire dans cette galerie piwigo.';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Nouveaux utilisateurs piwigo en cas de connection LDAP';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Ldap_Login Plugin';
|
||||||
|
$lang['Ldap_Login Plugin configuration'] = 'Configuration du plugin Ldap_Login';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Attention: Extension LDAP manquante.';
|
||||||
|
|
||||||
|
// ldap server connection
|
||||||
|
|
||||||
|
$lang['Ldap server host connection'] = 'Connection au serveur Ldap';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Les ports standarts seront utilisés si ce champs est laissé vide.';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Localhost et les ports standard du protocol seront utilisés si ces champs sont laissés vides.';
|
||||||
|
$lang['Ldap server host'] = 'Hote du serveur Ldap';
|
||||||
|
$lang['Secure connexion'] = 'Connexion sécurisée (ldaps)';
|
||||||
|
$lang['Ldap port'] = 'Port a utiliser';
|
||||||
|
|
||||||
|
// ldap attributes
|
||||||
|
|
||||||
|
$lang['Ldap attributes'] = 'Attributs ldap';
|
||||||
|
$lang['Base DN'] = 'Arbre ldap à explorer où rechercher les utilisateurs (ex : ou=users,dc=exemple,dc=com)';
|
||||||
|
$lang['Ldap filter'] = 'Filtre de recherche';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Attribut correspondant au nom d\'utilisateur';
|
||||||
|
|
||||||
|
// ldap connection credentials
|
||||||
|
|
||||||
|
$lang['Ldap connection credentials'] = 'Identifiants de connection LDAP';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Laissez les champs vides si le ldap accepte les connexions anonymes.';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Identifiant de connection, avec syntaxe LDAP complète (par ex : cn=admin,dc=example,dc=com).';
|
||||||
|
$lang['Bind password'] = 'Mot de passe de connection';
|
||||||
|
|
||||||
|
// test and save
|
||||||
|
|
||||||
|
$lang['Username'] = 'Votre nom d\'utilisateur LDAP';
|
||||||
|
$lang['Your password'] = 'Votre mot de passe LDAP.';
|
||||||
|
$lang['Ldap_Login Test'] = 'Test du plugin Ldap_Login';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Vous devez sauvegarder les paramètres avec le bouton Enregistrer juste au dessus avant de faire ce test.';
|
||||||
|
$lang['Test Settings'] = 'Tester les paramètres';
|
||||||
|
$lang['Save'] = 'Enregistrer';
|
||||||
|
|
||||||
|
// new piwigo users
|
||||||
|
|
||||||
|
$lang['If the LDAP doesn\'t furnish the mail address, users can set it up in the profile page.'] = 'Si le ldap ne fournit pas l\'adresse courriel, les utilisateurs peuvent l\'enregistrer dans la page de profil.';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Voulez-vous envoyer le courriel habituel aux nouveaux utilisateurs de Piwigo crées par le plugin ?';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Voulez-vous créer des utilisateurs piwigo lorsque quelqu\'un se connecte avec des identifiants ldap valides ?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Voulez-vous que les administrateurs du site soient prévenus lors de ces créations d\'utilisateurs ?';
|
||||||
|
|
||||||
|
?>
|
30
plugins/Ldap_Login/language/index.php
Normal file
30
plugins/Ldap_Login/language/index.php
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Recursive call
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
7
plugins/Ldap_Login/language/it_IT/index.php
Normal file
7
plugins/Ldap_Login/language/it_IT/index.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
51
plugins/Ldap_Login/language/it_IT/plugin.lang.php
Normal file
51
plugins/Ldap_Login/language/it_IT/plugin.lang.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Attenzione: LDAP Extension mancante.';
|
||||||
|
$lang['Ldap connection credentials'] = 'Credenziali di connessione ldap';
|
||||||
|
$lang['Username'] = 'Vostro nome utente ldap';
|
||||||
|
$lang['Ldap server host'] = 'Server host ldap';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Attributo corrispondente al nome utente';
|
||||||
|
$lang['Test Settings'] = 'Test impostazione';
|
||||||
|
$lang['Ldap filter :'] = 'Filtro ldap :';
|
||||||
|
$lang['Ldap port'] = 'Port ldap';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Configurazione Ldap_Login';
|
||||||
|
$lang['Ldap_Login Test'] = 'Test del plugin Ldap_Login';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Ldap_Login Plugin';
|
||||||
|
$lang['Ldap attributes'] = 'Attributi ldap';
|
||||||
|
$lang['Your password'] = 'La tua password LDAP.';
|
||||||
|
$lang['Secure connexion'] = 'Connessione sicura (ldaps)';
|
||||||
|
$lang['Save'] = 'Salva';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Devono essere creati nuovi utenti Piwigo quando gli utenti si autenticano con successo tramite LDAP?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Vuoi che gli amministratori siano avvisati tramite email in caso di nuova creazione utenti su ldap di accesso?';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Lascia i campi vuoti se LDAP accetta connessioni anonime.';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'E\' necessario salvare le impostazioni utilizzando il pulsante Salva quà sopra, prima della loro prova.';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Se vuoto, porte di protocollo localhost standard saranno utilizzate nella configurazione.';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Associa DN in stile LDAP (esempio: cn=admin,dc=example,dc=com).';
|
||||||
|
$lang['Base DN'] = 'Base DN dove si dovrebbero trovare gli utenti LDAP (per esempio: ou=users,dc=example,dc=com):';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Se vuoto, porte di protocollo standard, saranno utilizzate dal software.';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Nuovi utenti quando l\'autenticazione LDAP riesce';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'I nuovi utenti devono ricevere le email similmente agli utenti occasionali Piwigo?';
|
||||||
|
$lang['Ldap server host connection'] = 'Connessione al server LDAP';
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Tutti gli utenti LDAP possono utilizzare la password LDAP ovunque in Piwigo se necessario.';
|
||||||
|
$lang['Bind password'] = 'Associa password';
|
||||||
|
?>
|
7
plugins/Ldap_Login/language/lv_LV/index.php
Normal file
7
plugins/Ldap_Login/language/lv_LV/index.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
52
plugins/Ldap_Login/language/lv_LV/plugin.lang.php
Normal file
52
plugins/Ldap_Login/language/lv_LV/plugin.lang.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Jums ir nepieciešams saglabāt iestatījumus ar Save pogu pirms veikt to pārbaudi.';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Jauni lietotāji, kad LDAP autentifikācija ir veiksmīga';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Ja LDAP atļauj anonīmus savienojumus, atstājiet laukus tukšus.';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Ja tukšs, programmatūra izmantos standarta protokola portus.';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Ja tukšs, konfigurēšanai tiks izmantoti localhost un standarta protokola porti.';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Vai jūs vēlaties nosūtīt pastu jaunajiem lietotājiem, piemēram, kādu to saņem parastie Piwigo lietotāji?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Vai jūs vēlaties, lai admins tiek brīdināts pa pastu par jaunu lietotāju izveidošanu pēc pieteikšanās ar LDAP loginu?';
|
||||||
|
$lang['Base DN'] = '
|
||||||
|
Bāzes DN, kur būtu atrodami LDAP lietotājiem (ex : ou=users,dc=piemērs,dc=com) :';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Vai jūs ļautu izveidot jaunus Piwigo lietotājus, ja lietotāji veiksmīgi autentificētos LDAP?';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Piesaistīt DN ldap stilam (for ex : cn=admin,dc=piemērs,dc=com). ';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Lietotāja vārdam atbilstošs Atribūts';
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Ja nepieciešams, visi LDAP lietotāji var izmantot savu LDAP paroli jebkur Piwigo.';
|
||||||
|
$lang['Bind password'] = 'Piesaistīt paroli';
|
||||||
|
$lang['Your password'] = 'Jūsu LDAP parole';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Brīdinājums: Trūkst LDAP Paplašinājums.';
|
||||||
|
$lang['Username'] = 'Votre ldap lietotājvārds';
|
||||||
|
$lang['Test Settings'] = 'Pārbaudīt iestadījumus';
|
||||||
|
$lang['Secure connexion'] = 'Drošs savienojums (ldaps)';
|
||||||
|
$lang['Save'] = 'Saglabāt';
|
||||||
|
$lang['Ldap connection credentials'] = 'LDAP savienojuma pilnvaras';
|
||||||
|
$lang['Ldap server host'] = 'Ldap servera hosts';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Ldap_Login konfigurācija';
|
||||||
|
$lang['Ldap_Login Test'] = 'Ldap_Login Tests';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Ldap_Login Spraudnis';
|
||||||
|
$lang['Ldap server host connection'] = 'Ldap servera savienojums';
|
||||||
|
$lang['Ldap port'] = 'Ldap ports';
|
||||||
|
$lang['Ldap filter :'] = 'Ldap filtrs :';
|
||||||
|
$lang['Ldap attributes'] = 'Ldap atribūti';
|
||||||
|
?>
|
7
plugins/Ldap_Login/language/pt_BR/index.php
Normal file
7
plugins/Ldap_Login/language/pt_BR/index.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
52
plugins/Ldap_Login/language/pt_BR/plugin.lang.php
Normal file
52
plugins/Ldap_Login/language/pt_BR/plugin.lang.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Novos usuários quando autenticação LDAP é bem sucedida';
|
||||||
|
$lang['Save'] = 'Salvar';
|
||||||
|
$lang['Secure connexion'] = 'Conexão segura (ldaps)';
|
||||||
|
$lang['Test Settings'] = 'Configurações de teste';
|
||||||
|
$lang['Username'] = 'Seu nome de usuário LDAP';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Aviso: Faltando extensão LDAP';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Você precisa salvar as configurações usando o botão Salvar acima, antes de testá-las.';
|
||||||
|
$lang['Your password'] = 'Sua senha LDAP';
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Todos os usuários do LDAP podem usar sua senha LDAP em todo Piwigo se necessário.';
|
||||||
|
$lang['Attribute corresponding to the user name'] = '
|
||||||
|
Atributo correspondente ao nome de usuário';
|
||||||
|
$lang['Base DN'] = 'Base DN, onde os usuários de LDAP devem ser encontrados (por exemplo: ou = usuários, dc = exemplo, dc = com):';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Bind DN no estilo LDAP (por exemplo: cn = admin, dc = exemplo, dc = com).';
|
||||||
|
$lang['Bind password'] = 'Senha Bind';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Novos usuários Piwigo podem ser criados quando os usuários se autenticarem com sucesso via LDAP?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Você quer que os administradores sejam advertidos por email, em caso de criação de novos usuários usando-se o login do ldap?';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Deverão novos usuários receber mensagens semelhantes aos usuários Piwigo casuais?';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Se vazio, portas de protocolo localhost e padrão serão utilizados na configuração.';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Se vazio, portas de protocolo padrão serão usados pelo software.';
|
||||||
|
$lang['Ldap attributes'] = 'Atributos LDAP';
|
||||||
|
$lang['Ldap connection credentials'] = 'Credenciais de conexão LDAP';
|
||||||
|
$lang['Ldap filter :'] = 'Filtro LDAP';
|
||||||
|
$lang['Ldap port'] = 'Porta LDAP';
|
||||||
|
$lang['Ldap server host'] = 'Servidor host LDAP';
|
||||||
|
$lang['Ldap server host connection'] = 'Conexão com servidor LDAP';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Plugin Ldap_Login ';
|
||||||
|
$lang['Ldap_Login Test'] = 'Teste Ldap_Login';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Configuração Ldap_Login';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Deixe os campos em branco se o LDAP aceitar conexões anônimas.';
|
||||||
|
?>
|
7
plugins/Ldap_Login/language/pt_PT/index.php
Normal file
7
plugins/Ldap_Login/language/pt_PT/index.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
50
plugins/Ldap_Login/language/pt_PT/plugin.lang.php
Normal file
50
plugins/Ldap_Login/language/pt_PT/plugin.lang.php
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$lang['Save'] = 'Salvar';
|
||||||
|
$lang['Secure connexion'] = 'Ligação segura (Idaps)';
|
||||||
|
$lang['Test Settings'] = 'Definições Teste';
|
||||||
|
$lang['Username'] = 'Nome de utilizador LDAP';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Atenção: Esquecida a Extensão LDAP';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Antes de efetuar o teste, é preciso salvar as definições clicando no botão SALVAR acima.';
|
||||||
|
$lang['Your password'] = 'Senha LDAP';
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Todos os utilizadores LDAP podem usar a sua senha LDAP em qualquer parte do Piwigo se necessário';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Atributo correspondente ao nome de utilizador';
|
||||||
|
$lang['Base DN'] = 'Base DN onde podem ser encontrados os utilizadores LDAP (por exemplo: ou=utilizadores,dc=exemplo,dc=com):';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Vincular DN no estilo LDAP (por exemplo:cu=utilizadores,dc=exemplo, dc=com):';
|
||||||
|
$lang['Bind password'] = 'Vincular senha';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'poderão ser criados novos utilizadores Piwigo quando os utilizadores se autenticarem com sucesso via LDAP?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Deseja que os administradores sejam notificados por email, em caso de utilizadores criados após entrada LDAP?';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Os novos utilizadores deverão receber mail similar aos urtilizadores casuais piwigo?';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Se vazio, localhost e portas standard serão usadas na configuração';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Se vazio, localhost e portas standard serão usadas pelo software';
|
||||||
|
$lang['Ldap attributes'] = 'Atributos LDAP';
|
||||||
|
$lang['Ldap connection credentials'] = 'Credenciais de ligação LDAP';
|
||||||
|
$lang['Ldap filter :'] = 'Filtro LDAP';
|
||||||
|
$lang['Ldap port'] = 'Porta LDAP';
|
||||||
|
$lang['Ldap server host'] = 'Servidor de alojamento LDAP';
|
||||||
|
$lang['Ldap server host connection'] = 'Servidor ligação LDAP';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Extensão de Entrada_Ldap ';
|
||||||
|
$lang['Ldap_Login Test'] = 'Teste de Entrada_Ldap';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Configuração de Entrada_Ldap';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Deixar os campos vazios se LDAP aceitar ligações anónimas';
|
||||||
|
?>
|
7
plugins/Ldap_Login/language/ru_RU/index.php
Normal file
7
plugins/Ldap_Login/language/ru_RU/index.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
51
plugins/Ldap_Login/language/ru_RU/plugin.lang.php
Normal file
51
plugins/Ldap_Login/language/ru_RU/plugin.lang.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$lang['Base DN'] = 'Базовый DN для нахождения пользователей (например, ou=пользователи, dc=com):';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Привязка DN в стиле LDAP (например, cn=админ, dc=com).';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Новый пользователь, успешно аутентифицированный в LDAP ';
|
||||||
|
$lang['Save'] = 'Сохранить';
|
||||||
|
$lang['Secure connexion'] = 'Безопасное соединение ( LDAPS )';
|
||||||
|
$lang['Test Settings'] = 'Проверка настроек';
|
||||||
|
$lang['Username'] = 'Введите имя пользователя LDAP ';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Внимание: отсутствует расширение LDAP!';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Вы должны сохранить настройки, нажав на кнпку "Сохранить", и только затем переходить к проверке этих настроек.';
|
||||||
|
$lang['Your password'] = 'Ваш LDAP-пароль';
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Все пользователи LDAP могут использовать свой LDAP-пароль всюду на Piwigo, там где это необходимо.';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Атрибут, соответствующий имени пользователя';
|
||||||
|
$lang['Bind password'] = 'Привязка пароля';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Вы разрешаете создание нового пользователи Piwigo, если посетитель успешно верифицировался на LDAP?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Хотите направлять админам сообщения, что произошло создание нового пользователя после его входа в LDAP?';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Вы хотите отправить почту новым пользователям, как её получают обычные пользователи Piwigo?';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Если поле пустое, то локальный и стандартные порты протокола будут использоваться в конфигурации.';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Если поле пустое, то стандартный протокол портов будет использоваться программным обеспечением.';
|
||||||
|
$lang['Ldap attributes'] = 'Свойства LDAP';
|
||||||
|
$lang['Ldap connection credentials'] = 'Учетные данные подключения LDAP';
|
||||||
|
$lang['Ldap filter :'] = 'LDAP фильтр:';
|
||||||
|
$lang['Ldap port'] = 'LDAP порт';
|
||||||
|
$lang['Ldap server host'] = 'LDAP хост сервера';
|
||||||
|
$lang['Ldap server host connection'] = 'Подключение к серверу LDAP';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Плагин LDAP_Login';
|
||||||
|
$lang['Ldap_Login Test'] = 'Тест LDAP_Login';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Конфигурация LDAP_Login';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Оставьте эти поля пустыми, если разрешается LDAP принимать анонимные подключения.';
|
||||||
|
?>
|
7
plugins/Ldap_Login/language/sk_SK/index.php
Normal file
7
plugins/Ldap_Login/language/sk_SK/index.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
51
plugins/Ldap_Login/language/sk_SK/plugin.lang.php
Normal file
51
plugins/Ldap_Login/language/sk_SK/plugin.lang.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Môžu byť noví používatelia Piwigo vytvorení pri úspešnom overení cez LDAP?';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Chcete administrátorov upozorniť e-mailom v prípade vytvorenia nových používateľov po ldap prihlásení?';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Môžu noví používatelia prijímať poštu podobnú bežným používateľom Piwigo?';
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Ak je prázdne, budú použité localhost a štandardné porty protokolu z konfigurácii.';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Ak je prázdne, budú použité štandardné porty protokolu softvéru.';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Nechajte pole prázdne, ak LDAP prijíma anonymné pripojenie.';
|
||||||
|
$lang['Ldap connection credentials'] = 'Poverenia pre pripojenie LDAP';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Noví používatelia po úspešnej LDAP autorizácii';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Musíte uložiť nastavenie pomocou tlačidla Uložiť, pred ich testovaním.';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Upozornenie: chýba LDAP rozšírenie';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Ldap_Login nastavenia';
|
||||||
|
$lang['Ldap_Login Test'] = 'Ldap_Login test';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Ldap_Login doplnok';
|
||||||
|
$lang['Ldap filter :'] = 'LDAP filter';
|
||||||
|
$lang['Secure connexion'] = 'Bezpečné pripojenie (ldaps)';
|
||||||
|
$lang['Save'] = 'Uložiť';
|
||||||
|
$lang['Test Settings'] = 'Test nastavení';
|
||||||
|
$lang['Username'] = 'Vaše LDAP používateľské meno';
|
||||||
|
$lang['Your password'] = 'Vaše LDAP heslo';
|
||||||
|
$lang['Base DN'] = 'Základné DN, kde by mal byť nájdený používateľov LDAP (napr.: ou = používatelia, dc = example, dc = com):';
|
||||||
|
$lang['Ldap server host connection'] = 'LDAP serverové pripojenie';
|
||||||
|
$lang['Ldap server host'] = 'LDAP serverový hostiteľ';
|
||||||
|
$lang['Ldap port'] = 'LDAP port';
|
||||||
|
$lang['Ldap attributes'] = 'LDAP atribúty';
|
||||||
|
$lang['Bind password'] = 'Spojiť heslo';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'Spojiť DN LDAP štýlu (napr.: cn = admin, dc = example, dc = com).';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Atribút zodpovedajúci používateľskému menu';
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Všetci LDAP používatelia môžu v prípade potreby použite svoje LDAP heslo všade v Piwigo.';
|
||||||
|
?>
|
7
plugins/Ldap_Login/language/tr_TR/index.php
Normal file
7
plugins/Ldap_Login/language/tr_TR/index.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
51
plugins/Ldap_Login/language/tr_TR/plugin.lang.php
Normal file
51
plugins/Ldap_Login/language/tr_TR/plugin.lang.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$lang['If empty, localhost and standard protocol ports will be used in configuration.'] = 'Eğer boş bırakılırsa, yapılandırmada yerel sunucu (localhost) ve standart protokol portları kullanılacaktır.';
|
||||||
|
$lang['If empty, standard protocol ports will be used by the software.'] = 'Eğer boş bırakılırsa yazılım tarafından standart protokol portları kullanılır';
|
||||||
|
$lang['Your password'] = 'LDAP şifreniz.';
|
||||||
|
$lang['Warning: LDAP Extension missing.'] = 'Uyarı: LDAP uzantısı eksik.';
|
||||||
|
$lang['Username'] = 'LDAP kullanıcı adınız';
|
||||||
|
$lang['Test Settings'] = 'Test ayarları';
|
||||||
|
$lang['Save'] = 'Kaydet';
|
||||||
|
$lang['Secure connexion'] = 'Güvenli bağlantı (LDAPS)';
|
||||||
|
$lang['Ldap connection credentials'] = 'LDAP bağlantı kimliği';
|
||||||
|
$lang['Let the fields blank if the ldap accept anonymous connections.'] = 'Eğer LDAP anonim bağlantıyı kabul ediyorsa alanları boş bırakın';
|
||||||
|
$lang['Ldap_Login Plugin'] = 'Ldap Oturum Açma Eklentisi';
|
||||||
|
$lang['Ldap_Login Test'] = 'Ldap Oturum Açma Test';
|
||||||
|
$lang['Ldap_Login configuration'] = 'Ldap Oturum Açma Yapılandırma';
|
||||||
|
$lang['Ldap server host connection'] = 'LDAP sunucu bağlantısı';
|
||||||
|
$lang['Ldap server host'] = 'LDAP sunucusu barındırıcı';
|
||||||
|
$lang['Ldap filter :'] = 'LDAP filtresi:';
|
||||||
|
$lang['Ldap port'] = 'LDAP portu';
|
||||||
|
$lang['Ldap attributes'] = 'LDAP öz nitelikleri';
|
||||||
|
$lang['Bind password'] = 'Bağlı şifre';
|
||||||
|
$lang['Attribute corresponding to the user name'] = 'Kullanıcı adına karşılık gelen öz nitelik';
|
||||||
|
$lang['All LDAP users can use their ldap password everywhere on piwigo if needed.'] = 'Gerektiğinde tüm LDAP kullanıcıları Piwigo üzerinde LDAP şifrelerini kullanabilir.';
|
||||||
|
$lang['Base DN'] = 'LDAP kullanıcılarının bulunması gerektiğini ana DN (Örn: ou=kullanıcılar,dc=ornek,dc=com):';
|
||||||
|
$lang['You must save the settings with the Save button just up there before testing here.'] = 'Testten önce yukarıdaki Kaydet butonunu kullanarak ayarları kaydetmelisiniz.';
|
||||||
|
$lang['Bind DN, field in full ldap style'] = 'DN\'yi LDAP stiline bağla (Örn: cn=yonetici,dc=ornek,dc=com).';
|
||||||
|
$lang['New users when ldap auth is successfull'] = 'Yeni kullanıcılar - LDAP kimlik doğrulaması başarılı olduğunda';
|
||||||
|
$lang['Do you want admins to be advertised by mail in case of new users creation upon ldap login ?'] = 'Yöneticiler, LDAP oturumu açıldığında yeni kullanıcı yaratma durumundan eposta yoluyla bilgilendirilsin mi?';
|
||||||
|
$lang['Do you allow new piwigo users to be created when users authenticate succesfully on the ldap ?'] = 'Yeni kullanıcılar LDAP ile başarılı kimlik doğrulaması yaptıklarında yaratılsın mı?';
|
||||||
|
$lang['Do you want to send mail to the new users, like casual piwigo users receive ?'] = 'Yeni kullanıcılar diğer Piwigo kullanıcıları gibi eposta alsın mı?';
|
||||||
|
?>
|
114
plugins/Ldap_Login/main.inc.php
Normal file
114
plugins/Ldap_Login/main.inc.php
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Plugin Name: Ldap_Login
|
||||||
|
Version: 1.1
|
||||||
|
Description: Allow piwigo authentication along an ldap
|
||||||
|
Plugin URI: http://piwigo.org/ext/extension_view.php?eid=650
|
||||||
|
Author: 22decembre
|
||||||
|
Author URI: http://www.22decembre.eu
|
||||||
|
*/
|
||||||
|
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Define plugin constants |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
define('LDAP_LOGIN_ID', basename(dirname(__FILE__)));
|
||||||
|
define('LDAP_LOGIN_PATH' , PHPWG_PLUGINS_PATH . LDAP_LOGIN_ID . '/');
|
||||||
|
define('LDAP_LOGIN_ADMIN', get_root_url() . 'admin.php?page=plugin-' . LDAP_LOGIN_ID);
|
||||||
|
define('LDAP_LOGIN_VERSION', '1.1');
|
||||||
|
|
||||||
|
include_once(LDAP_LOGIN_PATH.'/class.ldap.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Event handlers |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
add_event_handler('init', 'ld_init');
|
||||||
|
|
||||||
|
add_event_handler('try_log_user','login', 0, 4);
|
||||||
|
|
||||||
|
add_event_handler('get_admin_plugin_menu_links', array(&$ldap, 'ldap_admin_menu'));
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Admin menu loading |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$ldap = new Ldap();
|
||||||
|
$ldap->load_config();
|
||||||
|
set_plugin_data($plugin['id'], $ldap);
|
||||||
|
unset($ldap);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | functions |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
function random_password( $length = 8 ) {
|
||||||
|
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
|
||||||
|
$password = substr( str_shuffle( $chars ), 0, $length );
|
||||||
|
return $password;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ld_init(){
|
||||||
|
load_language('plugin.lang', LDAP_LOGIN_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function login($success, $username, $password, $remember_me){
|
||||||
|
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$obj = new Ldap();
|
||||||
|
$obj->load_config();
|
||||||
|
$obj->ldap_conn() or die("Unable to connect LDAP server : ".$ldap->getErrorString());
|
||||||
|
|
||||||
|
if (!$obj->ldap_bind_as($username,$password)){ // bind with userdn
|
||||||
|
trigger_action('login_failure', stripslashes($username));
|
||||||
|
return false; // wrong password
|
||||||
|
}
|
||||||
|
|
||||||
|
// search user in piwigo database
|
||||||
|
$query = 'SELECT '.$conf['user_fields']['id'].' AS id FROM '.USERS_TABLE.' WHERE '.$conf['user_fields']['username'].' = \''.pwg_db_real_escape_string($username).'\' ;';
|
||||||
|
|
||||||
|
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
|
||||||
|
// if query is not empty, it means everything is ok and we can continue, auth is done !
|
||||||
|
if (!empty($row['id'])) {
|
||||||
|
log_user($row['id'], $remember_me);
|
||||||
|
trigger_action('login_success', stripslashes($username));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if query is empty but ldap auth is done we can create a piwigo user if it's said so !
|
||||||
|
else {
|
||||||
|
// this is where we check we are allowed to create new users upon that.
|
||||||
|
if ($obj->config['allow_newusers']) {
|
||||||
|
|
||||||
|
// we got the email address
|
||||||
|
if ($obj->ldap_mail($username)) {
|
||||||
|
$mail = $obj->ldap_mail($username);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$mail = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we actually register the new user
|
||||||
|
$new_id = register_user($username,random_password(8),$mail);
|
||||||
|
|
||||||
|
// now we fetch again his id in the piwigo db, and we get them, as we just created him !
|
||||||
|
//$query = 'SELECT '.$conf['user_fields']['id'].' AS id FROM '.USERS_TABLE.' WHERE '.$conf['user_fields']['username'].' = \''.pwg_db_real_escape_string($username).'\' ;';
|
||||||
|
//$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
|
||||||
|
log_user($new_id, False);
|
||||||
|
trigger_action('login_success', stripslashes($username));
|
||||||
|
redirect('profile.php');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// else : this is the normal behavior ! user is not created.
|
||||||
|
else {
|
||||||
|
trigger_action('login_failure', stripslashes($username));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
75
plugins/Ldap_Login/maintain.inc.php
Normal file
75
plugins/Ldap_Login/maintain.inc.php
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
|
||||||
|
|
||||||
|
include_once('class.ldap.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used to expose maintenance methods to the plugins manager
|
||||||
|
* It must extends PluginMaintain and be named "PLUGINID_maintain"
|
||||||
|
* where PLUGINID is the directory name of your plugin
|
||||||
|
*/
|
||||||
|
class Ldap_Login_maintain extends PluginMaintain
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* My pattern uses a single installation method, which handles both installation
|
||||||
|
* and activation, where Piwigo always calls 'activate' just after 'install'
|
||||||
|
* As a result I use a marker in order to not execute the installation method twice
|
||||||
|
*
|
||||||
|
* The installation function is called by main.inc.php and maintain.inc.php
|
||||||
|
* in order to install and/or update the plugin.
|
||||||
|
*
|
||||||
|
* That's why all operations must be conditionned :
|
||||||
|
* - use "if empty" for configuration vars
|
||||||
|
* - use "IF NOT EXISTS" for table creation
|
||||||
|
*/
|
||||||
|
private $installed = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* plugin installation
|
||||||
|
*
|
||||||
|
* perform here all needed step for the plugin installation
|
||||||
|
* such as create default config, add database tables,
|
||||||
|
* add fields to existing tables, create local folders...
|
||||||
|
*/
|
||||||
|
function install($plugin_version, &$errors=array())
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
$config=new Ldap();
|
||||||
|
|
||||||
|
if (file_exists(LDAP_LOGIN_PATH.'data.dat' )) {
|
||||||
|
$config->load_config();
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
$config->load_default_config();
|
||||||
|
}
|
||||||
|
|
||||||
|
$config->save_config();
|
||||||
|
|
||||||
|
$this->installed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* plugin activation
|
||||||
|
*
|
||||||
|
* this function is triggered after installation, by manual activation
|
||||||
|
* or after a plugin update
|
||||||
|
* for this last case you must manage updates tasks of your plugin in this function
|
||||||
|
*/
|
||||||
|
function activate($plugin_version, &$errors=array())
|
||||||
|
{
|
||||||
|
if (!$this->installed)
|
||||||
|
{
|
||||||
|
$this->install($plugin_version, $errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function deactivate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
function uninstall()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
4
plugins/Ldap_Login/pem_metadata.txt
Normal file
4
plugins/Ldap_Login/pem_metadata.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
File automatically created from SVN repository.
|
||||||
|
|
||||||
|
URL: http://piwigo.org/svn/extensions/Ldap_Login
|
||||||
|
Revision: 27288
|
112
scripts/install
Normal file
112
scripts/install
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Retrieve arguments
|
||||||
|
domain=$1
|
||||||
|
path=$2
|
||||||
|
user=$3
|
||||||
|
is_public=$4
|
||||||
|
|
||||||
|
# Check user parameter
|
||||||
|
sudo yunohost user list --json | grep -q "\"username\": \"$user\""
|
||||||
|
if [[ ! $? -eq 0 ]]; then
|
||||||
|
echo "Wrong user"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sudo yunohost app setting piwigo admin_user -v $user
|
||||||
|
|
||||||
|
# Check domain/path availability
|
||||||
|
sudo yunohost app checkurl $domain$path -a piwigo
|
||||||
|
if [[ ! $? -eq 0 ]]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generate random password
|
||||||
|
|
||||||
|
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
|
||||||
|
|
||||||
|
# Use 'piwigo' as database name and user
|
||||||
|
db_user=piwigo
|
||||||
|
|
||||||
|
# Initialize database and store mysql password for upgrade
|
||||||
|
sudo yunohost app initdb $db_user -p $db_pwd
|
||||||
|
sudo yunohost app setting piwigo mysqlpwd -v $db_pwd
|
||||||
|
|
||||||
|
|
||||||
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||||
|
|
||||||
|
final_path=/var/www/piwigo
|
||||||
|
|
||||||
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
||||||
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
||||||
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/piwigo.conf
|
||||||
|
|
||||||
|
# Copy files to the right place
|
||||||
|
|
||||||
|
|
||||||
|
datapath=/home/yunohost.app/piwigo
|
||||||
|
|
||||||
|
sudo mkdir -p $final_path
|
||||||
|
sudo mkdir -p $datapath
|
||||||
|
sudo mkdir -p $datapath/galleries
|
||||||
|
sudo mkdir -p $datapath/upload
|
||||||
|
sudo mkdir -p $final_path/_data
|
||||||
|
sudo cp -a ../sources/* $final_path
|
||||||
|
sudo ln -sd $datapath/_data $final_path/galleries
|
||||||
|
sudo ln -sd $datapath/upload $final_path/upload
|
||||||
|
sudo cp ../conf/index.php $final_path/upload
|
||||||
|
|
||||||
|
|
||||||
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/piwigo.conf
|
||||||
|
#sudo cp ../conf/php-fpm.conf /etc/php5/fpm/pool.d/piwigo.conf
|
||||||
|
#sudo cp ../conf/php-fpm.ini /etc/php5/fpm/conf.d/20-piwigo.ini
|
||||||
|
sudo cp -R ../plugins/Ldap_Login $final_path/plugins/Ldap_Login
|
||||||
|
|
||||||
|
|
||||||
|
# set permission
|
||||||
|
|
||||||
|
sudo chown -R www-data:www-data $final_path
|
||||||
|
sudo chmod -R 755 $final_path
|
||||||
|
sudo chmod 777 $final_path/_data
|
||||||
|
sudo chmod 777 $final_path/upload
|
||||||
|
sudo chmod 755 -R $final_path/galleries
|
||||||
|
|
||||||
|
|
||||||
|
# Reload Nginx and regenerate SSOwat conf
|
||||||
|
sudo service php5-fpm restart
|
||||||
|
sudo service nginx reload
|
||||||
|
sudo yunohost app setting piwigo skipped_uris -v "/"
|
||||||
|
sudo yunohost app ssowatconf
|
||||||
|
|
||||||
|
# Generate random password for admin
|
||||||
|
|
||||||
|
adm_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p')
|
||||||
|
|
||||||
|
#configure piwigo via curl
|
||||||
|
echo "127.0.0.1 $domain #yunopiwigo" | sudo tee -a /etc/hosts
|
||||||
|
sleep 2
|
||||||
|
curl -kL -X POST https://$domain$path/install.php?language=fr_FR --data "install=true&dbuser=$db_user&dbpasswd=$db_pwd&dbname=$db_user&admin_name=$user&admin_pass1=$adm_pwd&admin_pass2=$adm_pwd&admin_mail=webmaster@$domain" > /home/admin/test
|
||||||
|
|
||||||
|
#change variable in local/config/database.inc.php
|
||||||
|
|
||||||
|
sudo sed -i "s@DBTOCHANGE@$db_user@g" ../conf/database.inc.php
|
||||||
|
sudo sed -i "s@USERTOCHANGE@$db_user@g" ../conf/database.inc.php
|
||||||
|
sudo sed -i "s@PASSTOCHANGE@$db_pwd@g" ../conf/database.inc.php
|
||||||
|
|
||||||
|
sudo cp ../conf/database.inc.php $final_path/local/config/database.inc.php
|
||||||
|
|
||||||
|
#activate ldap plugin
|
||||||
|
|
||||||
|
mysql -u $db_user -p$db_pwd $db_user -e "INSERT INTO plugins (id,state,version) VALUES ('Ldap_Login','active','1.1');"
|
||||||
|
|
||||||
|
#protect URIs
|
||||||
|
|
||||||
|
if [ $is_public = "No" ];
|
||||||
|
then
|
||||||
|
sudo yunohost app setting piwigo protected_uris -v "/"
|
||||||
|
sudo yunohost app ssowatconf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove temporary entry in /etc/hosts
|
||||||
|
sudo sed -i '/yunopiwigo/d' /etc/hosts
|
||||||
|
|
||||||
|
|
15
scripts/remove
Normal file
15
scripts/remove
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
db_user=piwigo
|
||||||
|
db_name=piwigo
|
||||||
|
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||||
|
domain=$(sudo yunohost app setting piwigo domain)
|
||||||
|
|
||||||
|
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
|
||||||
|
|
||||||
|
sudo rm -rf /var/www/piwigo
|
||||||
|
sudo rm -f /etc/nginx/conf.d/$domain.d/piwigo.conf
|
||||||
|
sudo rm -rf /home/yunohost.app/piwigo
|
||||||
|
|
||||||
|
sudo service nginx reload
|
||||||
|
|
17
scripts/remove~
Normal file
17
scripts/remove~
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
db_user=piwigo
|
||||||
|
db_name=piwigo
|
||||||
|
root_pwd=$(sudo cat /etc/yunohost/mysql)
|
||||||
|
domain=$(sudo yunohost app setting piwigo domain)
|
||||||
|
|
||||||
|
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
|
||||||
|
|
||||||
|
sudo rm -rf /var/www/piwigo
|
||||||
|
sudo rm -f /etc/nginx/conf.d/$domain.d/piwigo.conf
|
||||||
|
sudo rm -f /etc/php5/fpm/pool.d/piwigo.conf
|
||||||
|
sudo rm -f /etc/php5/fpm/conf.d/20-piwigo.ini
|
||||||
|
sudo rm -rf /home/yunohost.app/piwigo
|
||||||
|
|
||||||
|
sudo service nginx reload
|
||||||
|
|
0
sources/_data/dummy.txt
Normal file
0
sources/_data/dummy.txt
Normal file
63
sources/about.php
Normal file
63
sources/about.php
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
//----------------------------------------------------------- include
|
||||||
|
define('PHPWG_ROOT_PATH','./');
|
||||||
|
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_GUEST);
|
||||||
|
|
||||||
|
//----------------------------------------------------- template initialization
|
||||||
|
//
|
||||||
|
// Start output of page
|
||||||
|
//
|
||||||
|
$title= l10n('About Piwigo');
|
||||||
|
$page['body_id'] = 'theAboutPage';
|
||||||
|
|
||||||
|
trigger_action('loc_begin_about');
|
||||||
|
|
||||||
|
$template->set_filename('about', 'about.tpl');
|
||||||
|
|
||||||
|
$template->assign('ABOUT_MESSAGE', load_language('about.html','', array('return'=>true)) );
|
||||||
|
|
||||||
|
$theme_about = load_language('about.html', PHPWG_THEMES_PATH.$user['theme'].'/', array('return' => true));
|
||||||
|
if ( $theme_about !== false )
|
||||||
|
{
|
||||||
|
$template->assign('THEME_ABOUT', $theme_about);
|
||||||
|
}
|
||||||
|
|
||||||
|
// include menubar
|
||||||
|
$themeconf = $template->get_template_vars('themeconf');
|
||||||
|
if (!isset($themeconf['hide_menu_on']) OR !in_array('theAboutPage', $themeconf['hide_menu_on']))
|
||||||
|
{
|
||||||
|
include( PHPWG_ROOT_PATH.'include/menubar.inc.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
||||||
|
flush_page_messages();
|
||||||
|
$template->pparse('about');
|
||||||
|
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
||||||
|
?>
|
200
sources/action.php
Normal file
200
sources/action.php
Normal file
|
@ -0,0 +1,200 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
define('PHPWG_ROOT_PATH','./');
|
||||||
|
session_cache_limiter('public');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||||
|
|
||||||
|
// Check Access and exit when user status is not ok
|
||||||
|
check_status(ACCESS_GUEST);
|
||||||
|
|
||||||
|
function guess_mime_type($ext)
|
||||||
|
{
|
||||||
|
switch ( strtolower($ext) )
|
||||||
|
{
|
||||||
|
case "jpe": case "jpeg":
|
||||||
|
case "jpg": $ctype="image/jpeg"; break;
|
||||||
|
case "png": $ctype="image/png"; break;
|
||||||
|
case "gif": $ctype="image/gif"; break;
|
||||||
|
case "tiff":
|
||||||
|
case "tif": $ctype="image/tiff"; break;
|
||||||
|
case "txt": $ctype="text/plain"; break;
|
||||||
|
case "html":
|
||||||
|
case "htm": $ctype="text/html"; break;
|
||||||
|
case "xml": $ctype="text/xml"; break;
|
||||||
|
case "pdf": $ctype="application/pdf"; break;
|
||||||
|
case "zip": $ctype="application/zip"; break;
|
||||||
|
case "ogg": $ctype="application/ogg"; break;
|
||||||
|
default: $ctype="application/octet-stream";
|
||||||
|
}
|
||||||
|
return $ctype;
|
||||||
|
}
|
||||||
|
|
||||||
|
function do_error( $code, $str )
|
||||||
|
{
|
||||||
|
set_status_header( $code );
|
||||||
|
echo $str ;
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!isset($_GET['id'])
|
||||||
|
or !is_numeric($_GET['id'])
|
||||||
|
or !isset($_GET['part'])
|
||||||
|
or !in_array($_GET['part'], array('e','r') ) )
|
||||||
|
{
|
||||||
|
do_error(400, 'Invalid request - id/part');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT * FROM '. IMAGES_TABLE.'
|
||||||
|
WHERE id='.$_GET['id'].'
|
||||||
|
;';
|
||||||
|
|
||||||
|
$element_info = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
if ( empty($element_info) )
|
||||||
|
{
|
||||||
|
do_error(404, 'Requested id not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
// $filter['visible_categories'] and $filter['visible_images']
|
||||||
|
// are not used because it's not necessary (filter <> restriction)
|
||||||
|
$query='
|
||||||
|
SELECT id
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON category_id = id
|
||||||
|
WHERE image_id = '.$_GET['id'].'
|
||||||
|
'.get_sql_condition_FandF(
|
||||||
|
array(
|
||||||
|
'forbidden_categories' => 'category_id',
|
||||||
|
'forbidden_images' => 'image_id',
|
||||||
|
),
|
||||||
|
' AND'
|
||||||
|
).'
|
||||||
|
LIMIT 1
|
||||||
|
;';
|
||||||
|
if ( pwg_db_num_rows(pwg_query($query))<1 )
|
||||||
|
{
|
||||||
|
do_error(401, 'Access denied');
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
|
||||||
|
$file='';
|
||||||
|
switch ($_GET['part'])
|
||||||
|
{
|
||||||
|
case 'e':
|
||||||
|
if ( !$user['enabled_high'] )
|
||||||
|
{
|
||||||
|
$deriv = new DerivativeImage(IMG_XXLARGE, new SrcImage($element_info));
|
||||||
|
if ( !$deriv->same_as_source() )
|
||||||
|
{
|
||||||
|
do_error(401, 'Access denied e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$file = get_element_path($element_info);
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
$file = original_to_representative( get_element_path($element_info), $element_info['representative_ext'] );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty($file) )
|
||||||
|
{
|
||||||
|
do_error(404, 'Requested file not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_GET['part'] == 'e') {
|
||||||
|
pwg_log($_GET['id'], 'high');
|
||||||
|
}
|
||||||
|
else if ($_GET['part'] == 'e')
|
||||||
|
{
|
||||||
|
pwg_log($_GET['id'], 'other');
|
||||||
|
}
|
||||||
|
|
||||||
|
$http_headers = array();
|
||||||
|
|
||||||
|
$ctype = null;
|
||||||
|
if (!url_is_remote($file))
|
||||||
|
{
|
||||||
|
if ( !@is_readable($file) )
|
||||||
|
{
|
||||||
|
do_error(404, "Requested file not found - $file");
|
||||||
|
}
|
||||||
|
$http_headers[] = 'Content-Length: '.@filesize($file);
|
||||||
|
if ( function_exists('mime_content_type') )
|
||||||
|
{
|
||||||
|
$ctype = mime_content_type($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$gmt_mtime = gmdate('D, d M Y H:i:s', filemtime($file)).' GMT';
|
||||||
|
$http_headers[] = 'Last-Modified: '.$gmt_mtime;
|
||||||
|
|
||||||
|
// following lines would indicate how the client should handle the cache
|
||||||
|
/* $max_age=300;
|
||||||
|
$http_headers[] = 'Expires: '.gmdate('D, d M Y H:i:s', time()+$max_age).' GMT';
|
||||||
|
// HTTP/1.1 only
|
||||||
|
$http_headers[] = 'Cache-Control: private, must-revalidate, max-age='.$max_age;*/
|
||||||
|
|
||||||
|
if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) )
|
||||||
|
{
|
||||||
|
set_status_header(304);
|
||||||
|
foreach ($http_headers as $header)
|
||||||
|
{
|
||||||
|
header( $header );
|
||||||
|
}
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($ctype))
|
||||||
|
{ // give it a guess
|
||||||
|
$ctype = guess_mime_type( get_extension($file) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$http_headers[] = 'Content-Type: '.$ctype;
|
||||||
|
|
||||||
|
if (isset($_GET['download']))
|
||||||
|
{
|
||||||
|
$http_headers[] = 'Content-Disposition: attachment; filename="'.$element_info['file'].'";';
|
||||||
|
$http_headers[] = 'Content-Transfer-Encoding: binary';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$http_headers[] = 'Content-Disposition: inline; filename="'
|
||||||
|
.basename($file).'";';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($http_headers as $header)
|
||||||
|
{
|
||||||
|
header( $header );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Looking at the safe_mode configuration for execution time
|
||||||
|
if (ini_get('safe_mode') == 0)
|
||||||
|
{
|
||||||
|
@set_time_limit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@readfile($file);
|
||||||
|
|
||||||
|
?>
|
309
sources/admin.php
Normal file
309
sources/admin.php
Normal file
|
@ -0,0 +1,309 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Basic constants and includes |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
define('PHPWG_ROOT_PATH','./');
|
||||||
|
define('IN_ADMIN', true);
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions_plugins.inc.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/add_core_tabs.inc.php');
|
||||||
|
|
||||||
|
trigger_action('loc_begin_admin');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Direct actions |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// save plugins_new display order (AJAX action)
|
||||||
|
if (isset($_GET['plugins_new_order']))
|
||||||
|
{
|
||||||
|
pwg_set_session_var('plugins_new_order', $_GET['plugins_new_order']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// theme changer
|
||||||
|
if (isset($_GET['change_theme']))
|
||||||
|
{
|
||||||
|
$admin_themes = array('roma', 'clear');
|
||||||
|
|
||||||
|
$new_admin_theme = array_pop(
|
||||||
|
array_diff(
|
||||||
|
$admin_themes,
|
||||||
|
array($conf['admin_theme'])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
conf_update_param('admin_theme', $new_admin_theme);
|
||||||
|
|
||||||
|
$url_params = array();
|
||||||
|
foreach (array('page', 'tab', 'section') as $url_param)
|
||||||
|
{
|
||||||
|
if (isset($_GET[$url_param]))
|
||||||
|
{
|
||||||
|
$url_params[] = $url_param.'='.$_GET[$url_param];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$redirect_url = 'admin.php';
|
||||||
|
if (count($url_params) > 0)
|
||||||
|
{
|
||||||
|
$redirect_url.= '?'.implode('&', $url_params);
|
||||||
|
}
|
||||||
|
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Synchronize user informations |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// sync_user() is only useful when external authentication is activated
|
||||||
|
if ($conf['external_authentification'])
|
||||||
|
{
|
||||||
|
sync_users();
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Variables init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$change_theme_url = PHPWG_ROOT_PATH.'admin.php?';
|
||||||
|
$test_get = $_GET;
|
||||||
|
unset($test_get['page']);
|
||||||
|
unset($test_get['section']);
|
||||||
|
unset($test_get['tag']);
|
||||||
|
if (count($test_get) == 0 and !empty($_SERVER['QUERY_STRING']))
|
||||||
|
{
|
||||||
|
$change_theme_url.= str_replace('&', '&', $_SERVER['QUERY_STRING']).'&';
|
||||||
|
}
|
||||||
|
$change_theme_url.= 'change_theme=1';
|
||||||
|
|
||||||
|
// ?page=plugin-community-pendings is an clean alias of
|
||||||
|
// ?page=plugin§ion=community/admin.php&tab=pendings
|
||||||
|
if (isset($_GET['page']) and preg_match('/^plugin-([^-]*)(?:-(.*))?$/', $_GET['page'], $matches))
|
||||||
|
{
|
||||||
|
$_GET['page'] = 'plugin';
|
||||||
|
$_GET['section'] = $matches[1].'/admin.php';
|
||||||
|
if (isset($matches[2]))
|
||||||
|
{
|
||||||
|
$_GET['tab'] = $matches[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ?page=album-134-properties is an clean alias of
|
||||||
|
// ?page=album&cat_id=134&tab=properties
|
||||||
|
if (isset($_GET['page']) and preg_match('/^album-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
|
||||||
|
{
|
||||||
|
$_GET['page'] = 'album';
|
||||||
|
$_GET['cat_id'] = $matches[1];
|
||||||
|
if (isset($matches[2]))
|
||||||
|
{
|
||||||
|
$_GET['tab'] = $matches[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ?page=photo-1234-properties is an clean alias of
|
||||||
|
// ?page=photo&image_id=1234&tab=properties
|
||||||
|
if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
|
||||||
|
{
|
||||||
|
$_GET['page'] = 'photo';
|
||||||
|
$_GET['image_id'] = $matches[1];
|
||||||
|
if (isset($matches[2]))
|
||||||
|
{
|
||||||
|
$_GET['tab'] = $matches[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['page'])
|
||||||
|
and preg_match('/^[a-z_]*$/', $_GET['page'])
|
||||||
|
and is_file(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php'))
|
||||||
|
{
|
||||||
|
$page['page'] = $_GET['page'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['page'] = 'intro';
|
||||||
|
}
|
||||||
|
|
||||||
|
$link_start = PHPWG_ROOT_PATH.'admin.php?page=';
|
||||||
|
$conf_link = $link_start.'configuration&section=';
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Template init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$title = l10n('Piwigo Administration'); // for include/page_header.php
|
||||||
|
$page['page_banner'] = '<h1>'.l10n('Piwigo Administration').'</h1>';
|
||||||
|
$page['body_id'] = 'theAdminPage';
|
||||||
|
|
||||||
|
$template->set_filenames(array('admin' => 'admin.tpl'));
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'USERNAME' => $user['username'],
|
||||||
|
'ENABLE_SYNCHRONIZATION' => $conf['enable_synchronization'],
|
||||||
|
'U_SITE_MANAGER'=> $link_start.'site_manager',
|
||||||
|
'U_HISTORY_STAT'=> $link_start.'stats',
|
||||||
|
'U_FAQ'=> $link_start.'help',
|
||||||
|
'U_SITES'=> $link_start.'remote_site',
|
||||||
|
'U_MAINTENANCE'=> $link_start.'maintenance',
|
||||||
|
'U_NOTIFICATION_BY_MAIL'=> $link_start.'notification_by_mail',
|
||||||
|
'U_CONFIG_GENERAL'=> $link_start.'configuration',
|
||||||
|
'U_CONFIG_DISPLAY'=> $conf_link.'default',
|
||||||
|
'U_CONFIG_EXTENTS'=> $link_start.'extend_for_templates',
|
||||||
|
'U_CONFIG_MENUBAR'=> $link_start.'menubar',
|
||||||
|
'U_CONFIG_LANGUAGES' => $link_start.'languages',
|
||||||
|
'U_CONFIG_THEMES'=> $link_start.'themes',
|
||||||
|
'U_CATEGORIES'=> $link_start.'cat_list',
|
||||||
|
'U_CAT_OPTIONS'=> $link_start.'cat_options',
|
||||||
|
'U_CAT_UPDATE'=> $link_start.'site_update&site=1',
|
||||||
|
'U_RATING'=> $link_start.'rating',
|
||||||
|
'U_RECENT_SET'=> $link_start.'batch_manager&filter=prefilter-last_import',
|
||||||
|
'U_BATCH'=> $link_start.'batch_manager',
|
||||||
|
'U_TAGS'=> $link_start.'tags',
|
||||||
|
'U_USERS'=> $link_start.'user_list',
|
||||||
|
'U_GROUPS'=> $link_start.'group_list',
|
||||||
|
'U_RETURN'=> get_gallery_home_url(),
|
||||||
|
'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php',
|
||||||
|
'U_LOGOUT'=> PHPWG_ROOT_PATH.'index.php?act=logout',
|
||||||
|
'U_PLUGINS'=> $link_start.'plugins',
|
||||||
|
'U_ADD_PHOTOS' => $link_start.'photos_add',
|
||||||
|
'U_CHANGE_THEME' => $change_theme_url,
|
||||||
|
'U_UPDATES' => $link_start.'updates',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($conf['activate_comments'])
|
||||||
|
{
|
||||||
|
$template->assign('U_COMMENTS', $link_start.'comments');
|
||||||
|
|
||||||
|
// pending comments
|
||||||
|
$query = '
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM '.COMMENTS_TABLE.'
|
||||||
|
WHERE validated=\'false\'
|
||||||
|
;';
|
||||||
|
list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
|
||||||
|
if ($nb_comments > 0)
|
||||||
|
{
|
||||||
|
$template->assign('NB_PENDING_COMMENTS', $nb_comments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// any photo in the caddie?
|
||||||
|
$query = '
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM '.CADDIE_TABLE.'
|
||||||
|
WHERE user_id = '.$user['id'].'
|
||||||
|
;';
|
||||||
|
list($nb_photos_in_caddie) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
|
||||||
|
if ($nb_photos_in_caddie > 0)
|
||||||
|
{
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'NB_PHOTOS_IN_CADDIE' => $nb_photos_in_caddie,
|
||||||
|
'U_CADDIE' => $link_start.'batch_manager&filter=prefilter-caddie',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Plugin menu |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$plugin_menu_links = trigger_event('get_admin_plugin_menu_links', array() );
|
||||||
|
|
||||||
|
function UC_name_compare($a, $b)
|
||||||
|
{
|
||||||
|
return strcmp(strtolower($a['NAME']), strtolower($b['NAME']));
|
||||||
|
}
|
||||||
|
usort($plugin_menu_links, 'UC_name_compare');
|
||||||
|
$template->assign('plugin_menu_items', $plugin_menu_links);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Refresh permissions |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Only for pages witch change permissions
|
||||||
|
if (
|
||||||
|
in_array($page['page'],
|
||||||
|
array(
|
||||||
|
'site_manager', // delete site
|
||||||
|
'site_update', // ?only POST
|
||||||
|
)
|
||||||
|
)
|
||||||
|
or ( !empty($_POST) and in_array($page['page'],
|
||||||
|
array(
|
||||||
|
'album', // public/private; lock/unlock, permissions
|
||||||
|
'cat_move',
|
||||||
|
'cat_options', // public/private; lock/unlock
|
||||||
|
'batch_manager', // associate/dissociate; delete; set level
|
||||||
|
'user_list', // group assoc; user level
|
||||||
|
'user_perm',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
invalidate_user_cache();
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Include specific page |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
trigger_action('loc_begin_admin_page');
|
||||||
|
include(PHPWG_ROOT_PATH.'admin/'.$page['page'].'.php');
|
||||||
|
|
||||||
|
$template->assign('ACTIVE_MENU', get_active_menu($page['page']));
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Add the Piwigo Official menu
|
||||||
|
$template->assign( 'pwgmenu', pwg_URL() );
|
||||||
|
|
||||||
|
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
||||||
|
|
||||||
|
trigger_action('loc_end_admin');
|
||||||
|
|
||||||
|
flush_page_messages();
|
||||||
|
|
||||||
|
$template->pparse('admin');
|
||||||
|
|
||||||
|
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
||||||
|
?>
|
90
sources/admin/album.php
Normal file
90
sources/admin/album.php
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if( !defined("PHPWG_ROOT_PATH") )
|
||||||
|
{
|
||||||
|
die ("Hacking attempt!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Basic checks |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
|
||||||
|
|
||||||
|
$admin_album_base_url = get_root_url().'admin.php?page=album-'.$_GET['cat_id'];
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT *
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE id = '.$_GET['cat_id'].'
|
||||||
|
;';
|
||||||
|
$category = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
|
||||||
|
if (!isset($category['id']))
|
||||||
|
{
|
||||||
|
die("unknown album");
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Tabs |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||||
|
|
||||||
|
$page['tab'] = 'properties';
|
||||||
|
|
||||||
|
if (isset($_GET['tab']))
|
||||||
|
{
|
||||||
|
$page['tab'] = $_GET['tab'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tabsheet = new tabsheet();
|
||||||
|
$tabsheet->set_id('album');
|
||||||
|
$tabsheet->select($page['tab']);
|
||||||
|
$tabsheet->assign();
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Load the tab |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if ('properties' == $page['tab'])
|
||||||
|
{
|
||||||
|
include(PHPWG_ROOT_PATH.'admin/cat_modify.php');
|
||||||
|
}
|
||||||
|
elseif ('sort_order' == $page['tab'])
|
||||||
|
{
|
||||||
|
include(PHPWG_ROOT_PATH.'admin/element_set_ranks.php');
|
||||||
|
}
|
||||||
|
elseif ('permissions' == $page['tab'])
|
||||||
|
{
|
||||||
|
$_GET['cat'] = $_GET['cat_id'];
|
||||||
|
include(PHPWG_ROOT_PATH.'admin/cat_perm.php');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
include(PHPWG_ROOT_PATH.'admin/album_'.$page['tab'].'.php');
|
||||||
|
}
|
||||||
|
?>
|
197
sources/admin/album_notification.php
Normal file
197
sources/admin/album_notification.php
Normal file
|
@ -0,0 +1,197 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die ("Hacking attempt!");
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | variable initialization |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$page['cat'] = $category['id'];
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | form submission |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// info by email to an access granted group of category informations
|
||||||
|
if (isset($_POST['submitEmail']) and !empty($_POST['group']))
|
||||||
|
{
|
||||||
|
set_make_full_url();
|
||||||
|
|
||||||
|
/* TODO: if $category['representative_picture_id']
|
||||||
|
is empty find child representative_picture_id */
|
||||||
|
if (!empty($category['representative_picture_id']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT id, file, path, representative_ext
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE id = '.$category['representative_picture_id'].'
|
||||||
|
;';
|
||||||
|
|
||||||
|
$result = pwg_query($query);
|
||||||
|
if (pwg_db_num_rows($result) > 0)
|
||||||
|
{
|
||||||
|
$element = pwg_db_fetch_assoc($result);
|
||||||
|
|
||||||
|
$img_url = '<a href="'.
|
||||||
|
make_picture_url(array(
|
||||||
|
'image_id' => $element['id'],
|
||||||
|
'image_file' => $element['file'],
|
||||||
|
'category' => $category
|
||||||
|
))
|
||||||
|
.'" class="thumblnk"><img src="'.DerivativeImage::url(IMG_THUMB, $element).'"></a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($img_url))
|
||||||
|
{
|
||||||
|
$img_url = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
pwg_mail_group(
|
||||||
|
$_POST['group'],
|
||||||
|
array(
|
||||||
|
'subject' => l10n('[%s] Visit album %s', $conf['gallery_title'], trigger_event('render_category_name', $category['name'], 'admin_cat_list')),
|
||||||
|
// TODO : change this language variable to 'Visit album %s'
|
||||||
|
// TODO : 'language_selected' => ....
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'filename' => 'cat_group_info',
|
||||||
|
'assign' => array(
|
||||||
|
'IMG_URL' => $img_url,
|
||||||
|
'CAT_NAME' => trigger_event('render_category_name', $category['name'], 'admin_cat_list'),
|
||||||
|
'LINK' => make_index_url(array(
|
||||||
|
'category' => array(
|
||||||
|
'id' => $category['id'],
|
||||||
|
'name' => trigger_event('render_category_name', $category['name'], 'admin_cat_list'),
|
||||||
|
'permalink' => $category['permalink']
|
||||||
|
)
|
||||||
|
)),
|
||||||
|
'CPL_CONTENT' => empty($_POST['mail_content']) ? '' : stripslashes($_POST['mail_content']),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
unset_make_full_url();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
name
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE id = '.$_POST['group'].'
|
||||||
|
;';
|
||||||
|
list($group_name) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('An information email was sent to group "%s"', $group_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template initialization |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->set_filename('album_notification', 'album_notification.tpl');
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'CATEGORIES_NAV' =>
|
||||||
|
get_cat_display_name_from_id(
|
||||||
|
$page['cat'],
|
||||||
|
'admin.php?page=album-'
|
||||||
|
),
|
||||||
|
'F_ACTION' => $admin_album_base_url.'-notification',
|
||||||
|
'PWG_TOKEN' => get_pwg_token(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | form construction |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id AS group_id
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
;';
|
||||||
|
$all_group_ids = array_from_query($query, 'group_id');
|
||||||
|
|
||||||
|
if (count($all_group_ids) == 0)
|
||||||
|
{
|
||||||
|
$template->assign('no_group_in_gallery', true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ('private' == $category['status'])
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
group_id
|
||||||
|
FROM '.GROUP_ACCESS_TABLE.'
|
||||||
|
WHERE cat_id = '.$category['id'].'
|
||||||
|
;';
|
||||||
|
$group_ids = array_from_query($query, 'group_id');
|
||||||
|
|
||||||
|
if (count($group_ids) == 0)
|
||||||
|
{
|
||||||
|
$template->assign('permission_url', $admin_album_base_url.'-permissions');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$group_ids = $all_group_ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($group_ids) > 0)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', $group_ids).')
|
||||||
|
ORDER BY name ASC
|
||||||
|
;';
|
||||||
|
$template->assign(
|
||||||
|
'group_mail_options',
|
||||||
|
simple_hash_from_query($query, 'id', 'name')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'album_notification');
|
||||||
|
?>
|
564
sources/admin/batch_manager.php
Normal file
564
sources/admin/batch_manager.php
Normal file
|
@ -0,0 +1,564 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Management of elements set. Elements can belong to a category or to the
|
||||||
|
* user caddie.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die('Hacking attempt!');
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
check_input_parameter('selection', $_POST, true, PATTERN_ID);
|
||||||
|
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | initialize current set |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// filters from form
|
||||||
|
if (isset($_POST['submitFilter']))
|
||||||
|
{
|
||||||
|
// echo '<pre>'; print_r($_POST); echo '</pre>';
|
||||||
|
unset($_REQUEST['start']); // new photo set must reset the page
|
||||||
|
$_SESSION['bulk_manager_filter'] = array();
|
||||||
|
|
||||||
|
if (isset($_POST['filter_prefilter_use']))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['prefilter'] = $_POST['filter_prefilter'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['filter_category_use']))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['category'] = $_POST['filter_category'];
|
||||||
|
|
||||||
|
if (isset($_POST['filter_category_recursive']))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['category_recursive'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['filter_tags_use']))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['tags'] = get_tag_ids($_POST['filter_tags'], false);
|
||||||
|
|
||||||
|
if (isset($_POST['tag_mode']) and in_array($_POST['tag_mode'], array('AND', 'OR')))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['tag_mode'] = $_POST['tag_mode'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['filter_level_use']))
|
||||||
|
{
|
||||||
|
if (in_array($_POST['filter_level'], $conf['available_permission_levels']))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['level'] = $_POST['filter_level'];
|
||||||
|
|
||||||
|
if (isset($_POST['filter_level_include_lower']))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['level_include_lower'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['filter_dimension_use']))
|
||||||
|
{
|
||||||
|
foreach (array('min_width','max_width','min_height','max_height') as $type)
|
||||||
|
{
|
||||||
|
if ( preg_match('#^[0-9]+$#', $_POST['filter_dimension_'. $type ]) )
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['dimension'][$type] = $_POST['filter_dimension_'. $type ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (array('min_ratio','max_ratio') as $type)
|
||||||
|
{
|
||||||
|
if ( preg_match('#^[0-9\.]+$#', $_POST['filter_dimension_'. $type ]) )
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['dimension'][$type] = $_POST['filter_dimension_'. $type ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// filters from url
|
||||||
|
else if (isset($_GET['filter']))
|
||||||
|
{
|
||||||
|
if (!is_array($_GET['filter']))
|
||||||
|
{
|
||||||
|
$_GET['filter'] = explode(',', $_GET['filter']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION['bulk_manager_filter'] = array();
|
||||||
|
|
||||||
|
foreach ($_GET['filter'] as $filter)
|
||||||
|
{
|
||||||
|
list($type, $value) = explode('-', $filter);
|
||||||
|
|
||||||
|
switch ($type)
|
||||||
|
{
|
||||||
|
case 'prefilter':
|
||||||
|
$_SESSION['bulk_manager_filter']['prefilter'] = $value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'album':
|
||||||
|
if (is_numeric($value))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['category'] = $value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'tag':
|
||||||
|
if (is_numeric($value))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['tags'] = array($value);
|
||||||
|
$_SESSION['bulk_manager_filter']['tag_mode'] = 'AND';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'level':
|
||||||
|
if (is_numeric($value) && in_array($value, $conf['available_permission_levels']))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter']['level'] = $value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($_SESSION['bulk_manager_filter']))
|
||||||
|
{
|
||||||
|
$_SESSION['bulk_manager_filter'] = array(
|
||||||
|
'prefilter' => 'caddie'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// echo '<pre>'; print_r($_SESSION['bulk_manager_filter']); echo '</pre>';
|
||||||
|
|
||||||
|
// depending on the current filter (in session), we find the appropriate photos
|
||||||
|
$filter_sets = array();
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['prefilter']))
|
||||||
|
{
|
||||||
|
switch ($_SESSION['bulk_manager_filter']['prefilter'])
|
||||||
|
{
|
||||||
|
case 'caddie':
|
||||||
|
$query = '
|
||||||
|
SELECT element_id
|
||||||
|
FROM '.CADDIE_TABLE.'
|
||||||
|
WHERE user_id = '.$user['id'].'
|
||||||
|
;';
|
||||||
|
$filter_sets[] = array_from_query($query, 'element_id');
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'favorites':
|
||||||
|
$query = '
|
||||||
|
SELECT image_id
|
||||||
|
FROM '.FAVORITES_TABLE.'
|
||||||
|
WHERE user_id = '.$user['id'].'
|
||||||
|
;';
|
||||||
|
$filter_sets[] = array_from_query($query, 'image_id');
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'last_import':
|
||||||
|
$query = '
|
||||||
|
SELECT MAX(date_available) AS date
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
;';
|
||||||
|
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
if (!empty($row['date']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE date_available BETWEEN '.pwg_db_get_recent_period_expression(1, $row['date']).' AND \''.$row['date'].'\'
|
||||||
|
;';
|
||||||
|
$filter_sets[] = array_from_query($query, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'no_virtual_album':
|
||||||
|
// we are searching elements not linked to any virtual category
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
;';
|
||||||
|
$all_elements = array_from_query($query, 'id');
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE dir IS NULL
|
||||||
|
;';
|
||||||
|
$virtual_categories = array_from_query($query, 'id');
|
||||||
|
if (!empty($virtual_categories))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT DISTINCT(image_id)
|
||||||
|
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||||
|
WHERE category_id IN ('.implode(',', $virtual_categories).')
|
||||||
|
;';
|
||||||
|
$linked_to_virtual = array_from_query($query, 'image_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter_sets[] = array_diff($all_elements, $linked_to_virtual);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'no_album':
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
LEFT JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id
|
||||||
|
WHERE category_id is null
|
||||||
|
;';
|
||||||
|
$filter_sets[] = array_from_query($query, 'id');
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'no_tag':
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
LEFT JOIN '.IMAGE_TAG_TABLE.' ON id = image_id
|
||||||
|
WHERE tag_id is null
|
||||||
|
;';
|
||||||
|
$filter_sets[] = array_from_query($query, 'id');
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case 'duplicates':
|
||||||
|
// we could use the group_concat MySQL function to retrieve the list of
|
||||||
|
// image_ids but it would not be compatible with PostgreSQL, so let's
|
||||||
|
// perform 2 queries instead. We hope there are not too many duplicates.
|
||||||
|
$query = '
|
||||||
|
SELECT file
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
GROUP BY file
|
||||||
|
HAVING COUNT(*) > 1
|
||||||
|
;';
|
||||||
|
$duplicate_files = array_from_query($query, 'file');
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE file IN (\''.implode("','", array_map('pwg_db_real_escape_string', $duplicate_files)).'\')
|
||||||
|
;';
|
||||||
|
$filter_sets[] = array_from_query($query, 'id');
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'all_photos':
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
'.$conf['order_by'];
|
||||||
|
|
||||||
|
$filter_sets[] = array_from_query($query, 'id');
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter_sets = trigger_event('perform_batch_manager_prefilters', $filter_sets, $_SESSION['bulk_manager_filter']['prefilter']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['category']))
|
||||||
|
{
|
||||||
|
$categories = array();
|
||||||
|
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['category_recursive']))
|
||||||
|
{
|
||||||
|
$categories = get_subcat_ids(array($_SESSION['bulk_manager_filter']['category']));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$categories = array($_SESSION['bulk_manager_filter']['category']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT DISTINCT(image_id)
|
||||||
|
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||||
|
WHERE category_id IN ('.implode(',', $categories).')
|
||||||
|
;';
|
||||||
|
$filter_sets[] = array_from_query($query, 'image_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['level']))
|
||||||
|
{
|
||||||
|
$operator = '=';
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['level_include_lower']))
|
||||||
|
{
|
||||||
|
$operator = '<=';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE level '.$operator.' '.$_SESSION['bulk_manager_filter']['level'].'
|
||||||
|
'.$conf['order_by'];
|
||||||
|
|
||||||
|
$filter_sets[] = array_from_query($query, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($_SESSION['bulk_manager_filter']['tags']))
|
||||||
|
{
|
||||||
|
$filter_sets[] = get_image_ids_for_tags(
|
||||||
|
$_SESSION['bulk_manager_filter']['tags'],
|
||||||
|
$_SESSION['bulk_manager_filter']['tag_mode'],
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
false // we don't apply permissions in administration screens
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['dimension']))
|
||||||
|
{
|
||||||
|
$where_clauses = array();
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['dimension']['min_width']))
|
||||||
|
{
|
||||||
|
$where_clause[] = 'width >= '.$_SESSION['bulk_manager_filter']['dimension']['min_width'];
|
||||||
|
}
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['dimension']['max_width']))
|
||||||
|
{
|
||||||
|
$where_clause[] = 'width <= '.$_SESSION['bulk_manager_filter']['dimension']['max_width'];
|
||||||
|
}
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['dimension']['min_height']))
|
||||||
|
{
|
||||||
|
$where_clause[] = 'height >= '.$_SESSION['bulk_manager_filter']['dimension']['min_height'];
|
||||||
|
}
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['dimension']['max_height']))
|
||||||
|
{
|
||||||
|
$where_clause[] = 'height <= '.$_SESSION['bulk_manager_filter']['dimension']['max_height'];
|
||||||
|
}
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['dimension']['min_ratio']))
|
||||||
|
{
|
||||||
|
$where_clause[] = 'width/height >= '.$_SESSION['bulk_manager_filter']['dimension']['min_ratio'];
|
||||||
|
}
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['dimension']['max_ratio']))
|
||||||
|
{
|
||||||
|
// max_ratio is a floor value, so must be a bit increased
|
||||||
|
$where_clause[] = 'width/height < '.($_SESSION['bulk_manager_filter']['dimension']['max_ratio']+0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE '.implode(' AND ',$where_clause).'
|
||||||
|
'.$conf['order_by'];
|
||||||
|
|
||||||
|
$filter_sets[] = array_from_query($query, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
$current_set = array_shift($filter_sets);
|
||||||
|
foreach ($filter_sets as $set)
|
||||||
|
{
|
||||||
|
$current_set = array_intersect($current_set, $set);
|
||||||
|
}
|
||||||
|
$page['cat_elements_id'] = $current_set;
|
||||||
|
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | first element to display |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// $page['start'] contains the number of the first element in its
|
||||||
|
// category. For exampe, $page['start'] = 12 means we must show elements #12
|
||||||
|
// and $page['nb_images'] next elements
|
||||||
|
|
||||||
|
if (!isset($_REQUEST['start'])
|
||||||
|
or !is_numeric($_REQUEST['start'])
|
||||||
|
or $_REQUEST['start'] < 0
|
||||||
|
or (isset($_REQUEST['display']) and 'all' == $_REQUEST['display']))
|
||||||
|
{
|
||||||
|
$page['start'] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['start'] = $_REQUEST['start'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Tabs |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$manager_link = get_root_url().'admin.php?page=batch_manager&mode=';
|
||||||
|
|
||||||
|
if (isset($_GET['mode']))
|
||||||
|
{
|
||||||
|
$page['tab'] = $_GET['mode'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['tab'] = 'global';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tabsheet = new tabsheet();
|
||||||
|
$tabsheet->set_id('batch_manager');
|
||||||
|
$tabsheet->select($page['tab']);
|
||||||
|
$tabsheet->assign();
|
||||||
|
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | tags |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id, name
|
||||||
|
FROM '.TAGS_TABLE.'
|
||||||
|
;';
|
||||||
|
$template->assign('tags', get_taglist($query, false));
|
||||||
|
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | dimensions |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$widths = array();
|
||||||
|
$heights = array();
|
||||||
|
$ratios = array();
|
||||||
|
|
||||||
|
// get all width, height and ratios
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
DISTINCT width, height
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE width IS NOT NULL
|
||||||
|
AND height IS NOT NULL
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
|
||||||
|
if (pwg_db_num_rows($result))
|
||||||
|
{
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
if ($row['width']>0 && $row['height']>0)
|
||||||
|
{
|
||||||
|
$widths[] = $row['width'];
|
||||||
|
$heights[] = $row['height'];
|
||||||
|
$ratios[] = floor($row['width'] / $row['height'] * 100) / 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($widths))
|
||||||
|
{ // arbitrary values, only used when no photos on the gallery
|
||||||
|
$widths = array(600, 1920, 3500);
|
||||||
|
$heights = array(480, 1080, 2300);
|
||||||
|
$ratios = array(1.25, 1.52, 1.78);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$widths = array_unique($widths);
|
||||||
|
sort($widths);
|
||||||
|
|
||||||
|
$heights = array_unique($heights);
|
||||||
|
sort($heights);
|
||||||
|
|
||||||
|
$ratios = array_unique($ratios);
|
||||||
|
sort($ratios);
|
||||||
|
|
||||||
|
$dimensions['widths'] = implode(',', $widths);
|
||||||
|
$dimensions['heights'] = implode(',', $heights);
|
||||||
|
$dimensions['ratios'] = implode(',', $ratios);
|
||||||
|
|
||||||
|
$dimensions['bounds'] = array(
|
||||||
|
'min_width' => $widths[0],
|
||||||
|
'max_width' => $widths[count($widths)-1],
|
||||||
|
'min_height' => $heights[0],
|
||||||
|
'max_height' => $heights[count($heights)-1],
|
||||||
|
'min_ratio' => $ratios[0],
|
||||||
|
'max_ratio' => $ratios[count($ratios)-1],
|
||||||
|
);
|
||||||
|
|
||||||
|
// find ratio categories
|
||||||
|
$ratio_categories = array(
|
||||||
|
'portrait' => array(),
|
||||||
|
'square' => array(),
|
||||||
|
'landscape' => array(),
|
||||||
|
'panorama' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($ratios as $ratio)
|
||||||
|
{
|
||||||
|
if ($ratio < 0.95)
|
||||||
|
{
|
||||||
|
$ratio_categories['portrait'][] = $ratio;
|
||||||
|
}
|
||||||
|
else if ($ratio >= 0.95 and $ratio <= 1.05)
|
||||||
|
{
|
||||||
|
$ratio_categories['square'][] = $ratio;
|
||||||
|
}
|
||||||
|
else if ($ratio > 1.05 and $ratio < 2)
|
||||||
|
{
|
||||||
|
$ratio_categories['landscape'][] = $ratio;
|
||||||
|
}
|
||||||
|
else if ($ratio >= 2)
|
||||||
|
{
|
||||||
|
$ratio_categories['panorama'][] = $ratio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (array_keys($ratio_categories) as $ratio_category)
|
||||||
|
{
|
||||||
|
if (count($ratio_categories[$ratio_category]) > 0)
|
||||||
|
{
|
||||||
|
$dimensions['ratio_'.$ratio_category] = array(
|
||||||
|
'min' => $ratio_categories[$ratio_category][0],
|
||||||
|
'max' => array_pop($ratio_categories[$ratio_category]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// selected=bound if nothing selected
|
||||||
|
foreach (array_keys($dimensions['bounds']) as $type)
|
||||||
|
{
|
||||||
|
$dimensions['selected'][$type] = isset($_SESSION['bulk_manager_filter']['dimension'][$type])
|
||||||
|
? $_SESSION['bulk_manager_filter']['dimension'][$type]
|
||||||
|
: $dimensions['bounds'][$type]
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign('dimensions', $dimensions);
|
||||||
|
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | open specific mode |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
include(PHPWG_ROOT_PATH.'admin/batch_manager_'.$page['tab'].'.php');
|
||||||
|
?>
|
734
sources/admin/batch_manager_global.php
Normal file
734
sources/admin/batch_manager_global.php
Normal file
|
@ -0,0 +1,734 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Management of elements set. Elements can belong to a category or to the
|
||||||
|
* user caddie.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die('Hacking attempt!');
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
trigger_action('loc_begin_element_set_global');
|
||||||
|
|
||||||
|
check_input_parameter('del_tags', $_POST, true, PATTERN_ID);
|
||||||
|
check_input_parameter('associate', $_POST, false, PATTERN_ID);
|
||||||
|
check_input_parameter('move', $_POST, false, PATTERN_ID);
|
||||||
|
check_input_parameter('dissociate', $_POST, false, PATTERN_ID);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | current selection |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$collection = array();
|
||||||
|
if (isset($_POST['setSelected']))
|
||||||
|
{
|
||||||
|
$collection = $page['cat_elements_id'];
|
||||||
|
}
|
||||||
|
else if (isset($_POST['selection']))
|
||||||
|
{
|
||||||
|
$collection = $_POST['selection'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | global mode form submission |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// $page['prefilter'] is a shortcut to test if the current filter contains a
|
||||||
|
// given prefilter. The idea is to make conditions simpler to write in the
|
||||||
|
// code.
|
||||||
|
$page['prefilter'] = 'none';
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['prefilter']))
|
||||||
|
{
|
||||||
|
$page['prefilter'] = $_SESSION['bulk_manager_filter']['prefilter'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
|
||||||
|
|
||||||
|
if (isset($_POST['submit']))
|
||||||
|
{
|
||||||
|
// if the user tries to apply an action, it means that there is at least 1
|
||||||
|
// photo in the selection
|
||||||
|
if (count($collection) == 0)
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('Select at least one photo');
|
||||||
|
}
|
||||||
|
|
||||||
|
$action = $_POST['selectAction'];
|
||||||
|
|
||||||
|
if ('remove_from_caddie' == $action)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.CADDIE_TABLE.'
|
||||||
|
WHERE element_id IN ('.implode(',', $collection).')
|
||||||
|
AND user_id = '.$user['id'].'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
// remove from caddie action available only in caddie so reload content
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('add_tags' == $action)
|
||||||
|
{
|
||||||
|
if (empty($_POST['add_tags']))
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('Select at least one tag');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$tag_ids = get_tag_ids($_POST['add_tags']);
|
||||||
|
add_tags($tag_ids, $collection);
|
||||||
|
|
||||||
|
if ('no_tag' == $page['prefilter'])
|
||||||
|
{
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('del_tags' == $action)
|
||||||
|
{
|
||||||
|
if (isset($_POST['del_tags']) and count($_POST['del_tags']) > 0)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.IMAGE_TAG_TABLE.'
|
||||||
|
WHERE image_id IN ('.implode(',', $collection).')
|
||||||
|
AND tag_id IN ('.implode(',', $_POST['del_tags']).')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('Select at least one tag');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('associate' == $action)
|
||||||
|
{
|
||||||
|
associate_images_to_categories(
|
||||||
|
$collection,
|
||||||
|
array($_POST['associate'])
|
||||||
|
);
|
||||||
|
|
||||||
|
$_SESSION['page_infos'] = array(
|
||||||
|
l10n('Information data registered in database')
|
||||||
|
);
|
||||||
|
|
||||||
|
// let's refresh the page because we the current set might be modified
|
||||||
|
if ('no_album' == $page['prefilter'])
|
||||||
|
{
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('no_virtual_album' == $page['prefilter'])
|
||||||
|
{
|
||||||
|
$category_info = get_cat_info($_POST['associate']);
|
||||||
|
if (empty($category_info['dir']))
|
||||||
|
{
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('move' == $action)
|
||||||
|
{
|
||||||
|
move_images_to_categories($collection, array($_POST['move']));
|
||||||
|
|
||||||
|
$_SESSION['page_infos'] = array(
|
||||||
|
l10n('Information data registered in database')
|
||||||
|
);
|
||||||
|
|
||||||
|
// let's refresh the page because we the current set might be modified
|
||||||
|
if ('no_album' == $page['prefilter'])
|
||||||
|
{
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('no_virtual_album' == $page['prefilter'])
|
||||||
|
{
|
||||||
|
$category_info = get_cat_info($_POST['move']);
|
||||||
|
if (empty($category_info['dir']))
|
||||||
|
{
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['category'])
|
||||||
|
and $_POST['move'] != $_SESSION['bulk_manager_filter']['category'])
|
||||||
|
{
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('dissociate' == $action)
|
||||||
|
{
|
||||||
|
// physical links must not be broken, so we must first retrieve image_id
|
||||||
|
// which create virtual links with the category to "dissociate from".
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||||
|
INNER JOIN '.IMAGES_TABLE.' ON image_id = id
|
||||||
|
WHERE category_id = '.$_POST['dissociate'].'
|
||||||
|
AND id IN ('.implode(',', $collection).')
|
||||||
|
AND (
|
||||||
|
category_id != storage_category_id
|
||||||
|
OR storage_category_id IS NULL
|
||||||
|
)
|
||||||
|
;';
|
||||||
|
$dissociables = array_from_query($query, 'id');
|
||||||
|
|
||||||
|
if (!empty($dissociables))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||||
|
WHERE category_id = '.$_POST['dissociate'].'
|
||||||
|
AND image_id IN ('.implode(',', $dissociables).')
|
||||||
|
';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
$_SESSION['page_infos'] = array(
|
||||||
|
l10n('Information data registered in database')
|
||||||
|
);
|
||||||
|
|
||||||
|
// let's refresh the page because the current set might be modified
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// author
|
||||||
|
if ('author' == $action)
|
||||||
|
{
|
||||||
|
if (isset($_POST['remove_author']))
|
||||||
|
{
|
||||||
|
$_POST['author'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas = array();
|
||||||
|
foreach ($collection as $image_id)
|
||||||
|
{
|
||||||
|
$datas[] = array(
|
||||||
|
'id' => $image_id,
|
||||||
|
'author' => $_POST['author']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
mass_updates(
|
||||||
|
IMAGES_TABLE,
|
||||||
|
array('primary' => array('id'), 'update' => array('author')),
|
||||||
|
$datas
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// title
|
||||||
|
if ('title' == $action)
|
||||||
|
{
|
||||||
|
if (isset($_POST['remove_title']))
|
||||||
|
{
|
||||||
|
$_POST['title'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas = array();
|
||||||
|
foreach ($collection as $image_id)
|
||||||
|
{
|
||||||
|
$datas[] = array(
|
||||||
|
'id' => $image_id,
|
||||||
|
'name' => $_POST['title']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
mass_updates(
|
||||||
|
IMAGES_TABLE,
|
||||||
|
array('primary' => array('id'), 'update' => array('name')),
|
||||||
|
$datas
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// date_creation
|
||||||
|
if ('date_creation' == $action)
|
||||||
|
{
|
||||||
|
$date_creation = sprintf(
|
||||||
|
'%u-%u-%u',
|
||||||
|
$_POST['date_creation_year'],
|
||||||
|
$_POST['date_creation_month'],
|
||||||
|
$_POST['date_creation_day']
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isset($_POST['remove_date_creation']))
|
||||||
|
{
|
||||||
|
$date_creation = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas = array();
|
||||||
|
foreach ($collection as $image_id)
|
||||||
|
{
|
||||||
|
$datas[] = array(
|
||||||
|
'id' => $image_id,
|
||||||
|
'date_creation' => $date_creation
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
mass_updates(
|
||||||
|
IMAGES_TABLE,
|
||||||
|
array('primary' => array('id'), 'update' => array('date_creation')),
|
||||||
|
$datas
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// privacy_level
|
||||||
|
if ('level' == $action)
|
||||||
|
{
|
||||||
|
$datas = array();
|
||||||
|
foreach ($collection as $image_id)
|
||||||
|
{
|
||||||
|
$datas[] = array(
|
||||||
|
'id' => $image_id,
|
||||||
|
'level' => $_POST['level']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
mass_updates(
|
||||||
|
IMAGES_TABLE,
|
||||||
|
array('primary' => array('id'), 'update' => array('level')),
|
||||||
|
$datas
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['level']))
|
||||||
|
{
|
||||||
|
if ($_POST['level'] < $_SESSION['bulk_manager_filter']['level'])
|
||||||
|
{
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add_to_caddie
|
||||||
|
if ('add_to_caddie' == $action)
|
||||||
|
{
|
||||||
|
fill_caddie($collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete
|
||||||
|
if ('delete' == $action)
|
||||||
|
{
|
||||||
|
if (isset($_POST['confirm_deletion']) and 1 == $_POST['confirm_deletion'])
|
||||||
|
{
|
||||||
|
$deleted_count = delete_elements($collection, true);
|
||||||
|
if ($deleted_count > 0)
|
||||||
|
{
|
||||||
|
$_SESSION['page_infos'][] = l10n_dec(
|
||||||
|
'%d photo was deleted', '%d photos were deleted',
|
||||||
|
$deleted_count
|
||||||
|
);
|
||||||
|
|
||||||
|
$redirect_url = get_root_url().'admin.php?page='.$_GET['page'];
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('No photo can be deleted');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('You need to confirm deletion');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// synchronize metadata
|
||||||
|
if ('metadata' == $action)
|
||||||
|
{
|
||||||
|
sync_metadata($collection);
|
||||||
|
$page['infos'][] = l10n('Metadata synchronized from file');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('delete_derivatives' == $action)
|
||||||
|
{
|
||||||
|
$query='SELECT path,representative_ext FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', $collection).')';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($info = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
foreach( $_POST['del_derivatives_type'] as $type)
|
||||||
|
{
|
||||||
|
delete_element_derivatives($info, $type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('generate_derivatives' == $action)
|
||||||
|
{
|
||||||
|
if ($_POST['regenerateSuccess'] != '0')
|
||||||
|
{
|
||||||
|
$page['infos'][] = l10n('%s photos have been regenerated', $_POST['regenerateSuccess']);
|
||||||
|
}
|
||||||
|
if ($_POST['regenerateError'] != '0')
|
||||||
|
{
|
||||||
|
$page['warnings'][] = l10n('%s photos can not be regenerated', $_POST['regenerateError']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger_action('element_set_global_action', $action, $collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$template->set_filenames(array('batch_manager_global' => 'batch_manager_global.tpl'));
|
||||||
|
|
||||||
|
$base_url = get_root_url().'admin.php';
|
||||||
|
|
||||||
|
$prefilters = array(
|
||||||
|
array('ID' => 'caddie', 'NAME' => l10n('Caddie')),
|
||||||
|
array('ID' => 'favorites', 'NAME' => l10n('Your favorites')),
|
||||||
|
array('ID' => 'last_import', 'NAME' => l10n('Last import')),
|
||||||
|
array('ID' => 'no_album', 'NAME' => l10n('With no album')),
|
||||||
|
array('ID' => 'no_tag', 'NAME' => l10n('With no tag')),
|
||||||
|
array('ID' => 'duplicates', 'NAME' => l10n('Duplicates')),
|
||||||
|
array('ID' => 'all_photos', 'NAME' => l10n('All'))
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($conf['enable_synchronization'])
|
||||||
|
{
|
||||||
|
$prefilters[] = array('ID' => 'no_virtual_album', 'NAME' => l10n('With no virtual album'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$prefilters = trigger_event('get_batch_manager_prefilters', $prefilters);
|
||||||
|
usort($prefilters, 'UC_name_compare');
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'prefilters' => $prefilters,
|
||||||
|
'filter' => $_SESSION['bulk_manager_filter'],
|
||||||
|
'selection' => $collection,
|
||||||
|
'all_elements' => $page['cat_elements_id'],
|
||||||
|
'START' => $page['start'],
|
||||||
|
'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')),
|
||||||
|
'F_ACTION'=>$base_url.get_query_string_diff(array('cat','start','tag','filter')),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | caddie options |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$template->assign('IN_CADDIE', 'caddie' == $page['prefilter']);
|
||||||
|
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | global mode form |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// privacy level
|
||||||
|
foreach ($conf['available_permission_levels'] as $level)
|
||||||
|
{
|
||||||
|
$level_options[$level] = l10n(sprintf('Level %d', $level));
|
||||||
|
|
||||||
|
if (0 == $level)
|
||||||
|
{
|
||||||
|
$level_options[$level] = l10n('Everybody');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'filter_level_options'=> $level_options,
|
||||||
|
'filter_level_options_selected' => isset($_SESSION['bulk_manager_filter']['level'])
|
||||||
|
? $_SESSION['bulk_manager_filter']['level']
|
||||||
|
: 0,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// tags
|
||||||
|
if (!empty($_SESSION['bulk_manager_filter']['tags']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name
|
||||||
|
FROM '.TAGS_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', $_SESSION['bulk_manager_filter']['tags']).')
|
||||||
|
;';
|
||||||
|
$template->assign('filter_tags', get_taglist($query));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Virtualy associate a picture to a category
|
||||||
|
$query = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
;';
|
||||||
|
$categories = array_from_query($query);
|
||||||
|
usort($categories, 'global_rank_compare');
|
||||||
|
display_select_categories($categories, array(), 'category_full_name_options', true);
|
||||||
|
|
||||||
|
display_select_cat_wrapper($query, array(), 'category_parent_options');
|
||||||
|
|
||||||
|
// in the filter box, which category to select by default
|
||||||
|
$selected_category = array();
|
||||||
|
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['category']))
|
||||||
|
{
|
||||||
|
$selected_category = array($_SESSION['bulk_manager_filter']['category']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we need to know the category in which the last photo was added
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
category_id,
|
||||||
|
id_uppercat
|
||||||
|
FROM '.IMAGES_TABLE.' AS i
|
||||||
|
JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON image_id = i.id
|
||||||
|
JOIN '.CATEGORIES_TABLE.' AS c ON category_id = c.id
|
||||||
|
ORDER BY i.id DESC
|
||||||
|
LIMIT 1
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
if (pwg_db_num_rows($result) > 0)
|
||||||
|
{
|
||||||
|
$row = pwg_db_fetch_assoc($result);
|
||||||
|
$selected_category = array($row['category_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign( 'filter_category_selected', $selected_category);
|
||||||
|
|
||||||
|
// Dissociate from a category : categories listed for dissociation can only
|
||||||
|
// represent virtual links. We can't create orphans. Links to physical
|
||||||
|
// categories can't be broken.
|
||||||
|
if (count($page['cat_elements_id']) > 0)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
DISTINCT(category_id) AS id,
|
||||||
|
c.name,
|
||||||
|
c.uppercats,
|
||||||
|
c.global_rank
|
||||||
|
FROM '.IMAGE_CATEGORY_TABLE.' AS ic
|
||||||
|
JOIN '.CATEGORIES_TABLE.' AS c ON c.id = ic.category_id
|
||||||
|
JOIN '.IMAGES_TABLE.' AS i ON i.id = ic.image_id
|
||||||
|
WHERE ic.image_id IN ('.implode(',', $page['cat_elements_id']).')
|
||||||
|
AND (
|
||||||
|
ic.category_id != i.storage_category_id
|
||||||
|
OR i.storage_category_id IS NULL
|
||||||
|
)
|
||||||
|
;';
|
||||||
|
display_select_cat_wrapper($query, array(), 'dissociate_options', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($page['cat_elements_id']) > 0)
|
||||||
|
{
|
||||||
|
// remove tags
|
||||||
|
$tags = get_common_tags($page['cat_elements_id'], -1);
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'DEL_TAG_SELECTION' => get_html_tag_selection($tags, 'del_tags'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// creation date
|
||||||
|
$day =
|
||||||
|
empty($_POST['date_creation_day']) ? date('j') : $_POST['date_creation_day'];
|
||||||
|
|
||||||
|
$month =
|
||||||
|
empty($_POST['date_creation_month']) ? date('n') : $_POST['date_creation_month'];
|
||||||
|
|
||||||
|
$year =
|
||||||
|
empty($_POST['date_creation_year']) ? date('Y') : $_POST['date_creation_year'];
|
||||||
|
|
||||||
|
$month_list = $lang['month'];
|
||||||
|
$month_list[0]='------------';
|
||||||
|
ksort($month_list);
|
||||||
|
$template->assign( array(
|
||||||
|
'month_list' => $month_list,
|
||||||
|
'DATE_CREATION_DAY' => (int)$day,
|
||||||
|
'DATE_CREATION_MONTH'=> (int)$month,
|
||||||
|
'DATE_CREATION_YEAR' => (int)$year,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// image level options
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'level_options'=> get_privacy_level_options(),
|
||||||
|
'level_options_selected' => 0,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// metadata
|
||||||
|
include_once( PHPWG_ROOT_PATH.'admin/site_reader_local.php');
|
||||||
|
$site_reader = new LocalSiteReader('./');
|
||||||
|
$used_metadata = implode( ', ', $site_reader->get_metadata_attributes());
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'used_metadata' => $used_metadata,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
//derivatives
|
||||||
|
$del_deriv_map = array();
|
||||||
|
foreach(ImageStdParams::get_defined_type_map() as $params)
|
||||||
|
{
|
||||||
|
$del_deriv_map[$params->type] = l10n($params->type);
|
||||||
|
}
|
||||||
|
$gen_deriv_map = $del_deriv_map;
|
||||||
|
$del_deriv_map[IMG_CUSTOM] = l10n(IMG_CUSTOM);
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'del_derivatives_types' => $del_deriv_map,
|
||||||
|
'generate_derivatives_types' => $gen_deriv_map,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | global mode thumbnails |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// how many items to display on this page
|
||||||
|
if (!empty($_GET['display']))
|
||||||
|
{
|
||||||
|
if ('all' == $_GET['display'])
|
||||||
|
{
|
||||||
|
$page['nb_images'] = count($page['cat_elements_id']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['nb_images'] = intval($_GET['display']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['nb_images'] = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nb_thumbs_page = 0;
|
||||||
|
|
||||||
|
if (count($page['cat_elements_id']) > 0)
|
||||||
|
{
|
||||||
|
$nav_bar = create_navigation_bar(
|
||||||
|
$base_url.get_query_string_diff(array('start')),
|
||||||
|
count($page['cat_elements_id']),
|
||||||
|
$page['start'],
|
||||||
|
$page['nb_images']
|
||||||
|
);
|
||||||
|
$template->assign('navbar', $nav_bar);
|
||||||
|
|
||||||
|
$is_category = false;
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['category'])
|
||||||
|
and !isset($_SESSION['bulk_manager_filter']['category_recursive']))
|
||||||
|
{
|
||||||
|
$is_category = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['prefilter'])
|
||||||
|
and 'duplicates' == $_SESSION['bulk_manager_filter']['prefilter'])
|
||||||
|
{
|
||||||
|
$conf['order_by'] = ' ORDER BY file, id';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id,path,representative_ext,file,filesize,level,name,width,height,rotation
|
||||||
|
FROM '.IMAGES_TABLE;
|
||||||
|
|
||||||
|
if ($is_category)
|
||||||
|
{
|
||||||
|
$category_info = get_cat_info($_SESSION['bulk_manager_filter']['category']);
|
||||||
|
|
||||||
|
$conf['order_by'] = $conf['order_by_inside_category'];
|
||||||
|
if (!empty($category_info['image_order']))
|
||||||
|
{
|
||||||
|
$conf['order_by'] = ' ORDER BY '.$category_info['image_order'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$query.= '
|
||||||
|
JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query.= '
|
||||||
|
WHERE id IN ('.implode(',', $page['cat_elements_id']).')';
|
||||||
|
|
||||||
|
if ($is_category)
|
||||||
|
{
|
||||||
|
$query.= '
|
||||||
|
AND category_id = '.$_SESSION['bulk_manager_filter']['category'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$query.= '
|
||||||
|
'.$conf['order_by'].'
|
||||||
|
LIMIT '.$page['nb_images'].' OFFSET '.$page['start'].'
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
|
||||||
|
$thumb_params = ImageStdParams::get_by_type(IMG_THUMB);
|
||||||
|
// template thumbnail initialization
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$nb_thumbs_page++;
|
||||||
|
$src_image = new SrcImage($row);
|
||||||
|
|
||||||
|
$ttitle = render_element_name($row);
|
||||||
|
if ($ttitle != get_name_from_file($row['file']))
|
||||||
|
{
|
||||||
|
$ttitle.= ' ('.$row['file'].')';
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->append(
|
||||||
|
'thumbnails', array_merge($row,
|
||||||
|
array(
|
||||||
|
'thumb' => new DerivativeImage($thumb_params, $src_image),
|
||||||
|
'TITLE' => $ttitle,
|
||||||
|
'FILE_SRC' => DerivativeImage::url(IMG_LARGE, $src_image),
|
||||||
|
'U_EDIT' => get_root_url().'admin.php?page=photo-'.$row['id'],
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
$template->assign('thumb_params', $thumb_params);
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'nb_thumbs_page' => $nb_thumbs_page,
|
||||||
|
'nb_thumbs_set' => count($page['cat_elements_id']),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
trigger_action('loc_end_element_set_global');
|
||||||
|
|
||||||
|
//----------------------------------------------------------- sending html code
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'batch_manager_global');
|
||||||
|
?>
|
287
sources/admin/batch_manager_unit.php
Normal file
287
sources/admin/batch_manager_unit.php
Normal file
|
@ -0,0 +1,287 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Management of elements set. Elements can belong to a category or to the
|
||||||
|
* user caddie.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die('Hacking attempt!');
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
trigger_action('loc_begin_element_set_unit');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | unit mode form submission |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (isset($_POST['submit']))
|
||||||
|
{
|
||||||
|
$collection = explode(',', $_POST['element_ids']);
|
||||||
|
|
||||||
|
$datas = array();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id, date_creation
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', $collection).')
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
$data['id'] = $row['id'];
|
||||||
|
$data['name'] = $_POST['name-'.$row['id']];
|
||||||
|
$data['author'] = $_POST['author-'.$row['id']];
|
||||||
|
$data['level'] = $_POST['level-'.$row['id']];
|
||||||
|
|
||||||
|
if ($conf['allow_html_descriptions'])
|
||||||
|
{
|
||||||
|
$data['comment'] = @$_POST['description-'.$row['id']];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$data['comment'] = strip_tags(@$_POST['description-'.$row['id']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['date_creation_action-'.$row['id']]))
|
||||||
|
{
|
||||||
|
if ('set' == $_POST['date_creation_action-'.$row['id']])
|
||||||
|
{
|
||||||
|
$data['date_creation'] =
|
||||||
|
$_POST['date_creation_year-'.$row['id']]
|
||||||
|
.'-'.$_POST['date_creation_month-'.$row['id']]
|
||||||
|
.'-'.$_POST['date_creation_day-'.$row['id']];
|
||||||
|
}
|
||||||
|
else if ('unset' == $_POST['date_creation_action-'.$row['id']])
|
||||||
|
{
|
||||||
|
$data['date_creation'] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$data['date_creation'] = $row['date_creation'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas[] = $data;
|
||||||
|
|
||||||
|
// tags management
|
||||||
|
$tag_ids = array();
|
||||||
|
if (!empty($_POST[ 'tags-'.$row['id'] ]))
|
||||||
|
{
|
||||||
|
$tag_ids = get_tag_ids($_POST[ 'tags-'.$row['id'] ]);
|
||||||
|
}
|
||||||
|
set_tags($tag_ids, $row['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
mass_updates(
|
||||||
|
IMAGES_TABLE,
|
||||||
|
array(
|
||||||
|
'primary' => array('id'),
|
||||||
|
'update' => array('name','author','level','comment','date_creation')
|
||||||
|
),
|
||||||
|
$datas
|
||||||
|
);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('Photo informations updated');
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->set_filenames(
|
||||||
|
array('batch_manager_unit' => 'batch_manager_unit.tpl'));
|
||||||
|
|
||||||
|
$base_url = PHPWG_ROOT_PATH.'admin.php';
|
||||||
|
|
||||||
|
$month_list = $lang['month'];
|
||||||
|
$month_list[0]='------------';
|
||||||
|
ksort($month_list);
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'U_ELEMENTS_PAGE' => $base_url.get_query_string_diff(array('display','start')),
|
||||||
|
'F_ACTION'=>$base_url.get_query_string_diff(array()),
|
||||||
|
'month_list' => $month_list,
|
||||||
|
'level_options' => get_privacy_level_options(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | global mode thumbnails |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// how many items to display on this page
|
||||||
|
if (!empty($_GET['display']))
|
||||||
|
{
|
||||||
|
if ('all' == $_GET['display'])
|
||||||
|
{
|
||||||
|
$page['nb_images'] = count($page['cat_elements_id']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['nb_images'] = intval($_GET['display']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['nb_images'] = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (count($page['cat_elements_id']) > 0)
|
||||||
|
{
|
||||||
|
$nav_bar = create_navigation_bar(
|
||||||
|
$base_url.get_query_string_diff(array('start')),
|
||||||
|
count($page['cat_elements_id']),
|
||||||
|
$page['start'],
|
||||||
|
$page['nb_images']
|
||||||
|
);
|
||||||
|
$template->assign(array('navbar' => $nav_bar));
|
||||||
|
|
||||||
|
$element_ids = array();
|
||||||
|
|
||||||
|
$is_category = false;
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['category'])
|
||||||
|
and !isset($_SESSION['bulk_manager_filter']['category_recursive']))
|
||||||
|
{
|
||||||
|
$is_category = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_SESSION['bulk_manager_filter']['prefilter'])
|
||||||
|
and 'duplicates' == $_SESSION['bulk_manager_filter']['prefilter'])
|
||||||
|
{
|
||||||
|
$conf['order_by'] = ' ORDER BY file, id';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT *
|
||||||
|
FROM '.IMAGES_TABLE;
|
||||||
|
|
||||||
|
if ($is_category)
|
||||||
|
{
|
||||||
|
$category_info = get_cat_info($_SESSION['bulk_manager_filter']['category']);
|
||||||
|
|
||||||
|
$conf['order_by'] = $conf['order_by_inside_category'];
|
||||||
|
if (!empty($category_info['image_order']))
|
||||||
|
{
|
||||||
|
$conf['order_by'] = ' ORDER BY '.$category_info['image_order'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$query.= '
|
||||||
|
JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query.= '
|
||||||
|
WHERE id IN ('.implode(',', $page['cat_elements_id']).')';
|
||||||
|
|
||||||
|
if ($is_category)
|
||||||
|
{
|
||||||
|
$query.= '
|
||||||
|
AND category_id = '.$_SESSION['bulk_manager_filter']['category'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$query.= '
|
||||||
|
'.$conf['order_by'].'
|
||||||
|
LIMIT '.$page['nb_images'].' OFFSET '.$page['start'].'
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$element_ids[] = $row['id'];
|
||||||
|
|
||||||
|
$src_image = new SrcImage($row);
|
||||||
|
|
||||||
|
// creation date
|
||||||
|
if (!empty($row['date_creation']))
|
||||||
|
{
|
||||||
|
list($year,$month,$day) = explode('-', $row['date_creation']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list($year,$month,$day) = array('',0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name
|
||||||
|
FROM '.IMAGE_TAG_TABLE.' AS it
|
||||||
|
JOIN '.TAGS_TABLE.' AS t ON t.id = it.tag_id
|
||||||
|
WHERE image_id = '.$row['id'].'
|
||||||
|
;';
|
||||||
|
$tag_selection = get_taglist($query);
|
||||||
|
|
||||||
|
$legend = render_element_name($row);
|
||||||
|
if ($legend != get_name_from_file($row['file']))
|
||||||
|
{
|
||||||
|
$legend.= ' ('.$row['file'].')';
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->append(
|
||||||
|
'elements', array_merge($row,
|
||||||
|
array(
|
||||||
|
'ID' => $row['id'],
|
||||||
|
'TN_SRC' => DerivativeImage::url(IMG_THUMB, $src_image),
|
||||||
|
'FILE_SRC' => DerivativeImage::url(IMG_LARGE, $src_image),
|
||||||
|
'LEGEND' => $legend,
|
||||||
|
'U_EDIT' => get_root_url().'admin.php?page=photo-'.$row['id'],
|
||||||
|
'NAME' => htmlspecialchars(@$row['name']),
|
||||||
|
'AUTHOR' => htmlspecialchars(@$row['author']),
|
||||||
|
'LEVEL' => !empty($row['level'])?$row['level']:'0',
|
||||||
|
'DESCRIPTION' => htmlspecialchars(@$row['comment']),
|
||||||
|
'DATE_CREATION_YEAR' => $year,
|
||||||
|
'DATE_CREATION_MONTH' => (int)$month,
|
||||||
|
'DATE_CREATION_DAY' => (int)$day,
|
||||||
|
'TAGS' => $tag_selection,
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign('ELEMENT_IDS', implode(',', $element_ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger_action('loc_end_element_set_unit');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'batch_manager_unit');
|
||||||
|
?>
|
372
sources/admin/cat_list.php
Normal file
372
sources/admin/cat_list.php
Normal file
|
@ -0,0 +1,372 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die('Hacking attempt!');
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
trigger_action('loc_begin_cat_list');
|
||||||
|
|
||||||
|
if (!empty($_POST) or isset($_GET['delete']))
|
||||||
|
{
|
||||||
|
check_pwg_token();
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | functions |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save the rank depending on given categories order
|
||||||
|
*
|
||||||
|
* The list of ordered categories id is supposed to be in the same parent
|
||||||
|
* category
|
||||||
|
*
|
||||||
|
* @param array categories
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function save_categories_order($categories)
|
||||||
|
{
|
||||||
|
$current_rank_for_id_uppercat = array();
|
||||||
|
$current_rank = 0;
|
||||||
|
|
||||||
|
$datas = array();
|
||||||
|
foreach ($categories as $category)
|
||||||
|
{
|
||||||
|
if (is_array($category))
|
||||||
|
{
|
||||||
|
$id = $category['id'];
|
||||||
|
$id_uppercat = $category['id_uppercat'];
|
||||||
|
|
||||||
|
if (!isset($current_rank_for_id_uppercat[$id_uppercat]))
|
||||||
|
{
|
||||||
|
$current_rank_for_id_uppercat[$id_uppercat] = 0;
|
||||||
|
}
|
||||||
|
$current_rank = ++$current_rank_for_id_uppercat[$id_uppercat];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$id = $category;
|
||||||
|
$current_rank++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas[] = array('id' => $id, 'rank' => $current_rank);
|
||||||
|
}
|
||||||
|
$fields = array('primary' => array('id'), 'update' => array('rank'));
|
||||||
|
mass_updates(CATEGORIES_TABLE, $fields, $datas);
|
||||||
|
|
||||||
|
update_global_rank();
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | initialization |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
check_input_parameter('parent_id', $_GET, false, PATTERN_ID);
|
||||||
|
|
||||||
|
$categories = array();
|
||||||
|
|
||||||
|
$base_url = get_root_url().'admin.php?page=cat_list';
|
||||||
|
$navigation = '<a href="'.$base_url.'">';
|
||||||
|
$navigation.= l10n('Home');
|
||||||
|
$navigation.= '</a>';
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | tabs |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$page['tab'] = 'list';
|
||||||
|
include(PHPWG_ROOT_PATH.'admin/include/albums_tab.inc.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | virtual categories management |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// request to delete a virtual category
|
||||||
|
if (isset($_GET['delete']) and is_numeric($_GET['delete']))
|
||||||
|
{
|
||||||
|
delete_categories(array($_GET['delete']));
|
||||||
|
$_SESSION['page_infos'] = array(l10n('Virtual album deleted'));
|
||||||
|
update_global_rank();
|
||||||
|
invalidate_user_cache();
|
||||||
|
|
||||||
|
$redirect_url = get_root_url().'admin.php?page=cat_list';
|
||||||
|
if (isset($_GET['parent_id']))
|
||||||
|
{
|
||||||
|
$redirect_url.= '&parent_id='.$_GET['parent_id'];
|
||||||
|
}
|
||||||
|
redirect($redirect_url);
|
||||||
|
}
|
||||||
|
// request to add a virtual category
|
||||||
|
elseif (isset($_POST['submitAdd']))
|
||||||
|
{
|
||||||
|
$output_create = create_virtual_category(
|
||||||
|
$_POST['virtual_name'],
|
||||||
|
@$_GET['parent_id']
|
||||||
|
);
|
||||||
|
|
||||||
|
invalidate_user_cache();
|
||||||
|
if (isset($output_create['error']))
|
||||||
|
{
|
||||||
|
$page['errors'][] = $output_create['error'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['infos'][] = $output_create['info'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// save manual category ordering
|
||||||
|
elseif (isset($_POST['submitManualOrder']))
|
||||||
|
{
|
||||||
|
asort($_POST['catOrd'], SORT_NUMERIC);
|
||||||
|
save_categories_order(array_keys($_POST['catOrd']));
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('Album manual order was saved');
|
||||||
|
}
|
||||||
|
elseif (isset($_POST['submitAutoOrder']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE id_uppercat '.
|
||||||
|
(!isset($_GET['parent_id']) ? 'IS NULL' : '= '.$_GET['parent_id']).'
|
||||||
|
;';
|
||||||
|
$category_ids = array_from_query($query, 'id');
|
||||||
|
|
||||||
|
if (isset($_POST['recursive']))
|
||||||
|
{
|
||||||
|
$category_ids = get_subcat_ids($category_ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
$categories = array();
|
||||||
|
$names = array();
|
||||||
|
$id_uppercats = array();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id, name, id_uppercat
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', $category_ids).')
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$categories[] = array(
|
||||||
|
'id' => $row['id'],
|
||||||
|
'id_uppercat' => $row['id_uppercat'],
|
||||||
|
);
|
||||||
|
$names[] = $row['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
array_multisort(
|
||||||
|
$names,
|
||||||
|
SORT_REGULAR,
|
||||||
|
'asc' == $_POST['ascdesc'] ? SORT_ASC : SORT_DESC,
|
||||||
|
$categories
|
||||||
|
);
|
||||||
|
save_categories_order($categories);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('Albums automatically sorted');
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Navigation path |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (isset($_GET['parent_id']))
|
||||||
|
{
|
||||||
|
$navigation.= $conf['level_separator'];
|
||||||
|
|
||||||
|
$navigation.= get_cat_display_name_from_id(
|
||||||
|
$_GET['parent_id'],
|
||||||
|
$base_url.'&parent_id='
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template initialization |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$template->set_filename('categories', 'cat_list.tpl');
|
||||||
|
|
||||||
|
$form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_list';
|
||||||
|
if (isset($_GET['parent_id']))
|
||||||
|
{
|
||||||
|
$form_action.= '&parent_id='.$_GET['parent_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign(array(
|
||||||
|
'CATEGORIES_NAV'=>$navigation,
|
||||||
|
'F_ACTION'=>$form_action,
|
||||||
|
'PWG_TOKEN' => get_pwg_token(),
|
||||||
|
));
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Categories display |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$categories = array();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id, name, permalink, dir, rank, status
|
||||||
|
FROM '.CATEGORIES_TABLE;
|
||||||
|
if (!isset($_GET['parent_id']))
|
||||||
|
{
|
||||||
|
$query.= '
|
||||||
|
WHERE id_uppercat IS NULL';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query.= '
|
||||||
|
WHERE id_uppercat = '.$_GET['parent_id'];
|
||||||
|
}
|
||||||
|
$query.= '
|
||||||
|
ORDER BY rank ASC
|
||||||
|
;';
|
||||||
|
$categories = hash_from_query($query, 'id');
|
||||||
|
|
||||||
|
// get the categories containing images directly
|
||||||
|
$categories_with_images = array();
|
||||||
|
if (count($categories))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
category_id,
|
||||||
|
COUNT(*) AS nb_photos
|
||||||
|
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||||
|
GROUP BY category_id
|
||||||
|
;';
|
||||||
|
// WHERE category_id IN ('.implode(',', array_keys($categories)).')
|
||||||
|
|
||||||
|
$nb_photos_in = query2array($query, 'category_id', 'nb_photos');
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
uppercats
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
;';
|
||||||
|
$all_categories = query2array($query, 'id', 'uppercats');
|
||||||
|
$subcats_of = array();
|
||||||
|
|
||||||
|
foreach (array_keys($categories) as $cat_id)
|
||||||
|
{
|
||||||
|
foreach ($all_categories as $id => $uppercats)
|
||||||
|
{
|
||||||
|
if (preg_match('/(^|,)'.$cat_id.',/', $uppercats))
|
||||||
|
{
|
||||||
|
@$subcats_of[$cat_id][] = $id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$nb_sub_photos = array();
|
||||||
|
foreach ($subcats_of as $cat_id => $subcat_ids)
|
||||||
|
{
|
||||||
|
$nb_photos = 0;
|
||||||
|
foreach ($subcat_ids as $id)
|
||||||
|
{
|
||||||
|
if (isset($nb_photos_in[$id]))
|
||||||
|
{
|
||||||
|
$nb_photos+= $nb_photos_in[$id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$nb_sub_photos[$cat_id] = $nb_photos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign('categories', array());
|
||||||
|
$base_url = get_root_url().'admin.php?page=';
|
||||||
|
|
||||||
|
if (isset($_GET['parent_id']))
|
||||||
|
{
|
||||||
|
$template->assign(
|
||||||
|
'PARENT_EDIT',
|
||||||
|
$base_url.'album-'.$_GET['parent_id']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($categories as $category)
|
||||||
|
{
|
||||||
|
$cat_list_url = $base_url.'cat_list';
|
||||||
|
|
||||||
|
$self_url = $cat_list_url;
|
||||||
|
if (isset($_GET['parent_id']))
|
||||||
|
{
|
||||||
|
$self_url.= '&parent_id='.$_GET['parent_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tpl_cat =
|
||||||
|
array(
|
||||||
|
'NAME' =>
|
||||||
|
trigger_event(
|
||||||
|
'render_category_name',
|
||||||
|
$category['name'],
|
||||||
|
'admin_cat_list'
|
||||||
|
),
|
||||||
|
'NB_PHOTOS' => isset($nb_photos_in[$category['id']]) ? $nb_photos_in[$category['id']] : 0,
|
||||||
|
'NB_SUB_PHOTOS' => isset($nb_sub_photos[$category['id']]) ? $nb_sub_photos[$category['id']] : 0,
|
||||||
|
'NB_SUB_ALBUMS' => isset($subcats_of[$category['id']]) ? count($subcats_of[$category['id']]) : 0,
|
||||||
|
'ID' => $category['id'],
|
||||||
|
'RANK' => $category['rank']*10,
|
||||||
|
|
||||||
|
'U_JUMPTO' => make_index_url(
|
||||||
|
array(
|
||||||
|
'category' => $category
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'],
|
||||||
|
'U_EDIT' => $base_url.'album-'.$category['id'],
|
||||||
|
|
||||||
|
'IS_VIRTUAL' => empty($category['dir'])
|
||||||
|
);
|
||||||
|
|
||||||
|
if (empty($category['dir']))
|
||||||
|
{
|
||||||
|
$tpl_cat['U_DELETE'] = $self_url.'&delete='.$category['id'];
|
||||||
|
$tpl_cat['U_DELETE'].= '&pwg_token='.get_pwg_token();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($conf['enable_synchronization'])
|
||||||
|
{
|
||||||
|
$tpl_cat['U_SYNC'] = $base_url.'site_update&site=1&cat_id='.$category['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->append('categories', $tpl_cat);
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger_action('loc_end_cat_list');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'categories');
|
||||||
|
?>
|
390
sources/admin/cat_modify.php
Normal file
390
sources/admin/cat_modify.php
Normal file
|
@ -0,0 +1,390 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die('Hacking attempt!');
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||||
|
|
||||||
|
|
||||||
|
// get_complete_dir returns the concatenation of get_site_url and
|
||||||
|
// get_local_dir
|
||||||
|
// Example : "pets > rex > 1_year_old" is on the the same site as the
|
||||||
|
// Piwigo files and this category has 22 for identifier
|
||||||
|
// get_complete_dir(22) returns "./galleries/pets/rex/1_year_old/"
|
||||||
|
function get_complete_dir( $category_id )
|
||||||
|
{
|
||||||
|
return get_site_url($category_id).get_local_dir($category_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get_local_dir returns an array with complete path without the site url
|
||||||
|
// Example : "pets > rex > 1_year_old" is on the the same site as the
|
||||||
|
// Piwigo files and this category has 22 for identifier
|
||||||
|
// get_local_dir(22) returns "pets/rex/1_year_old/"
|
||||||
|
function get_local_dir( $category_id )
|
||||||
|
{
|
||||||
|
global $page;
|
||||||
|
|
||||||
|
$uppercats = '';
|
||||||
|
$local_dir = '';
|
||||||
|
|
||||||
|
if ( isset( $page['plain_structure'][$category_id]['uppercats'] ) )
|
||||||
|
{
|
||||||
|
$uppercats = $page['plain_structure'][$category_id]['uppercats'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query = 'SELECT uppercats';
|
||||||
|
$query.= ' FROM '.CATEGORIES_TABLE.' WHERE id = '.$category_id;
|
||||||
|
$query.= ';';
|
||||||
|
$row = pwg_db_fetch_assoc( pwg_query( $query ) );
|
||||||
|
$uppercats = $row['uppercats'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$upper_array = explode( ',', $uppercats );
|
||||||
|
|
||||||
|
$database_dirs = array();
|
||||||
|
$query = 'SELECT id,dir';
|
||||||
|
$query.= ' FROM '.CATEGORIES_TABLE.' WHERE id IN ('.$uppercats.')';
|
||||||
|
$query.= ';';
|
||||||
|
$result = pwg_query( $query );
|
||||||
|
while( $row = pwg_db_fetch_assoc( $result ) )
|
||||||
|
{
|
||||||
|
$database_dirs[$row['id']] = $row['dir'];
|
||||||
|
}
|
||||||
|
foreach ($upper_array as $id)
|
||||||
|
{
|
||||||
|
$local_dir.= $database_dirs[$id].'/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $local_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
// retrieving the site url : "http://domain.com/gallery/" or
|
||||||
|
// simply "./galleries/"
|
||||||
|
function get_site_url($category_id)
|
||||||
|
{
|
||||||
|
global $page;
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT galleries_url
|
||||||
|
FROM '.SITES_TABLE.' AS s,'.CATEGORIES_TABLE.' AS c
|
||||||
|
WHERE s.id = c.site_id
|
||||||
|
AND c.id = '.$category_id.'
|
||||||
|
;';
|
||||||
|
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
return $row['galleries_url'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
trigger_action('loc_begin_cat_modify');
|
||||||
|
|
||||||
|
//---------------------------------------------------------------- verification
|
||||||
|
if ( !isset( $_GET['cat_id'] ) || !is_numeric( $_GET['cat_id'] ) )
|
||||||
|
{
|
||||||
|
trigger_error( 'missing cat_id param', E_USER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------- form criteria check
|
||||||
|
if (isset($_POST['submit']))
|
||||||
|
{
|
||||||
|
$data = array(
|
||||||
|
'id' => $_GET['cat_id'],
|
||||||
|
'name' => @$_POST['name'],
|
||||||
|
'comment' =>
|
||||||
|
$conf['allow_html_descriptions'] ?
|
||||||
|
@$_POST['comment'] : strip_tags(@$_POST['comment']),
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($conf['activate_comments'])
|
||||||
|
{
|
||||||
|
$data['commentable'] = isset($_POST['commentable'])?$_POST['commentable']:'false';
|
||||||
|
}
|
||||||
|
|
||||||
|
single_update(
|
||||||
|
CATEGORIES_TABLE,
|
||||||
|
$data,
|
||||||
|
array('id' => $data['id'])
|
||||||
|
);
|
||||||
|
|
||||||
|
// retrieve cat infos before continuing (following updates are expensive)
|
||||||
|
$cat_info = get_cat_info($_GET['cat_id']);
|
||||||
|
|
||||||
|
if ($cat_info['visible'] != get_boolean( $_POST['visible'] ) )
|
||||||
|
{
|
||||||
|
set_cat_visible(array($_GET['cat_id']), $_POST['visible']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// in case the use moves his album to the gallery root, we force
|
||||||
|
// $_POST['parent'] from 0 to null to be compared with
|
||||||
|
// $cat_info['id_uppercat']
|
||||||
|
if (empty($_POST['parent']))
|
||||||
|
{
|
||||||
|
$_POST['parent'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// only move virtual albums
|
||||||
|
if (empty($cat_info['dir']) and $cat_info['id_uppercat'] != $_POST['parent'])
|
||||||
|
{
|
||||||
|
move_categories( array($_GET['cat_id']), $_POST['parent'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
$_SESSION['page_infos'][] = l10n('Album updated successfully');
|
||||||
|
$redirect = true;
|
||||||
|
}
|
||||||
|
elseif (isset($_POST['set_random_representant']))
|
||||||
|
{
|
||||||
|
set_random_representant(array($_GET['cat_id']));
|
||||||
|
$redirect = true;
|
||||||
|
}
|
||||||
|
elseif (isset($_POST['delete_representant']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE '.CATEGORIES_TABLE.'
|
||||||
|
SET representative_picture_id = NULL
|
||||||
|
WHERE id = '.$_GET['cat_id'].'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
$redirect = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($redirect))
|
||||||
|
{
|
||||||
|
redirect($admin_album_base_url.'-properties');
|
||||||
|
}
|
||||||
|
|
||||||
|
// nullable fields
|
||||||
|
foreach (array('comment','dir','site_id', 'id_uppercat') as $nullable)
|
||||||
|
{
|
||||||
|
if (!isset($category[$nullable]))
|
||||||
|
{
|
||||||
|
$category[$nullable] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$category['is_virtual'] = empty($category['dir']) ? true : false;
|
||||||
|
|
||||||
|
$query = 'SELECT DISTINCT category_id
|
||||||
|
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||||
|
WHERE category_id = '.$_GET['cat_id'].'
|
||||||
|
LIMIT 1';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
$category['has_images'] = pwg_db_num_rows($result)>0 ? true : false;
|
||||||
|
|
||||||
|
// Navigation path
|
||||||
|
$navigation = get_cat_display_name_cache(
|
||||||
|
$category['uppercats'],
|
||||||
|
get_root_url().'admin.php?page=album-'
|
||||||
|
);
|
||||||
|
|
||||||
|
$form_action = $admin_album_base_url.'-properties';
|
||||||
|
|
||||||
|
//----------------------------------------------------- template initialization
|
||||||
|
$template->set_filename( 'album_properties', 'cat_modify.tpl');
|
||||||
|
|
||||||
|
$base_url = get_root_url().'admin.php?page=';
|
||||||
|
$cat_list_url = $base_url.'cat_list';
|
||||||
|
|
||||||
|
$self_url = $cat_list_url;
|
||||||
|
if (!empty($category['id_uppercat']))
|
||||||
|
{
|
||||||
|
$self_url.= '&parent_id='.$category['id_uppercat'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'CATEGORIES_NAV' => $navigation,
|
||||||
|
'CAT_ID' => $category['id'],
|
||||||
|
'CAT_NAME' => @htmlspecialchars($category['name']),
|
||||||
|
'CAT_COMMENT' => @htmlspecialchars($category['comment']),
|
||||||
|
'CAT_VISIBLE' => boolean_to_string($category['visible']),
|
||||||
|
|
||||||
|
'U_JUMPTO' => make_index_url(
|
||||||
|
array(
|
||||||
|
'category' => $category
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
'U_ADD_PHOTOS_ALBUM' => $base_url.'photos_add&album='.$category['id'],
|
||||||
|
'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'],
|
||||||
|
'U_HELP' => get_root_url().'admin/popuphelp.php?page=cat_modify',
|
||||||
|
|
||||||
|
'F_ACTION' => $form_action,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($conf['activate_comments'])
|
||||||
|
{
|
||||||
|
$template->assign('CAT_COMMENTABLE', boolean_to_string($category['commentable']));
|
||||||
|
}
|
||||||
|
|
||||||
|
// manage album elements link
|
||||||
|
if ($category['has_images'])
|
||||||
|
{
|
||||||
|
$template->assign(
|
||||||
|
'U_MANAGE_ELEMENTS',
|
||||||
|
$base_url.'batch_manager&filter=album-'.$category['id']
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
COUNT(image_id),
|
||||||
|
MIN(DATE(date_available)),
|
||||||
|
MAX(DATE(date_available))
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
|
||||||
|
WHERE category_id = '.$category['id'].'
|
||||||
|
;';
|
||||||
|
list($image_count, $min_date, $max_date) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
|
||||||
|
if ($min_date == $max_date)
|
||||||
|
{
|
||||||
|
$intro = l10n(
|
||||||
|
'This album contains %d photos, added on %s.',
|
||||||
|
$image_count,
|
||||||
|
format_date($min_date)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$intro = l10n(
|
||||||
|
'This album contains %d photos, added between %s and %s.',
|
||||||
|
$image_count,
|
||||||
|
format_date($min_date),
|
||||||
|
format_date($max_date)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$intro = l10n('This album contains no photo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$intro.= '<br>'.l10n('Numeric identifier : %d', $category['id']);
|
||||||
|
|
||||||
|
$template->assign('INTRO', $intro);
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
'U_MANAGE_RANKS',
|
||||||
|
$base_url.'element_set_ranks&cat_id='.$category['id']
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($category['is_virtual'])
|
||||||
|
{
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'U_DELETE' => $self_url.'&delete='.$category['id'].'&pwg_token='.get_pwg_token(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$category['cat_full_dir'] = get_complete_dir($_GET['cat_id']);
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'CAT_FULL_DIR' => preg_replace('/\/$/', '', $category['cat_full_dir'])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($conf['enable_synchronization'])
|
||||||
|
{
|
||||||
|
$template->assign(
|
||||||
|
'U_SYNC',
|
||||||
|
$base_url.'site_update&site=1&cat_id='.$category['id']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// representant management
|
||||||
|
if ($category['has_images']
|
||||||
|
or !empty($category['representative_picture_id']))
|
||||||
|
{
|
||||||
|
$tpl_representant = array();
|
||||||
|
|
||||||
|
// picture to display : the identified representant or the generic random
|
||||||
|
// representant ?
|
||||||
|
if (!empty($category['representative_picture_id']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT id,representative_ext,path
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE id = '.$category['representative_picture_id'].'
|
||||||
|
;';
|
||||||
|
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
$src = DerivativeImage::thumb_url($row);
|
||||||
|
$url = get_root_url().'admin.php?page=photo-'.$category['representative_picture_id'];
|
||||||
|
|
||||||
|
$tpl_representant['picture'] =
|
||||||
|
array(
|
||||||
|
'SRC' => $src,
|
||||||
|
'URL' => $url
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// can the admin choose to set a new random representant ?
|
||||||
|
$tpl_representant['ALLOW_SET_RANDOM'] = ($category['has_images']) ? true : false;
|
||||||
|
|
||||||
|
// can the admin delete the current representant ?
|
||||||
|
if (
|
||||||
|
($category['has_images']
|
||||||
|
and $conf['allow_random_representative'])
|
||||||
|
or
|
||||||
|
(!$category['has_images']
|
||||||
|
and !empty($category['representative_picture_id'])))
|
||||||
|
{
|
||||||
|
$tpl_representant['ALLOW_DELETE'] = true;
|
||||||
|
}
|
||||||
|
$template->assign('representant', $tpl_representant);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($category['is_virtual'])
|
||||||
|
{
|
||||||
|
// the category can be moved in any category but in itself, in any
|
||||||
|
// sub-category
|
||||||
|
$unmovables = get_subcat_ids(array($category['id']));
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE id NOT IN ('.implode(',', $unmovables).')
|
||||||
|
;';
|
||||||
|
|
||||||
|
display_select_cat_wrapper(
|
||||||
|
$query,
|
||||||
|
empty($category['id_uppercat']) ? array() : array($category['id_uppercat']),
|
||||||
|
'move_cat_options'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger_action('loc_end_cat_modify');
|
||||||
|
|
||||||
|
//----------------------------------------------------------- sending html code
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'album_properties');
|
||||||
|
?>
|
108
sources/admin/cat_move.php
Normal file
108
sources/admin/cat_move.php
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die('Hacking attempt!');
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | functions |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | categories movement |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (isset($_POST['submit']))
|
||||||
|
{
|
||||||
|
if (count($_POST['selection']) > 0)
|
||||||
|
{
|
||||||
|
// TODO: tests
|
||||||
|
move_categories($_POST['selection'], $_POST['parent']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('Select at least one album');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template initialization |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$template->set_filename('cat_move', 'cat_move.tpl');
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'U_HELP' => get_root_url().'admin/popuphelp.php?page=cat_move',
|
||||||
|
'F_ACTION' => get_root_url().'admin.php?page=cat_move',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | tabs |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$page['tab'] = 'move';
|
||||||
|
include(PHPWG_ROOT_PATH.'admin/include/albums_tab.inc.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Categories display |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE dir IS NULL
|
||||||
|
;';
|
||||||
|
display_select_cat_wrapper(
|
||||||
|
$query,
|
||||||
|
array(),
|
||||||
|
'category_to_move_options'
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
;';
|
||||||
|
|
||||||
|
display_select_cat_wrapper(
|
||||||
|
$query,
|
||||||
|
array(),
|
||||||
|
'category_parent_options'
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_move');
|
||||||
|
?>
|
256
sources/admin/cat_options.php
Normal file
256
sources/admin/cat_options.php
Normal file
|
@ -0,0 +1,256 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die ("Hacking attempt!");
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | modification registration |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// print '<pre>';
|
||||||
|
// print_r($_POST);
|
||||||
|
// print '</pre>';
|
||||||
|
if (isset($_POST['falsify'])
|
||||||
|
and isset($_POST['cat_true'])
|
||||||
|
and count($_POST['cat_true']) > 0)
|
||||||
|
{
|
||||||
|
switch ($_GET['section'])
|
||||||
|
{
|
||||||
|
case 'comments' :
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE '.CATEGORIES_TABLE.'
|
||||||
|
SET commentable = \'false\'
|
||||||
|
WHERE id IN ('.implode(',', $_POST['cat_true']).')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'visible' :
|
||||||
|
{
|
||||||
|
set_cat_visible($_POST['cat_true'], 'false');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'status' :
|
||||||
|
{
|
||||||
|
set_cat_status($_POST['cat_true'], 'private');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'representative' :
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE '.CATEGORIES_TABLE.'
|
||||||
|
SET representative_picture_id = NULL
|
||||||
|
WHERE id IN ('.implode(',', $_POST['cat_true']).')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isset($_POST['trueify'])
|
||||||
|
and isset($_POST['cat_false'])
|
||||||
|
and count($_POST['cat_false']) > 0)
|
||||||
|
{
|
||||||
|
switch ($_GET['section'])
|
||||||
|
{
|
||||||
|
case 'comments' :
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE '.CATEGORIES_TABLE.'
|
||||||
|
SET commentable = \'true\'
|
||||||
|
WHERE id IN ('.implode(',', $_POST['cat_false']).')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'visible' :
|
||||||
|
{
|
||||||
|
set_cat_visible($_POST['cat_false'], 'true');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'status' :
|
||||||
|
{
|
||||||
|
set_cat_status($_POST['cat_false'], 'public');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'representative' :
|
||||||
|
{
|
||||||
|
// theoretically, all categories in $_POST['cat_false'] contain at
|
||||||
|
// least one element, so Piwigo can find a representant.
|
||||||
|
set_random_representant($_POST['cat_false']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->set_filenames(
|
||||||
|
array(
|
||||||
|
'cat_options' => 'cat_options.tpl',
|
||||||
|
'double_select' => 'double_select.tpl'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$page['section'] = isset($_GET['section']) ? $_GET['section'] : 'status';
|
||||||
|
$base_url = PHPWG_ROOT_PATH.'admin.php?page=cat_options&section=';
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'U_HELP' => get_root_url().'admin/popuphelp.php?page=cat_options',
|
||||||
|
'F_ACTION'=>$base_url.$page['section']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// TabSheet
|
||||||
|
$tabsheet = new tabsheet();
|
||||||
|
$tabsheet->set_id('cat_options');
|
||||||
|
$tabsheet->select($page['section']);
|
||||||
|
$tabsheet->assign();
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | form display |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// for each section, categories in the multiselect field can be :
|
||||||
|
//
|
||||||
|
// - true : commentable for comment section
|
||||||
|
// - false : un-commentable for comment section
|
||||||
|
// - NA : (not applicable) for virtual categories
|
||||||
|
//
|
||||||
|
// for true and false status, we associates an array of category ids,
|
||||||
|
// function display_select_categories will use the given CSS class for each
|
||||||
|
// option
|
||||||
|
$cats_true = array();
|
||||||
|
$cats_false = array();
|
||||||
|
switch ($page['section'])
|
||||||
|
{
|
||||||
|
case 'comments' :
|
||||||
|
{
|
||||||
|
$query_true = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE commentable = \'true\'
|
||||||
|
;';
|
||||||
|
$query_false = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE commentable = \'false\'
|
||||||
|
;';
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'L_SECTION' => l10n('Authorize users to add comments on selected albums'),
|
||||||
|
'L_CAT_OPTIONS_TRUE' => l10n('Authorized'),
|
||||||
|
'L_CAT_OPTIONS_FALSE' => l10n('Forbidden'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'visible' :
|
||||||
|
{
|
||||||
|
$query_true = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE visible = \'true\'
|
||||||
|
;';
|
||||||
|
$query_false = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE visible = \'false\'
|
||||||
|
;';
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'L_SECTION' => l10n('Lock albums'),
|
||||||
|
'L_CAT_OPTIONS_TRUE' => l10n('Unlocked'),
|
||||||
|
'L_CAT_OPTIONS_FALSE' => l10n('Locked'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'status' :
|
||||||
|
{
|
||||||
|
$query_true = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE status = \'public\'
|
||||||
|
;';
|
||||||
|
$query_false = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE status = \'private\'
|
||||||
|
;';
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'L_SECTION' => l10n('Manage authorizations for selected albums'),
|
||||||
|
'L_CAT_OPTIONS_TRUE' => l10n('Public'),
|
||||||
|
'L_CAT_OPTIONS_FALSE' => l10n('Private'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'representative' :
|
||||||
|
{
|
||||||
|
$query_true = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE representative_picture_id IS NOT NULL
|
||||||
|
;';
|
||||||
|
$query_false = '
|
||||||
|
SELECT DISTINCT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=category_id
|
||||||
|
WHERE representative_picture_id IS NULL
|
||||||
|
;';
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'L_SECTION' => l10n('Representative'),
|
||||||
|
'L_CAT_OPTIONS_TRUE' => l10n('singly represented'),
|
||||||
|
'L_CAT_OPTIONS_FALSE' => l10n('randomly represented')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
display_select_cat_wrapper($query_true,array(),'category_option_true');
|
||||||
|
display_select_cat_wrapper($query_false,array(),'category_option_false');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('DOUBLE_SELECT', 'double_select');
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_options');
|
||||||
|
?>
|
304
sources/admin/cat_perm.php
Normal file
304
sources/admin/cat_perm.php
Normal file
|
@ -0,0 +1,304 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die ("Hacking attempt!");
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | variable initialization |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$page['cat'] = $category['id'];
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | form submission |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!empty($_POST))
|
||||||
|
{
|
||||||
|
check_pwg_token();
|
||||||
|
|
||||||
|
if ($category['status'] != $_POST['status'])
|
||||||
|
{
|
||||||
|
set_cat_status(array($page['cat']), $_POST['status']);
|
||||||
|
$category['status'] = $_POST['status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('private' == $_POST['status'])
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// manage groups
|
||||||
|
//
|
||||||
|
$query = '
|
||||||
|
SELECT group_id
|
||||||
|
FROM '.GROUP_ACCESS_TABLE.'
|
||||||
|
WHERE cat_id = '.$page['cat'].'
|
||||||
|
;';
|
||||||
|
$groups_granted = array_from_query($query, 'group_id');
|
||||||
|
|
||||||
|
if (!isset($_POST['groups']))
|
||||||
|
{
|
||||||
|
$_POST['groups'] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// remove permissions to groups
|
||||||
|
//
|
||||||
|
$deny_groups = array_diff($groups_granted, $_POST['groups']);
|
||||||
|
if (count($deny_groups) > 0)
|
||||||
|
{
|
||||||
|
// if you forbid access to an album, all sub-albums become
|
||||||
|
// automatically forbidden
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.GROUP_ACCESS_TABLE.'
|
||||||
|
WHERE group_id IN ('.implode(',', $deny_groups).')
|
||||||
|
AND cat_id IN ('.implode(',', get_subcat_ids(array($page['cat']))).')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// add permissions to groups
|
||||||
|
//
|
||||||
|
$grant_groups = $_POST['groups'];
|
||||||
|
if (count($grant_groups) > 0)
|
||||||
|
{
|
||||||
|
$cat_ids = get_uppercat_ids(array($page['cat']));
|
||||||
|
if (isset($_POST['apply_on_sub']))
|
||||||
|
{
|
||||||
|
$cat_ids = array_merge($cat_ids, get_subcat_ids(array($page['cat'])));
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', $cat_ids).')
|
||||||
|
AND status = \'private\'
|
||||||
|
;';
|
||||||
|
$private_cats = array_from_query($query, 'id');
|
||||||
|
|
||||||
|
$inserts = array();
|
||||||
|
foreach ($private_cats as $cat_id)
|
||||||
|
{
|
||||||
|
foreach ($grant_groups as $group_id)
|
||||||
|
{
|
||||||
|
$inserts[] = array(
|
||||||
|
'group_id' => $group_id,
|
||||||
|
'cat_id' => $cat_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mass_inserts(
|
||||||
|
GROUP_ACCESS_TABLE,
|
||||||
|
array('group_id','cat_id'),
|
||||||
|
$inserts,
|
||||||
|
array('ignore'=>true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// users
|
||||||
|
//
|
||||||
|
$query = '
|
||||||
|
SELECT user_id
|
||||||
|
FROM '.USER_ACCESS_TABLE.'
|
||||||
|
WHERE cat_id = '.$page['cat'].'
|
||||||
|
;';
|
||||||
|
$users_granted = array_from_query($query, 'user_id');
|
||||||
|
|
||||||
|
if (!isset($_POST['users']))
|
||||||
|
{
|
||||||
|
$_POST['users'] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// remove permissions to users
|
||||||
|
//
|
||||||
|
$deny_users = array_diff($users_granted, $_POST['users']);
|
||||||
|
if (count($deny_users) > 0)
|
||||||
|
{
|
||||||
|
// if you forbid access to an album, all sub-album become automatically
|
||||||
|
// forbidden
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.USER_ACCESS_TABLE.'
|
||||||
|
WHERE user_id IN ('.implode(',', $deny_users).')
|
||||||
|
AND cat_id IN ('.implode(',', get_subcat_ids(array($page['cat']))).')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// add permissions to users
|
||||||
|
//
|
||||||
|
$grant_users = $_POST['users'];
|
||||||
|
if (count($grant_users) > 0)
|
||||||
|
{
|
||||||
|
add_permission_on_category($page['cat'], $grant_users);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('Album updated successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template initialization |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->set_filename('cat_perm', 'cat_perm.tpl');
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'CATEGORIES_NAV' =>
|
||||||
|
get_cat_display_name_from_id(
|
||||||
|
$page['cat'],
|
||||||
|
'admin.php?page=album-'
|
||||||
|
),
|
||||||
|
'U_HELP' => get_root_url().'admin/popuphelp.php?page=cat_perm',
|
||||||
|
'F_ACTION' => $admin_album_base_url.'-permissions',
|
||||||
|
'private' => ('private' == $category['status']),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | form construction |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// groups denied are the groups not granted. So we need to find all groups
|
||||||
|
// minus groups granted to find groups denied.
|
||||||
|
|
||||||
|
$groups = array();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id, name
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
ORDER BY name ASC
|
||||||
|
;';
|
||||||
|
$groups = simple_hash_from_query($query, 'id', 'name');
|
||||||
|
$template->assign('groups', $groups);
|
||||||
|
|
||||||
|
// groups granted to access the category
|
||||||
|
$query = '
|
||||||
|
SELECT group_id
|
||||||
|
FROM '.GROUP_ACCESS_TABLE.'
|
||||||
|
WHERE cat_id = '.$page['cat'].'
|
||||||
|
;';
|
||||||
|
$group_granted_ids = array_from_query($query, 'group_id');
|
||||||
|
$template->assign('groups_selected', $group_granted_ids);
|
||||||
|
|
||||||
|
// users...
|
||||||
|
$users = array();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT '.$conf['user_fields']['id'].' AS id,
|
||||||
|
'.$conf['user_fields']['username'].' AS username
|
||||||
|
FROM '.USERS_TABLE.'
|
||||||
|
;';
|
||||||
|
$users = simple_hash_from_query($query, 'id', 'username');
|
||||||
|
$template->assign('users', $users);
|
||||||
|
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT user_id
|
||||||
|
FROM '.USER_ACCESS_TABLE.'
|
||||||
|
WHERE cat_id = '.$page['cat'].'
|
||||||
|
;';
|
||||||
|
$user_granted_direct_ids = array_from_query($query, 'user_id');
|
||||||
|
$template->assign('users_selected', $user_granted_direct_ids);
|
||||||
|
|
||||||
|
|
||||||
|
$user_granted_indirect_ids = array();
|
||||||
|
if (count($group_granted_ids) > 0)
|
||||||
|
{
|
||||||
|
$granted_groups = array();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT user_id, group_id
|
||||||
|
FROM '.USER_GROUP_TABLE.'
|
||||||
|
WHERE group_id IN ('.implode(',', $group_granted_ids).')
|
||||||
|
';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
if (!isset($granted_groups[ $row['group_id'] ]))
|
||||||
|
{
|
||||||
|
$granted_groups[ $row['group_id'] ] = array();
|
||||||
|
}
|
||||||
|
$granted_groups[ $row['group_id'] ][] = $row['user_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_granted_by_group_ids = array();
|
||||||
|
|
||||||
|
foreach ($granted_groups as $group_users)
|
||||||
|
{
|
||||||
|
$user_granted_by_group_ids = array_merge($user_granted_by_group_ids, $group_users);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_granted_by_group_ids = array_unique($user_granted_by_group_ids);
|
||||||
|
|
||||||
|
$user_granted_indirect_ids = array_diff(
|
||||||
|
$user_granted_by_group_ids,
|
||||||
|
$user_granted_direct_ids
|
||||||
|
);
|
||||||
|
|
||||||
|
$template->assign('nb_users_granted_indirect', count($user_granted_indirect_ids));
|
||||||
|
|
||||||
|
foreach ($granted_groups as $group_id => $group_users)
|
||||||
|
{
|
||||||
|
$group_usernames = array();
|
||||||
|
foreach ($group_users as $user_id)
|
||||||
|
{
|
||||||
|
if (in_array($user_id, $user_granted_indirect_ids))
|
||||||
|
{
|
||||||
|
$group_usernames[] = $users[$user_id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->append(
|
||||||
|
'user_granted_indirect_groups',
|
||||||
|
array(
|
||||||
|
'group_name' => $groups[$group_id],
|
||||||
|
'group_users' => implode(', ', $group_usernames),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'INHERIT' => $conf['inheritance_by_default']));
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'cat_perm');
|
||||||
|
?>
|
232
sources/admin/comments.php
Normal file
232
sources/admin/comments.php
Normal file
|
@ -0,0 +1,232 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die ("Hacking attempt!");
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
|
||||||
|
if (isset($_GET['start']) and is_numeric($_GET['start']))
|
||||||
|
{
|
||||||
|
$page['start'] = $_GET['start'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['start'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | actions |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!empty($_POST))
|
||||||
|
{
|
||||||
|
if (empty($_POST['comments']))
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('Select at least one comment');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
include_once( PHPWG_ROOT_PATH .'include/functions_comment.inc.php' );
|
||||||
|
check_input_parameter('comments', $_POST, true, PATTERN_ID);
|
||||||
|
|
||||||
|
if (isset($_POST['validate']))
|
||||||
|
{
|
||||||
|
validate_user_comment($_POST['comments']);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n_dec(
|
||||||
|
'%d user comment validated', '%d user comments validated',
|
||||||
|
count($_POST['comments'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['reject']))
|
||||||
|
{
|
||||||
|
delete_user_comment($_POST['comments']);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n_dec(
|
||||||
|
'%d user comment rejected', '%d user comments rejected',
|
||||||
|
count($_POST['comments'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->set_filenames(array('comments'=>'comments.tpl'));
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'F_ACTION' => get_root_url().'admin.php?page=comments'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Tabs |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||||
|
|
||||||
|
$tabsheet = new tabsheet();
|
||||||
|
$tabsheet->set_id('comments');
|
||||||
|
$tabsheet->select('');
|
||||||
|
$tabsheet->assign();
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | comments display |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$nb_total = 0;
|
||||||
|
$nb_pending = 0;
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
COUNT(*) AS counter,
|
||||||
|
validated
|
||||||
|
FROM '.COMMENTS_TABLE.'
|
||||||
|
GROUP BY validated
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$nb_total+= $row['counter'];
|
||||||
|
|
||||||
|
if ('false' == $row['validated'])
|
||||||
|
{
|
||||||
|
$nb_pending = $row['counter'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_GET['filter']) and $nb_pending > 0)
|
||||||
|
{
|
||||||
|
$page['filter'] = 'pending';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['filter'] = 'all';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['filter']) and 'pending' == $_GET['filter'])
|
||||||
|
{
|
||||||
|
$page['filter'] = $_GET['filter'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'nb_total' => $nb_total,
|
||||||
|
'nb_pending' => $nb_pending,
|
||||||
|
'filter' => $page['filter'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$where_clauses = array('1=1');
|
||||||
|
|
||||||
|
if ('pending' == $page['filter'])
|
||||||
|
{
|
||||||
|
$where_clauses[] = 'validated=\'false\'';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
c.id,
|
||||||
|
c.image_id,
|
||||||
|
c.date,
|
||||||
|
c.author,
|
||||||
|
'.$conf['user_fields']['username'].' AS username,
|
||||||
|
c.content,
|
||||||
|
i.path,
|
||||||
|
i.representative_ext,
|
||||||
|
validated
|
||||||
|
FROM '.COMMENTS_TABLE.' AS c
|
||||||
|
INNER JOIN '.IMAGES_TABLE.' AS i
|
||||||
|
ON i.id = c.image_id
|
||||||
|
LEFT JOIN '.USERS_TABLE.' AS u
|
||||||
|
ON u.'.$conf['user_fields']['id'].' = c.author_id
|
||||||
|
WHERE '.implode(' AND ', $where_clauses).'
|
||||||
|
ORDER BY c.date DESC
|
||||||
|
LIMIT '.$page['start'].', '.$conf['comments_page_nb_comments'].'
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$thumb = DerivativeImage::thumb_url(
|
||||||
|
array(
|
||||||
|
'id'=>$row['image_id'],
|
||||||
|
'path'=>$row['path'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (empty($row['author_id']))
|
||||||
|
{
|
||||||
|
$author_name = $row['author'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$author_name = stripslashes($row['username']);
|
||||||
|
}
|
||||||
|
$template->append(
|
||||||
|
'comments',
|
||||||
|
array(
|
||||||
|
'U_PICTURE' => get_root_url().'admin.php?page=photo-'.$row['image_id'],
|
||||||
|
'ID' => $row['id'],
|
||||||
|
'TN_SRC' => $thumb,
|
||||||
|
'AUTHOR' => trigger_event('render_comment_author', $author_name),
|
||||||
|
'DATE' => format_date($row['date'], true),
|
||||||
|
'CONTENT' => trigger_event('render_comment_content',$row['content']),
|
||||||
|
'IS_PENDING' => ('false' == $row['validated']),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$list[] = $row['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | navigation bar |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$navbar = create_navigation_bar(
|
||||||
|
get_root_url().'admin.php'.get_query_string_diff(array('start')),
|
||||||
|
('pending' == $page['filter'] ? $nb_pending : $nb_total),
|
||||||
|
$page['start'],
|
||||||
|
$conf['comments_page_nb_comments']
|
||||||
|
);
|
||||||
|
|
||||||
|
$template->assign('navbar', $navbar);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
|
||||||
|
|
||||||
|
?>
|
605
sources/admin/configuration.php
Normal file
605
sources/admin/configuration.php
Normal file
|
@ -0,0 +1,605 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if( !defined("PHPWG_ROOT_PATH") )
|
||||||
|
{
|
||||||
|
die ("Hacking attempt!");
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
//-------------------------------------------------------- sections definitions
|
||||||
|
|
||||||
|
check_input_parameter('section', $_GET, false, '/^[a-z]+$/i');
|
||||||
|
|
||||||
|
if (!isset($_GET['section']))
|
||||||
|
{
|
||||||
|
$page['section'] = 'main';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['section'] = $_GET['section'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$main_checkboxes = array(
|
||||||
|
'allow_user_registration',
|
||||||
|
'obligatory_user_mail_address',
|
||||||
|
'rate',
|
||||||
|
'rate_anonymous',
|
||||||
|
'email_admin_on_new_user',
|
||||||
|
'allow_user_customization',
|
||||||
|
'log',
|
||||||
|
'history_admin',
|
||||||
|
'history_guest',
|
||||||
|
);
|
||||||
|
|
||||||
|
$sizes_checkboxes = array(
|
||||||
|
'original_resize',
|
||||||
|
);
|
||||||
|
|
||||||
|
$comments_checkboxes = array(
|
||||||
|
'activate_comments',
|
||||||
|
'comments_forall',
|
||||||
|
'comments_validation',
|
||||||
|
'email_admin_on_comment',
|
||||||
|
'email_admin_on_comment_validation',
|
||||||
|
'user_can_delete_comment',
|
||||||
|
'user_can_edit_comment',
|
||||||
|
'email_admin_on_comment_edition',
|
||||||
|
'email_admin_on_comment_deletion',
|
||||||
|
'comments_author_mandatory',
|
||||||
|
'comments_email_mandatory',
|
||||||
|
);
|
||||||
|
|
||||||
|
$display_checkboxes = array(
|
||||||
|
'menubar_filter_icon',
|
||||||
|
'index_sort_order_input',
|
||||||
|
'index_flat_icon',
|
||||||
|
'index_posted_date_icon',
|
||||||
|
'index_created_date_icon',
|
||||||
|
'index_slideshow_icon',
|
||||||
|
'index_new_icon',
|
||||||
|
'picture_metadata_icon',
|
||||||
|
'picture_slideshow_icon',
|
||||||
|
'picture_favorite_icon',
|
||||||
|
'picture_download_icon',
|
||||||
|
'picture_navigation_icons',
|
||||||
|
'picture_navigation_thumb',
|
||||||
|
'picture_menu',
|
||||||
|
);
|
||||||
|
|
||||||
|
$display_info_checkboxes = array(
|
||||||
|
'author',
|
||||||
|
'created_on',
|
||||||
|
'posted_on',
|
||||||
|
'dimensions',
|
||||||
|
'file',
|
||||||
|
'filesize',
|
||||||
|
'tags',
|
||||||
|
'categories',
|
||||||
|
'visits',
|
||||||
|
'rating_score',
|
||||||
|
'privacy_level',
|
||||||
|
);
|
||||||
|
|
||||||
|
// image order management
|
||||||
|
$sort_fields = array(
|
||||||
|
'' => '',
|
||||||
|
'file ASC' => l10n('File name, A → Z'),
|
||||||
|
'file DESC' => l10n('File name, Z → A'),
|
||||||
|
'name ASC' => l10n('Photo title, A → Z'),
|
||||||
|
'name DESC' => l10n('Photo title, Z → A'),
|
||||||
|
'date_creation DESC' => l10n('Date created, new → old'),
|
||||||
|
'date_creation ASC' => l10n('Date created, old → new'),
|
||||||
|
'date_available DESC' => l10n('Date posted, new → old'),
|
||||||
|
'date_available ASC' => l10n('Date posted, old → new'),
|
||||||
|
'rating_score DESC' => l10n('Rating score, high → low'),
|
||||||
|
'rating_score ASC' => l10n('Rating score, low → high'),
|
||||||
|
'hit DESC' => l10n('Visits, high → low'),
|
||||||
|
'hit ASC' => l10n('Visits, low → high'),
|
||||||
|
'id ASC' => l10n('Numeric identifier, 1 → 9'),
|
||||||
|
'id DESC' => l10n('Numeric identifier, 9 → 1'),
|
||||||
|
'rank ASC' => l10n('Manual sort order'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$comments_order = array(
|
||||||
|
'ASC' => l10n('Show oldest comments first'),
|
||||||
|
'DESC' => l10n('Show latest comments first'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$mail_themes = array(
|
||||||
|
'clear' => 'Clear',
|
||||||
|
'dark' => 'Dark',
|
||||||
|
);
|
||||||
|
|
||||||
|
//------------------------------ verification and registration of modifications
|
||||||
|
if (isset($_POST['submit']))
|
||||||
|
{
|
||||||
|
$int_pattern = '/^\d+$/';
|
||||||
|
|
||||||
|
switch ($page['section'])
|
||||||
|
{
|
||||||
|
case 'main' :
|
||||||
|
{
|
||||||
|
if ( !isset($conf['order_by_custom']) and !isset($conf['order_by_inside_category_custom']) )
|
||||||
|
{
|
||||||
|
if ( !empty($_POST['order_by']) )
|
||||||
|
{
|
||||||
|
$used = array();
|
||||||
|
foreach ($_POST['order_by'] as $i => $val)
|
||||||
|
{
|
||||||
|
if (empty($val) or isset($used[$val]))
|
||||||
|
{
|
||||||
|
unset($_POST['order_by'][$i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$used[$val] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !count($_POST['order_by']) )
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('No order field selected');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// limit to the number of available parameters
|
||||||
|
$order_by = $order_by_inside_category = array_slice($_POST['order_by'], 0, ceil(count($sort_fields)/2));
|
||||||
|
|
||||||
|
// there is no rank outside categories
|
||||||
|
if ( ($i = array_search('rank ASC', $order_by)) !== false)
|
||||||
|
{
|
||||||
|
unset($order_by[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// must define a default order_by if user want to order by rank only
|
||||||
|
if ( count($order_by) == 0 )
|
||||||
|
{
|
||||||
|
$order_by = array('id ASC');
|
||||||
|
}
|
||||||
|
|
||||||
|
$_POST['order_by'] = 'ORDER BY '.implode(', ', $order_by);
|
||||||
|
$_POST['order_by_inside_category'] = 'ORDER BY '.implode(', ', $order_by_inside_category);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('No order field selected');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach( $main_checkboxes as $checkbox)
|
||||||
|
{
|
||||||
|
$_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'watermark' :
|
||||||
|
{
|
||||||
|
include(PHPWG_ROOT_PATH.'admin/include/configuration_watermark_process.inc.php');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'sizes' :
|
||||||
|
{
|
||||||
|
include(PHPWG_ROOT_PATH.'admin/include/configuration_sizes_process.inc.php');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'comments' :
|
||||||
|
{
|
||||||
|
// the number of comments per page must be an integer between 5 and 50
|
||||||
|
// included
|
||||||
|
if (!preg_match($int_pattern, $_POST['nb_comment_page'])
|
||||||
|
or $_POST['nb_comment_page'] < 5
|
||||||
|
or $_POST['nb_comment_page'] > 50)
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('The number of comments a page must be between 5 and 50 included.');
|
||||||
|
}
|
||||||
|
foreach( $comments_checkboxes as $checkbox)
|
||||||
|
{
|
||||||
|
$_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'default' :
|
||||||
|
{
|
||||||
|
// Never go here
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'display' :
|
||||||
|
{
|
||||||
|
if (!preg_match($int_pattern, $_POST['nb_categories_page'])
|
||||||
|
or $_POST['nb_categories_page'] < 4)
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('The number of albums a page must be above 4.');
|
||||||
|
}
|
||||||
|
foreach( $display_checkboxes as $checkbox)
|
||||||
|
{
|
||||||
|
$_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
|
||||||
|
}
|
||||||
|
foreach( $display_info_checkboxes as $checkbox)
|
||||||
|
{
|
||||||
|
$_POST['picture_informations'][$checkbox] =
|
||||||
|
empty($_POST['picture_informations'][$checkbox])? false : true;
|
||||||
|
}
|
||||||
|
$_POST['picture_informations'] = addslashes(serialize($_POST['picture_informations']));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// updating configuration if no error found
|
||||||
|
if (!in_array($page['section'], array('sizes', 'watermark')) and count($page['errors']) == 0)
|
||||||
|
{
|
||||||
|
//echo '<pre>'; print_r($_POST); echo '</pre>';
|
||||||
|
$result = pwg_query('SELECT param FROM '.CONFIG_TABLE);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
if (isset($_POST[$row['param']]))
|
||||||
|
{
|
||||||
|
$value = $_POST[$row['param']];
|
||||||
|
|
||||||
|
if ('gallery_title' == $row['param'])
|
||||||
|
{
|
||||||
|
if (!$conf['allow_html_descriptions'])
|
||||||
|
{
|
||||||
|
$value = strip_tags($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
UPDATE '.CONFIG_TABLE.'
|
||||||
|
SET value = \''. str_replace("\'", "''", $value).'\'
|
||||||
|
WHERE param = \''.$row['param'].'\'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$page['infos'][] = l10n('Information data registered in database');
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------ $conf reinitialization
|
||||||
|
load_conf_from_db();
|
||||||
|
}
|
||||||
|
|
||||||
|
// restore default derivatives settings
|
||||||
|
if ('sizes' == $page['section'] and isset($_GET['action']) and 'restore_settings' == $_GET['action'])
|
||||||
|
{
|
||||||
|
ImageStdParams::set_and_save( ImageStdParams::get_default_sizes() );
|
||||||
|
pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param = \'disabled_derivatives\'');
|
||||||
|
clear_derivative_cache();
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('Your configuration settings are saved');
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------- template initialization
|
||||||
|
$template->set_filename('config', 'configuration.tpl');
|
||||||
|
|
||||||
|
// TabSheet
|
||||||
|
$tabsheet = new tabsheet();
|
||||||
|
$tabsheet->set_id('configuration');
|
||||||
|
$tabsheet->select($page['section']);
|
||||||
|
$tabsheet->assign();
|
||||||
|
|
||||||
|
$action = get_root_url().'admin.php?page=configuration';
|
||||||
|
$action.= '&section='.$page['section'];
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'U_HELP' => get_root_url().'admin/popuphelp.php?page=configuration',
|
||||||
|
'F_ACTION'=>$action
|
||||||
|
));
|
||||||
|
|
||||||
|
switch ($page['section'])
|
||||||
|
{
|
||||||
|
case 'main' :
|
||||||
|
{
|
||||||
|
|
||||||
|
function order_by_is_local()
|
||||||
|
{
|
||||||
|
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
|
||||||
|
if (isset($conf['local_dir_site']))
|
||||||
|
{
|
||||||
|
@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($conf['order_by']) or isset($conf['order_by_inside_category']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (order_by_is_local())
|
||||||
|
{
|
||||||
|
$page['warnings'][] = l10n('You have specified <i>$conf[\'order_by\']</i> in your local configuration file, this parameter in deprecated, please remove it or rename it into <i>$conf[\'order_by_custom\']</i> !');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($conf['order_by_custom']) or isset($conf['order_by_inside_category_custom']) )
|
||||||
|
{
|
||||||
|
$order_by = array('');
|
||||||
|
$template->assign('ORDER_BY_IS_CUSTOM', true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$out = array();
|
||||||
|
$order_by = trim($conf['order_by_inside_category']);
|
||||||
|
$order_by = str_replace('ORDER BY ', null, $order_by);
|
||||||
|
$order_by = explode(', ', $order_by);
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
'main',
|
||||||
|
array(
|
||||||
|
'CONF_GALLERY_TITLE' => htmlspecialchars($conf['gallery_title']),
|
||||||
|
'CONF_PAGE_BANNER' => htmlspecialchars($conf['page_banner']),
|
||||||
|
'week_starts_on_options' => array(
|
||||||
|
'sunday' => $lang['day'][0],
|
||||||
|
'monday' => $lang['day'][1],
|
||||||
|
),
|
||||||
|
'week_starts_on_options_selected' => $conf['week_starts_on'],
|
||||||
|
'mail_theme' => $conf['mail_theme'],
|
||||||
|
'mail_theme_options' => $mail_themes,
|
||||||
|
'order_by' => $order_by,
|
||||||
|
'order_by_options' => $sort_fields,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($main_checkboxes as $checkbox)
|
||||||
|
{
|
||||||
|
$template->append(
|
||||||
|
'main',
|
||||||
|
array(
|
||||||
|
$checkbox => $conf[$checkbox]
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'comments' :
|
||||||
|
{
|
||||||
|
$template->assign(
|
||||||
|
'comments',
|
||||||
|
array(
|
||||||
|
'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
|
||||||
|
'comments_order'=>$conf['comments_order'],
|
||||||
|
'comments_order_options'=> $comments_order
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($comments_checkboxes as $checkbox)
|
||||||
|
{
|
||||||
|
$template->append(
|
||||||
|
'comments',
|
||||||
|
array(
|
||||||
|
$checkbox => $conf[$checkbox]
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'default' :
|
||||||
|
{
|
||||||
|
$edit_user = build_user($conf['guest_id'], false);
|
||||||
|
include_once(PHPWG_ROOT_PATH.'profile.php');
|
||||||
|
|
||||||
|
$errors = array();
|
||||||
|
if (save_profile_from_post($edit_user, $errors))
|
||||||
|
{
|
||||||
|
// Reload user
|
||||||
|
$edit_user = build_user($conf['guest_id'], false);
|
||||||
|
$page['infos'][] = l10n('Information data registered in database');
|
||||||
|
}
|
||||||
|
$page['errors'] = array_merge($page['errors'], $errors);
|
||||||
|
|
||||||
|
load_profile_in_template(
|
||||||
|
$action,
|
||||||
|
'',
|
||||||
|
$edit_user
|
||||||
|
);
|
||||||
|
$template->assign('default', array());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'display' :
|
||||||
|
{
|
||||||
|
foreach ($display_checkboxes as $checkbox)
|
||||||
|
{
|
||||||
|
$template->append(
|
||||||
|
'display',
|
||||||
|
array(
|
||||||
|
$checkbox => $conf[$checkbox]
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$template->append(
|
||||||
|
'display',
|
||||||
|
array(
|
||||||
|
'picture_informations' => unserialize($conf['picture_informations']),
|
||||||
|
'NB_CATEGORIES_PAGE' => $conf['nb_categories_page'],
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'sizes' :
|
||||||
|
{
|
||||||
|
// we only load the derivatives if it was not already loaded: it occurs
|
||||||
|
// when submitting the form and an error remains
|
||||||
|
if (!isset($page['sizes_loaded_in_tpl']))
|
||||||
|
{
|
||||||
|
$is_gd = (pwg_image::get_library()=='gd')? true : false;
|
||||||
|
$template->assign('is_gd', $is_gd);
|
||||||
|
$template->assign(
|
||||||
|
'sizes',
|
||||||
|
array(
|
||||||
|
'original_resize_maxwidth' => $conf['original_resize_maxwidth'],
|
||||||
|
'original_resize_maxheight' => $conf['original_resize_maxheight'],
|
||||||
|
'original_resize_quality' => $conf['original_resize_quality'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($sizes_checkboxes as $checkbox)
|
||||||
|
{
|
||||||
|
$template->append(
|
||||||
|
'sizes',
|
||||||
|
array(
|
||||||
|
$checkbox => $conf[$checkbox]
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// derivatives = multiple size
|
||||||
|
$enabled = ImageStdParams::get_defined_type_map();
|
||||||
|
$disabled = @unserialize(@$conf['disabled_derivatives']);
|
||||||
|
if ($disabled === false)
|
||||||
|
{
|
||||||
|
$disabled = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$tpl_vars = array();
|
||||||
|
foreach(ImageStdParams::get_all_types() as $type)
|
||||||
|
{
|
||||||
|
$tpl_var = array();
|
||||||
|
|
||||||
|
$tpl_var['must_square'] = ($type==IMG_SQUARE ? true : false);
|
||||||
|
$tpl_var['must_enable'] = ($type==IMG_SQUARE || $type==IMG_THUMB)? true : false;
|
||||||
|
|
||||||
|
if ($params = @$enabled[$type])
|
||||||
|
{
|
||||||
|
$tpl_var['enabled'] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$tpl_var['enabled']=false;
|
||||||
|
$params=@$disabled[$type];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($params)
|
||||||
|
{
|
||||||
|
list($tpl_var['w'],$tpl_var['h']) = $params->sizing->ideal_size;
|
||||||
|
if ( ($tpl_var['crop'] = round(100*$params->sizing->max_crop)) > 0)
|
||||||
|
{
|
||||||
|
list($tpl_var['minw'],$tpl_var['minh']) = $params->sizing->min_size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$tpl_var['minw'] = $tpl_var['minh'] = "";
|
||||||
|
}
|
||||||
|
$tpl_var['sharpen'] = $params->sharpen;
|
||||||
|
}
|
||||||
|
$tpl_vars[$type]=$tpl_var;
|
||||||
|
}
|
||||||
|
$template->assign('derivatives', $tpl_vars);
|
||||||
|
$template->assign('resize_quality', ImageStdParams::$quality);
|
||||||
|
|
||||||
|
$tpl_vars = array();
|
||||||
|
$now = time();
|
||||||
|
foreach(ImageStdParams::$custom as $custom=>$time)
|
||||||
|
{
|
||||||
|
$tpl_vars[$custom] = ($now-$time<=24*3600) ? l10n('today') : time_since($time, 'day');
|
||||||
|
}
|
||||||
|
$template->assign('custom_derivatives', $tpl_vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'watermark' :
|
||||||
|
{
|
||||||
|
$watermark_files = array();
|
||||||
|
foreach (glob(PHPWG_ROOT_PATH.'themes/default/watermarks/*.png') as $file)
|
||||||
|
{
|
||||||
|
$watermark_files[] = substr($file, strlen(PHPWG_ROOT_PATH));
|
||||||
|
}
|
||||||
|
if ( ($glob=glob(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'watermarks/*.png')) !== false)
|
||||||
|
{
|
||||||
|
foreach ($glob as $file)
|
||||||
|
{
|
||||||
|
$watermark_files[] = substr($file, strlen(PHPWG_ROOT_PATH));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$watermark_filemap = array( '' => '---' );
|
||||||
|
foreach( $watermark_files as $file)
|
||||||
|
{
|
||||||
|
$display = basename($file);
|
||||||
|
$watermark_filemap[$file] = $display;
|
||||||
|
}
|
||||||
|
$template->assign('watermark_files', $watermark_filemap);
|
||||||
|
|
||||||
|
if ($template->get_template_vars('watermark') === null)
|
||||||
|
{
|
||||||
|
$wm = ImageStdParams::get_watermark();
|
||||||
|
|
||||||
|
$position = 'custom';
|
||||||
|
if ($wm->xpos == 0 and $wm->ypos == 0)
|
||||||
|
{
|
||||||
|
$position = 'topleft';
|
||||||
|
}
|
||||||
|
if ($wm->xpos == 100 and $wm->ypos == 0)
|
||||||
|
{
|
||||||
|
$position = 'topright';
|
||||||
|
}
|
||||||
|
if ($wm->xpos == 50 and $wm->ypos == 50)
|
||||||
|
{
|
||||||
|
$position = 'middle';
|
||||||
|
}
|
||||||
|
if ($wm->xpos == 0 and $wm->ypos == 100)
|
||||||
|
{
|
||||||
|
$position = 'bottomleft';
|
||||||
|
}
|
||||||
|
if ($wm->xpos == 100 and $wm->ypos == 100)
|
||||||
|
{
|
||||||
|
$position = 'bottomright';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($wm->xrepeat != 0)
|
||||||
|
{
|
||||||
|
$position = 'custom';
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
'watermark',
|
||||||
|
array(
|
||||||
|
'file' => $wm->file,
|
||||||
|
'minw' => $wm->min_size[0],
|
||||||
|
'minh' => $wm->min_size[1],
|
||||||
|
'xpos' => $wm->xpos,
|
||||||
|
'ypos' => $wm->ypos,
|
||||||
|
'xrepeat' => $wm->xrepeat,
|
||||||
|
'opacity' => $wm->opacity,
|
||||||
|
'position' => $position,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------- sending html code
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'config');
|
||||||
|
?>
|
275
sources/admin/element_set_ranks.php
Normal file
275
sources/admin/element_set_ranks.php
Normal file
|
@ -0,0 +1,275 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change rank of images inside a category
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die('Hacking attempt!');
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
if (!isset($_GET['cat_id']) or !is_numeric($_GET['cat_id']))
|
||||||
|
{
|
||||||
|
trigger_error('missing cat_id param', E_USER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
$page['category_id'] = $_GET['cat_id'];
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | functions |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save the rank depending on given images order
|
||||||
|
*
|
||||||
|
* The list of ordered images id is supposed to be in the same parent
|
||||||
|
* category
|
||||||
|
*
|
||||||
|
* @param array categories
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function save_images_order($category_id, $images)
|
||||||
|
{
|
||||||
|
$current_rank = 0;
|
||||||
|
$datas = array();
|
||||||
|
foreach ($images as $id)
|
||||||
|
{
|
||||||
|
$datas[] = array(
|
||||||
|
'category_id' => $category_id,
|
||||||
|
'image_id' => $id,
|
||||||
|
'rank' => ++$current_rank,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$fields = array(
|
||||||
|
'primary' => array('image_id', 'category_id'),
|
||||||
|
'update' => array('rank')
|
||||||
|
);
|
||||||
|
mass_updates(IMAGE_CATEGORY_TABLE, $fields, $datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | global mode form submission |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$image_order_choices = array('default', 'rank', 'user_define');
|
||||||
|
$image_order_choice = 'default';
|
||||||
|
|
||||||
|
if (isset($_POST['submit']))
|
||||||
|
{
|
||||||
|
if (isset($_POST['rank_of_image']))
|
||||||
|
{
|
||||||
|
asort($_POST['rank_of_image'], SORT_NUMERIC);
|
||||||
|
|
||||||
|
save_images_order(
|
||||||
|
$page['category_id'],
|
||||||
|
array_keys($_POST['rank_of_image'])
|
||||||
|
);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('Images manual order was saved');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($_POST['image_order_choice'])
|
||||||
|
&& in_array($_POST['image_order_choice'], $image_order_choices))
|
||||||
|
{
|
||||||
|
$image_order_choice = $_POST['image_order_choice'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$image_order = null;
|
||||||
|
if ($image_order_choice=='user_define')
|
||||||
|
{
|
||||||
|
for ($i=0; $i<3; $i++)
|
||||||
|
{
|
||||||
|
if (!empty($_POST['image_order'][$i]))
|
||||||
|
{
|
||||||
|
if (!empty($image_order)) $image_order.= ',';
|
||||||
|
$image_order.= $_POST['image_order'][$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($image_order_choice=='rank')
|
||||||
|
{
|
||||||
|
$image_order = 'rank ASC';
|
||||||
|
}
|
||||||
|
$query = '
|
||||||
|
UPDATE '.CATEGORIES_TABLE.'
|
||||||
|
SET image_order = '.(isset($image_order) ? '\''.$image_order.'\'' : 'NULL').'
|
||||||
|
WHERE id='.$page['category_id'];
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
if (isset($_POST['image_order_subcats']))
|
||||||
|
{
|
||||||
|
$cat_info = get_cat_info($page['category_id']);
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
UPDATE '.CATEGORIES_TABLE.'
|
||||||
|
SET image_order = '.(isset($image_order) ? '\''.$image_order.'\'' : 'NULL').'
|
||||||
|
WHERE uppercats LIKE \''.$cat_info['uppercats'].',%\'';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('Your configuration settings are saved');
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
$template->set_filenames(
|
||||||
|
array('element_set_ranks' => 'element_set_ranks.tpl')
|
||||||
|
);
|
||||||
|
|
||||||
|
$base_url = get_root_url().'admin.php';
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT *
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE id = '.$page['category_id'].'
|
||||||
|
;';
|
||||||
|
$category = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
|
||||||
|
if ($category['image_order']=='rank')
|
||||||
|
{
|
||||||
|
$image_order_choice = 'rank';
|
||||||
|
}
|
||||||
|
elseif ($category['image_order']!='')
|
||||||
|
{
|
||||||
|
$image_order_choice = 'user_define';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Navigation path
|
||||||
|
$navigation = get_cat_display_name_cache(
|
||||||
|
$category['uppercats'],
|
||||||
|
get_root_url().'admin.php?page=album-'
|
||||||
|
);
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'CATEGORIES_NAV' => $navigation,
|
||||||
|
'F_ACTION' => $base_url.get_query_string_diff(array()),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | thumbnails |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
file,
|
||||||
|
path,
|
||||||
|
representative_ext,
|
||||||
|
width, height, rotation,
|
||||||
|
name,
|
||||||
|
rank
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id
|
||||||
|
WHERE category_id = '.$page['category_id'].'
|
||||||
|
ORDER BY rank
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
if (pwg_db_num_rows($result) > 0)
|
||||||
|
{
|
||||||
|
// template thumbnail initialization
|
||||||
|
$current_rank = 1;
|
||||||
|
$derivativeParams = ImageStdParams::get_by_type(IMG_SQUARE);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$derivative = new DerivativeImage($derivativeParams, new SrcImage($row));
|
||||||
|
|
||||||
|
if ( !empty( $row['name'] ) )
|
||||||
|
{
|
||||||
|
$thumbnail_name = $row['name'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$file_wo_ext = get_filename_wo_extension($row['file']);
|
||||||
|
$thumbnail_name = str_replace('_', ' ', $file_wo_ext);
|
||||||
|
}
|
||||||
|
$current_rank++;
|
||||||
|
$template->append(
|
||||||
|
'thumbnails',
|
||||||
|
array(
|
||||||
|
'ID' => $row['id'],
|
||||||
|
'NAME' => $thumbnail_name,
|
||||||
|
'TN_SRC' => $derivative->get_url(),
|
||||||
|
'RANK' => $current_rank * 10,
|
||||||
|
'SIZE' => $derivative->get_size(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// image order management
|
||||||
|
$sort_fields = array(
|
||||||
|
'' => '',
|
||||||
|
'file ASC' => l10n('File name, A → Z'),
|
||||||
|
'file DESC' => l10n('File name, Z → A'),
|
||||||
|
'name ASC' => l10n('Photo title, A → Z'),
|
||||||
|
'name DESC' => l10n('Photo title, Z → A'),
|
||||||
|
'date_creation DESC' => l10n('Date created, new → old'),
|
||||||
|
'date_creation ASC' => l10n('Date created, old → new'),
|
||||||
|
'date_available DESC' => l10n('Date posted, new → old'),
|
||||||
|
'date_available ASC' => l10n('Date posted, old → new'),
|
||||||
|
'rating_score DESC' => l10n('Rating score, high → low'),
|
||||||
|
'rating_score ASC' => l10n('Rating score, low → high'),
|
||||||
|
'hit DESC' => l10n('Visits, high → low'),
|
||||||
|
'hit ASC' => l10n('Visits, low → high'),
|
||||||
|
'id ASC' => l10n('Numeric identifier, 1 → 9'),
|
||||||
|
'id DESC' => l10n('Numeric identifier, 9 → 1'),
|
||||||
|
'rank ASC' => l10n('Manual sort order'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$template->assign('image_order_options', $sort_fields);
|
||||||
|
|
||||||
|
$image_order = explode(',', $category['image_order']);
|
||||||
|
|
||||||
|
for ($i=0; $i<3; $i++) // 3 fields
|
||||||
|
{
|
||||||
|
if ( isset($image_order[$i]) )
|
||||||
|
{
|
||||||
|
$template->append('image_order', $image_order[$i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$template->append('image_order', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign('image_order_choice', $image_order_choice);
|
||||||
|
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'element_set_ranks');
|
||||||
|
?>
|
204
sources/admin/extend_for_templates.php
Normal file
204
sources/admin/extend_for_templates.php
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define replacement conditions for each template from template-extension
|
||||||
|
* (template called "replacer").
|
||||||
|
*
|
||||||
|
* "original template" from ./template/yoga (or any other than yoga)
|
||||||
|
* will be replaced by a "replacer" if the replacer is linked to this "original template"
|
||||||
|
* (and optionally, when the requested URL contains an "optional URL keyword").
|
||||||
|
*
|
||||||
|
* "Optional URL keywords" are those you can find after the module name in URLs.
|
||||||
|
*
|
||||||
|
* Therefore "Optional URL keywords" can be an active "permalink"
|
||||||
|
* (see permalinks in our documentation for further explanation).
|
||||||
|
*/
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// initialization |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
$tpl_extension = isset($conf['extents_for_templates']) ?
|
||||||
|
unserialize($conf['extents_for_templates']) : array();
|
||||||
|
$new_extensions = get_extents();
|
||||||
|
|
||||||
|
/* Selective URLs keyword */
|
||||||
|
$relevant_parameters = array(
|
||||||
|
'----------',
|
||||||
|
'category',
|
||||||
|
'favorites',
|
||||||
|
'most_visited',
|
||||||
|
'best_rated',
|
||||||
|
'recent_pics',
|
||||||
|
'recent_cats',
|
||||||
|
'created-monthly-calendar',
|
||||||
|
'posted-monthly-calendar',
|
||||||
|
'search',
|
||||||
|
'flat',
|
||||||
|
'list', /* <=> Random */
|
||||||
|
'tags',
|
||||||
|
);
|
||||||
|
$query = '
|
||||||
|
SELECT permalink
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE permalink IS NOT NULL
|
||||||
|
';
|
||||||
|
|
||||||
|
/* Add active permalinks */
|
||||||
|
$permalinks = array_from_query($query, 'permalink');
|
||||||
|
$relevant_parameters = array_merge($relevant_parameters, $permalinks);
|
||||||
|
|
||||||
|
/* Link all supported templates to their respective handle */
|
||||||
|
$eligible_templates = array(
|
||||||
|
'----------' => 'N/A',
|
||||||
|
'about.tpl' => 'about',
|
||||||
|
'comments.tpl' => 'comments',
|
||||||
|
'comment_list.tpl' => 'comment_list',
|
||||||
|
'footer.tpl' => 'tail',
|
||||||
|
'header.tpl' => 'header',
|
||||||
|
'identification.tpl' => 'identification',
|
||||||
|
'index.tpl' => 'index',
|
||||||
|
'mainpage_categories.tpl' => 'index_category_thumbnails',
|
||||||
|
'menubar.tpl' => 'menubar',
|
||||||
|
'menubar_categories.tpl' => 'mbCategories',
|
||||||
|
'menubar_identification.tpl' => 'mbIdentification',
|
||||||
|
'menubar_links.tpl' => 'mbLinks',
|
||||||
|
'menubar_menu.tpl' => 'mbMenu',
|
||||||
|
'menubar_specials.tpl' => 'mbSpecials',
|
||||||
|
'menubar_tags.tpl' => 'mbTags',
|
||||||
|
'month_calendar.tpl' => 'month_calendar',
|
||||||
|
'navigation_bar.tpl' => 'navbar',
|
||||||
|
'nbm.tpl' => 'nbm',
|
||||||
|
'notification.tpl' => 'notification',
|
||||||
|
'password.tpl' => 'password',
|
||||||
|
'picture.tpl' => 'picture',
|
||||||
|
'picture_content.tpl' => 'default_content',
|
||||||
|
'picture_nav_buttons.tpl' => 'picture_nav_buttons',
|
||||||
|
'popuphelp.tpl' => 'popuphelp',
|
||||||
|
'profile.tpl' => 'profile',
|
||||||
|
'profile_content.tpl' => 'profile_content',
|
||||||
|
'redirect.tpl' => 'redirect',
|
||||||
|
'register.tpl' => 'register',
|
||||||
|
'search.tpl' => 'search',
|
||||||
|
'search_rules.tpl' => 'search_rules',
|
||||||
|
'slideshow.tpl' => 'slideshow',
|
||||||
|
'tags.tpl' => 'tags',
|
||||||
|
'thumbnails.tpl' => 'index_thumbnails',
|
||||||
|
);
|
||||||
|
|
||||||
|
$flip_templates = array_flip($eligible_templates);
|
||||||
|
|
||||||
|
$available_templates = array_merge(
|
||||||
|
array('N/A' => '----------'),
|
||||||
|
get_dirs(PHPWG_ROOT_PATH.'themes'));
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | selected templates |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (isset($_POST['submit']))
|
||||||
|
{
|
||||||
|
$replacements = array();
|
||||||
|
$i = 0;
|
||||||
|
while (isset($_POST['reptpl'][$i]))
|
||||||
|
{
|
||||||
|
$newtpl = $_POST['reptpl'][$i];
|
||||||
|
$original = $_POST['original'][$i];
|
||||||
|
$handle = $eligible_templates[$original];
|
||||||
|
$url_keyword = $_POST['url'][$i];
|
||||||
|
if ($url_keyword == '----------') $url_keyword = 'N/A';
|
||||||
|
$bound_tpl = $_POST['bound'][$i];
|
||||||
|
if ($bound_tpl == '----------') $bound_tpl = 'N/A';
|
||||||
|
if ($handle != 'N/A')
|
||||||
|
{
|
||||||
|
$replacements[$newtpl] = array($handle, $url_keyword, $bound_tpl);
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
$conf['extents_for_templates'] = serialize($replacements);
|
||||||
|
$tpl_extension = $replacements;
|
||||||
|
/* ecrire la nouvelle conf */
|
||||||
|
$query = '
|
||||||
|
UPDATE '.CONFIG_TABLE.'
|
||||||
|
SET value = \''. $conf['extents_for_templates'] .'\'
|
||||||
|
WHERE param = \'extents_for_templates\';';
|
||||||
|
if (pwg_query($query))
|
||||||
|
{
|
||||||
|
$page['infos'][] = l10n('Templates configuration has been recorded.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/* Clearing (remove old extents, add new ones) */
|
||||||
|
foreach ($tpl_extension as $file => $conditions)
|
||||||
|
{
|
||||||
|
if ( !in_array($file,$new_extensions) ) unset($tpl_extension[$file]);
|
||||||
|
else $new_extensions = array_diff($new_extensions,array($file));
|
||||||
|
}
|
||||||
|
foreach ($new_extensions as $file)
|
||||||
|
{
|
||||||
|
$tpl_extension[$file] = array('N/A', 'N/A', 'N/A');
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->set_filenames(array('extend_for_templates'
|
||||||
|
=> 'extend_for_templates.tpl'));
|
||||||
|
|
||||||
|
$base_url = PHPWG_ROOT_PATH.'admin.php?page=extend_for_templates';
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'U_HELP' => get_root_url().'admin/popuphelp.php?page=extend_for_templates',
|
||||||
|
));
|
||||||
|
ksort($tpl_extension);
|
||||||
|
foreach ($tpl_extension as $file => $conditions)
|
||||||
|
{
|
||||||
|
$handle = $conditions[0];
|
||||||
|
$url_keyword = $conditions[1];
|
||||||
|
$bound_tpl = $conditions[2];
|
||||||
|
{
|
||||||
|
$template->append('extents',
|
||||||
|
array(
|
||||||
|
'replacer' => $file,
|
||||||
|
'url_parameter' => $relevant_parameters,
|
||||||
|
'original_tpl' => array_keys($eligible_templates),
|
||||||
|
'bound_tpl' => $available_templates,
|
||||||
|
'selected_tpl' => $flip_templates[$handle],
|
||||||
|
'selected_url' => $url_keyword,
|
||||||
|
'selected_bound' => $bound_tpl,)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | html code display |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'extend_for_templates');
|
||||||
|
?>
|
431
sources/admin/group_list.php
Normal file
431
sources/admin/group_list.php
Normal file
|
@ -0,0 +1,431 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if( !defined("PHPWG_ROOT_PATH") )
|
||||||
|
{
|
||||||
|
die ("Hacking attempt!");
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | tabs |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||||
|
|
||||||
|
$my_base_url = get_root_url().'admin.php?page=';
|
||||||
|
|
||||||
|
$tabsheet = new tabsheet();
|
||||||
|
$tabsheet->set_id('groups');
|
||||||
|
$tabsheet->select('group_list');
|
||||||
|
$tabsheet->assign();
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
if (!empty($_POST) or isset($_GET['delete']) or isset($_GET['toggle_is_default']))
|
||||||
|
{
|
||||||
|
check_pwg_token();
|
||||||
|
}
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | add a group |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (isset($_POST['submit_add']))
|
||||||
|
{
|
||||||
|
if (empty($_POST['groupname']))
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('The name of a group must not contain " or \' or be empty.');
|
||||||
|
}
|
||||||
|
if (count($page['errors']) == 0)
|
||||||
|
{
|
||||||
|
// is the group not already existing ?
|
||||||
|
$query = '
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE name = \''.$_POST['groupname'].'\'
|
||||||
|
;';
|
||||||
|
list($count) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
if ($count != 0)
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('This name is already used by another group.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($page['errors']) == 0)
|
||||||
|
{
|
||||||
|
// creating the group
|
||||||
|
$query = '
|
||||||
|
INSERT INTO '.GROUPS_TABLE.'
|
||||||
|
(name)
|
||||||
|
VALUES
|
||||||
|
(\''.pwg_db_real_escape_string($_POST['groupname']).'\')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('group "%s" added', $_POST['groupname']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | action send |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
if (isset($_POST['submit']) and isset($_POST['selectAction']) and isset($_POST['group_selection']))
|
||||||
|
{
|
||||||
|
// if the user tries to apply an action, it means that there is at least 1
|
||||||
|
// photo in the selection
|
||||||
|
$groups = $_POST['group_selection'];
|
||||||
|
if (count($groups) == 0)
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('Select at least one group');
|
||||||
|
}
|
||||||
|
|
||||||
|
$action = $_POST['selectAction'];
|
||||||
|
|
||||||
|
// +
|
||||||
|
// |rename a group
|
||||||
|
// +
|
||||||
|
|
||||||
|
if ($action=="rename")
|
||||||
|
{
|
||||||
|
// is the group not already existing ?
|
||||||
|
$query = '
|
||||||
|
SELECT name
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
;';
|
||||||
|
$group_names = array_from_query($query, 'name');
|
||||||
|
foreach($groups as $group)
|
||||||
|
{
|
||||||
|
if ( in_array($_POST['rename_'.$group.''], $group_names))
|
||||||
|
{
|
||||||
|
$page['errors'][] = $_POST['rename_'.$group.''].' | '.l10n('This name is already used by another group.');
|
||||||
|
}
|
||||||
|
elseif ( !empty($_POST['rename_'.$group.'']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE '.GROUPS_TABLE.'
|
||||||
|
SET name = \''.pwg_db_real_escape_string($_POST['rename_'.$group.'']).'\'
|
||||||
|
WHERE id = '.$group.'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +
|
||||||
|
// |delete a group
|
||||||
|
// +
|
||||||
|
|
||||||
|
if ($action=="delete" and isset($_POST['confirm_deletion']) and $_POST['confirm_deletion'])
|
||||||
|
{
|
||||||
|
foreach($groups as $group)
|
||||||
|
{
|
||||||
|
// destruction of the access linked to the group
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.GROUP_ACCESS_TABLE.'
|
||||||
|
WHERE group_id = '.$group.'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
// destruction of the users links for this group
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.USER_GROUP_TABLE.'
|
||||||
|
WHERE group_id = '.$group.'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT name
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE id = '.$group.'
|
||||||
|
;';
|
||||||
|
list($groupname) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
|
||||||
|
// destruction of the group
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE id = '.$group.'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('group "%s" deleted', $groupname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +
|
||||||
|
// |merge groups into a new one
|
||||||
|
// +
|
||||||
|
|
||||||
|
if ($action=="merge" and count($groups) > 1)
|
||||||
|
{
|
||||||
|
// is the group not already existing ?
|
||||||
|
$query = '
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE name = \''.pwg_db_real_escape_string($_POST['merge']).'\'
|
||||||
|
;';
|
||||||
|
list($count) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
if ($count != 0)
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('This name is already used by another group.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// creating the group
|
||||||
|
$query = '
|
||||||
|
INSERT INTO '.GROUPS_TABLE.'
|
||||||
|
(name)
|
||||||
|
VALUES
|
||||||
|
(\''.pwg_db_real_escape_string($_POST['merge']).'\')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE name = \''.pwg_db_real_escape_string($_POST['merge']).'\'
|
||||||
|
;';
|
||||||
|
list($groupid) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
}
|
||||||
|
$grp_access = array();
|
||||||
|
$usr_grp = array();
|
||||||
|
foreach($groups as $group)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT *
|
||||||
|
FROM '.GROUP_ACCESS_TABLE.'
|
||||||
|
WHERE group_id = '.$group.'
|
||||||
|
;';
|
||||||
|
$res=pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($res))
|
||||||
|
{
|
||||||
|
$new_grp_access= array(
|
||||||
|
'cat_id' => $row['cat_id'],
|
||||||
|
'group_id' => $groupid
|
||||||
|
);
|
||||||
|
if (!in_array($new_grp_access,$grp_access))
|
||||||
|
{
|
||||||
|
$grp_access[]=$new_grp_access;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT *
|
||||||
|
FROM '.USER_GROUP_TABLE.'
|
||||||
|
WHERE group_id = '.$group.'
|
||||||
|
;';
|
||||||
|
$res=pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($res))
|
||||||
|
{
|
||||||
|
$new_usr_grp= array(
|
||||||
|
'user_id' => $row['user_id'],
|
||||||
|
'group_id' => $groupid
|
||||||
|
);
|
||||||
|
if (!in_array($new_usr_grp,$usr_grp))
|
||||||
|
{
|
||||||
|
$usr_grp[]=$new_usr_grp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mass_inserts(USER_GROUP_TABLE, array('user_id','group_id'), $usr_grp);
|
||||||
|
mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $grp_access);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('group "%s" added', $_POST['merge']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// +
|
||||||
|
// |duplicate a group
|
||||||
|
// +
|
||||||
|
|
||||||
|
if ($action=="duplicate" )
|
||||||
|
{
|
||||||
|
foreach($groups as $group)
|
||||||
|
{
|
||||||
|
if ( empty($_POST['duplicate_'.$group.'']) )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// is the group not already existing ?
|
||||||
|
$query = '
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE name = \''.pwg_db_real_escape_string($_POST['duplicate_'.$group.'']).'\'
|
||||||
|
;';
|
||||||
|
list($count) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
if ($count != 0)
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('This name is already used by another group.');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// creating the group
|
||||||
|
$query = '
|
||||||
|
INSERT INTO '.GROUPS_TABLE.'
|
||||||
|
(name)
|
||||||
|
VALUES
|
||||||
|
(\''.pwg_db_real_escape_string($_POST['duplicate_'.$group.'']).'\')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE name = \''.pwg_db_real_escape_string($_POST['duplicate_'.$group.'']).'\'
|
||||||
|
;';
|
||||||
|
|
||||||
|
list($groupid) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
$query = '
|
||||||
|
SELECT *
|
||||||
|
FROM '.GROUP_ACCESS_TABLE.'
|
||||||
|
WHERE group_id = '.$group.'
|
||||||
|
;';
|
||||||
|
$grp_access = array();
|
||||||
|
$res=pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($res))
|
||||||
|
{
|
||||||
|
$grp_access[] = array(
|
||||||
|
'cat_id' => $row['cat_id'],
|
||||||
|
'group_id' => $groupid
|
||||||
|
);
|
||||||
|
}
|
||||||
|
mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $grp_access);
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT *
|
||||||
|
FROM '.USER_GROUP_TABLE.'
|
||||||
|
WHERE group_id = '.$group.'
|
||||||
|
;';
|
||||||
|
$usr_grp = array();
|
||||||
|
$res=pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($res))
|
||||||
|
{
|
||||||
|
$usr_grp[] = array(
|
||||||
|
'user_id' => $row['user_id'],
|
||||||
|
'group_id' => $groupid
|
||||||
|
);
|
||||||
|
}
|
||||||
|
mass_inserts(USER_GROUP_TABLE, array('user_id','group_id'), $usr_grp);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('group "%s" added', $_POST['duplicate_'.$group.'']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// +
|
||||||
|
// | toggle_default
|
||||||
|
// +
|
||||||
|
|
||||||
|
if ($action=="toggle_default")
|
||||||
|
{
|
||||||
|
foreach($groups as $group)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT name, is_default
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
WHERE id = '.$group.'
|
||||||
|
;';
|
||||||
|
list($groupname, $is_default) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
|
||||||
|
// update of the group
|
||||||
|
$query = '
|
||||||
|
UPDATE '.GROUPS_TABLE.'
|
||||||
|
SET is_default = \''.boolean_to_string(!get_boolean($is_default)).'\'
|
||||||
|
WHERE id = '.$group.'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('group "%s" updated', $groupname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
invalidate_user_cache();
|
||||||
|
}
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->set_filenames(array('group_list' => 'group_list.tpl'));
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'F_ADD_ACTION' => get_root_url().'admin.php?page=group_list',
|
||||||
|
'U_HELP' => get_root_url().'admin/popuphelp.php?page=group_list',
|
||||||
|
'PWG_TOKEN' => get_pwg_token(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | group list |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id, name, is_default
|
||||||
|
FROM '.GROUPS_TABLE.'
|
||||||
|
ORDER BY name ASC
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
|
||||||
|
$admin_url = get_root_url().'admin.php?page=';
|
||||||
|
$perm_url = $admin_url.'group_perm&group_id=';
|
||||||
|
$del_url = $admin_url.'group_list&delete=';
|
||||||
|
$toggle_is_default_url = $admin_url.'group_list&toggle_is_default=';
|
||||||
|
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT u.'. $conf['user_fields']['username'].' AS username
|
||||||
|
FROM '.USERS_TABLE.' AS u
|
||||||
|
INNER JOIN '.USER_GROUP_TABLE.' AS ug
|
||||||
|
ON u.'.$conf['user_fields']['id'].' = ug.user_id
|
||||||
|
WHERE ug.group_id = '.$row['id'].'
|
||||||
|
;';
|
||||||
|
$members=array();
|
||||||
|
$res=pwg_query($query);
|
||||||
|
while ($us= pwg_db_fetch_assoc($res))
|
||||||
|
{
|
||||||
|
$members[]=$us['username'];
|
||||||
|
}
|
||||||
|
$template->append(
|
||||||
|
'groups',
|
||||||
|
array(
|
||||||
|
'NAME' => $row['name'],
|
||||||
|
'ID' => $row['id'],
|
||||||
|
'IS_DEFAULT' => (get_boolean($row['is_default']) ? ' ['.l10n('default').']' : ''),
|
||||||
|
'NB_MEMBERS' => count($members),
|
||||||
|
'L_MEMBERS' => implode(' <span class="userSeparator">·</span> ', $members),
|
||||||
|
'MEMBERS' => l10n_dec('%d member', '%d members', count($members)),
|
||||||
|
'U_DELETE' => $del_url.$row['id'].'&pwg_token='.get_pwg_token(),
|
||||||
|
'U_PERM' => $perm_url.$row['id'],
|
||||||
|
'U_ISDEFAULT' => $toggle_is_default_url.$row['id'].'&pwg_token='.get_pwg_token(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'group_list');
|
||||||
|
|
||||||
|
?>
|
182
sources/admin/group_perm.php
Normal file
182
sources/admin/group_perm.php
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if( !defined("PHPWG_ROOT_PATH") )
|
||||||
|
{
|
||||||
|
die ("Hacking attempt!");
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | variables init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (isset($_GET['group_id']) and is_numeric($_GET['group_id']))
|
||||||
|
{
|
||||||
|
$page['group'] = $_GET['group_id'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
die('group_id URL parameter is missing');
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | updates |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (isset($_POST['falsify'])
|
||||||
|
and isset($_POST['cat_true'])
|
||||||
|
and count($_POST['cat_true']) > 0)
|
||||||
|
{
|
||||||
|
// if you forbid access to a category, all sub-categories become
|
||||||
|
// automatically forbidden
|
||||||
|
$subcats = get_subcat_ids($_POST['cat_true']);
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.GROUP_ACCESS_TABLE.'
|
||||||
|
WHERE group_id = '.$page['group'].'
|
||||||
|
AND cat_id IN ('.implode(',', $subcats).')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
else if (isset($_POST['trueify'])
|
||||||
|
and isset($_POST['cat_false'])
|
||||||
|
and count($_POST['cat_false']) > 0)
|
||||||
|
{
|
||||||
|
$uppercats = get_uppercat_ids($_POST['cat_false']);
|
||||||
|
$private_uppercats = array();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', $uppercats).')
|
||||||
|
AND status = \'private\'
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$private_uppercats[] = $row['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// retrying to authorize a category which is already authorized may cause
|
||||||
|
// an error (in SQL statement), so we need to know which categories are
|
||||||
|
// accesible
|
||||||
|
$authorized_ids = array();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT cat_id
|
||||||
|
FROM '.GROUP_ACCESS_TABLE.'
|
||||||
|
WHERE group_id = '.$page['group'].'
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$authorized_ids[] = $row['cat_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$inserts = array();
|
||||||
|
$to_autorize_ids = array_diff($private_uppercats, $authorized_ids);
|
||||||
|
foreach ($to_autorize_ids as $to_autorize_id)
|
||||||
|
{
|
||||||
|
$inserts[] = array(
|
||||||
|
'group_id' => $page['group'],
|
||||||
|
'cat_id' => $to_autorize_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
mass_inserts(GROUP_ACCESS_TABLE, array('group_id','cat_id'), $inserts);
|
||||||
|
invalidate_user_cache();
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->set_filenames(
|
||||||
|
array(
|
||||||
|
'group_perm' => 'group_perm.tpl',
|
||||||
|
'double_select' => 'double_select.tpl'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'TITLE' =>
|
||||||
|
l10n(
|
||||||
|
'Manage permissions for group "%s"',
|
||||||
|
get_groupname($page['group'])
|
||||||
|
),
|
||||||
|
'L_CAT_OPTIONS_TRUE'=>l10n('Authorized'),
|
||||||
|
'L_CAT_OPTIONS_FALSE'=>l10n('Forbidden'),
|
||||||
|
|
||||||
|
'F_ACTION' =>
|
||||||
|
get_root_url().
|
||||||
|
'admin.php?page=group_perm&group_id='.
|
||||||
|
$page['group']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// only private categories are listed
|
||||||
|
$query_true = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.' INNER JOIN '.GROUP_ACCESS_TABLE.' ON cat_id = id
|
||||||
|
WHERE status = \'private\'
|
||||||
|
AND group_id = '.$page['group'].'
|
||||||
|
;';
|
||||||
|
display_select_cat_wrapper($query_true,array(),'category_option_true');
|
||||||
|
|
||||||
|
$result = pwg_query($query_true);
|
||||||
|
$authorized_ids = array();
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$authorized_ids[] = $row['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$query_false = '
|
||||||
|
SELECT id,name,uppercats,global_rank
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE status = \'private\'';
|
||||||
|
if (count($authorized_ids) > 0)
|
||||||
|
{
|
||||||
|
$query_false.= '
|
||||||
|
AND id NOT IN ('.implode(',', $authorized_ids).')';
|
||||||
|
}
|
||||||
|
$query_false.= '
|
||||||
|
;';
|
||||||
|
display_select_cat_wrapper($query_false,array(),'category_option_false');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | html code display |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('DOUBLE_SELECT', 'double_select');
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'group_perm');
|
||||||
|
|
||||||
|
?>
|
67
sources/admin/help.php
Normal file
67
sources/admin/help.php
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
$help_link = get_root_url().'admin.php?page=help§ion=';
|
||||||
|
$selected = null;
|
||||||
|
|
||||||
|
if (!isset($_GET['section']))
|
||||||
|
{
|
||||||
|
$selected = 'add_photos';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$selected = $_GET['section'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tabsheet = new tabsheet();
|
||||||
|
$tabsheet->set_id('help');
|
||||||
|
$tabsheet->select($selected);
|
||||||
|
$tabsheet->assign();
|
||||||
|
|
||||||
|
$template->set_filenames(array('help' => 'help.tpl'));
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'HELP_CONTENT' => load_language(
|
||||||
|
'help/help_'.$tabsheet->selected.'.html',
|
||||||
|
'',
|
||||||
|
array('return'=>true)
|
||||||
|
),
|
||||||
|
'HELP_SECTION_TITLE' => $tabsheet->sheets[ $tabsheet->selected ]['caption'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | sending html code |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'help');
|
||||||
|
?>
|
675
sources/admin/history.php
Normal file
675
sources/admin/history.php
Normal file
|
@ -0,0 +1,675 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display filtered history lines
|
||||||
|
*/
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | functions |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | initialization |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (!defined('PHPWG_ROOT_PATH'))
|
||||||
|
{
|
||||||
|
die('Hacking attempt!');
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions_history.inc.php');
|
||||||
|
|
||||||
|
if (isset($_GET['start']) and is_numeric($_GET['start']))
|
||||||
|
{
|
||||||
|
$page['start'] = $_GET['start'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['start'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$types = array('none', 'picture', 'high', 'other');
|
||||||
|
|
||||||
|
$display_thumbnails = array('no_display_thumbnail' => l10n('No display'),
|
||||||
|
'display_thumbnail_classic' => l10n('Classic display'),
|
||||||
|
'display_thumbnail_hoverbox' => l10n('Hoverbox display')
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Check Access and exit when user status is not ok |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
check_status(ACCESS_ADMINISTRATOR);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Build search criteria and redirect to results |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$page['errors'] = array();
|
||||||
|
$search = array();
|
||||||
|
|
||||||
|
if (isset($_POST['submit']))
|
||||||
|
{
|
||||||
|
// dates
|
||||||
|
if (!empty($_POST['start_year']))
|
||||||
|
{
|
||||||
|
$search['fields']['date-after'] = sprintf(
|
||||||
|
'%d-%02d-%02d',
|
||||||
|
$_POST['start_year'],
|
||||||
|
$_POST['start_month'],
|
||||||
|
$_POST['start_day']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($_POST['end_year']))
|
||||||
|
{
|
||||||
|
$search['fields']['date-before'] = sprintf(
|
||||||
|
'%d-%02d-%02d',
|
||||||
|
$_POST['end_year'],
|
||||||
|
$_POST['end_month'],
|
||||||
|
$_POST['end_day']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($_POST['types']))
|
||||||
|
{
|
||||||
|
$search['fields']['types'] = $types;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$search['fields']['types'] = $_POST['types'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$search['fields']['user'] = $_POST['user'];
|
||||||
|
|
||||||
|
if (!empty($_POST['image_id']))
|
||||||
|
{
|
||||||
|
$search['fields']['image_id'] = intval($_POST['image_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($_POST['filename']))
|
||||||
|
{
|
||||||
|
$search['fields']['filename'] = str_replace(
|
||||||
|
'*',
|
||||||
|
'%',
|
||||||
|
pwg_db_real_escape_string($_POST['filename'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($_POST['ip']))
|
||||||
|
{
|
||||||
|
$search['fields']['ip'] = str_replace(
|
||||||
|
'*',
|
||||||
|
'%',
|
||||||
|
pwg_db_real_escape_string($_POST['ip'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$search['fields']['display_thumbnail'] = $_POST['display_thumbnail'];
|
||||||
|
// Display choise are also save to one cookie
|
||||||
|
if (!empty($_POST['display_thumbnail'])
|
||||||
|
and isset($display_thumbnails[$_POST['display_thumbnail']]))
|
||||||
|
{
|
||||||
|
$cookie_val = $_POST['display_thumbnail'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$cookie_val = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
pwg_set_cookie_var('display_thumbnail', $cookie_val, strtotime('+1 month') );
|
||||||
|
|
||||||
|
// TODO manage inconsistency of having $_POST['image_id'] and
|
||||||
|
// $_POST['filename'] simultaneously
|
||||||
|
|
||||||
|
if (!empty($search))
|
||||||
|
{
|
||||||
|
// register search rules in database, then they will be available on
|
||||||
|
// thumbnails page and picture page.
|
||||||
|
$query ='
|
||||||
|
INSERT INTO '.SEARCH_TABLE.'
|
||||||
|
(rules)
|
||||||
|
VALUES
|
||||||
|
(\''.serialize($search).'\')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
$search_id = pwg_db_insert_id(SEARCH_TABLE);
|
||||||
|
|
||||||
|
redirect(
|
||||||
|
PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('Empty query. No criteria has been entered.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | template init |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->set_filename('history', 'history.tpl');
|
||||||
|
|
||||||
|
// TabSheet initialization
|
||||||
|
history_tabsheet();
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'U_HELP' => get_root_url().'admin/popuphelp.php?page=history',
|
||||||
|
'F_ACTION' => get_root_url().'admin.php?page=history'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | history lines |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (isset($_GET['search_id'])
|
||||||
|
and $page['search_id'] = (int)$_GET['search_id'])
|
||||||
|
{
|
||||||
|
// what are the lines to display in reality ?
|
||||||
|
$query = '
|
||||||
|
SELECT rules
|
||||||
|
FROM '.SEARCH_TABLE.'
|
||||||
|
WHERE id = '.$page['search_id'].'
|
||||||
|
;';
|
||||||
|
list($serialized_rules) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
|
||||||
|
$page['search'] = unserialize($serialized_rules);
|
||||||
|
|
||||||
|
if (isset($_GET['user_id']))
|
||||||
|
{
|
||||||
|
if (!is_numeric($_GET['user_id']))
|
||||||
|
{
|
||||||
|
die('user_id GET parameter must be an integer value');
|
||||||
|
}
|
||||||
|
|
||||||
|
$page['search']['fields']['user'] = $_GET['user_id'];
|
||||||
|
|
||||||
|
$query ='
|
||||||
|
INSERT INTO '.SEARCH_TABLE.'
|
||||||
|
(rules)
|
||||||
|
VALUES
|
||||||
|
(\''.serialize($page['search']).'\')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
$search_id = pwg_db_insert_id(SEARCH_TABLE);
|
||||||
|
|
||||||
|
redirect(
|
||||||
|
PHPWG_ROOT_PATH.'admin.php?page=history&search_id='.$search_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = trigger_event('get_history', array(), $page['search'], $types);
|
||||||
|
usort($data, 'history_compare');
|
||||||
|
|
||||||
|
$page['nb_lines'] = count($data);
|
||||||
|
|
||||||
|
$history_lines = array();
|
||||||
|
$user_ids = array();
|
||||||
|
$username_of = array();
|
||||||
|
$category_ids = array();
|
||||||
|
$image_ids = array();
|
||||||
|
$has_tags = false;
|
||||||
|
|
||||||
|
foreach ($data as $row)
|
||||||
|
{
|
||||||
|
$user_ids[$row['user_id']] = 1;
|
||||||
|
|
||||||
|
if (isset($row['category_id']))
|
||||||
|
{
|
||||||
|
$category_ids[$row['category_id']] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($row['image_id']))
|
||||||
|
{
|
||||||
|
$image_ids[$row['image_id']] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($row['tag_ids']))
|
||||||
|
{
|
||||||
|
$has_tags = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$history_lines[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare reference data (users, tags, categories...)
|
||||||
|
if (count($user_ids) > 0)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT '.$conf['user_fields']['id'].' AS id
|
||||||
|
, '.$conf['user_fields']['username'].' AS username
|
||||||
|
FROM '.USERS_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', array_keys($user_ids)).')
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
|
||||||
|
$username_of = array();
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$username_of[$row['id']] = stripslashes($row['username']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($category_ids) > 0)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT id, uppercats
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', array_keys($category_ids)).')
|
||||||
|
;';
|
||||||
|
$uppercats_of = simple_hash_from_query($query, 'id', 'uppercats');
|
||||||
|
|
||||||
|
$name_of_category = array();
|
||||||
|
|
||||||
|
foreach ($uppercats_of as $category_id => $uppercats)
|
||||||
|
{
|
||||||
|
$name_of_category[$category_id] = get_cat_display_name_cache(
|
||||||
|
$uppercats
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($image_ids) > 0)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
IF(name IS NULL, file, name) AS label,
|
||||||
|
filesize,
|
||||||
|
file,
|
||||||
|
path,
|
||||||
|
representative_ext
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE id IN ('.implode(',', array_keys($image_ids)).')
|
||||||
|
;';
|
||||||
|
// $label_of_image = simple_hash_from_query($query, 'id', 'label');
|
||||||
|
$label_of_image = array();
|
||||||
|
$filesize_of_image = array();
|
||||||
|
$file_of_image = array();
|
||||||
|
$path_of_image = array();
|
||||||
|
$representative_ext_of_image = array();
|
||||||
|
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$label_of_image[ $row['id'] ] = trigger_event('render_element_description', $row['label']);
|
||||||
|
|
||||||
|
if (isset($row['filesize']))
|
||||||
|
{
|
||||||
|
$filesize_of_image[ $row['id'] ] = $row['filesize'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$file_of_image[ $row['id'] ] = $row['file'];
|
||||||
|
$path_of_image[ $row['id'] ] = $row['path'];
|
||||||
|
$representative_ext_of_image[ $row['id'] ] = $row['representative_ext'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($has_tags > 0)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name, url_name
|
||||||
|
FROM '.TAGS_TABLE;
|
||||||
|
|
||||||
|
global $name_of_tag; // used for preg_replace
|
||||||
|
$name_of_tag = array();
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($row=pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$name_of_tag[ $row['id'] ] = '<a href="'.make_index_url( array('tags'=>array($row))).'">'.trigger_event("render_tag_name", $row['name'], $row).'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
$first_line = $page['start'] + 1;
|
||||||
|
$last_line = $page['start'] + $conf['nb_logs_page'];
|
||||||
|
|
||||||
|
$summary['total_filesize'] = 0;
|
||||||
|
$summary['guests_IP'] = array();
|
||||||
|
|
||||||
|
foreach ($history_lines as $line)
|
||||||
|
{
|
||||||
|
if (isset($line['image_type']) and $line['image_type'] == 'high')
|
||||||
|
{
|
||||||
|
if (isset($filesize_of_image[$line['image_id']]))
|
||||||
|
{
|
||||||
|
$summary['total_filesize'] += $filesize_of_image[$line['image_id']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($line['user_id'] == $conf['guest_id'])
|
||||||
|
{
|
||||||
|
if (!isset($summary['guests_IP'][ $line['IP'] ]))
|
||||||
|
{
|
||||||
|
$summary['guests_IP'][ $line['IP'] ] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$summary['guests_IP'][ $line['IP'] ]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
if ($i < $first_line or $i > $last_line)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user_string = '';
|
||||||
|
if (isset($username_of[$line['user_id']]))
|
||||||
|
{
|
||||||
|
$user_string.= $username_of[$line['user_id']];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$user_string.= $line['user_id'];
|
||||||
|
}
|
||||||
|
$user_string.= ' <a href="';
|
||||||
|
$user_string.= PHPWG_ROOT_PATH.'admin.php?page=history';
|
||||||
|
$user_string.= '&search_id='.$page['search_id'];
|
||||||
|
$user_string.= '&user_id='.$line['user_id'];
|
||||||
|
$user_string.= '">+</a>';
|
||||||
|
|
||||||
|
$tags_string = '';
|
||||||
|
if (isset($line['tag_ids']))
|
||||||
|
{
|
||||||
|
$tags_string = preg_replace_callback(
|
||||||
|
'/(\d+)/',
|
||||||
|
create_function('$m', 'global $name_of_tag; return isset($name_of_tag[$m[1]]) ? $name_of_tag[$m[1]] : $m[1];'),
|
||||||
|
str_replace(
|
||||||
|
',',
|
||||||
|
', ',
|
||||||
|
$line['tag_ids']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$image_string = '';
|
||||||
|
if (isset($line['image_id']))
|
||||||
|
{
|
||||||
|
$picture_url = make_picture_url(
|
||||||
|
array(
|
||||||
|
'image_id' => $line['image_id'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isset($file_of_image[$line['image_id']]))
|
||||||
|
{
|
||||||
|
$element = array(
|
||||||
|
'id' => $line['image_id'],
|
||||||
|
'file' => $file_of_image[$line['image_id']],
|
||||||
|
'path' => $path_of_image[$line['image_id']],
|
||||||
|
'representative_ext' => $representative_ext_of_image[$line['image_id']],
|
||||||
|
);
|
||||||
|
$thumbnail_display = $page['search']['fields']['display_thumbnail'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$thumbnail_display = 'no_display_thumbnail';
|
||||||
|
}
|
||||||
|
|
||||||
|
$image_title = '('.$line['image_id'].')';
|
||||||
|
|
||||||
|
if (isset($label_of_image[$line['image_id']]))
|
||||||
|
{
|
||||||
|
$image_title.= ' '.$label_of_image[$line['image_id']];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$image_title.= ' unknown filename';
|
||||||
|
}
|
||||||
|
|
||||||
|
$image_string = '';
|
||||||
|
|
||||||
|
switch ($thumbnail_display)
|
||||||
|
{
|
||||||
|
case 'no_display_thumbnail':
|
||||||
|
{
|
||||||
|
$image_string= '<a href="'.$picture_url.'">'.$image_title.'</a>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'display_thumbnail_classic':
|
||||||
|
{
|
||||||
|
$image_string =
|
||||||
|
'<a class="thumbnail" href="'.$picture_url.'">'
|
||||||
|
.'<span><img src="'.DerivativeImage::thumb_url($element)
|
||||||
|
.'" alt="'.$image_title.'" title="'.$image_title.'">'
|
||||||
|
.'</span></a>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'display_thumbnail_hoverbox':
|
||||||
|
{
|
||||||
|
$image_string =
|
||||||
|
'<a class="over" href="'.$picture_url.'">'
|
||||||
|
.'<span><img src="'.DerivativeImage::thumb_url($element)
|
||||||
|
.'" alt="'.$image_title.'" title="'.$image_title.'">'
|
||||||
|
.'</span>'.$image_title.'</a>';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->append(
|
||||||
|
'search_results',
|
||||||
|
array(
|
||||||
|
'DATE' => $line['date'],
|
||||||
|
'TIME' => $line['time'],
|
||||||
|
'USER' => $user_string,
|
||||||
|
'IP' => $line['IP'],
|
||||||
|
'IMAGE' => $image_string,
|
||||||
|
'TYPE' => $line['image_type'],
|
||||||
|
'SECTION' => $line['section'],
|
||||||
|
'CATEGORY' => isset($line['category_id'])
|
||||||
|
? ( isset($name_of_category[$line['category_id']])
|
||||||
|
? $name_of_category[$line['category_id']]
|
||||||
|
: 'deleted '.$line['category_id'] )
|
||||||
|
: '',
|
||||||
|
'TAGS' => $tags_string,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$summary['nb_guests'] = 0;
|
||||||
|
if (count(array_keys($summary['guests_IP'])) > 0)
|
||||||
|
{
|
||||||
|
$summary['nb_guests'] = count(array_keys($summary['guests_IP']));
|
||||||
|
|
||||||
|
// we delete the "guest" from the $username_of hash so that it is
|
||||||
|
// avoided in next steps
|
||||||
|
unset($username_of[ $conf['guest_id'] ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$summary['nb_members'] = count($username_of);
|
||||||
|
|
||||||
|
$member_strings = array();
|
||||||
|
foreach ($username_of as $user_id => $user_name)
|
||||||
|
{
|
||||||
|
$member_string = $user_name.' <a href="';
|
||||||
|
$member_string.= get_root_url().'admin.php?page=history';
|
||||||
|
$member_string.= '&search_id='.$page['search_id'];
|
||||||
|
$member_string.= '&user_id='.$user_id;
|
||||||
|
$member_string.= '">+</a>';
|
||||||
|
|
||||||
|
$member_strings[] = $member_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
'search_summary',
|
||||||
|
array(
|
||||||
|
'NB_LINES' => l10n_dec(
|
||||||
|
'%d line filtered', '%d lines filtered',
|
||||||
|
$page['nb_lines']
|
||||||
|
),
|
||||||
|
'FILESIZE' => $summary['total_filesize'] != 0 ? ceil($summary['total_filesize']/1024).' MB' : '',
|
||||||
|
'USERS' => l10n_dec(
|
||||||
|
'%d user', '%d users',
|
||||||
|
$summary['nb_members'] + $summary['nb_guests']
|
||||||
|
),
|
||||||
|
'MEMBERS' => sprintf(
|
||||||
|
l10n_dec('%d member', '%d members', $summary['nb_members']).': %s',
|
||||||
|
implode(', ', $member_strings)
|
||||||
|
),
|
||||||
|
'GUESTS' => l10n_dec(
|
||||||
|
'%d guest', '%d guests',
|
||||||
|
$summary['nb_guests']
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
unset($name_of_tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | navigation bar |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if (isset($page['search_id']))
|
||||||
|
{
|
||||||
|
$navbar = create_navigation_bar(
|
||||||
|
get_root_url().'admin.php'.get_query_string_diff(array('start')),
|
||||||
|
$page['nb_lines'],
|
||||||
|
$page['start'],
|
||||||
|
$conf['nb_logs_page']
|
||||||
|
);
|
||||||
|
|
||||||
|
$template->assign('navbar', $navbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | filter form |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$form = array();
|
||||||
|
|
||||||
|
if (isset($page['search']))
|
||||||
|
{
|
||||||
|
if (isset($page['search']['fields']['date-after']))
|
||||||
|
{
|
||||||
|
$tokens = explode('-', $page['search']['fields']['date-after']);
|
||||||
|
|
||||||
|
$form['start_year'] = (int)$tokens[0];
|
||||||
|
$form['start_month'] = (int)$tokens[1];
|
||||||
|
$form['start_day'] = (int)$tokens[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($page['search']['fields']['date-before']))
|
||||||
|
{
|
||||||
|
$tokens = explode('-', $page['search']['fields']['date-before']);
|
||||||
|
|
||||||
|
$form['end_year'] = (int)$tokens[0];
|
||||||
|
$form['end_month'] = (int)$tokens[1];
|
||||||
|
$form['end_day'] = (int)$tokens[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
$form['types'] = $page['search']['fields']['types'];
|
||||||
|
|
||||||
|
if (isset($page['search']['fields']['user']))
|
||||||
|
{
|
||||||
|
$form['user'] = $page['search']['fields']['user'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$form['user'] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form['image_id'] = @$page['search']['fields']['image_id'];
|
||||||
|
$form['filename'] = @$page['search']['fields']['filename'];
|
||||||
|
$form['ip'] = @$page['search']['fields']['ip'];
|
||||||
|
|
||||||
|
$form['display_thumbnail'] = @$page['search']['fields']['display_thumbnail'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// by default, at page load, we want the selected date to be the current
|
||||||
|
// date
|
||||||
|
$form['start_year'] = $form['end_year'] = date('Y');
|
||||||
|
$form['start_month'] = $form['end_month'] = date('n');
|
||||||
|
$form['start_day'] = $form['end_day'] = date('j');
|
||||||
|
$form['types'] = $types;
|
||||||
|
// Hoverbox by default
|
||||||
|
$form['display_thumbnail'] =
|
||||||
|
pwg_get_cookie_var('display_thumbnail', 'no_display_thumbnail');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$month_list = $lang['month'];
|
||||||
|
$month_list[0]='------------';
|
||||||
|
ksort($month_list);
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'IMAGE_ID' => @$form['image_id'],
|
||||||
|
'FILENAME' => @$form['filename'],
|
||||||
|
'IP' => @$form['ip'],
|
||||||
|
|
||||||
|
'month_list' => $month_list,
|
||||||
|
|
||||||
|
'START_DAY_SELECTED' => @$form['start_day'],
|
||||||
|
'START_MONTH_SELECTED' => @$form['start_month'],
|
||||||
|
'START_YEAR' => @$form['start_year'],
|
||||||
|
|
||||||
|
'END_DAY_SELECTED' => @$form['end_day'],
|
||||||
|
'END_MONTH_SELECTED' => @$form['end_month'],
|
||||||
|
'END_YEAR' => @$form['end_year'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'type_option_values' => $types,
|
||||||
|
'type_option_selected' => $form['types']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
'.$conf['user_fields']['id'].' AS id,
|
||||||
|
'.$conf['user_fields']['username'].' AS username
|
||||||
|
FROM '.USERS_TABLE.'
|
||||||
|
ORDER BY username ASC
|
||||||
|
;';
|
||||||
|
$template->assign(
|
||||||
|
array(
|
||||||
|
'user_options' => simple_hash_from_query($query, 'id','username'),
|
||||||
|
'user_options_selected' => array(@$form['user'])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$template->assign('display_thumbnails', $display_thumbnails);
|
||||||
|
$template->assign('display_thumbnail_selected', $form['display_thumbnail']);
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | html code display |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'history');
|
||||||
|
?>
|
155
sources/admin/include/add_core_tabs.inc.php
Normal file
155
sources/admin/include/add_core_tabs.inc.php
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
add_event_handler('tabsheet_before_select', 'add_core_tabs', 0, 2);
|
||||||
|
|
||||||
|
function add_core_tabs($sheets, $tab_id)
|
||||||
|
{
|
||||||
|
switch($tab_id)
|
||||||
|
{
|
||||||
|
case 'album':
|
||||||
|
global $admin_album_base_url;
|
||||||
|
$sheets['properties'] = array('caption' => '<span class="icon-pencil"></span>'.l10n('Properties'), 'url' => $admin_album_base_url.'-properties');
|
||||||
|
$sheets['sort_order'] = array('caption' => '<span class="icon-shuffle"></span>'.l10n('Manage photo ranks'), 'url' => $admin_album_base_url.'-sort_order');
|
||||||
|
$sheets['permissions'] = array('caption' => '<span class="icon-lock"></span>'.l10n('Permissions'), 'url' => $admin_album_base_url.'-permissions');
|
||||||
|
$sheets['notification'] = array('caption' => '<span class="icon-mail-alt"></span>'.l10n('Notification'), 'url' => $admin_album_base_url.'-notification');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'albums':
|
||||||
|
global $my_base_url;
|
||||||
|
$sheets['list'] = array('caption' => '<span class="icon-menu"></span>'.l10n('List'), 'url' => $my_base_url.'cat_list');
|
||||||
|
$sheets['move'] = array('caption' => '<span class="icon-move"></span>'.l10n('Move'), 'url' => $my_base_url.'cat_move');
|
||||||
|
$sheets['permalinks'] = array('caption' => '<span class="icon-link"></span>'.l10n('Permalinks'), 'url' => $my_base_url.'permalinks');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'batch_manager':
|
||||||
|
global $manager_link;
|
||||||
|
$sheets['global'] = array('caption' => l10n('global mode'), 'url' => $manager_link.'global');
|
||||||
|
$sheets['unit'] = array('caption' => l10n('unit mode'), 'url' => $manager_link.'unit');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'cat_options':
|
||||||
|
global $link_start, $conf;
|
||||||
|
$sheets['status'] = array('caption' => '<span class="icon-lock"></span>'.l10n('Public / Private'), 'url' => $link_start.'cat_options&section=status');
|
||||||
|
$sheets['visible'] = array('caption' => '<span class="icon-block"></span>'.l10n('Lock'), 'url' => $link_start.'cat_options&section=visible');
|
||||||
|
if ($conf['activate_comments'])
|
||||||
|
$sheets['comments'] = array('caption' => '<span class="icon-chat"></span>'.l10n('Comments'), 'url' => $link_start.'cat_options&section=comments');
|
||||||
|
if ($conf['allow_random_representative'])
|
||||||
|
$sheets['representative'] = array('caption' => l10n('Representative'), 'url' => $link_start.'cat_options&section=representative');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'comments':
|
||||||
|
$sheets[''] = array('caption' => l10n('User comments'), 'url' => '');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'users':
|
||||||
|
$sheets[''] = array('caption' => '<span class="icon-users"> </span>'.l10n('User list'), 'url' => '');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'groups':
|
||||||
|
$sheets[''] = array('caption' => '<span class="icon-group"> </span>'.l10n('Groups'), 'url' => '');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'configuration':
|
||||||
|
global $conf_link;
|
||||||
|
$sheets['main'] = array('caption' => l10n('General'), 'url' => $conf_link.'main');
|
||||||
|
$sheets['sizes'] = array('caption' => l10n('Photo sizes'), 'url' => $conf_link.'sizes');
|
||||||
|
$sheets['watermark'] = array('caption' => l10n('Watermark'), 'url' => $conf_link.'watermark');
|
||||||
|
$sheets['display'] = array('caption' => l10n('Display'), 'url' => $conf_link.'display');
|
||||||
|
$sheets['comments'] = array('caption' => l10n('Comments'), 'url' => $conf_link.'comments');
|
||||||
|
$sheets['default'] = array('caption' => l10n('Guest Settings'), 'url' => $conf_link.'default');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'help':
|
||||||
|
global $help_link;
|
||||||
|
$sheets['add_photos'] = array('caption' => l10n('Add Photos'), 'url' => $help_link.'add_photos');
|
||||||
|
$sheets['permissions'] = array('caption' => l10n('Permissions'), 'url' => $help_link.'permissions');
|
||||||
|
$sheets['groups'] = array('caption' => l10n('Groups'), 'url' => $help_link.'groups');
|
||||||
|
$sheets['virtual_links'] = array('caption' => l10n('Virtual Links'), 'url' => $help_link.'virtual_links');
|
||||||
|
$sheets['misc'] = array('caption' => l10n('Miscellaneous'), 'url' => $help_link.'misc');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'history':
|
||||||
|
global $link_start;
|
||||||
|
$sheets['stats'] = array('caption' => '<span class="icon-signal"></span>'.l10n('Statistics'), 'url' => $link_start.'stats');
|
||||||
|
$sheets['history'] = array('caption' => '<span class="icon-search"></span>'.l10n('Search'), 'url' => $link_start.'history');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'languages':
|
||||||
|
global $my_base_url;
|
||||||
|
$sheets['installed'] = array('caption' => '<span class="icon-language"></span>'.l10n('Installed Languages'), 'url' => $my_base_url.'&tab=installed');
|
||||||
|
$sheets['update'] = array('caption' => '<span class="icon-arrows-cw"></span>'.l10n('Check for updates'), 'url' => $my_base_url.'&tab=update');
|
||||||
|
$sheets['new'] = array('caption' => '<span class="icon-plus-circled"></span>'.l10n('Add New Language'), 'url' => $my_base_url.'&tab=new');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'nbm':
|
||||||
|
global $base_url;
|
||||||
|
$sheets['param'] = array('caption' => l10n('Parameter'), 'url' => $base_url.'?page=notification_by_mail&mode=param');
|
||||||
|
$sheets['subscribe'] = array('caption' => l10n('Subscribe'), 'url' => $base_url.'?page=notification_by_mail&mode=subscribe');
|
||||||
|
$sheets['send'] = array('caption' => l10n('Send'), 'url' => $base_url.'?page=notification_by_mail&mode=send');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'photo':
|
||||||
|
global $admin_photo_base_url;
|
||||||
|
$sheets['properties'] = array('caption' => l10n('Properties'), 'url' => $admin_photo_base_url.'-properties');
|
||||||
|
$sheets['coi'] = array('caption' => '<span class="icon-crop"></span>'.l10n('Center of interest'), 'url' => $admin_photo_base_url.'-coi');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'photos_add':
|
||||||
|
global $conf;
|
||||||
|
$sheets['direct'] = array('caption' => '<span class="icon-upload"></span>'.l10n('Web Form'), 'url' => PHOTOS_ADD_BASE_URL.'&section=direct');
|
||||||
|
$sheets['applications'] = array('caption' => '<span class="icon-network"></span>'.l10n('Applications'), 'url' => PHOTOS_ADD_BASE_URL.'&section=applications');
|
||||||
|
if ($conf['enable_synchronization'])
|
||||||
|
$sheets['ftp'] = array('caption' => '<span class="icon-exchange"></span>'.l10n('FTP + Synchronization'), 'url' => PHOTOS_ADD_BASE_URL.'&section=ftp');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'plugins':
|
||||||
|
global $my_base_url;
|
||||||
|
$sheets['installed'] = array('caption' => '<span class="icon-equalizer"></span>'.l10n('Plugin list'), 'url' => $my_base_url.'&tab=installed');
|
||||||
|
$sheets['update'] = array('caption' => '<span class="icon-arrows-cw"></span>'.l10n('Check for updates'), 'url' => $my_base_url.'&tab=update');
|
||||||
|
$sheets['new'] = array('caption' => '<span class="icon-plus-circled"></span>'.l10n('Other plugins'), 'url' => $my_base_url.'&tab=new');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'rating':
|
||||||
|
$sheets['rating'] = array('caption' => l10n('Photos'), 'url' => get_root_url().'admin.php?page=rating');
|
||||||
|
$sheets['rating_user'] = array('caption' => l10n('Users'), 'url' => get_root_url().'admin.php?page=rating_user');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'themes':
|
||||||
|
global $my_base_url;
|
||||||
|
$sheets['installed'] = array('caption' => '<span class="icon-brush"></span>'.l10n('Installed Themes'), 'url' => $my_base_url.'&tab=installed');
|
||||||
|
$sheets['update'] = array('caption' => '<span class="icon-arrows-cw"></span>'.l10n('Check for updates'), 'url' => $my_base_url.'&tab=update');
|
||||||
|
$sheets['new'] = array('caption' => '<span class="icon-plus-circled"></span>'.l10n('Add New Theme'), 'url' => $my_base_url.'&tab=new');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'updates':
|
||||||
|
global $my_base_url;
|
||||||
|
$sheets['pwg'] = array('caption' => l10n('Piwigo Update'), 'url' => $my_base_url);
|
||||||
|
$sheets['ext'] = array('caption' => l10n('Extensions Update'), 'url' => $my_base_url.'&tab=ext');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sheets;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
33
sources/admin/include/albums_tab.inc.php
Normal file
33
sources/admin/include/albums_tab.inc.php
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||||
|
|
||||||
|
$my_base_url = get_root_url().'admin.php?page=';
|
||||||
|
|
||||||
|
$tabsheet = new tabsheet();
|
||||||
|
$tabsheet->set_id('albums');
|
||||||
|
$tabsheet->select($page['tab']);
|
||||||
|
$tabsheet->assign();
|
||||||
|
|
||||||
|
?>
|
258
sources/admin/include/c13y_internal.class.php
Normal file
258
sources/admin/include/c13y_internal.class.php
Normal file
|
@ -0,0 +1,258 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
class c13y_internal
|
||||||
|
{
|
||||||
|
function c13y_internal()
|
||||||
|
{
|
||||||
|
add_event_handler('list_check_integrity', array(&$this, 'c13y_version'));
|
||||||
|
add_event_handler('list_check_integrity', array(&$this, 'c13y_exif'));
|
||||||
|
add_event_handler('list_check_integrity', array(&$this, 'c13y_user'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check version
|
||||||
|
*
|
||||||
|
* @param c13y object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function c13y_version($c13y)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$check_list = array();
|
||||||
|
|
||||||
|
$check_list[] = array(
|
||||||
|
'type' => 'PHP',
|
||||||
|
'current' => phpversion(),
|
||||||
|
'required' => REQUIRED_PHP_VERSION,
|
||||||
|
);
|
||||||
|
|
||||||
|
$check_list[] = array(
|
||||||
|
'type' => 'MySQL',
|
||||||
|
'current' => pwg_get_db_version(),
|
||||||
|
'required' => REQUIRED_MYSQL_VERSION,
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($check_list as $elem)
|
||||||
|
{
|
||||||
|
if (version_compare($elem['current'], $elem['required'], '<'))
|
||||||
|
{
|
||||||
|
$c13y->add_anomaly(
|
||||||
|
sprintf(l10n('The version of %s [%s] installed is not compatible with the version required [%s]'), $elem['type'], $elem['current'], $elem['required']),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
l10n('You need to upgrade your system to take full advantage of the application else the application will not work correctly, or not at all')
|
||||||
|
.'<br>'.
|
||||||
|
$c13y->get_htlm_links_more_info());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check exif
|
||||||
|
*
|
||||||
|
* @param c13y object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function c13y_exif($c13y)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
foreach (array('show_exif', 'use_exif') as $value)
|
||||||
|
{
|
||||||
|
if (($conf[$value]) and (!function_exists('read_exif_data')))
|
||||||
|
{
|
||||||
|
$c13y->add_anomaly(
|
||||||
|
sprintf(l10n('%s value is not correct file because exif are not supported'), '$conf[\''.$value.'\']'),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
sprintf(l10n('%s must be to set to false in your local/config/config.inc.php file'), '$conf[\''.$value.'\']')
|
||||||
|
.'<br>'.
|
||||||
|
$c13y->get_htlm_links_more_info());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check user
|
||||||
|
*
|
||||||
|
* @param c13y object
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function c13y_user($c13y)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$c13y_users = array();
|
||||||
|
$c13y_users[$conf['guest_id']] = array(
|
||||||
|
'status' => 'guest',
|
||||||
|
'l10n_non_existent' => 'Main "guest" user does not exist',
|
||||||
|
'l10n_bad_status' => 'Main "guest" user status is incorrect');
|
||||||
|
|
||||||
|
if ($conf['guest_id'] != $conf['default_user_id'])
|
||||||
|
{
|
||||||
|
$c13y_users[$conf['default_user_id']] = array(
|
||||||
|
'password' => null,
|
||||||
|
'l10n_non_existent' => 'Default user does not exist');
|
||||||
|
}
|
||||||
|
|
||||||
|
$c13y_users[$conf['webmaster_id']] = array(
|
||||||
|
'status' => 'webmaster',
|
||||||
|
'l10n_non_existent' => 'Main "webmaster" user does not exist',
|
||||||
|
'l10n_bad_status' => 'Main "webmaster" user status is incorrect');
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
select u.'.$conf['user_fields']['id'].' as id, ui.status
|
||||||
|
from '.USERS_TABLE.' as u
|
||||||
|
left join '.USER_INFOS_TABLE.' as ui
|
||||||
|
on u.'.$conf['user_fields']['id'].' = ui.user_id
|
||||||
|
where
|
||||||
|
u.'.$conf['user_fields']['id'].' in ('.implode(',', array_keys($c13y_users)).')
|
||||||
|
;';
|
||||||
|
|
||||||
|
|
||||||
|
$status = array();
|
||||||
|
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$status[$row['id']] = $row['status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($c13y_users as $id => $data)
|
||||||
|
{
|
||||||
|
if (!array_key_exists($id, $status))
|
||||||
|
{
|
||||||
|
$c13y->add_anomaly(l10n($data['l10n_non_existent']), 'c13y_correction_user',
|
||||||
|
array('id' => $id, 'action' => 'creation'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (!empty($data['status']) and $status[$id] != $data['status'])
|
||||||
|
{
|
||||||
|
$c13y->add_anomaly(l10n($data['l10n_bad_status']), 'c13y_correction_user',
|
||||||
|
array('id' => $id, 'action' => 'status'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do correction user
|
||||||
|
*
|
||||||
|
* @param user_id, action
|
||||||
|
* @return boolean true if ok else false
|
||||||
|
*/
|
||||||
|
function c13y_correction_user($id, $action)
|
||||||
|
{
|
||||||
|
global $conf, $page;
|
||||||
|
|
||||||
|
$result = false;
|
||||||
|
|
||||||
|
if (!empty($id))
|
||||||
|
{
|
||||||
|
switch ($action)
|
||||||
|
{
|
||||||
|
case 'creation':
|
||||||
|
if ($id == $conf['guest_id'])
|
||||||
|
{
|
||||||
|
$name = 'guest';
|
||||||
|
$password = null;
|
||||||
|
}
|
||||||
|
else if ($id == $conf['default_user_id'])
|
||||||
|
{
|
||||||
|
$name = 'guest';
|
||||||
|
$password = null;
|
||||||
|
}
|
||||||
|
else if ($id == $conf['webmaster_id'])
|
||||||
|
{
|
||||||
|
$name = 'webmaster';
|
||||||
|
$password = generate_key(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($name))
|
||||||
|
{
|
||||||
|
$name_ok = false;
|
||||||
|
while (!$name_ok)
|
||||||
|
{
|
||||||
|
$name_ok = (get_userid($name) === false);
|
||||||
|
if (!$name_ok)
|
||||||
|
{
|
||||||
|
$name .= generate_key(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$inserts = array(
|
||||||
|
array(
|
||||||
|
'id' => $id,
|
||||||
|
'username' => addslashes($name),
|
||||||
|
'password' => $password
|
||||||
|
),
|
||||||
|
);
|
||||||
|
mass_inserts(USERS_TABLE, array_keys($inserts[0]), $inserts);
|
||||||
|
|
||||||
|
create_user_infos($id);
|
||||||
|
|
||||||
|
$page['infos'][] = sprintf(l10n('User "%s" created with "%s" like password'), $name, $password);
|
||||||
|
|
||||||
|
$result = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'status':
|
||||||
|
if ($id == $conf['guest_id'])
|
||||||
|
{
|
||||||
|
$status = 'guest';
|
||||||
|
}
|
||||||
|
else if ($id == $conf['default_user_id'])
|
||||||
|
{
|
||||||
|
$status = 'guest';
|
||||||
|
}
|
||||||
|
else if ($id == $conf['webmaster_id'])
|
||||||
|
{
|
||||||
|
$status = 'webmaster';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($status))
|
||||||
|
{
|
||||||
|
$updates = array(
|
||||||
|
array(
|
||||||
|
'user_id' => $id,
|
||||||
|
'status' => $status
|
||||||
|
),
|
||||||
|
);
|
||||||
|
mass_updates(USER_INFOS_TABLE,
|
||||||
|
array('primary' => array('user_id'),'update' => array('status')),
|
||||||
|
$updates);
|
||||||
|
|
||||||
|
$page['infos'][] = sprintf(l10n('Status of user "%s" updated'), get_username($id));
|
||||||
|
|
||||||
|
$result = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
346
sources/admin/include/check_integrity.class.php
Normal file
346
sources/admin/include/check_integrity.class.php
Normal file
|
@ -0,0 +1,346 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
class check_integrity
|
||||||
|
{
|
||||||
|
var $ignore_list;
|
||||||
|
var $retrieve_list;
|
||||||
|
var $build_ignore_list;
|
||||||
|
|
||||||
|
function check_integrity()
|
||||||
|
{
|
||||||
|
$this->ignore_list = array();
|
||||||
|
$this->retrieve_list = array();
|
||||||
|
$this->build_ignore_list = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check integrities
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function check()
|
||||||
|
{
|
||||||
|
global $page, $header_notes, $conf;
|
||||||
|
|
||||||
|
// Ignore list
|
||||||
|
$conf_c13y_ignore = unserialize($conf['c13y_ignore']);
|
||||||
|
if (
|
||||||
|
is_array($conf_c13y_ignore) and
|
||||||
|
isset($conf_c13y_ignore['version']) and
|
||||||
|
($conf_c13y_ignore['version'] == PHPWG_VERSION) and
|
||||||
|
is_array($conf_c13y_ignore['list'])
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$ignore_list_changed = false;
|
||||||
|
$this->ignore_list = $conf_c13y_ignore['list'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ignore_list_changed = true;
|
||||||
|
$this->ignore_list = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve list
|
||||||
|
$this->retrieve_list = array();
|
||||||
|
$this->build_ignore_list = array();
|
||||||
|
|
||||||
|
trigger_action('list_check_integrity', $this);
|
||||||
|
|
||||||
|
// Information
|
||||||
|
if (count($this->retrieve_list) > 0)
|
||||||
|
{
|
||||||
|
$header_notes[] = l10n_dec(
|
||||||
|
'%d anomaly has been detected.', '%d anomalies have been detected.',
|
||||||
|
count($this->retrieve_list)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Treatments
|
||||||
|
if (isset($_POST['c13y_submit_correction']) and isset($_POST['c13y_selection']))
|
||||||
|
{
|
||||||
|
$corrected_count = 0;
|
||||||
|
$not_corrected_count = 0;
|
||||||
|
|
||||||
|
foreach ($this->retrieve_list as $i => $c13y)
|
||||||
|
{
|
||||||
|
if (!empty($c13y['correction_fct']) and
|
||||||
|
$c13y['is_callable'] and
|
||||||
|
in_array($c13y['id'], $_POST['c13y_selection']))
|
||||||
|
{
|
||||||
|
if (is_array($c13y['correction_fct_args']))
|
||||||
|
{
|
||||||
|
$args = $c13y['correction_fct_args'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (!is_null($c13y['correction_fct_args']))
|
||||||
|
{
|
||||||
|
$args = array($c13y['correction_fct_args']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$args = array();
|
||||||
|
}
|
||||||
|
$this->retrieve_list[$i]['corrected'] = call_user_func_array($c13y['correction_fct'], $args);
|
||||||
|
|
||||||
|
if ($this->retrieve_list[$i]['corrected'])
|
||||||
|
{
|
||||||
|
$corrected_count += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$not_corrected_count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($corrected_count > 0)
|
||||||
|
{
|
||||||
|
$page['infos'][] = l10n_dec(
|
||||||
|
'%d anomaly has been corrected.', '%d anomalies have been detected corrected.',
|
||||||
|
$corrected_count
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ($not_corrected_count > 0)
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n_dec(
|
||||||
|
'%d anomaly has not been corrected.', '%d anomalies have not been corrected.',
|
||||||
|
$not_corrected_count
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isset($_POST['c13y_submit_ignore']) and isset($_POST['c13y_selection']))
|
||||||
|
{
|
||||||
|
$ignored_count = 0;
|
||||||
|
|
||||||
|
foreach ($this->retrieve_list as $i => $c13y)
|
||||||
|
{
|
||||||
|
if (in_array($c13y['id'], $_POST['c13y_selection']))
|
||||||
|
{
|
||||||
|
$this->build_ignore_list[] = $c13y['id'];
|
||||||
|
$this->retrieve_list[$i]['ignored'] = true;
|
||||||
|
$ignored_count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ignored_count > 0)
|
||||||
|
{
|
||||||
|
$page['infos'][] = l10n_dec(
|
||||||
|
'%d anomaly has been ignored.', '%d anomalies have been ignored.',
|
||||||
|
$ignored_count
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ignore_list_changed =
|
||||||
|
(
|
||||||
|
($ignore_list_changed) or
|
||||||
|
(count(array_diff($this->ignore_list, $this->build_ignore_list)) > 0) or
|
||||||
|
(count(array_diff($this->build_ignore_list, $this->ignore_list)) > 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($ignore_list_changed)
|
||||||
|
{
|
||||||
|
$this->update_conf($this->build_ignore_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display anomalies list
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function display()
|
||||||
|
{
|
||||||
|
global $template;
|
||||||
|
|
||||||
|
$check_automatic_correction = false;
|
||||||
|
$submit_automatic_correction = false;
|
||||||
|
$submit_ignore = false;
|
||||||
|
|
||||||
|
if (isset($this->retrieve_list) and count($this->retrieve_list) > 0)
|
||||||
|
{
|
||||||
|
$template->set_filenames(array('check_integrity' => 'check_integrity.tpl'));
|
||||||
|
|
||||||
|
foreach ($this->retrieve_list as $i => $c13y)
|
||||||
|
{
|
||||||
|
$can_select = false;
|
||||||
|
$c13y_display = array(
|
||||||
|
'id' => $c13y['id'],
|
||||||
|
'anomaly' => $c13y['anomaly'],
|
||||||
|
'show_ignore_msg' => false,
|
||||||
|
'show_correction_success_fct' => false,
|
||||||
|
'correction_error_fct' => '',
|
||||||
|
'show_correction_fct' => false,
|
||||||
|
'correction_error_fct' => '',
|
||||||
|
'show_correction_bad_fct' => false,
|
||||||
|
'correction_msg' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isset($c13y['ignored']))
|
||||||
|
{
|
||||||
|
if ($c13y['ignored'])
|
||||||
|
{
|
||||||
|
$c13y_display['show_ignore_msg'] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
die('$c13y[\'ignored\'] cannot be false');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!empty($c13y['correction_fct']))
|
||||||
|
{
|
||||||
|
if (isset($c13y['corrected']))
|
||||||
|
{
|
||||||
|
if ($c13y['corrected'])
|
||||||
|
{
|
||||||
|
$c13y_display['show_correction_success_fct'] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$c13y_display['correction_error_fct'] = $this->get_htlm_links_more_info();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ($c13y['is_callable'])
|
||||||
|
{
|
||||||
|
$c13y_display['show_correction_fct'] = true;
|
||||||
|
$template->append('c13y_do_check', $c13y['id']);
|
||||||
|
$submit_automatic_correction = true;
|
||||||
|
$can_select = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$c13y_display['show_correction_bad_fct'] = true;
|
||||||
|
$can_select = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$can_select = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($c13y['correction_msg']) and !isset($c13y['corrected']))
|
||||||
|
{
|
||||||
|
$c13y_display['correction_msg'] = $c13y['correction_msg'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$c13y_display['can_select'] = $can_select;
|
||||||
|
if ($can_select)
|
||||||
|
{
|
||||||
|
$submit_ignore = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->append('c13y_list', $c13y_display);
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign('c13y_show_submit_automatic_correction', $submit_automatic_correction);
|
||||||
|
$template->assign('c13y_show_submit_ignore', $submit_ignore);
|
||||||
|
|
||||||
|
$template->concat('ADMIN_CONTENT', $template->parse('check_integrity', true));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add anomaly data
|
||||||
|
*
|
||||||
|
* @param anomaly arguments
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function add_anomaly($anomaly, $correction_fct = null, $correction_fct_args = null, $correction_msg = null)
|
||||||
|
{
|
||||||
|
$id = md5($anomaly.$correction_fct.serialize($correction_fct_args).$correction_msg);
|
||||||
|
|
||||||
|
if (in_array($id, $this->ignore_list))
|
||||||
|
{
|
||||||
|
$this->build_ignore_list[] = $id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->retrieve_list[] =
|
||||||
|
array(
|
||||||
|
'id' => $id,
|
||||||
|
'anomaly' => $anomaly,
|
||||||
|
'correction_fct' => $correction_fct,
|
||||||
|
'correction_fct_args' => $correction_fct_args,
|
||||||
|
'correction_msg' => $correction_msg,
|
||||||
|
'is_callable' => is_callable($correction_fct));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update table config
|
||||||
|
*
|
||||||
|
* @param ignore list array
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function update_conf($conf_ignore_list = array())
|
||||||
|
{
|
||||||
|
$conf_c13y_ignore = array();
|
||||||
|
$conf_c13y_ignore['version'] = PHPWG_VERSION;
|
||||||
|
$conf_c13y_ignore['list'] = $conf_ignore_list;
|
||||||
|
$query = 'update '.CONFIG_TABLE.' set value =\''.serialize($conf_c13y_ignore).'\'where param = \'c13y_ignore\';';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply maintenance
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function maintenance()
|
||||||
|
{
|
||||||
|
$this->update_conf();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns links more informations
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return html links
|
||||||
|
*/
|
||||||
|
function get_htlm_links_more_info()
|
||||||
|
{
|
||||||
|
$pwg_links = pwg_URL();
|
||||||
|
$link_fmt = '<a href="%s" onclick="window.open(this.href, \'\'); return false;">%s</a>';
|
||||||
|
return
|
||||||
|
sprintf
|
||||||
|
(
|
||||||
|
l10n('Go to %s or %s for more informations'),
|
||||||
|
sprintf($link_fmt, $pwg_links['FORUM'], l10n('the forum')),
|
||||||
|
sprintf($link_fmt, $pwg_links['WIKI'], l10n('the wiki'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
280
sources/admin/include/configuration_sizes_process.inc.php
Normal file
280
sources/admin/include/configuration_sizes_process.inc.php
Normal file
|
@ -0,0 +1,280 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if( !defined("PHPWG_ROOT_PATH") )
|
||||||
|
{
|
||||||
|
die ("Hacking attempt!");
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = array();
|
||||||
|
|
||||||
|
// original resize
|
||||||
|
$original_fields = array(
|
||||||
|
'original_resize',
|
||||||
|
'original_resize_maxwidth',
|
||||||
|
'original_resize_maxheight',
|
||||||
|
'original_resize_quality',
|
||||||
|
);
|
||||||
|
|
||||||
|
$updates = array();
|
||||||
|
|
||||||
|
foreach ($original_fields as $field)
|
||||||
|
{
|
||||||
|
$value = !empty($_POST[$field]) ? $_POST[$field] : null;
|
||||||
|
$updates[$field] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
save_upload_form_config($updates, $page['errors'], $errors);
|
||||||
|
|
||||||
|
if ($_POST['resize_quality'] < 50 or $_POST['resize_quality'] > 98)
|
||||||
|
{
|
||||||
|
$errors['resize_quality'] = '[50..98]';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pderivatives = $_POST['d'];
|
||||||
|
|
||||||
|
// step 1 - sanitize HTML input
|
||||||
|
foreach ($pderivatives as $type => &$pderivative)
|
||||||
|
{
|
||||||
|
if ($pderivative['must_square'] = ($type==IMG_SQUARE ? true : false))
|
||||||
|
{
|
||||||
|
$pderivative['h'] = $pderivative['w'];
|
||||||
|
$pderivative['minh'] = $pderivative['minw'] = $pderivative['w'];
|
||||||
|
$pderivative['crop'] = 100;
|
||||||
|
}
|
||||||
|
$pderivative['must_enable'] = ($type==IMG_SQUARE || $type==IMG_THUMB)? true : false;
|
||||||
|
$pderivative['enabled'] = isset($pderivative['enabled']) || $pderivative['must_enable'] ? true : false;
|
||||||
|
|
||||||
|
if (isset($pderivative['crop']))
|
||||||
|
{
|
||||||
|
$pderivative['crop'] = 100;
|
||||||
|
$pderivative['minw'] = $pderivative['w'];
|
||||||
|
$pderivative['minh'] = $pderivative['h'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pderivative['crop'] = 0;
|
||||||
|
$pderivative['minw'] = null;
|
||||||
|
$pderivative['minh'] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($pderivative);
|
||||||
|
|
||||||
|
// step 2 - check validity
|
||||||
|
$prev_w = $prev_h = 0;
|
||||||
|
foreach(ImageStdParams::get_all_types() as $type)
|
||||||
|
{
|
||||||
|
$pderivative = $pderivatives[$type];
|
||||||
|
if (!$pderivative['enabled'])
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type == IMG_THUMB)
|
||||||
|
{
|
||||||
|
$w = intval($pderivative['w']);
|
||||||
|
if ($w <= 0)
|
||||||
|
{
|
||||||
|
$errors[$type]['w'] = '>0';
|
||||||
|
}
|
||||||
|
|
||||||
|
$h = intval($pderivative['h']);
|
||||||
|
if ($h <= 0)
|
||||||
|
{
|
||||||
|
$errors[$type]['h'] = '>0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (max($w,$h) <= $prev_w)
|
||||||
|
{
|
||||||
|
$errors[$type]['w'] = $errors[$type]['h'] = '>'.$prev_w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$v = intval($pderivative['w']);
|
||||||
|
if ($v <= 0 or $v <= $prev_w)
|
||||||
|
{
|
||||||
|
$errors[$type]['w'] = '>'.$prev_w;
|
||||||
|
}
|
||||||
|
|
||||||
|
$v = intval($pderivative['h']);
|
||||||
|
if ($v <= 0 or $v <= $prev_h)
|
||||||
|
{
|
||||||
|
$errors[$type]['h'] = '>'.$prev_h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($errors) == 0)
|
||||||
|
{
|
||||||
|
$prev_w = intval($pderivative['w']);
|
||||||
|
$prev_h = intval($pderivative['h']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$v = intval($pderivative['sharpen']);
|
||||||
|
if ($v<0 || $v>100)
|
||||||
|
{
|
||||||
|
$errors[$type]['sharpen'] = '[0..100]';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// step 3 - save data
|
||||||
|
if (count($errors) == 0)
|
||||||
|
{
|
||||||
|
$quality_changed = ImageStdParams::$quality != intval($_POST['resize_quality']);
|
||||||
|
ImageStdParams::$quality = intval($_POST['resize_quality']);
|
||||||
|
|
||||||
|
$enabled = ImageStdParams::get_defined_type_map();
|
||||||
|
$disabled = @unserialize( @$conf['disabled_derivatives'] );
|
||||||
|
if ($disabled === false)
|
||||||
|
{
|
||||||
|
$disabled = array();
|
||||||
|
}
|
||||||
|
$changed_types = array();
|
||||||
|
|
||||||
|
foreach (ImageStdParams::get_all_types() as $type)
|
||||||
|
{
|
||||||
|
$pderivative = $pderivatives[$type];
|
||||||
|
|
||||||
|
if ($pderivative['enabled'])
|
||||||
|
{
|
||||||
|
$new_params = new DerivativeParams(
|
||||||
|
new SizingParams(
|
||||||
|
array(intval($pderivative['w']), intval($pderivative['h'])),
|
||||||
|
round($pderivative['crop'] / 100, 2),
|
||||||
|
array(intval($pderivative['minw']), intval($pderivative['minh']))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$new_params->sharpen = intval($pderivative['sharpen']);
|
||||||
|
|
||||||
|
ImageStdParams::apply_global($new_params);
|
||||||
|
|
||||||
|
if (isset($enabled[$type]))
|
||||||
|
{
|
||||||
|
$old_params = $enabled[$type];
|
||||||
|
$same = true;
|
||||||
|
if (!size_equals($old_params->sizing->ideal_size, $new_params->sizing->ideal_size)
|
||||||
|
or $old_params->sizing->max_crop != $new_params->sizing->max_crop)
|
||||||
|
{
|
||||||
|
$same = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($same
|
||||||
|
and $new_params->sizing->max_crop != 0
|
||||||
|
and !size_equals($old_params->sizing->min_size, $new_params->sizing->min_size))
|
||||||
|
{
|
||||||
|
$same = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($quality_changed
|
||||||
|
|| $new_params->sharpen != $old_params->sharpen)
|
||||||
|
{
|
||||||
|
$same = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$same)
|
||||||
|
{
|
||||||
|
$new_params->last_mod_time = time();
|
||||||
|
$changed_types[] = $type;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$new_params->last_mod_time = $old_params->last_mod_time;
|
||||||
|
}
|
||||||
|
$enabled[$type] = $new_params;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// now enabled, before was disabled
|
||||||
|
$enabled[$type] = $new_params;
|
||||||
|
unset($disabled[$type]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{// disabled
|
||||||
|
if (isset($enabled[$type]))
|
||||||
|
{// now disabled, before was enabled
|
||||||
|
$changed_types[] = $type;
|
||||||
|
$disabled[$type] = $enabled[$type];
|
||||||
|
unset($enabled[$type]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$enabled_by = array(); // keys ordered by all types
|
||||||
|
foreach(ImageStdParams::get_all_types() as $type)
|
||||||
|
{
|
||||||
|
if (isset($enabled[$type]))
|
||||||
|
{
|
||||||
|
$enabled_by[$type] = $enabled[$type];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach( array_keys(ImageStdParams::$custom) as $custom)
|
||||||
|
{
|
||||||
|
if (isset($_POST['delete_custom_derivative_'.$custom]))
|
||||||
|
{
|
||||||
|
$changed_types[] = $custom;
|
||||||
|
unset(ImageStdParams::$custom[$custom]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageStdParams::set_and_save($enabled_by);
|
||||||
|
if (count($disabled) == 0)
|
||||||
|
{
|
||||||
|
$query='DELETE FROM '.CONFIG_TABLE.' WHERE param = \'disabled_derivatives\'';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
conf_update_param('disabled_derivatives', addslashes(serialize($disabled)) );
|
||||||
|
}
|
||||||
|
$conf['disabled_derivatives'] = serialize($disabled);
|
||||||
|
|
||||||
|
if (count($changed_types))
|
||||||
|
{
|
||||||
|
clear_derivative_cache($changed_types);
|
||||||
|
}
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('Your configuration settings are saved');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach ($original_fields as $field)
|
||||||
|
{
|
||||||
|
if (isset($_POST[$field]))
|
||||||
|
{
|
||||||
|
$template->append(
|
||||||
|
'sizes',
|
||||||
|
array(
|
||||||
|
$field => $_POST[$field]
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign('derivatives', $pderivatives);
|
||||||
|
$template->assign('ferrors', $errors);
|
||||||
|
$template->assign('resize_quality', $_POST['resize_quality']);
|
||||||
|
$page['sizes_loaded_in_tpl'] = true;
|
||||||
|
}
|
||||||
|
?>
|
184
sources/admin/include/configuration_watermark_process.inc.php
Normal file
184
sources/admin/include/configuration_watermark_process.inc.php
Normal file
|
@ -0,0 +1,184 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
if( !defined("PHPWG_ROOT_PATH") )
|
||||||
|
{
|
||||||
|
die ("Hacking attempt!");
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = array();
|
||||||
|
$pwatermark = $_POST['w'];
|
||||||
|
|
||||||
|
// step 0 - manage upload if any
|
||||||
|
if (isset($_FILES['watermarkImage']) and !empty($_FILES['watermarkImage']['tmp_name']))
|
||||||
|
{
|
||||||
|
list($width, $height, $type) = getimagesize($_FILES['watermarkImage']['tmp_name']);
|
||||||
|
if (IMAGETYPE_PNG != $type)
|
||||||
|
{
|
||||||
|
$errors['watermarkImage'] = sprintf(
|
||||||
|
l10n('Allowed file types: %s.'),
|
||||||
|
'PNG'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$upload_dir = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'watermarks';
|
||||||
|
if (mkgetdir($upload_dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR))
|
||||||
|
{
|
||||||
|
$new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png';
|
||||||
|
$file_path = $upload_dir.'/'.$new_name;
|
||||||
|
|
||||||
|
if (move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path))
|
||||||
|
{
|
||||||
|
$pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['errors'][] = $errors['watermarkImage'] = "$file_path " .l10n('no write access');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['errors'][] = $errors['watermarkImage'] = sprintf( l10n('Add write access to the "%s" directory'), $upload_dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// step 1 - sanitize HTML input
|
||||||
|
switch ($pwatermark['position'])
|
||||||
|
{
|
||||||
|
case 'topleft':
|
||||||
|
{
|
||||||
|
$pwatermark['xpos'] = 0;
|
||||||
|
$pwatermark['ypos'] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'topright':
|
||||||
|
{
|
||||||
|
$pwatermark['xpos'] = 100;
|
||||||
|
$pwatermark['ypos'] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'middle':
|
||||||
|
{
|
||||||
|
$pwatermark['xpos'] = 50;
|
||||||
|
$pwatermark['ypos'] = 50;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'bottomleft':
|
||||||
|
{
|
||||||
|
$pwatermark['xpos'] = 0;
|
||||||
|
$pwatermark['ypos'] = 100;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'bottomright':
|
||||||
|
{
|
||||||
|
$pwatermark['xpos'] = 100;
|
||||||
|
$pwatermark['ypos'] = 100;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// step 2 - check validity
|
||||||
|
$v = intval($pwatermark['xpos']);
|
||||||
|
if ($v < 0 or $v > 100)
|
||||||
|
{
|
||||||
|
$errors['watermark']['xpos'] = '[0..100]';
|
||||||
|
}
|
||||||
|
|
||||||
|
$v = intval($pwatermark['ypos']);
|
||||||
|
if ($v < 0 or $v > 100)
|
||||||
|
{
|
||||||
|
$errors['watermark']['ypos'] = '[0..100]';
|
||||||
|
}
|
||||||
|
|
||||||
|
$v = intval($pwatermark['opacity']);
|
||||||
|
if ($v <= 0 or $v > 100)
|
||||||
|
{
|
||||||
|
$errors['watermark']['opacity'] = '(0..100]';
|
||||||
|
}
|
||||||
|
|
||||||
|
// step 3 - save data
|
||||||
|
if (count($errors) == 0)
|
||||||
|
{
|
||||||
|
$watermark = new WatermarkParams();
|
||||||
|
$watermark->file = $pwatermark['file'];
|
||||||
|
$watermark->xpos = intval($pwatermark['xpos']);
|
||||||
|
$watermark->ypos = intval($pwatermark['ypos']);
|
||||||
|
$watermark->xrepeat = intval($pwatermark['xrepeat']);
|
||||||
|
$watermark->opacity = intval($pwatermark['opacity']);
|
||||||
|
$watermark->min_size = array(intval($pwatermark['minw']),intval($pwatermark['minh']));
|
||||||
|
|
||||||
|
$old_watermark = ImageStdParams::get_watermark();
|
||||||
|
$watermark_changed =
|
||||||
|
$watermark->file != $old_watermark->file
|
||||||
|
|| $watermark->xpos != $old_watermark->xpos
|
||||||
|
|| $watermark->ypos != $old_watermark->ypos
|
||||||
|
|| $watermark->xrepeat != $old_watermark->xrepeat
|
||||||
|
|| $watermark->opacity != $old_watermark->opacity;
|
||||||
|
|
||||||
|
// save the new watermark configuration
|
||||||
|
ImageStdParams::set_watermark($watermark);
|
||||||
|
|
||||||
|
// do we have to regenerate the derivatives (and which types)?
|
||||||
|
$changed_types = array();
|
||||||
|
|
||||||
|
foreach (ImageStdParams::get_defined_type_map() as $type => $params)
|
||||||
|
{
|
||||||
|
$old_use_watermark = $params->use_watermark;
|
||||||
|
ImageStdParams::apply_global($params);
|
||||||
|
|
||||||
|
$changed = $params->use_watermark != $old_use_watermark;
|
||||||
|
if (!$changed and $params->use_watermark)
|
||||||
|
{
|
||||||
|
$changed = $watermark_changed;
|
||||||
|
}
|
||||||
|
if (!$changed and $params->use_watermark)
|
||||||
|
{
|
||||||
|
// if thresholds change and before/after the threshold is lower than the corresponding derivative side -> some derivatives might switch the watermark
|
||||||
|
$changed |= $watermark->min_size[0]!=$old_watermark->min_size[0] and ($watermark->min_size[0]<$params->max_width() or $old_watermark->min_size[0]<$params->max_width());
|
||||||
|
$changed |= $watermark->min_size[1]!=$old_watermark->min_size[1] and ($watermark->min_size[1]<$params->max_height() or $old_watermark->min_size[1]<$params->max_height());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($changed)
|
||||||
|
{
|
||||||
|
$params->last_mod_time = time();
|
||||||
|
$changed_types[] = $type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageStdParams::save();
|
||||||
|
|
||||||
|
if (count($changed_types))
|
||||||
|
{
|
||||||
|
clear_derivative_cache($changed_types);
|
||||||
|
}
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('Your configuration settings are saved');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$template->assign('watermark', $pwatermark);
|
||||||
|
$template->assign('ferrors', $errors);
|
||||||
|
}
|
||||||
|
?>
|
2730
sources/admin/include/functions.php
Normal file
2730
sources/admin/include/functions.php
Normal file
File diff suppressed because it is too large
Load diff
162
sources/admin/include/functions_history.inc.php
Normal file
162
sources/admin/include/functions_history.inc.php
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||||
|
|
||||||
|
function history_tabsheet()
|
||||||
|
{
|
||||||
|
global $page, $link_start;
|
||||||
|
|
||||||
|
// TabSheet
|
||||||
|
$tabsheet = new tabsheet();
|
||||||
|
$tabsheet->set_id('history');
|
||||||
|
$tabsheet->select($page['page']);
|
||||||
|
$tabsheet->assign();
|
||||||
|
}
|
||||||
|
|
||||||
|
function history_compare($a, $b)
|
||||||
|
{
|
||||||
|
return strcmp($a['date'].$a['time'], $b['date'].$b['time']);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_history($data, $search, $types)
|
||||||
|
{
|
||||||
|
if (isset($search['fields']['filename']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE file LIKE \''.$search['fields']['filename'].'\'
|
||||||
|
;';
|
||||||
|
$search['image_ids'] = array_from_query($query, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// echo '<pre>'; print_r($search); echo '</pre>';
|
||||||
|
|
||||||
|
$clauses = array();
|
||||||
|
|
||||||
|
if (isset($search['fields']['date-after']))
|
||||||
|
{
|
||||||
|
$clauses[] = "date >= '".$search['fields']['date-after']."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search['fields']['date-before']))
|
||||||
|
{
|
||||||
|
$clauses[] = "date <= '".$search['fields']['date-before']."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search['fields']['types']))
|
||||||
|
{
|
||||||
|
$local_clauses = array();
|
||||||
|
|
||||||
|
foreach ($types as $type) {
|
||||||
|
if (in_array($type, $search['fields']['types'])) {
|
||||||
|
$clause = 'image_type ';
|
||||||
|
if ($type == 'none')
|
||||||
|
{
|
||||||
|
$clause.= 'IS NULL';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$clause.= "= '".$type."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
$local_clauses[] = $clause;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($local_clauses) > 0)
|
||||||
|
{
|
||||||
|
$clauses[] = implode(' OR ', $local_clauses);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search['fields']['user'])
|
||||||
|
and $search['fields']['user'] != -1)
|
||||||
|
{
|
||||||
|
$clauses[] = 'user_id = '.$search['fields']['user'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search['fields']['image_id']))
|
||||||
|
{
|
||||||
|
$clauses[] = 'image_id = '.$search['fields']['image_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search['fields']['filename']))
|
||||||
|
{
|
||||||
|
if (count($search['image_ids']) == 0)
|
||||||
|
{
|
||||||
|
// a clause that is always false
|
||||||
|
$clauses[] = '1 = 2 ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$clauses[] = 'image_id IN ('.implode(', ', $search['image_ids']).')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($search['fields']['ip']))
|
||||||
|
{
|
||||||
|
$clauses[] = 'IP LIKE "'.$search['fields']['ip'].'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
$clauses = prepend_append_array_items($clauses, '(', ')');
|
||||||
|
|
||||||
|
$where_separator =
|
||||||
|
implode(
|
||||||
|
"\n AND ",
|
||||||
|
$clauses
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
date,
|
||||||
|
time,
|
||||||
|
user_id,
|
||||||
|
IP,
|
||||||
|
section,
|
||||||
|
category_id,
|
||||||
|
tag_ids,
|
||||||
|
image_id,
|
||||||
|
image_type
|
||||||
|
FROM '.HISTORY_TABLE.'
|
||||||
|
WHERE '.$where_separator.'
|
||||||
|
;';
|
||||||
|
|
||||||
|
// LIMIT '.$conf['nb_logs_page'].' OFFSET '.$page['start'].'
|
||||||
|
|
||||||
|
$result = pwg_query($query);
|
||||||
|
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$data[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_event_handler('get_history', 'get_history', EVENT_HANDLER_PRIORITY_NEUTRAL, 3);
|
||||||
|
trigger_action('functions_history_included');
|
||||||
|
|
||||||
|
?>
|
102
sources/admin/include/functions_install.inc.php
Normal file
102
sources/admin/include/functions_install.inc.php
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loads an sql file and executes all queries
|
||||||
|
*
|
||||||
|
* Before executing a query, $replaced is... replaced by $replacing. This is
|
||||||
|
* useful when the SQL file contains generic words. Drop table queries are
|
||||||
|
* not executed.
|
||||||
|
*
|
||||||
|
* @param string filepath
|
||||||
|
* @param string replaced
|
||||||
|
* @param string replacing
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function execute_sqlfile($filepath, $replaced, $replacing, $dblayer)
|
||||||
|
{
|
||||||
|
$sql_lines = file($filepath);
|
||||||
|
$query = '';
|
||||||
|
foreach ($sql_lines as $sql_line)
|
||||||
|
{
|
||||||
|
$sql_line = trim($sql_line);
|
||||||
|
if (preg_match('/(^--|^$)/', $sql_line))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$query.= ' '.$sql_line;
|
||||||
|
// if we reached the end of query, we execute it and reinitialize the
|
||||||
|
// variable "query"
|
||||||
|
if (preg_match('/;$/', $sql_line))
|
||||||
|
{
|
||||||
|
$query = trim($query);
|
||||||
|
$query = str_replace($replaced, $replacing, $query);
|
||||||
|
// we don't execute "DROP TABLE" queries
|
||||||
|
if (!preg_match('/^DROP TABLE/i', $query))
|
||||||
|
{
|
||||||
|
if ('mysql' == $dblayer)
|
||||||
|
{
|
||||||
|
if ( preg_match('/^(CREATE TABLE .*)[\s]*;[\s]*/im', $query, $matches) )
|
||||||
|
{
|
||||||
|
$query = $matches[1].' DEFAULT CHARACTER SET utf8'.';';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
$query = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatically activate all core themes in the "themes" directory.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function activate_core_themes()
|
||||||
|
{
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
|
||||||
|
$themes = new themes();
|
||||||
|
foreach ($themes->fs_themes as $theme_id => $fs_theme)
|
||||||
|
{
|
||||||
|
if (in_array($theme_id, array('elegant', 'smartpocket')))
|
||||||
|
{
|
||||||
|
$themes->perform_action('activate', $theme_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_db_connect(&$infos, &$errors)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pwg_db_connect($_POST['dbhost'], $_POST['dbuser'],
|
||||||
|
$_POST['dbpasswd'], $_POST['dbname']);
|
||||||
|
pwg_db_check_version();
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
$errors[] = l10n($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
320
sources/admin/include/functions_metadata.php
Normal file
320
sources/admin/include/functions_metadata.php
Normal file
|
@ -0,0 +1,320 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'/include/functions_metadata.inc.php');
|
||||||
|
|
||||||
|
|
||||||
|
function get_sync_iptc_data($file)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$map = $conf['use_iptc_mapping'];
|
||||||
|
|
||||||
|
$iptc = get_iptc_data($file, $map);
|
||||||
|
|
||||||
|
foreach ($iptc as $pwg_key => $value)
|
||||||
|
{
|
||||||
|
if (in_array($pwg_key, array('date_creation', 'date_available')))
|
||||||
|
{
|
||||||
|
if (preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches))
|
||||||
|
{
|
||||||
|
$year = $matches[1];
|
||||||
|
$month = $matches[2];
|
||||||
|
$day = $matches[3];
|
||||||
|
|
||||||
|
if (!checkdate($month, $day, $year))
|
||||||
|
{
|
||||||
|
// we suppose the year is correct
|
||||||
|
$month = 1;
|
||||||
|
$day = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$iptc[$pwg_key] = $year.'-'.$month.'-'.$day;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($iptc['keywords']))
|
||||||
|
{
|
||||||
|
// official keywords separator is the comma
|
||||||
|
$iptc['keywords'] = preg_replace('/[.;]/', ',', $iptc['keywords']);
|
||||||
|
$iptc['keywords'] = preg_replace('/,+/', ',', $iptc['keywords']);
|
||||||
|
$iptc['keywords'] = preg_replace('/^,+|,+$/', '', $iptc['keywords']);
|
||||||
|
|
||||||
|
$iptc['keywords'] = implode(
|
||||||
|
',',
|
||||||
|
array_unique(
|
||||||
|
explode(
|
||||||
|
',',
|
||||||
|
$iptc['keywords']
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($iptc as $pwg_key => $value)
|
||||||
|
{
|
||||||
|
$iptc[$pwg_key] = addslashes($iptc[$pwg_key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $iptc;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_sync_exif_data($file)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$exif = get_exif_data($file, $conf['use_exif_mapping']);
|
||||||
|
|
||||||
|
foreach ($exif as $pwg_key => $value)
|
||||||
|
{
|
||||||
|
if (in_array($pwg_key, array('date_creation', 'date_available')))
|
||||||
|
{
|
||||||
|
if (preg_match('/^(\d{4}).(\d{2}).(\d{2}) (\d{2}).(\d{2}).(\d{2})/', $value, $matches))
|
||||||
|
{
|
||||||
|
$exif[$pwg_key] = $matches[1].'-'.$matches[2].'-'.$matches[3].' '.$matches[4].':'.$matches[5].':'.$matches[6];
|
||||||
|
}
|
||||||
|
elseif (preg_match('/^(\d{4}).(\d{2}).(\d{2})/', $value, $matches))
|
||||||
|
{
|
||||||
|
$exif[$pwg_key] = $matches[1].'-'.$matches[2].'-'.$matches[3];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unset($exif[$pwg_key]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$exif[$pwg_key] = addslashes($exif[$pwg_key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $exif;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get_sync_metadata_attributes()
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$update_fields = array('filesize', 'width', 'height');
|
||||||
|
|
||||||
|
if ($conf['use_exif'])
|
||||||
|
{
|
||||||
|
$update_fields =
|
||||||
|
array_merge(
|
||||||
|
$update_fields,
|
||||||
|
array_keys($conf['use_exif_mapping']),
|
||||||
|
array('latitude', 'longitude')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($conf['use_iptc'])
|
||||||
|
{
|
||||||
|
$update_fields =
|
||||||
|
array_merge(
|
||||||
|
$update_fields,
|
||||||
|
array_keys($conf['use_iptc_mapping'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_unique($update_fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_sync_metadata($infos)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
$file = PHPWG_ROOT_PATH.$infos['path'];
|
||||||
|
$fs = @filesize($file);
|
||||||
|
|
||||||
|
if ($fs===false)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$infos['filesize'] = floor($fs/1024);
|
||||||
|
|
||||||
|
if (isset($infos['representative_ext']))
|
||||||
|
{
|
||||||
|
$file = original_to_representative($file, $infos['representative_ext']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($image_size = @getimagesize($file))
|
||||||
|
{
|
||||||
|
$infos['width'] = $image_size[0];
|
||||||
|
$infos['height'] = $image_size[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($conf['use_exif'])
|
||||||
|
{
|
||||||
|
$exif = get_sync_exif_data($file);
|
||||||
|
$infos = array_merge($infos, $exif);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($conf['use_iptc'])
|
||||||
|
{
|
||||||
|
$iptc = get_sync_iptc_data($file);
|
||||||
|
$infos = array_merge($infos, $iptc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $infos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function sync_metadata($ids)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
if (!defined('CURRENT_DATE'))
|
||||||
|
{
|
||||||
|
define('CURRENT_DATE', date('Y-m-d'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas = array();
|
||||||
|
$tags_of = array();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id, path, representative_ext
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE id IN (
|
||||||
|
'.wordwrap(implode(', ', $ids), 160, "\n").'
|
||||||
|
)
|
||||||
|
;';
|
||||||
|
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($data = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$data = get_sync_metadata($data);
|
||||||
|
if ($data === false)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $data['id'];
|
||||||
|
foreach (array('keywords', 'tags') as $key)
|
||||||
|
{
|
||||||
|
if (isset($data[$key]))
|
||||||
|
{
|
||||||
|
if (!isset($tags_of[$id]))
|
||||||
|
{
|
||||||
|
$tags_of[$id] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (explode(',', $data[$key]) as $tag_name)
|
||||||
|
{
|
||||||
|
$tags_of[$id][] = tag_id_from_tag_name($tag_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['date_metadata_update'] = CURRENT_DATE;
|
||||||
|
|
||||||
|
$datas[] = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($datas) > 0)
|
||||||
|
{
|
||||||
|
$update_fields = get_sync_metadata_attributes();
|
||||||
|
$update_fields[] = 'date_metadata_update';
|
||||||
|
|
||||||
|
$update_fields = array_diff(
|
||||||
|
$update_fields,
|
||||||
|
array('tags', 'keywords')
|
||||||
|
);
|
||||||
|
|
||||||
|
mass_updates(
|
||||||
|
IMAGES_TABLE,
|
||||||
|
array(
|
||||||
|
'primary' => array('id'),
|
||||||
|
'update' => $update_fields
|
||||||
|
),
|
||||||
|
$datas,
|
||||||
|
MASS_UPDATES_SKIP_EMPTY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
set_tags_of($tags_of);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns an array associating element id (images.id) with its complete
|
||||||
|
* path in the filesystem
|
||||||
|
*
|
||||||
|
* @param int id_uppercat
|
||||||
|
* @param int site_id
|
||||||
|
* @param boolean recursive ?
|
||||||
|
* @param boolean only newly added files ?
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function get_filelist($category_id = '', $site_id=1, $recursive = false,
|
||||||
|
$only_new = false)
|
||||||
|
{
|
||||||
|
// filling $cat_ids : all categories required
|
||||||
|
$cat_ids = array();
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE site_id = '.$site_id.'
|
||||||
|
AND dir IS NOT NULL';
|
||||||
|
if (is_numeric($category_id))
|
||||||
|
{
|
||||||
|
if ($recursive)
|
||||||
|
{
|
||||||
|
$query.= '
|
||||||
|
AND uppercats '.DB_REGEX_OPERATOR.' \'(^|,)'.$category_id.'(,|$)\'
|
||||||
|
';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query.= '
|
||||||
|
AND id = '.$category_id.'
|
||||||
|
';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$query.= '
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$cat_ids[] = $row['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($cat_ids) == 0)
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id, path, representative_ext
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE storage_category_id IN ('.implode(',', $cat_ids).')';
|
||||||
|
if ($only_new)
|
||||||
|
{
|
||||||
|
$query.= '
|
||||||
|
AND date_metadata_update IS NULL
|
||||||
|
';
|
||||||
|
}
|
||||||
|
$query.= '
|
||||||
|
;';
|
||||||
|
return hash_from_query($query, 'id');
|
||||||
|
}
|
||||||
|
?>
|
546
sources/admin/include/functions_notification_by_mail.inc.php
Normal file
546
sources/admin/include/functions_notification_by_mail.inc.php
Normal file
|
@ -0,0 +1,546 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/* nbm_global_var */
|
||||||
|
$env_nbm = array
|
||||||
|
(
|
||||||
|
'start_time' => get_moment(),
|
||||||
|
'sendmail_timeout' => (intval(ini_get('max_execution_time')) * $conf['nbm_max_treatment_timeout_percent']),
|
||||||
|
'is_sendmail_timeout' => false
|
||||||
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(!isset($env_nbm['sendmail_timeout'])) or
|
||||||
|
(!is_numeric($env_nbm['sendmail_timeout'])) or
|
||||||
|
($env_nbm['sendmail_timeout'] <= 0)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$env_nbm['sendmail_timeout'] = $conf['nbm_treatment_timeout_default'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Search an available check_key
|
||||||
|
*
|
||||||
|
* It's a copy of function find_available_feed_id
|
||||||
|
*
|
||||||
|
* @return string nbm identifier
|
||||||
|
*/
|
||||||
|
function find_available_check_key()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
$key = generate_key(16);
|
||||||
|
$query = '
|
||||||
|
select
|
||||||
|
count(*)
|
||||||
|
from
|
||||||
|
'.USER_MAIL_NOTIFICATION_TABLE.'
|
||||||
|
where
|
||||||
|
check_key = \''.$key.'\';';
|
||||||
|
|
||||||
|
list($count) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
if ($count == 0)
|
||||||
|
{
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check sendmail timeout state
|
||||||
|
*
|
||||||
|
* @return true, if it's timeout
|
||||||
|
*/
|
||||||
|
function check_sendmail_timeout()
|
||||||
|
{
|
||||||
|
global $env_nbm;
|
||||||
|
|
||||||
|
$env_nbm['is_sendmail_timeout'] = ((get_moment() - $env_nbm['start_time']) > $env_nbm['sendmail_timeout']);
|
||||||
|
|
||||||
|
return $env_nbm['is_sendmail_timeout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add quote to all elements of check_key_list
|
||||||
|
*
|
||||||
|
* @return quoted check key list
|
||||||
|
*/
|
||||||
|
function quote_check_key_list($check_key_list = array())
|
||||||
|
{
|
||||||
|
return array_map(create_function('$s', 'return \'\\\'\'.$s.\'\\\'\';'), $check_key_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Execute all main queries to get list of user
|
||||||
|
*
|
||||||
|
* Type are the type of list 'subscribe', 'send'
|
||||||
|
*
|
||||||
|
* return array of users
|
||||||
|
*/
|
||||||
|
function get_user_notifications($action, $check_key_list = array(), $enabled_filter_value = '')
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$data_users = array();
|
||||||
|
|
||||||
|
if (in_array($action, array('subscribe', 'send')))
|
||||||
|
{
|
||||||
|
$quoted_check_key_list = quote_check_key_list($check_key_list);
|
||||||
|
if (count($quoted_check_key_list) != 0 )
|
||||||
|
{
|
||||||
|
$query_and_check_key = ' and
|
||||||
|
check_key in ('.implode(",", $quoted_check_key_list).') ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query_and_check_key = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
select
|
||||||
|
N.user_id,
|
||||||
|
N.check_key,
|
||||||
|
U.'.$conf['user_fields']['username'].' as username,
|
||||||
|
U.'.$conf['user_fields']['email'].' as mail_address,
|
||||||
|
N.enabled,
|
||||||
|
N.last_send
|
||||||
|
from
|
||||||
|
'.USER_MAIL_NOTIFICATION_TABLE.' as N,
|
||||||
|
'.USERS_TABLE.' as U
|
||||||
|
where
|
||||||
|
N.user_id = U.'.$conf['user_fields']['id'];
|
||||||
|
|
||||||
|
if ($action == 'send')
|
||||||
|
{
|
||||||
|
// No mail empty and all users enabled
|
||||||
|
$query .= ' and
|
||||||
|
N.enabled = \'true\' and
|
||||||
|
U.'.$conf['user_fields']['email'].' is not null';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query .= $query_and_check_key;
|
||||||
|
|
||||||
|
if (isset($enabled_filter_value) and ($enabled_filter_value != ''))
|
||||||
|
{
|
||||||
|
$query .= ' and
|
||||||
|
N.enabled = \''.boolean_to_string($enabled_filter_value).'\'';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query .= '
|
||||||
|
order by';
|
||||||
|
|
||||||
|
if ($action == 'send')
|
||||||
|
{
|
||||||
|
$query .= '
|
||||||
|
last_send, username;';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query .= '
|
||||||
|
username;';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query .= ';';
|
||||||
|
|
||||||
|
$result = pwg_query($query);
|
||||||
|
if (!empty($result))
|
||||||
|
{
|
||||||
|
while ($nbm_user = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$data_users[] = $nbm_user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data_users;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Begin of use nbm environment
|
||||||
|
* Prepare and save current environment and initialize data in order to send mail
|
||||||
|
*
|
||||||
|
* Return none
|
||||||
|
*/
|
||||||
|
function begin_users_env_nbm($is_to_send_mail = false)
|
||||||
|
{
|
||||||
|
global $user, $lang, $lang_info, $conf, $env_nbm;
|
||||||
|
|
||||||
|
// Save $user, $lang_info and $lang arrays (include/user.inc.php has been executed)
|
||||||
|
$env_nbm['save_user'] = $user;
|
||||||
|
// Save current language to stack, necessary because $user change during NBM
|
||||||
|
switch_lang_to($user['language']);
|
||||||
|
|
||||||
|
$env_nbm['is_to_send_mail'] = $is_to_send_mail;
|
||||||
|
|
||||||
|
if ($is_to_send_mail)
|
||||||
|
{
|
||||||
|
// Init mail configuration
|
||||||
|
$env_nbm['email_format'] = get_str_email_format($conf['nbm_send_html_mail']);
|
||||||
|
$env_nbm['send_as_name'] = ((isset($conf['nbm_send_mail_as']) and !empty($conf['nbm_send_mail_as'])) ? $conf['nbm_send_mail_as'] : get_mail_sender_name());
|
||||||
|
$env_nbm['send_as_mail_address'] = get_webmaster_mail_address();
|
||||||
|
$env_nbm['send_as_mail_formated'] = format_email($env_nbm['send_as_name'], $env_nbm['send_as_mail_address']);
|
||||||
|
// Init mail counter
|
||||||
|
$env_nbm['error_on_mail_count'] = 0;
|
||||||
|
$env_nbm['sent_mail_count'] = 0;
|
||||||
|
// Save sendmail message info and error in the original language
|
||||||
|
$env_nbm['msg_info'] = l10n('Mail sent to %s [%s].');
|
||||||
|
$env_nbm['msg_error'] = l10n('Error when sending email to %s [%s].');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* End of use nbm environment
|
||||||
|
* Restore environment
|
||||||
|
*
|
||||||
|
* Return none
|
||||||
|
*/
|
||||||
|
function end_users_env_nbm()
|
||||||
|
{
|
||||||
|
global $user, $lang, $lang_info, $env_nbm;
|
||||||
|
|
||||||
|
// Restore $user, $lang_info and $lang arrays (include/user.inc.php has been executed)
|
||||||
|
$user = $env_nbm['save_user'];
|
||||||
|
// Restore current language to stack, necessary because $user change during NBM
|
||||||
|
switch_lang_back();
|
||||||
|
|
||||||
|
if ($env_nbm['is_to_send_mail'])
|
||||||
|
{
|
||||||
|
unset($env_nbm['email_format']);
|
||||||
|
unset($env_nbm['send_as_name']);
|
||||||
|
unset($env_nbm['send_as_mail_address']);
|
||||||
|
unset($env_nbm['send_as_mail_formated']);
|
||||||
|
// Don t unset counter
|
||||||
|
//unset($env_nbm['error_on_mail_count']);
|
||||||
|
//unset($env_nbm['sent_mail_count']);
|
||||||
|
unset($env_nbm['msg_info']);
|
||||||
|
unset($env_nbm['msg_error']);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($env_nbm['save_user']);
|
||||||
|
unset($env_nbm['is_to_send_mail']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set user on nbm enviromnent
|
||||||
|
*
|
||||||
|
* Return none
|
||||||
|
*/
|
||||||
|
function set_user_on_env_nbm(&$nbm_user, $is_action_send)
|
||||||
|
{
|
||||||
|
global $user, $lang, $lang_info, $env_nbm;
|
||||||
|
|
||||||
|
$user = build_user( $nbm_user['user_id'], true );
|
||||||
|
|
||||||
|
switch_lang_to($user['language']);
|
||||||
|
|
||||||
|
if ($is_action_send)
|
||||||
|
{
|
||||||
|
$env_nbm['mail_template'] = get_mail_template($env_nbm['email_format']);
|
||||||
|
$env_nbm['mail_template']->set_filename('notification_by_mail', 'notification_by_mail.tpl');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unset user on nbm enviromnent
|
||||||
|
*
|
||||||
|
* Return none
|
||||||
|
*/
|
||||||
|
function unset_user_on_env_nbm()
|
||||||
|
{
|
||||||
|
global $env_nbm;
|
||||||
|
|
||||||
|
switch_lang_back();
|
||||||
|
unset($env_nbm['mail_template']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inc Counter success
|
||||||
|
*
|
||||||
|
* Return none
|
||||||
|
*/
|
||||||
|
function inc_mail_sent_success($nbm_user)
|
||||||
|
{
|
||||||
|
global $page, $env_nbm;
|
||||||
|
|
||||||
|
$env_nbm['sent_mail_count'] += 1;
|
||||||
|
$page['infos'][] = sprintf($env_nbm['msg_info'], stripslashes($nbm_user['username']), $nbm_user['mail_address']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inc Counter failed
|
||||||
|
*
|
||||||
|
* Return none
|
||||||
|
*/
|
||||||
|
function inc_mail_sent_failed($nbm_user)
|
||||||
|
{
|
||||||
|
global $page, $env_nbm;
|
||||||
|
|
||||||
|
$env_nbm['error_on_mail_count'] += 1;
|
||||||
|
$page['errors'][] = sprintf($env_nbm['msg_error'], stripslashes($nbm_user['username']), $nbm_user['mail_address']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display Counter Info
|
||||||
|
*
|
||||||
|
* Return none
|
||||||
|
*/
|
||||||
|
function display_counter_info()
|
||||||
|
{
|
||||||
|
global $page, $env_nbm;
|
||||||
|
|
||||||
|
if ($env_nbm['error_on_mail_count'] != 0)
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n_dec(
|
||||||
|
'%d mail was not sent.', '%d mails were not sent.',
|
||||||
|
$env_nbm['error_on_mail_count']
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($env_nbm['sent_mail_count'] != 0)
|
||||||
|
{
|
||||||
|
$page['infos'][] = l10n_dec(
|
||||||
|
'%d mail was sent.', '%d mails were sent.',
|
||||||
|
$env_nbm['sent_mail_count']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($env_nbm['sent_mail_count'] == 0)
|
||||||
|
{
|
||||||
|
$page['infos'][] = l10n('No mail to send.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['infos'][] = l10n_dec(
|
||||||
|
'%d mail was sent.', '%d mails were sent.',
|
||||||
|
$env_nbm['sent_mail_count']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function assign_vars_nbm_mail_content($nbm_user)
|
||||||
|
{
|
||||||
|
global $env_nbm;
|
||||||
|
|
||||||
|
set_make_full_url();
|
||||||
|
|
||||||
|
$env_nbm['mail_template']->assign
|
||||||
|
(
|
||||||
|
array
|
||||||
|
(
|
||||||
|
'USERNAME' => stripslashes($nbm_user['username']),
|
||||||
|
|
||||||
|
'SEND_AS_NAME' => $env_nbm['send_as_name'],
|
||||||
|
|
||||||
|
'UNSUBSCRIBE_LINK' => add_url_params(get_gallery_home_url().'/nbm.php', array('unsubscribe' => $nbm_user['check_key'])),
|
||||||
|
'SUBSCRIBE_LINK' => add_url_params(get_gallery_home_url().'/nbm.php', array('subscribe' => $nbm_user['check_key'])),
|
||||||
|
'CONTACT_EMAIL' => $env_nbm['send_as_mail_address']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
unset_make_full_url();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Subscribe or unsubscribe notification by mail
|
||||||
|
*
|
||||||
|
* is_subscribe define if action=subscribe or unsubscribe
|
||||||
|
* check_key list where action will be done
|
||||||
|
*
|
||||||
|
* @return check_key list treated
|
||||||
|
*/
|
||||||
|
function do_subscribe_unsubscribe_notification_by_mail($is_admin_request, $is_subscribe = false, $check_key_list = array())
|
||||||
|
{
|
||||||
|
global $conf, $page, $env_nbm, $conf;
|
||||||
|
|
||||||
|
set_make_full_url();
|
||||||
|
|
||||||
|
$check_key_treated = array();
|
||||||
|
$updated_data_count = 0;
|
||||||
|
$error_on_updated_data_count = 0;
|
||||||
|
|
||||||
|
if ($is_subscribe)
|
||||||
|
{
|
||||||
|
$msg_info = l10n('User %s [%s] was added to the subscription list.');
|
||||||
|
$msg_error = l10n('User %s [%s] was not added to the subscription list.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$msg_info = l10n('User %s [%s] was removed from the subscription list.');
|
||||||
|
$msg_error = l10n('User %s [%s] was not removed from the subscription list.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($check_key_list) != 0)
|
||||||
|
{
|
||||||
|
$updates = array();
|
||||||
|
$enabled_value = boolean_to_string($is_subscribe);
|
||||||
|
$data_users = get_user_notifications('subscribe', $check_key_list, !$is_subscribe);
|
||||||
|
|
||||||
|
// Prepare message after change language
|
||||||
|
$msg_break_timeout = l10n('Time to send mail is limited. Others mails are skipped.');
|
||||||
|
|
||||||
|
// Begin nbm users environment
|
||||||
|
begin_users_env_nbm(true);
|
||||||
|
|
||||||
|
foreach ($data_users as $nbm_user)
|
||||||
|
{
|
||||||
|
if (check_sendmail_timeout())
|
||||||
|
{
|
||||||
|
// Stop fill list on 'send', if the quota is override
|
||||||
|
$page['errors'][] = $msg_break_timeout;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill return list
|
||||||
|
$check_key_treated[] = $nbm_user['check_key'];
|
||||||
|
|
||||||
|
$do_update = true;
|
||||||
|
if ($nbm_user['mail_address'] != '')
|
||||||
|
{
|
||||||
|
// set env nbm user
|
||||||
|
set_user_on_env_nbm($nbm_user, true);
|
||||||
|
|
||||||
|
$subject = '['.$conf['gallery_title'].'] '.($is_subscribe ? l10n('Subscribe to notification by mail'): l10n('Unsubscribe from notification by mail'));
|
||||||
|
|
||||||
|
// Assign current var for nbm mail
|
||||||
|
assign_vars_nbm_mail_content($nbm_user);
|
||||||
|
|
||||||
|
$section_action_by = ($is_subscribe ? 'subscribe_by_' : 'unsubscribe_by_');
|
||||||
|
$section_action_by .= ($is_admin_request ? 'admin' : 'himself');
|
||||||
|
$env_nbm['mail_template']->assign
|
||||||
|
(
|
||||||
|
array
|
||||||
|
(
|
||||||
|
$section_action_by => true,
|
||||||
|
'GOTO_GALLERY_TITLE' => $conf['gallery_title'],
|
||||||
|
'GOTO_GALLERY_URL' => get_gallery_home_url(),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$ret = pwg_mail(
|
||||||
|
array(
|
||||||
|
'name' => stripslashes($nbm_user['username']),
|
||||||
|
'email' => $nbm_user['mail_address'],
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'from' => $env_nbm['send_as_mail_formated'],
|
||||||
|
'subject' => $subject,
|
||||||
|
'email_format' => $env_nbm['email_format'],
|
||||||
|
'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
|
||||||
|
'content_format' => $env_nbm['email_format'],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($ret)
|
||||||
|
{
|
||||||
|
inc_mail_sent_success($nbm_user);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inc_mail_sent_failed($nbm_user);
|
||||||
|
$do_update = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unset env nbm user
|
||||||
|
unset_user_on_env_nbm();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($do_update)
|
||||||
|
{
|
||||||
|
$updates[] = array(
|
||||||
|
'check_key' => $nbm_user['check_key'],
|
||||||
|
'enabled' => $enabled_value
|
||||||
|
);
|
||||||
|
$updated_data_count += 1;
|
||||||
|
$page['infos'][] = sprintf($msg_info, stripslashes($nbm_user['username']), $nbm_user['mail_address']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error_on_updated_data_count += 1;
|
||||||
|
$page['errors'][] = sprintf($msg_error, stripslashes($nbm_user['username']), $nbm_user['mail_address']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore nbm environment
|
||||||
|
end_users_env_nbm();
|
||||||
|
|
||||||
|
display_counter_info();
|
||||||
|
|
||||||
|
mass_updates(
|
||||||
|
USER_MAIL_NOTIFICATION_TABLE,
|
||||||
|
array(
|
||||||
|
'primary' => array('check_key'),
|
||||||
|
'update' => array('enabled')
|
||||||
|
),
|
||||||
|
$updates
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$page['infos'][] = l10n_dec(
|
||||||
|
'%d user was updated.', '%d users were updated.',
|
||||||
|
$updated_data_count
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($error_on_updated_data_count != 0)
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n_dec(
|
||||||
|
'%d user was not updated.', '%d users were not updated.',
|
||||||
|
$error_on_updated_data_count
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset_make_full_url();
|
||||||
|
|
||||||
|
return $check_key_treated;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unsubscribe notification by mail
|
||||||
|
*
|
||||||
|
* check_key list where action will be done
|
||||||
|
*
|
||||||
|
* @return check_key list treated
|
||||||
|
*/
|
||||||
|
function unsubscribe_notification_by_mail($is_admin_request, $check_key_list = array())
|
||||||
|
{
|
||||||
|
return do_subscribe_unsubscribe_notification_by_mail($is_admin_request, false, $check_key_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Subscribe notification by mail
|
||||||
|
*
|
||||||
|
* check_key list where action will be done
|
||||||
|
*
|
||||||
|
* @return check_key list treated
|
||||||
|
*/
|
||||||
|
function subscribe_notification_by_mail($is_admin_request, $check_key_list = array())
|
||||||
|
{
|
||||||
|
return do_subscribe_unsubscribe_notification_by_mail($is_admin_request, true, $check_key_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
204
sources/admin/include/functions_permalinks.php
Normal file
204
sources/admin/include/functions_permalinks.php
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/** returns a category id that corresponds to the given permalink (or null)
|
||||||
|
* @param string permalink
|
||||||
|
*/
|
||||||
|
function get_cat_id_from_permalink( $permalink )
|
||||||
|
{
|
||||||
|
$query ='
|
||||||
|
SELECT id FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE permalink=\''.$permalink.'\'';
|
||||||
|
$ids = array_from_query($query, 'id');
|
||||||
|
if (!empty($ids))
|
||||||
|
{
|
||||||
|
return $ids[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** returns a category id that has used before this permalink (or null)
|
||||||
|
* @param string permalink
|
||||||
|
* @param boolean is_hit if true update the usage counters on the old permalinks
|
||||||
|
*/
|
||||||
|
function get_cat_id_from_old_permalink($permalink)
|
||||||
|
{
|
||||||
|
$query='
|
||||||
|
SELECT c.id
|
||||||
|
FROM '.OLD_PERMALINKS_TABLE.' op INNER JOIN '.CATEGORIES_TABLE.' c
|
||||||
|
ON op.cat_id=c.id
|
||||||
|
WHERE op.permalink=\''.$permalink.'\'
|
||||||
|
LIMIT 1';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
$cat_id = null;
|
||||||
|
if ( pwg_db_num_rows($result) )
|
||||||
|
list( $cat_id ) = pwg_db_fetch_row($result);
|
||||||
|
return $cat_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** deletes the permalink associated with a category
|
||||||
|
* returns true on success
|
||||||
|
* @param int cat_id the target category id
|
||||||
|
* @param boolean save if true, the current category-permalink association
|
||||||
|
* is saved in the old permalinks table in case external links hit it
|
||||||
|
*/
|
||||||
|
function delete_cat_permalink( $cat_id, $save )
|
||||||
|
{
|
||||||
|
global $page, $cache;
|
||||||
|
$query = '
|
||||||
|
SELECT permalink
|
||||||
|
FROM '.CATEGORIES_TABLE.'
|
||||||
|
WHERE id=\''.$cat_id.'\'
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
if ( pwg_db_num_rows($result) )
|
||||||
|
{
|
||||||
|
list($permalink) = pwg_db_fetch_row($result);
|
||||||
|
}
|
||||||
|
if ( !isset($permalink) )
|
||||||
|
{// no permalink; nothing to do
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ($save)
|
||||||
|
{
|
||||||
|
$old_cat_id = get_cat_id_from_old_permalink($permalink);
|
||||||
|
if ( isset($old_cat_id) and $old_cat_id!=$cat_id )
|
||||||
|
{
|
||||||
|
$page['errors'][] =
|
||||||
|
sprintf(
|
||||||
|
l10n('Permalink %s has been previously used by album %s. Delete from the permalink history first'),
|
||||||
|
$permalink, $old_cat_id
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$query = '
|
||||||
|
UPDATE '.CATEGORIES_TABLE.'
|
||||||
|
SET permalink=NULL
|
||||||
|
WHERE id='.$cat_id.'
|
||||||
|
LIMIT 1';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
unset( $cache['cat_names'] ); //force regeneration
|
||||||
|
if ($save)
|
||||||
|
{
|
||||||
|
if ( isset($old_cat_id) )
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE '.OLD_PERMALINKS_TABLE.'
|
||||||
|
SET date_deleted=NOW()
|
||||||
|
WHERE cat_id='.$cat_id.' AND permalink=\''.$permalink.'\'';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
INSERT INTO '.OLD_PERMALINKS_TABLE.'
|
||||||
|
(permalink, cat_id, date_deleted)
|
||||||
|
VALUES
|
||||||
|
( \''.$permalink.'\','.$cat_id.',NOW() )';
|
||||||
|
}
|
||||||
|
pwg_query( $query );
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** sets a new permalink for a category
|
||||||
|
* returns true on success
|
||||||
|
* @param int cat_id the target category id
|
||||||
|
* @param string permalink the new permalink
|
||||||
|
* @param boolean save if true, the current category-permalink association
|
||||||
|
* is saved in the old permalinks table in case external links hit it
|
||||||
|
*/
|
||||||
|
function set_cat_permalink( $cat_id, $permalink, $save )
|
||||||
|
{
|
||||||
|
global $page, $cache;
|
||||||
|
|
||||||
|
$sanitized_permalink = preg_replace( '#[^a-zA-Z0-9_/-]#', '' ,$permalink);
|
||||||
|
$sanitized_permalink = trim($sanitized_permalink, '/');
|
||||||
|
$sanitized_permalink = str_replace('//', '/', $sanitized_permalink);
|
||||||
|
if ( $sanitized_permalink != $permalink
|
||||||
|
or preg_match( '#^(\d)+(-.*)?$#', $permalink) )
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('The permalink name must be composed of a-z, A-Z, 0-9, "-", "_" or "/". It must not be numeric or start with number followed by "-"');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the new permalink is actively used
|
||||||
|
$existing_cat_id = get_cat_id_from_permalink( $permalink );
|
||||||
|
if ( isset($existing_cat_id) )
|
||||||
|
{
|
||||||
|
if ( $existing_cat_id==$cat_id )
|
||||||
|
{// no change required
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$page['errors'][] =
|
||||||
|
sprintf(
|
||||||
|
l10n('Permalink %s is already used by album %s'),
|
||||||
|
$permalink, $existing_cat_id
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the new permalink was historically used
|
||||||
|
$old_cat_id = get_cat_id_from_old_permalink($permalink);
|
||||||
|
if ( isset($old_cat_id) and $old_cat_id!=$cat_id )
|
||||||
|
{
|
||||||
|
$page['errors'][] =
|
||||||
|
sprintf(
|
||||||
|
l10n('Permalink %s has been previously used by album %s. Delete from the permalink history first'),
|
||||||
|
$permalink, $old_cat_id
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !delete_cat_permalink($cat_id, $save ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($old_cat_id) )
|
||||||
|
{// the new permalink must not be active and old at the same time
|
||||||
|
assert( $old_cat_id==$cat_id );
|
||||||
|
$query = '
|
||||||
|
DELETE FROM '.OLD_PERMALINKS_TABLE.'
|
||||||
|
WHERE cat_id='.$old_cat_id.' AND permalink=\''.$permalink.'\'';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
UPDATE '.CATEGORIES_TABLE.'
|
||||||
|
SET permalink=\''.$permalink.'\'
|
||||||
|
WHERE id='.$cat_id;
|
||||||
|
// LIMIT 1';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
unset( $cache['cat_names'] ); //force regeneration
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
46
sources/admin/include/functions_plugins.inc.php
Normal file
46
sources/admin/include/functions_plugins.inc.php
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves an url for a plugin page.
|
||||||
|
* @param string file - php script full name
|
||||||
|
*/
|
||||||
|
function get_admin_plugin_menu_link($file)
|
||||||
|
{
|
||||||
|
global $page;
|
||||||
|
$real_file = realpath($file);
|
||||||
|
$url = get_root_url().'admin.php?page=plugin';
|
||||||
|
if (false!==$real_file)
|
||||||
|
{
|
||||||
|
$real_plugin_path = rtrim(realpath(PHPWG_PLUGINS_PATH), '\\/');
|
||||||
|
$file = substr($real_file, strlen($real_plugin_path)+1);
|
||||||
|
$file = str_replace('\\', '/', $file);//Windows
|
||||||
|
$url .= '&section='.urlencode($file);
|
||||||
|
}
|
||||||
|
else if (isset($page['errors']))
|
||||||
|
{
|
||||||
|
$page['errors'][] = 'PLUGIN ERROR: "'.$file.'" is not a valid file';
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
?>
|
326
sources/admin/include/functions_upgrade.php
Normal file
326
sources/admin/include/functions_upgrade.php
Normal file
|
@ -0,0 +1,326 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
function check_upgrade()
|
||||||
|
{
|
||||||
|
if (defined('PHPWG_IN_UPGRADE'))
|
||||||
|
{
|
||||||
|
return PHPWG_IN_UPGRADE;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// concerning upgrade, we use the default tables
|
||||||
|
function prepare_conf_upgrade()
|
||||||
|
{
|
||||||
|
global $prefixeTable;
|
||||||
|
|
||||||
|
// $conf is not used for users tables
|
||||||
|
// define cannot be re-defined
|
||||||
|
define('CATEGORIES_TABLE', $prefixeTable.'categories');
|
||||||
|
define('COMMENTS_TABLE', $prefixeTable.'comments');
|
||||||
|
define('CONFIG_TABLE', $prefixeTable.'config');
|
||||||
|
define('FAVORITES_TABLE', $prefixeTable.'favorites');
|
||||||
|
define('GROUP_ACCESS_TABLE', $prefixeTable.'group_access');
|
||||||
|
define('GROUPS_TABLE', $prefixeTable.'groups');
|
||||||
|
define('HISTORY_TABLE', $prefixeTable.'history');
|
||||||
|
define('HISTORY_SUMMARY_TABLE', $prefixeTable.'history_summary');
|
||||||
|
define('IMAGE_CATEGORY_TABLE', $prefixeTable.'image_category');
|
||||||
|
define('IMAGES_TABLE', $prefixeTable.'images');
|
||||||
|
define('SESSIONS_TABLE', $prefixeTable.'sessions');
|
||||||
|
define('SITES_TABLE', $prefixeTable.'sites');
|
||||||
|
define('USER_ACCESS_TABLE', $prefixeTable.'user_access');
|
||||||
|
define('USER_GROUP_TABLE', $prefixeTable.'user_group');
|
||||||
|
define('USERS_TABLE', $prefixeTable.'users');
|
||||||
|
define('USER_INFOS_TABLE', $prefixeTable.'user_infos');
|
||||||
|
define('USER_FEED_TABLE', $prefixeTable.'user_feed');
|
||||||
|
define('RATE_TABLE', $prefixeTable.'rate');
|
||||||
|
define('USER_CACHE_TABLE', $prefixeTable.'user_cache');
|
||||||
|
define('USER_CACHE_CATEGORIES_TABLE', $prefixeTable.'user_cache_categories');
|
||||||
|
define('CADDIE_TABLE', $prefixeTable.'caddie');
|
||||||
|
define('UPGRADE_TABLE', $prefixeTable.'upgrade');
|
||||||
|
define('SEARCH_TABLE', $prefixeTable.'search');
|
||||||
|
define('USER_MAIL_NOTIFICATION_TABLE', $prefixeTable.'user_mail_notification');
|
||||||
|
define('TAGS_TABLE', $prefixeTable.'tags');
|
||||||
|
define('IMAGE_TAG_TABLE', $prefixeTable.'image_tag');
|
||||||
|
define('PLUGINS_TABLE', $prefixeTable.'plugins');
|
||||||
|
define('OLD_PERMALINKS_TABLE', $prefixeTable.'old_permalinks');
|
||||||
|
define('THEMES_TABLE', $prefixeTable.'themes');
|
||||||
|
define('LANGUAGES_TABLE', $prefixeTable.'languages');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deactivate all non-standard plugins
|
||||||
|
function deactivate_non_standard_plugins()
|
||||||
|
{
|
||||||
|
global $page;
|
||||||
|
|
||||||
|
$standard_plugins = array(
|
||||||
|
'admin_multi_view',
|
||||||
|
'c13y_upgrade',
|
||||||
|
'event_tracer',
|
||||||
|
'language_switch',
|
||||||
|
'LocalFilesEditor'
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.PREFIX_TABLE.'plugins
|
||||||
|
WHERE state = \'active\'
|
||||||
|
AND id NOT IN (\'' . implode('\',\'', $standard_plugins) . '\')
|
||||||
|
;';
|
||||||
|
|
||||||
|
$result = pwg_query($query);
|
||||||
|
$plugins = array();
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$plugins[] = $row['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($plugins))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE '.PREFIX_TABLE.'plugins
|
||||||
|
SET state=\'inactive\'
|
||||||
|
WHERE id IN (\'' . implode('\',\'', $plugins) . '\')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('As a precaution, following plugins have been deactivated. You must check for plugins upgrade before reactiving them:')
|
||||||
|
.'<p><i>'.implode(', ', $plugins).'</i></p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deactivate all non-standard themes
|
||||||
|
function deactivate_non_standard_themes()
|
||||||
|
{
|
||||||
|
global $page, $conf;
|
||||||
|
|
||||||
|
$standard_themes = array(
|
||||||
|
'clear',
|
||||||
|
'Sylvia',
|
||||||
|
'dark',
|
||||||
|
'elegant',
|
||||||
|
'smartpocket',
|
||||||
|
);
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name
|
||||||
|
FROM '.PREFIX_TABLE.'themes
|
||||||
|
WHERE id NOT IN (\''.implode("','", $standard_themes).'\')
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
$theme_ids = array();
|
||||||
|
$theme_names = array();
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$theme_ids[] = $row['id'];
|
||||||
|
$theme_names[] = $row['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($theme_ids))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.PREFIX_TABLE.'themes
|
||||||
|
WHERE id IN (\''.implode("','", $theme_ids).'\')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
$page['infos'][] = l10n('As a precaution, following themes have been deactivated. You must check for themes upgrade before reactiving them:')
|
||||||
|
.'<p><i>'.implode(', ', $theme_names).'</i></p>';
|
||||||
|
|
||||||
|
// what is the default theme?
|
||||||
|
$query = '
|
||||||
|
SELECT theme
|
||||||
|
FROM '.PREFIX_TABLE.'user_infos
|
||||||
|
WHERE user_id = '.$conf['default_user_id'].'
|
||||||
|
;';
|
||||||
|
list($default_theme) = pwg_db_fetch_row(pwg_query($query));
|
||||||
|
|
||||||
|
// if the default theme has just been deactivated, let's set another core theme as default
|
||||||
|
if (in_array($default_theme, $theme_ids))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE '.PREFIX_TABLE.'user_infos
|
||||||
|
SET theme = \'elegant\'
|
||||||
|
WHERE user_id = '.$conf['default_user_id'].'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deactivate all templates
|
||||||
|
function deactivate_templates()
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
UPDATE '.PREFIX_TABLE.'config
|
||||||
|
SET value = \''. array() .'\'
|
||||||
|
WHERE param = \'extents_for_templates\';';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check access rights
|
||||||
|
function check_upgrade_access_rights()
|
||||||
|
{
|
||||||
|
global $conf, $page, $current_release;
|
||||||
|
|
||||||
|
if (version_compare($current_release, '2.0', '>=') and isset($_COOKIE[session_name()]))
|
||||||
|
{
|
||||||
|
// Check if user is already connected as webmaster
|
||||||
|
session_start();
|
||||||
|
if (!empty($_SESSION['pwg_uid']))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT status
|
||||||
|
FROM '.USER_INFOS_TABLE.'
|
||||||
|
WHERE user_id = '.$_SESSION['pwg_uid'].'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
if (isset($row['status']) and $row['status'] == 'webmaster')
|
||||||
|
{
|
||||||
|
define('PHPWG_IN_UPGRADE', true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_POST['username']) or !isset($_POST['password']))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$username = $_POST['username'];
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
if(!@get_magic_quotes_gpc())
|
||||||
|
{
|
||||||
|
$username = pwg_db_real_escape_string($username);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version_compare($current_release, '2.0', '<'))
|
||||||
|
{
|
||||||
|
$username = utf8_decode($username);
|
||||||
|
$password = utf8_decode($password);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version_compare($current_release, '1.5', '<'))
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT password, status
|
||||||
|
FROM '.USERS_TABLE.'
|
||||||
|
WHERE username = \''.$username.'\'
|
||||||
|
;';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT u.password, ui.status
|
||||||
|
FROM '.USERS_TABLE.' AS u
|
||||||
|
INNER JOIN '.USER_INFOS_TABLE.' AS ui
|
||||||
|
ON u.'.$conf['user_fields']['id'].'=ui.user_id
|
||||||
|
WHERE '.$conf['user_fields']['username'].'=\''.$username.'\'
|
||||||
|
;';
|
||||||
|
}
|
||||||
|
$row = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
|
||||||
|
if (!$conf['password_verify']($password, $row['password']))
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('Invalid password!');
|
||||||
|
}
|
||||||
|
elseif ($row['status'] != 'admin' and $row['status'] != 'webmaster')
|
||||||
|
{
|
||||||
|
$page['errors'][] = l10n('You do not have access rights to run upgrade');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
define('PHPWG_IN_UPGRADE', true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* which upgrades are available ?
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function get_available_upgrade_ids()
|
||||||
|
{
|
||||||
|
$upgrades_path = PHPWG_ROOT_PATH.'install/db';
|
||||||
|
|
||||||
|
$available_upgrade_ids = array();
|
||||||
|
|
||||||
|
if ($contents = opendir($upgrades_path))
|
||||||
|
{
|
||||||
|
while (($node = readdir($contents)) !== false)
|
||||||
|
{
|
||||||
|
if (is_file($upgrades_path.'/'.$node)
|
||||||
|
and preg_match('/^(.*?)-database\.php$/', $node, $match))
|
||||||
|
{
|
||||||
|
$available_upgrade_ids[] = $match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
natcasesort($available_upgrade_ids);
|
||||||
|
|
||||||
|
return $available_upgrade_ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns true if there are available upgrade files
|
||||||
|
*/
|
||||||
|
function check_upgrade_feed()
|
||||||
|
{
|
||||||
|
// retrieve already applied upgrades
|
||||||
|
$query = '
|
||||||
|
SELECT id
|
||||||
|
FROM '.UPGRADE_TABLE.'
|
||||||
|
;';
|
||||||
|
$applied = array_from_query($query, 'id');
|
||||||
|
|
||||||
|
// retrieve existing upgrades
|
||||||
|
$existing = get_available_upgrade_ids();
|
||||||
|
|
||||||
|
// which upgrades need to be applied?
|
||||||
|
return (count(array_diff($existing, $applied)) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function upgrade_db_connect()
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pwg_db_connect($conf['db_host'], $conf['db_user'],
|
||||||
|
$conf['db_password'], $conf['db_base']);
|
||||||
|
pwg_db_check_version();
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
my_error(l10n($e->getMessage()), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
585
sources/admin/include/functions_upload.inc.php
Normal file
585
sources/admin/include/functions_upload.inc.php
Normal file
|
@ -0,0 +1,585 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
|
||||||
|
|
||||||
|
// add default event handler for image and thumbnail resize
|
||||||
|
add_event_handler('upload_image_resize', 'pwg_image_resize', EVENT_HANDLER_PRIORITY_NEUTRAL, 7);
|
||||||
|
add_event_handler('upload_thumbnail_resize', 'pwg_image_resize', EVENT_HANDLER_PRIORITY_NEUTRAL, 9);
|
||||||
|
|
||||||
|
function get_upload_form_config()
|
||||||
|
{
|
||||||
|
// default configuration for upload
|
||||||
|
$upload_form_config = array(
|
||||||
|
'original_resize' => array(
|
||||||
|
'default' => false,
|
||||||
|
'can_be_null' => false,
|
||||||
|
),
|
||||||
|
|
||||||
|
'original_resize_maxwidth' => array(
|
||||||
|
'default' => 2000,
|
||||||
|
'min' => 500,
|
||||||
|
'max' => 20000,
|
||||||
|
'pattern' => '/^\d+$/',
|
||||||
|
'can_be_null' => false,
|
||||||
|
'error_message' => l10n('The original maximum width must be a number between %d and %d'),
|
||||||
|
),
|
||||||
|
|
||||||
|
'original_resize_maxheight' => array(
|
||||||
|
'default' => 2000,
|
||||||
|
'min' => 300,
|
||||||
|
'max' => 20000,
|
||||||
|
'pattern' => '/^\d+$/',
|
||||||
|
'can_be_null' => false,
|
||||||
|
'error_message' => l10n('The original maximum height must be a number between %d and %d'),
|
||||||
|
),
|
||||||
|
|
||||||
|
'original_resize_quality' => array(
|
||||||
|
'default' => 95,
|
||||||
|
'min' => 50,
|
||||||
|
'max' => 98,
|
||||||
|
'pattern' => '/^\d+$/',
|
||||||
|
'can_be_null' => false,
|
||||||
|
'error_message' => l10n('The original image quality must be a number between %d and %d'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $upload_form_config;
|
||||||
|
}
|
||||||
|
|
||||||
|
function save_upload_form_config($data, &$errors=array(), &$form_errors=array())
|
||||||
|
{
|
||||||
|
if (!is_array($data) or empty($data))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$upload_form_config = get_upload_form_config();
|
||||||
|
$updates = array();
|
||||||
|
|
||||||
|
foreach ($data as $field => $value)
|
||||||
|
{
|
||||||
|
if (!isset($upload_form_config[$field]))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (is_bool($upload_form_config[$field]['default']))
|
||||||
|
{
|
||||||
|
if (isset($value))
|
||||||
|
{
|
||||||
|
$value = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$updates[] = array(
|
||||||
|
'param' => $field,
|
||||||
|
'value' => boolean_to_string($value)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
elseif ($upload_form_config[$field]['can_be_null'] and empty($value))
|
||||||
|
{
|
||||||
|
$updates[] = array(
|
||||||
|
'param' => $field,
|
||||||
|
'value' => 'false'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$min = $upload_form_config[$field]['min'];
|
||||||
|
$max = $upload_form_config[$field]['max'];
|
||||||
|
$pattern = $upload_form_config[$field]['pattern'];
|
||||||
|
|
||||||
|
if (preg_match($pattern, $value) and $value >= $min and $value <= $max)
|
||||||
|
{
|
||||||
|
$updates[] = array(
|
||||||
|
'param' => $field,
|
||||||
|
'value' => $value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$errors[] = sprintf(
|
||||||
|
$upload_form_config[$field]['error_message'],
|
||||||
|
$min, $max
|
||||||
|
);
|
||||||
|
|
||||||
|
$form_errors[$field] = '['.$min.' .. '.$max.']';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($errors) == 0)
|
||||||
|
{
|
||||||
|
mass_updates(
|
||||||
|
CONFIG_TABLE,
|
||||||
|
array(
|
||||||
|
'primary' => array('param'),
|
||||||
|
'update' => array('value')
|
||||||
|
),
|
||||||
|
$updates
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_uploaded_file($source_filepath, $original_filename=null, $categories=null, $level=null, $image_id=null, $original_md5sum=null)
|
||||||
|
{
|
||||||
|
// 1) move uploaded file to upload/2010/01/22/20100122003814-449ada00.jpg
|
||||||
|
//
|
||||||
|
// 2) keep/resize original
|
||||||
|
//
|
||||||
|
// 3) register in database
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// * check md5sum (already exists?)
|
||||||
|
|
||||||
|
global $conf, $user;
|
||||||
|
|
||||||
|
if (isset($original_md5sum))
|
||||||
|
{
|
||||||
|
$md5sum = $original_md5sum;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$md5sum = md5_file($source_filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$file_path = null;
|
||||||
|
$is_tiff = false;
|
||||||
|
|
||||||
|
if (isset($image_id))
|
||||||
|
{
|
||||||
|
// this photo already exists, we update it
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
path
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE id = '.$image_id.'
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$file_path = $row['path'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($file_path))
|
||||||
|
{
|
||||||
|
die('['.__FUNCTION__.'] this photo does not exist in the database');
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete all physical files related to the photo (thumbnail, web site, HD)
|
||||||
|
delete_element_files(array($image_id));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// this photo is new
|
||||||
|
|
||||||
|
// current date
|
||||||
|
list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
|
||||||
|
list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4);
|
||||||
|
|
||||||
|
// upload directory hierarchy
|
||||||
|
$upload_dir = sprintf(
|
||||||
|
PHPWG_ROOT_PATH.$conf['upload_dir'].'/%s/%s/%s',
|
||||||
|
$year,
|
||||||
|
$month,
|
||||||
|
$day
|
||||||
|
);
|
||||||
|
|
||||||
|
// compute file path
|
||||||
|
$date_string = preg_replace('/[^\d]/', '', $dbnow);
|
||||||
|
$random_string = substr($md5sum, 0, 8);
|
||||||
|
$filename_wo_ext = $date_string.'-'.$random_string;
|
||||||
|
$file_path = $upload_dir.'/'.$filename_wo_ext.'.';
|
||||||
|
|
||||||
|
list($width, $height, $type) = getimagesize($source_filepath);
|
||||||
|
if (IMAGETYPE_PNG == $type)
|
||||||
|
{
|
||||||
|
$file_path.= 'png';
|
||||||
|
}
|
||||||
|
elseif (IMAGETYPE_GIF == $type)
|
||||||
|
{
|
||||||
|
$file_path.= 'gif';
|
||||||
|
}
|
||||||
|
elseif (IMAGETYPE_TIFF_MM == $type or IMAGETYPE_TIFF_II == $type)
|
||||||
|
{
|
||||||
|
$is_tiff = true;
|
||||||
|
$file_path.= 'tif';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$file_path.= 'jpg';
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_directory($upload_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_uploaded_file($source_filepath))
|
||||||
|
{
|
||||||
|
move_uploaded_file($source_filepath, $file_path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rename($source_filepath, $file_path);
|
||||||
|
}
|
||||||
|
@chmod($file_path, 0644);
|
||||||
|
|
||||||
|
if ($is_tiff and pwg_image::get_library() == 'ext_imagick')
|
||||||
|
{
|
||||||
|
// move the uploaded file to pwg_representative sub-directory
|
||||||
|
$representative_file_path = dirname($file_path).'/pwg_representative/';
|
||||||
|
$representative_file_path.= get_filename_wo_extension(basename($file_path)).'.';
|
||||||
|
|
||||||
|
$representative_ext = $conf['tiff_representative_ext'];
|
||||||
|
$representative_file_path.= $representative_ext;
|
||||||
|
|
||||||
|
prepare_directory(dirname($representative_file_path));
|
||||||
|
|
||||||
|
$exec = $conf['ext_imagick_dir'].'convert';
|
||||||
|
|
||||||
|
if ('jpg' == $conf['tiff_representative_ext'])
|
||||||
|
{
|
||||||
|
$exec .= ' -quality 98';
|
||||||
|
}
|
||||||
|
|
||||||
|
$exec .= ' "'.realpath($file_path).'"';
|
||||||
|
|
||||||
|
$dest = pathinfo($representative_file_path);
|
||||||
|
$exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"';
|
||||||
|
|
||||||
|
$exec .= ' 2>&1';
|
||||||
|
@exec($exec, $returnarray);
|
||||||
|
|
||||||
|
// sometimes ImageMagick creates file-0.jpg (full size) + file-1.jpg
|
||||||
|
// (thumbnail). I don't know how to avoid it.
|
||||||
|
$representative_file_abspath = realpath($dest['dirname']).'/'.$dest['basename'];
|
||||||
|
if (!file_exists($representative_file_abspath))
|
||||||
|
{
|
||||||
|
$first_file_abspath = preg_replace(
|
||||||
|
'/\.'.$representative_ext.'$/',
|
||||||
|
'-0.'.$representative_ext,
|
||||||
|
$representative_file_abspath
|
||||||
|
);
|
||||||
|
|
||||||
|
if (file_exists($first_file_abspath))
|
||||||
|
{
|
||||||
|
rename($first_file_abspath, $representative_file_abspath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pwg_image::get_library() != 'gd')
|
||||||
|
{
|
||||||
|
if ($conf['original_resize'])
|
||||||
|
{
|
||||||
|
$need_resize = need_resize($file_path, $conf['original_resize_maxwidth'], $conf['original_resize_maxheight']);
|
||||||
|
|
||||||
|
if ($need_resize)
|
||||||
|
{
|
||||||
|
$img = new pwg_image($file_path);
|
||||||
|
|
||||||
|
$img->pwg_resize(
|
||||||
|
$file_path,
|
||||||
|
$conf['original_resize_maxwidth'],
|
||||||
|
$conf['original_resize_maxheight'],
|
||||||
|
$conf['original_resize_quality'],
|
||||||
|
$conf['upload_form_automatic_rotation'],
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
$img->destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we need to save the rotation angle in the database to compute
|
||||||
|
// width/height of "multisizes"
|
||||||
|
$rotation_angle = pwg_image::get_rotation_angle($file_path);
|
||||||
|
$rotation = pwg_image::get_rotation_code_from_angle($rotation_angle);
|
||||||
|
|
||||||
|
$file_infos = pwg_image_infos($file_path);
|
||||||
|
|
||||||
|
if (isset($image_id))
|
||||||
|
{
|
||||||
|
$update = array(
|
||||||
|
'file' => pwg_db_real_escape_string(isset($original_filename) ? $original_filename : basename($file_path)),
|
||||||
|
'filesize' => $file_infos['filesize'],
|
||||||
|
'width' => $file_infos['width'],
|
||||||
|
'height' => $file_infos['height'],
|
||||||
|
'md5sum' => $md5sum,
|
||||||
|
'added_by' => $user['id'],
|
||||||
|
'rotation' => $rotation,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isset($level))
|
||||||
|
{
|
||||||
|
$update['level'] = $level;
|
||||||
|
}
|
||||||
|
|
||||||
|
single_update(
|
||||||
|
IMAGES_TABLE,
|
||||||
|
$update,
|
||||||
|
array('id' => $image_id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// database registration
|
||||||
|
$file = pwg_db_real_escape_string(isset($original_filename) ? $original_filename : basename($file_path));
|
||||||
|
$insert = array(
|
||||||
|
'file' => $file,
|
||||||
|
'name' => get_name_from_file($file),
|
||||||
|
'date_available' => $dbnow,
|
||||||
|
'path' => preg_replace('#^'.preg_quote(PHPWG_ROOT_PATH).'#', '', $file_path),
|
||||||
|
'filesize' => $file_infos['filesize'],
|
||||||
|
'width' => $file_infos['width'],
|
||||||
|
'height' => $file_infos['height'],
|
||||||
|
'md5sum' => $md5sum,
|
||||||
|
'added_by' => $user['id'],
|
||||||
|
'rotation' => $rotation,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isset($level))
|
||||||
|
{
|
||||||
|
$insert['level'] = $level;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($representative_ext))
|
||||||
|
{
|
||||||
|
$insert['representative_ext'] = $representative_ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
single_insert(IMAGES_TABLE, $insert);
|
||||||
|
|
||||||
|
$image_id = pwg_db_insert_id(IMAGES_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($categories) and count($categories) > 0)
|
||||||
|
{
|
||||||
|
associate_images_to_categories(
|
||||||
|
array($image_id),
|
||||||
|
$categories
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update metadata from the uploaded file (exif/iptc)
|
||||||
|
if ($conf['use_exif'] and !function_exists('read_exif_data'))
|
||||||
|
{
|
||||||
|
$conf['use_exif'] = false;
|
||||||
|
}
|
||||||
|
sync_metadata(array($image_id));
|
||||||
|
|
||||||
|
invalidate_user_cache();
|
||||||
|
|
||||||
|
// cache thumbnail
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
path
|
||||||
|
FROM '.IMAGES_TABLE.'
|
||||||
|
WHERE id = '.$image_id.'
|
||||||
|
;';
|
||||||
|
$image_infos = pwg_db_fetch_assoc(pwg_query($query));
|
||||||
|
|
||||||
|
set_make_full_url();
|
||||||
|
// in case we are on uploadify.php, we have to replace the false path
|
||||||
|
$thumb_url = preg_replace('#admin/include/i#', 'i', DerivativeImage::thumb_url($image_infos));
|
||||||
|
unset_make_full_url();
|
||||||
|
|
||||||
|
fetchRemote($thumb_url, $dest);
|
||||||
|
|
||||||
|
|
||||||
|
return $image_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepare_directory($directory)
|
||||||
|
{
|
||||||
|
if (!is_dir($directory)) {
|
||||||
|
if (substr(PHP_OS, 0, 3) == 'WIN')
|
||||||
|
{
|
||||||
|
$directory = str_replace('/', DIRECTORY_SEPARATOR, $directory);
|
||||||
|
}
|
||||||
|
umask(0000);
|
||||||
|
$recursive = true;
|
||||||
|
if (!@mkdir($directory, 0777, $recursive))
|
||||||
|
{
|
||||||
|
die('[prepare_directory] cannot create directory "'.$directory.'"');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_writable($directory))
|
||||||
|
{
|
||||||
|
// last chance to make the directory writable
|
||||||
|
@chmod($directory, 0777);
|
||||||
|
|
||||||
|
if (!is_writable($directory))
|
||||||
|
{
|
||||||
|
die('[prepare_directory] directory "'.$directory.'" has no write access');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
secure_directory($directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
function need_resize($image_filepath, $max_width, $max_height)
|
||||||
|
{
|
||||||
|
// TODO : the resize check should take the orientation into account. If a
|
||||||
|
// rotation must be applied to the resized photo, then we should test
|
||||||
|
// invert width and height.
|
||||||
|
list($width, $height) = getimagesize($image_filepath);
|
||||||
|
|
||||||
|
if ($width > $max_width or $height > $max_height)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pwg_image_infos($path)
|
||||||
|
{
|
||||||
|
list($width, $height) = getimagesize($path);
|
||||||
|
$filesize = floor(filesize($path)/1024);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'width' => $width,
|
||||||
|
'height' => $height,
|
||||||
|
'filesize' => $filesize,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_valid_image_extension($extension)
|
||||||
|
{
|
||||||
|
return in_array(strtolower($extension), array('jpg', 'jpeg', 'png', 'gif'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function file_upload_error_message($error_code)
|
||||||
|
{
|
||||||
|
switch ($error_code) {
|
||||||
|
case UPLOAD_ERR_INI_SIZE:
|
||||||
|
return sprintf(
|
||||||
|
l10n('The uploaded file exceeds the upload_max_filesize directive in php.ini: %sB'),
|
||||||
|
get_ini_size('upload_max_filesize', false)
|
||||||
|
);
|
||||||
|
case UPLOAD_ERR_FORM_SIZE:
|
||||||
|
return l10n('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form');
|
||||||
|
case UPLOAD_ERR_PARTIAL:
|
||||||
|
return l10n('The uploaded file was only partially uploaded');
|
||||||
|
case UPLOAD_ERR_NO_FILE:
|
||||||
|
return l10n('No file was uploaded');
|
||||||
|
case UPLOAD_ERR_NO_TMP_DIR:
|
||||||
|
return l10n('Missing a temporary folder');
|
||||||
|
case UPLOAD_ERR_CANT_WRITE:
|
||||||
|
return l10n('Failed to write file to disk');
|
||||||
|
case UPLOAD_ERR_EXTENSION:
|
||||||
|
return l10n('File upload stopped by extension');
|
||||||
|
default:
|
||||||
|
return l10n('Unknown upload error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_ini_size($ini_key, $in_bytes=true)
|
||||||
|
{
|
||||||
|
$size = ini_get($ini_key);
|
||||||
|
|
||||||
|
if ($in_bytes)
|
||||||
|
{
|
||||||
|
$size = convert_shorthand_notation_to_bytes($size);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
function convert_shorthand_notation_to_bytes($value)
|
||||||
|
{
|
||||||
|
$suffix = substr($value, -1);
|
||||||
|
$multiply_by = null;
|
||||||
|
|
||||||
|
if ('K' == $suffix)
|
||||||
|
{
|
||||||
|
$multiply_by = 1024;
|
||||||
|
}
|
||||||
|
else if ('M' == $suffix)
|
||||||
|
{
|
||||||
|
$multiply_by = 1024*1024;
|
||||||
|
}
|
||||||
|
else if ('G' == $suffix)
|
||||||
|
{
|
||||||
|
$multiply_by = 1024*1024*1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($multiply_by))
|
||||||
|
{
|
||||||
|
$value = substr($value, 0, -1);
|
||||||
|
$value*= $multiply_by;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_upload_error($upload_id, $error_message)
|
||||||
|
{
|
||||||
|
$_SESSION['uploads_error'][$upload_id][] = $error_message;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ready_for_upload_message()
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
$relative_dir = preg_replace('#^'.PHPWG_ROOT_PATH.'#', '', $conf['upload_dir']);
|
||||||
|
|
||||||
|
if (!is_dir($conf['upload_dir']))
|
||||||
|
{
|
||||||
|
if (!is_writable(dirname($conf['upload_dir'])))
|
||||||
|
{
|
||||||
|
return sprintf(
|
||||||
|
l10n('Create the "%s" directory at the root of your Piwigo installation'),
|
||||||
|
$relative_dir
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!is_writable($conf['upload_dir']))
|
||||||
|
{
|
||||||
|
@chmod($conf['upload_dir'], 0777);
|
||||||
|
|
||||||
|
if (!is_writable($conf['upload_dir']))
|
||||||
|
{
|
||||||
|
return sprintf(
|
||||||
|
l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),
|
||||||
|
$relative_dir
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
?>
|
821
sources/admin/include/image.class.php
Normal file
821
sources/admin/include/image.class.php
Normal file
|
@ -0,0 +1,821 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Image Interface |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Define all needed methods for image class
|
||||||
|
interface imageInterface
|
||||||
|
{
|
||||||
|
function get_width();
|
||||||
|
|
||||||
|
function get_height();
|
||||||
|
|
||||||
|
function set_compression_quality($quality);
|
||||||
|
|
||||||
|
function crop($width, $height, $x, $y);
|
||||||
|
|
||||||
|
function strip();
|
||||||
|
|
||||||
|
function rotate($rotation);
|
||||||
|
|
||||||
|
function resize($width, $height);
|
||||||
|
|
||||||
|
function sharpen($amount);
|
||||||
|
|
||||||
|
function compose($overlay, $x, $y, $opacity);
|
||||||
|
|
||||||
|
function write($destination_filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Main Image Class |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
class pwg_image
|
||||||
|
{
|
||||||
|
var $image;
|
||||||
|
var $library = '';
|
||||||
|
var $source_filepath = '';
|
||||||
|
static $ext_imagick_version = '';
|
||||||
|
|
||||||
|
function __construct($source_filepath, $library=null)
|
||||||
|
{
|
||||||
|
$this->source_filepath = $source_filepath;
|
||||||
|
|
||||||
|
trigger_action('load_image_library', array(&$this) );
|
||||||
|
|
||||||
|
if (is_object($this->image))
|
||||||
|
{
|
||||||
|
return; // A plugin may have load its own library
|
||||||
|
}
|
||||||
|
|
||||||
|
$extension = strtolower(get_extension($source_filepath));
|
||||||
|
|
||||||
|
if (!in_array($extension, array('jpg', 'jpeg', 'png', 'gif')))
|
||||||
|
{
|
||||||
|
die('[Image] unsupported file extension');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!($this->library = self::get_library($library, $extension)))
|
||||||
|
{
|
||||||
|
die('No image library available on your server.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = 'image_'.$this->library;
|
||||||
|
$this->image = new $class($source_filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unknow methods will be redirected to image object
|
||||||
|
function __call($method, $arguments)
|
||||||
|
{
|
||||||
|
return call_user_func_array(array($this->image, $method), $arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Piwigo resize function
|
||||||
|
function pwg_resize($destination_filepath, $max_width, $max_height, $quality, $automatic_rotation=true, $strip_metadata=false, $crop=false, $follow_orientation=true)
|
||||||
|
{
|
||||||
|
$starttime = get_moment();
|
||||||
|
|
||||||
|
// width/height
|
||||||
|
$source_width = $this->image->get_width();
|
||||||
|
$source_height = $this->image->get_height();
|
||||||
|
|
||||||
|
$rotation = null;
|
||||||
|
if ($automatic_rotation)
|
||||||
|
{
|
||||||
|
$rotation = self::get_rotation_angle($this->source_filepath);
|
||||||
|
}
|
||||||
|
$resize_dimensions = self::get_resize_dimensions($source_width, $source_height, $max_width, $max_height, $rotation, $crop, $follow_orientation);
|
||||||
|
|
||||||
|
// testing on height is useless in theory: if width is unchanged, there
|
||||||
|
// should be no resize, because width/height ratio is not modified.
|
||||||
|
if ($resize_dimensions['width'] == $source_width and $resize_dimensions['height'] == $source_height)
|
||||||
|
{
|
||||||
|
// the image doesn't need any resize! We just copy it to the destination
|
||||||
|
copy($this->source_filepath, $destination_filepath);
|
||||||
|
return $this->get_resize_result($destination_filepath, $resize_dimensions['width'], $resize_dimensions['height'], $starttime);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->image->set_compression_quality($quality);
|
||||||
|
|
||||||
|
if ($strip_metadata)
|
||||||
|
{
|
||||||
|
// we save a few kilobytes. For example a thumbnail with metadata weights 25KB, without metadata 7KB.
|
||||||
|
$this->image->strip();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($resize_dimensions['crop']))
|
||||||
|
{
|
||||||
|
$this->image->crop($resize_dimensions['crop']['width'], $resize_dimensions['crop']['height'], $resize_dimensions['crop']['x'], $resize_dimensions['crop']['y']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->image->resize($resize_dimensions['width'], $resize_dimensions['height']);
|
||||||
|
|
||||||
|
if (!empty($rotation))
|
||||||
|
{
|
||||||
|
$this->image->rotate($rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->image->write($destination_filepath);
|
||||||
|
|
||||||
|
// everything should be OK if we are here!
|
||||||
|
return $this->get_resize_result($destination_filepath, $resize_dimensions['width'], $resize_dimensions['height'], $starttime);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function get_resize_dimensions($width, $height, $max_width, $max_height, $rotation=null, $crop=false, $follow_orientation=true)
|
||||||
|
{
|
||||||
|
$rotate_for_dimensions = false;
|
||||||
|
if (isset($rotation) and in_array(abs($rotation), array(90, 270)))
|
||||||
|
{
|
||||||
|
$rotate_for_dimensions = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rotate_for_dimensions)
|
||||||
|
{
|
||||||
|
list($width, $height) = array($height, $width);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($crop)
|
||||||
|
{
|
||||||
|
$x = 0;
|
||||||
|
$y = 0;
|
||||||
|
|
||||||
|
if ($width < $height and $follow_orientation)
|
||||||
|
{
|
||||||
|
list($max_width, $max_height) = array($max_height, $max_width);
|
||||||
|
}
|
||||||
|
|
||||||
|
$img_ratio = $width / $height;
|
||||||
|
$dest_ratio = $max_width / $max_height;
|
||||||
|
|
||||||
|
if($dest_ratio > $img_ratio)
|
||||||
|
{
|
||||||
|
$destHeight = round($width * $max_height / $max_width);
|
||||||
|
$y = round(($height - $destHeight) / 2 );
|
||||||
|
$height = $destHeight;
|
||||||
|
}
|
||||||
|
elseif ($dest_ratio < $img_ratio)
|
||||||
|
{
|
||||||
|
$destWidth = round($height * $max_width / $max_height);
|
||||||
|
$x = round(($width - $destWidth) / 2 );
|
||||||
|
$width = $destWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ratio_width = $width / $max_width;
|
||||||
|
$ratio_height = $height / $max_height;
|
||||||
|
$destination_width = $width;
|
||||||
|
$destination_height = $height;
|
||||||
|
|
||||||
|
// maximal size exceeded ?
|
||||||
|
if ($ratio_width > 1 or $ratio_height > 1)
|
||||||
|
{
|
||||||
|
if ($ratio_width < $ratio_height)
|
||||||
|
{
|
||||||
|
$destination_width = round($width / $ratio_height);
|
||||||
|
$destination_height = $max_height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$destination_width = $max_width;
|
||||||
|
$destination_height = round($height / $ratio_width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rotate_for_dimensions)
|
||||||
|
{
|
||||||
|
list($destination_width, $destination_height) = array($destination_height, $destination_width);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = array(
|
||||||
|
'width' => $destination_width,
|
||||||
|
'height'=> $destination_height,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($crop and ($x or $y))
|
||||||
|
{
|
||||||
|
$result['crop'] = array(
|
||||||
|
'width' => $width,
|
||||||
|
'height' => $height,
|
||||||
|
'x' => $x,
|
||||||
|
'y' => $y,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function get_rotation_angle($source_filepath)
|
||||||
|
{
|
||||||
|
list($width, $height, $type) = getimagesize($source_filepath);
|
||||||
|
if (IMAGETYPE_JPEG != $type)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('exif_read_data'))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rotation = 0;
|
||||||
|
|
||||||
|
$exif = exif_read_data($source_filepath);
|
||||||
|
|
||||||
|
if (isset($exif['Orientation']) and preg_match('/^\s*(\d)/', $exif['Orientation'], $matches))
|
||||||
|
{
|
||||||
|
$orientation = $matches[1];
|
||||||
|
if (in_array($orientation, array(3, 4)))
|
||||||
|
{
|
||||||
|
$rotation = 180;
|
||||||
|
}
|
||||||
|
elseif (in_array($orientation, array(5, 6)))
|
||||||
|
{
|
||||||
|
$rotation = 270;
|
||||||
|
}
|
||||||
|
elseif (in_array($orientation, array(7, 8)))
|
||||||
|
{
|
||||||
|
$rotation = 90;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function get_rotation_code_from_angle($rotation_angle)
|
||||||
|
{
|
||||||
|
switch($rotation_angle)
|
||||||
|
{
|
||||||
|
case 0: return 0;
|
||||||
|
case 90: return 1;
|
||||||
|
case 180: return 2;
|
||||||
|
case 270: return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static function get_rotation_angle_from_code($rotation_code)
|
||||||
|
{
|
||||||
|
switch($rotation_code%4)
|
||||||
|
{
|
||||||
|
case 0: return 0;
|
||||||
|
case 1: return 90;
|
||||||
|
case 2: return 180;
|
||||||
|
case 3: return 270;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns a normalized convolution kernel for sharpening*/
|
||||||
|
static function get_sharpen_matrix($amount)
|
||||||
|
{
|
||||||
|
// Amount should be in the range of 48-10
|
||||||
|
$amount = round(abs(-48 + ($amount * 0.38)), 2);
|
||||||
|
|
||||||
|
$matrix = array(
|
||||||
|
array(-1, -1, -1),
|
||||||
|
array(-1, $amount, -1),
|
||||||
|
array(-1, -1, -1),
|
||||||
|
);
|
||||||
|
|
||||||
|
$norm = array_sum(array_map('array_sum', $matrix));
|
||||||
|
|
||||||
|
for ($i=0; $i<3; $i++)
|
||||||
|
{
|
||||||
|
$line = & $matrix[$i];
|
||||||
|
for ($j=0; $j<3; $j++)
|
||||||
|
{
|
||||||
|
$line[$j] /= $norm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function get_resize_result($destination_filepath, $width, $height, $time=null)
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'source' => $this->source_filepath,
|
||||||
|
'destination' => $destination_filepath,
|
||||||
|
'width' => $width,
|
||||||
|
'height' => $height,
|
||||||
|
'size' => floor(filesize($destination_filepath) / 1024).' KB',
|
||||||
|
'time' => $time ? number_format((get_moment() - $time) * 1000, 2, '.', ' ').' ms' : null,
|
||||||
|
'library' => $this->library,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function is_imagick()
|
||||||
|
{
|
||||||
|
return (extension_loaded('imagick') and class_exists('Imagick'));
|
||||||
|
}
|
||||||
|
|
||||||
|
static function is_ext_imagick()
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
if (!function_exists('exec'))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@exec($conf['ext_imagick_dir'].'convert -version', $returnarray);
|
||||||
|
if (is_array($returnarray) and !empty($returnarray[0]) and preg_match('/ImageMagick/i', $returnarray[0]))
|
||||||
|
{
|
||||||
|
if (preg_match('/Version: ImageMagick (\d+\.\d+\.\d+-?\d*)/', $returnarray[0], $match))
|
||||||
|
{
|
||||||
|
self::$ext_imagick_version = $match[1];
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function is_gd()
|
||||||
|
{
|
||||||
|
return function_exists('gd_info');
|
||||||
|
}
|
||||||
|
|
||||||
|
static function get_library($library=null, $extension=null)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
if (is_null($library))
|
||||||
|
{
|
||||||
|
$library = $conf['graphics_library'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Choose image library
|
||||||
|
switch (strtolower($library))
|
||||||
|
{
|
||||||
|
case 'auto':
|
||||||
|
case 'imagick':
|
||||||
|
if ($extension != 'gif' and self::is_imagick())
|
||||||
|
{
|
||||||
|
return 'imagick';
|
||||||
|
}
|
||||||
|
case 'ext_imagick':
|
||||||
|
if ($extension != 'gif' and self::is_ext_imagick())
|
||||||
|
{
|
||||||
|
return 'ext_imagick';
|
||||||
|
}
|
||||||
|
case 'gd':
|
||||||
|
if (self::is_gd())
|
||||||
|
{
|
||||||
|
return 'gd';
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if ($library != 'auto')
|
||||||
|
{
|
||||||
|
// Requested library not available. Try another library
|
||||||
|
return self::get_library('auto', $extension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroy()
|
||||||
|
{
|
||||||
|
if (method_exists($this->image, 'destroy'))
|
||||||
|
{
|
||||||
|
return $this->image->destroy();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Class for Imagick extension |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
class image_imagick implements imageInterface
|
||||||
|
{
|
||||||
|
var $image;
|
||||||
|
|
||||||
|
function __construct($source_filepath)
|
||||||
|
{
|
||||||
|
// A bug cause that Imagick class can not be extended
|
||||||
|
$this->image = new Imagick($source_filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_width()
|
||||||
|
{
|
||||||
|
return $this->image->getImageWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_height()
|
||||||
|
{
|
||||||
|
return $this->image->getImageHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_compression_quality($quality)
|
||||||
|
{
|
||||||
|
return $this->image->setImageCompressionQuality($quality);
|
||||||
|
}
|
||||||
|
|
||||||
|
function crop($width, $height, $x, $y)
|
||||||
|
{
|
||||||
|
return $this->image->cropImage($width, $height, $x, $y);
|
||||||
|
}
|
||||||
|
|
||||||
|
function strip()
|
||||||
|
{
|
||||||
|
return $this->image->stripImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
function rotate($rotation)
|
||||||
|
{
|
||||||
|
$this->image->rotateImage(new ImagickPixel(), -$rotation);
|
||||||
|
$this->image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resize($width, $height)
|
||||||
|
{
|
||||||
|
$this->image->setInterlaceScheme(Imagick::INTERLACE_LINE);
|
||||||
|
|
||||||
|
// TODO need to explain this condition
|
||||||
|
if ($this->get_width()%2 == 0
|
||||||
|
&& $this->get_height()%2 == 0
|
||||||
|
&& $this->get_width() > 3*$width)
|
||||||
|
{
|
||||||
|
$this->image->scaleImage($this->get_width()/2, $this->get_height()/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->image->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sharpen($amount)
|
||||||
|
{
|
||||||
|
$m = pwg_image::get_sharpen_matrix($amount);
|
||||||
|
return $this->image->convolveImage($m);
|
||||||
|
}
|
||||||
|
|
||||||
|
function compose($overlay, $x, $y, $opacity)
|
||||||
|
{
|
||||||
|
$ioverlay = $overlay->image->image;
|
||||||
|
/*if ($ioverlay->getImageAlphaChannel() !== Imagick::ALPHACHANNEL_OPAQUE)
|
||||||
|
{
|
||||||
|
// Force the image to have an alpha channel
|
||||||
|
$ioverlay->setImageAlphaChannel(Imagick::ALPHACHANNEL_OPAQUE);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
global $dirty_trick_xrepeat;
|
||||||
|
if ( !isset($dirty_trick_xrepeat) && $opacity < 100)
|
||||||
|
{// NOTE: Using setImageOpacity will destroy current alpha channels!
|
||||||
|
$ioverlay->evaluateImage(Imagick::EVALUATE_MULTIPLY, $opacity / 100, Imagick::CHANNEL_ALPHA);
|
||||||
|
$dirty_trick_xrepeat = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->image->compositeImage($ioverlay, Imagick::COMPOSITE_DISSOLVE, $x, $y);
|
||||||
|
}
|
||||||
|
|
||||||
|
function write($destination_filepath)
|
||||||
|
{
|
||||||
|
// use 4:2:2 chroma subsampling (reduce file size by 20-30% with "almost" no human perception)
|
||||||
|
$this->image->setSamplingFactors( array(2,1) );
|
||||||
|
return $this->image->writeImage($destination_filepath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Class for ImageMagick external installation |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
class image_ext_imagick implements imageInterface
|
||||||
|
{
|
||||||
|
var $imagickdir = '';
|
||||||
|
var $source_filepath = '';
|
||||||
|
var $width = '';
|
||||||
|
var $height = '';
|
||||||
|
var $commands = array();
|
||||||
|
|
||||||
|
function __construct($source_filepath)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
$this->source_filepath = $source_filepath;
|
||||||
|
$this->imagickdir = $conf['ext_imagick_dir'];
|
||||||
|
|
||||||
|
if (strpos(@$_SERVER['SCRIPT_FILENAME'], '/kunden/') === 0) // 1and1
|
||||||
|
{
|
||||||
|
@putenv('MAGICK_THREAD_LIMIT=1');
|
||||||
|
}
|
||||||
|
|
||||||
|
$command = $this->imagickdir.'identify -format "%wx%h" "'.realpath($source_filepath).'"';
|
||||||
|
@exec($command, $returnarray);
|
||||||
|
if(!is_array($returnarray) or empty($returnarray[0]) or !preg_match('/^(\d+)x(\d+)$/', $returnarray[0], $match))
|
||||||
|
{
|
||||||
|
die("[External ImageMagick] Corrupt image\n" . var_export($returnarray, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->width = $match[1];
|
||||||
|
$this->height = $match[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_command($command, $params=null)
|
||||||
|
{
|
||||||
|
$this->commands[$command] = $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_width()
|
||||||
|
{
|
||||||
|
return $this->width;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_height()
|
||||||
|
{
|
||||||
|
return $this->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
function crop($width, $height, $x, $y)
|
||||||
|
{
|
||||||
|
$this->add_command('crop', $width.'x'.$height.'+'.$x.'+'.$y);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function strip()
|
||||||
|
{
|
||||||
|
$this->add_command('strip');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rotate($rotation)
|
||||||
|
{
|
||||||
|
if (empty($rotation))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($rotation==90 || $rotation==270)
|
||||||
|
{
|
||||||
|
$tmp = $this->width;
|
||||||
|
$this->width = $this->height;
|
||||||
|
$this->height = $tmp;
|
||||||
|
}
|
||||||
|
$this->add_command('rotate', -$rotation);
|
||||||
|
$this->add_command('orient', 'top-left');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_compression_quality($quality)
|
||||||
|
{
|
||||||
|
$this->add_command('quality', $quality);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resize($width, $height)
|
||||||
|
{
|
||||||
|
$this->add_command('filter', 'Lanczos');
|
||||||
|
$this->add_command('resize', $width.'x'.$height.'!');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sharpen($amount)
|
||||||
|
{
|
||||||
|
$m = pwg_image::get_sharpen_matrix($amount);
|
||||||
|
|
||||||
|
$param ='convolve "'.count($m).':';
|
||||||
|
foreach ($m as $line)
|
||||||
|
{
|
||||||
|
$param .= ' ';
|
||||||
|
$param .= implode(',', $line);
|
||||||
|
}
|
||||||
|
$param .= '"';
|
||||||
|
$this->add_command('morphology', $param);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function compose($overlay, $x, $y, $opacity)
|
||||||
|
{
|
||||||
|
$param = 'compose dissolve -define compose:args='.$opacity;
|
||||||
|
$param .= ' '.escapeshellarg(realpath($overlay->image->source_filepath));
|
||||||
|
$param .= ' -gravity NorthWest -geometry +'.$x.'+'.$y;
|
||||||
|
$param .= ' -composite';
|
||||||
|
$this->add_command($param);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function write($destination_filepath)
|
||||||
|
{
|
||||||
|
$this->add_command('interlace', 'line'); // progressive rendering
|
||||||
|
// use 4:2:2 chroma subsampling (reduce file size by 20-30% with "almost" no human perception)
|
||||||
|
//
|
||||||
|
// option deactivated for Piwigo 2.4.1, it doesn't work fo old versions
|
||||||
|
// of ImageMagick, see bug:2672. To reactivate once we have a better way
|
||||||
|
// to detect IM version and when we know which version supports this
|
||||||
|
// option
|
||||||
|
//
|
||||||
|
if (version_compare(pwg_image::$ext_imagick_version, '6.6') > 0)
|
||||||
|
{
|
||||||
|
$this->add_command('sampling-factor', '4:2:2' );
|
||||||
|
}
|
||||||
|
|
||||||
|
$exec = $this->imagickdir.'convert';
|
||||||
|
$exec .= ' "'.realpath($this->source_filepath).'"';
|
||||||
|
|
||||||
|
foreach ($this->commands as $command => $params)
|
||||||
|
{
|
||||||
|
$exec .= ' -'.$command;
|
||||||
|
if (!empty($params))
|
||||||
|
{
|
||||||
|
$exec .= ' '.$params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$dest = pathinfo($destination_filepath);
|
||||||
|
$exec .= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'" 2>&1';
|
||||||
|
@exec($exec, $returnarray);
|
||||||
|
|
||||||
|
if (function_exists('ilog')) ilog($exec);
|
||||||
|
if (is_array($returnarray) && (count($returnarray)>0) )
|
||||||
|
{
|
||||||
|
if (function_exists('ilog')) ilog('ERROR', $returnarray);
|
||||||
|
foreach($returnarray as $line)
|
||||||
|
trigger_error($line, E_USER_WARNING);
|
||||||
|
}
|
||||||
|
return is_array($returnarray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Class for GD library |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
class image_gd implements imageInterface
|
||||||
|
{
|
||||||
|
var $image;
|
||||||
|
var $quality = 95;
|
||||||
|
|
||||||
|
function __construct($source_filepath)
|
||||||
|
{
|
||||||
|
$gd_info = gd_info();
|
||||||
|
$extension = strtolower(get_extension($source_filepath));
|
||||||
|
|
||||||
|
if (in_array($extension, array('jpg', 'jpeg')))
|
||||||
|
{
|
||||||
|
$this->image = imagecreatefromjpeg($source_filepath);
|
||||||
|
}
|
||||||
|
else if ($extension == 'png')
|
||||||
|
{
|
||||||
|
$this->image = imagecreatefrompng($source_filepath);
|
||||||
|
}
|
||||||
|
elseif ($extension == 'gif' and $gd_info['GIF Read Support'] and $gd_info['GIF Create Support'])
|
||||||
|
{
|
||||||
|
$this->image = imagecreatefromgif($source_filepath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
die('[Image GD] unsupported file extension');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_width()
|
||||||
|
{
|
||||||
|
return imagesx($this->image);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_height()
|
||||||
|
{
|
||||||
|
return imagesy($this->image);
|
||||||
|
}
|
||||||
|
|
||||||
|
function crop($width, $height, $x, $y)
|
||||||
|
{
|
||||||
|
$dest = imagecreatetruecolor($width, $height);
|
||||||
|
|
||||||
|
imagealphablending($dest, false);
|
||||||
|
imagesavealpha($dest, true);
|
||||||
|
if (function_exists('imageantialias'))
|
||||||
|
{
|
||||||
|
imageantialias($dest, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = imagecopymerge($dest, $this->image, 0, 0, $x, $y, $width, $height, 100);
|
||||||
|
|
||||||
|
if ($result !== false)
|
||||||
|
{
|
||||||
|
imagedestroy($this->image);
|
||||||
|
$this->image = $dest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imagedestroy($dest);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function strip()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rotate($rotation)
|
||||||
|
{
|
||||||
|
$dest = imagerotate($this->image, $rotation, 0);
|
||||||
|
imagedestroy($this->image);
|
||||||
|
$this->image = $dest;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_compression_quality($quality)
|
||||||
|
{
|
||||||
|
$this->quality = $quality;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resize($width, $height)
|
||||||
|
{
|
||||||
|
$dest = imagecreatetruecolor($width, $height);
|
||||||
|
|
||||||
|
imagealphablending($dest, false);
|
||||||
|
imagesavealpha($dest, true);
|
||||||
|
if (function_exists('imageantialias'))
|
||||||
|
{
|
||||||
|
imageantialias($dest, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $width, $height, $this->get_width(), $this->get_height());
|
||||||
|
|
||||||
|
if ($result !== false)
|
||||||
|
{
|
||||||
|
imagedestroy($this->image);
|
||||||
|
$this->image = $dest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imagedestroy($dest);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sharpen($amount)
|
||||||
|
{
|
||||||
|
$m = pwg_image::get_sharpen_matrix($amount);
|
||||||
|
return imageconvolution($this->image, $m, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function compose($overlay, $x, $y, $opacity)
|
||||||
|
{
|
||||||
|
$ioverlay = $overlay->image->image;
|
||||||
|
/* A replacement for php's imagecopymerge() function that supports the alpha channel
|
||||||
|
See php bug #23815: http://bugs.php.net/bug.php?id=23815 */
|
||||||
|
|
||||||
|
$ow = imagesx($ioverlay);
|
||||||
|
$oh = imagesy($ioverlay);
|
||||||
|
|
||||||
|
// Create a new blank image the site of our source image
|
||||||
|
$cut = imagecreatetruecolor($ow, $oh);
|
||||||
|
|
||||||
|
// Copy the blank image into the destination image where the source goes
|
||||||
|
imagecopy($cut, $this->image, 0, 0, $x, $y, $ow, $oh);
|
||||||
|
|
||||||
|
// Place the source image in the destination image
|
||||||
|
imagecopy($cut, $ioverlay, 0, 0, 0, 0, $ow, $oh);
|
||||||
|
imagecopymerge($this->image, $cut, $x, $y, 0, 0, $ow, $oh, $opacity);
|
||||||
|
imagedestroy($cut);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function write($destination_filepath)
|
||||||
|
{
|
||||||
|
$extension = strtolower(get_extension($destination_filepath));
|
||||||
|
|
||||||
|
if ($extension == 'png')
|
||||||
|
{
|
||||||
|
imagepng($this->image, $destination_filepath);
|
||||||
|
}
|
||||||
|
elseif ($extension == 'gif')
|
||||||
|
{
|
||||||
|
imagegif($this->image, $destination_filepath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imagejpeg($this->image, $destination_filepath, $this->quality);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroy()
|
||||||
|
{
|
||||||
|
imagedestroy($this->image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
30
sources/admin/include/index.php
Normal file
30
sources/admin/include/index.php
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Recursive call
|
||||||
|
$url = '../';
|
||||||
|
header( 'Request-URI: '.$url );
|
||||||
|
header( 'Content-Location: '.$url );
|
||||||
|
header( 'Location: '.$url );
|
||||||
|
exit();
|
||||||
|
?>
|
410
sources/admin/include/languages.class.php
Normal file
410
sources/admin/include/languages.class.php
Normal file
|
@ -0,0 +1,410 @@
|
||||||
|
<?php
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Piwigo - a PHP based photo gallery |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
||||||
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
||||||
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
// | This program is free software; you can redistribute it and/or modify |
|
||||||
|
// | it under the terms of the GNU General Public License as published by |
|
||||||
|
// | the Free Software Foundation |
|
||||||
|
// | |
|
||||||
|
// | This program is distributed in the hope that it will be useful, but |
|
||||||
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||||
|
// | General Public License for more details. |
|
||||||
|
// | |
|
||||||
|
// | You should have received a copy of the GNU General Public License |
|
||||||
|
// | along with this program; if not, write to the Free Software |
|
||||||
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||||
|
// | USA. |
|
||||||
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
|
class languages
|
||||||
|
{
|
||||||
|
var $fs_languages = array();
|
||||||
|
var $db_languages = array();
|
||||||
|
var $server_languages = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize $fs_languages and $db_languages
|
||||||
|
*/
|
||||||
|
function languages($target_charset = null)
|
||||||
|
{
|
||||||
|
$this->get_fs_languages($target_charset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform requested actions
|
||||||
|
* @param string - action
|
||||||
|
* @param string - language id
|
||||||
|
* @param array - errors
|
||||||
|
*/
|
||||||
|
function perform_action($action, $language_id)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
if (isset($this->db_languages[$language_id]))
|
||||||
|
{
|
||||||
|
$crt_db_language = $this->db_languages[$language_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = array();
|
||||||
|
|
||||||
|
switch ($action)
|
||||||
|
{
|
||||||
|
case 'activate':
|
||||||
|
if (isset($crt_db_language))
|
||||||
|
{
|
||||||
|
$errors[] = 'CANNOT ACTIVATE - LANGUAGE IS ALREADY ACTIVATED';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
INSERT INTO '.LANGUAGES_TABLE.'
|
||||||
|
(id, version, name)
|
||||||
|
VALUES(\''.$language_id.'\',
|
||||||
|
\''.$this->fs_languages[$language_id]['version'].'\',
|
||||||
|
\''.$this->fs_languages[$language_id]['name'].'\')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'deactivate':
|
||||||
|
if (!isset($crt_db_language))
|
||||||
|
{
|
||||||
|
$errors[] = 'CANNOT DEACTIVATE - LANGUAGE IS ALREADY DEACTIVATED';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($language_id == get_default_language())
|
||||||
|
{
|
||||||
|
$errors[] = 'CANNOT DEACTIVATE - LANGUAGE IS DEFAULT LANGUAGE';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = '
|
||||||
|
DELETE
|
||||||
|
FROM '.LANGUAGES_TABLE.'
|
||||||
|
WHERE id= \''.$language_id.'\'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'delete':
|
||||||
|
if (!empty($crt_db_language))
|
||||||
|
{
|
||||||
|
$errors[] = 'CANNOT DELETE - LANGUAGE IS ACTIVATED';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!isset($this->fs_languages[$language_id]))
|
||||||
|
{
|
||||||
|
$errors[] = 'CANNOT DELETE - LANGUAGE DOES NOT EXIST';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set default language to user who are using this language
|
||||||
|
$query = '
|
||||||
|
UPDATE '.USER_INFOS_TABLE.'
|
||||||
|
SET language = \''.get_default_language().'\'
|
||||||
|
WHERE language = \''.$language_id.'\'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
|
||||||
|
deltree(PHPWG_ROOT_PATH.'language/'.$language_id, PHPWG_ROOT_PATH.'language/trash');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'set_default':
|
||||||
|
$query = '
|
||||||
|
UPDATE '.USER_INFOS_TABLE.'
|
||||||
|
SET language = \''.$language_id.'\'
|
||||||
|
WHERE user_id IN ('.$conf['default_user_id'].', '.$conf['guest_id'].')
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get languages defined in the language directory
|
||||||
|
*/
|
||||||
|
function get_fs_languages($target_charset = null)
|
||||||
|
{
|
||||||
|
if ( empty($target_charset) )
|
||||||
|
{
|
||||||
|
$target_charset = get_pwg_charset();
|
||||||
|
}
|
||||||
|
$target_charset = strtolower($target_charset);
|
||||||
|
|
||||||
|
$dir = opendir(PHPWG_ROOT_PATH.'language');
|
||||||
|
while ($file = readdir($dir))
|
||||||
|
{
|
||||||
|
if ($file!='.' and $file!='..')
|
||||||
|
{
|
||||||
|
$path = PHPWG_ROOT_PATH.'language/'.$file;
|
||||||
|
if (is_dir($path) and !is_link($path)
|
||||||
|
and preg_match('/^[a-zA-Z0-9-_]+$/', $file )
|
||||||
|
and file_exists($path.'/common.lang.php')
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$language = array(
|
||||||
|
'name'=>$file,
|
||||||
|
'code'=>$file,
|
||||||
|
'version'=>'0',
|
||||||
|
'uri'=>'',
|
||||||
|
'author'=>'',
|
||||||
|
);
|
||||||
|
$plg_data = implode( '', file($path.'/common.lang.php') );
|
||||||
|
|
||||||
|
if ( preg_match("|Language Name: (.*)|", $plg_data, $val) )
|
||||||
|
{
|
||||||
|
$language['name'] = trim( $val[1] );
|
||||||
|
$language['name'] = convert_charset($language['name'], 'utf-8', $target_charset);
|
||||||
|
}
|
||||||
|
if (preg_match("|Version: (.*)|", $plg_data, $val))
|
||||||
|
{
|
||||||
|
$language['version'] = trim($val[1]);
|
||||||
|
}
|
||||||
|
if ( preg_match("|Language URI: (.*)|", $plg_data, $val) )
|
||||||
|
{
|
||||||
|
$language['uri'] = trim($val[1]);
|
||||||
|
}
|
||||||
|
if ( preg_match("|Author: (.*)|", $plg_data, $val) )
|
||||||
|
{
|
||||||
|
$language['author'] = trim($val[1]);
|
||||||
|
}
|
||||||
|
if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )
|
||||||
|
{
|
||||||
|
$language['author uri'] = trim($val[1]);
|
||||||
|
}
|
||||||
|
if (!empty($language['uri']) and strpos($language['uri'] , 'extension_view.php?eid='))
|
||||||
|
{
|
||||||
|
list( , $extension) = explode('extension_view.php?eid=', $language['uri']);
|
||||||
|
if (is_numeric($extension)) $language['extension'] = $extension;
|
||||||
|
}
|
||||||
|
// IMPORTANT SECURITY !
|
||||||
|
$language = array_map('htmlspecialchars', $language);
|
||||||
|
$this->fs_languages[$file] = $language;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($dir);
|
||||||
|
@uasort($this->fs_languages, 'name_compare');
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_db_languages()
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT id, name
|
||||||
|
FROM '.LANGUAGES_TABLE.'
|
||||||
|
ORDER BY name ASC
|
||||||
|
;';
|
||||||
|
$result = pwg_query($query);
|
||||||
|
|
||||||
|
while ($row = pwg_db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$this->db_languages[ $row['id'] ] = $row['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve PEM server datas to $server_languages
|
||||||
|
*/
|
||||||
|
function get_server_languages($new=false)
|
||||||
|
{
|
||||||
|
global $user, $conf;
|
||||||
|
|
||||||
|
$get_data = array(
|
||||||
|
'category_id' => $conf['pem_languages_category'],
|
||||||
|
'format' => 'php',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Retrieve PEM versions
|
||||||
|
$version = PHPWG_VERSION;
|
||||||
|
$versions_to_check = array();
|
||||||
|
$url = PEM_URL . '/api/get_version_list.php';
|
||||||
|
if (fetchRemote($url, $result, $get_data) and $pem_versions = @unserialize($result))
|
||||||
|
{
|
||||||
|
if (!preg_match('/^\d+\.\d+\.\d+$/', $version))
|
||||||
|
{
|
||||||
|
$version = $pem_versions[0]['name'];
|
||||||
|
}
|
||||||
|
$branch = get_branch_from_version($version);
|
||||||
|
foreach ($pem_versions as $pem_version)
|
||||||
|
{
|
||||||
|
if (strpos($pem_version['name'], $branch) === 0)
|
||||||
|
{
|
||||||
|
$versions_to_check[] = $pem_version['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($versions_to_check))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Languages to check
|
||||||
|
$languages_to_check = array();
|
||||||
|
foreach($this->fs_languages as $fs_language)
|
||||||
|
{
|
||||||
|
if (isset($fs_language['extension']))
|
||||||
|
{
|
||||||
|
$languages_to_check[] = $fs_language['extension'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve PEM languages infos
|
||||||
|
$url = PEM_URL . '/api/get_revision_list.php';
|
||||||
|
$get_data = array_merge($get_data, array(
|
||||||
|
'last_revision_only' => 'true',
|
||||||
|
'version' => implode(',', $versions_to_check),
|
||||||
|
'lang' => $user['language'],
|
||||||
|
'get_nb_downloads' => 'true',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (!empty($languages_to_check))
|
||||||
|
{
|
||||||
|
if ($new)
|
||||||
|
{
|
||||||
|
$get_data['extension_exclude'] = implode(',', $languages_to_check);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$get_data['extension_include'] = implode(',', $languages_to_check);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fetchRemote($url, $result, $get_data))
|
||||||
|
{
|
||||||
|
$pem_languages = @unserialize($result);
|
||||||
|
if (!is_array($pem_languages))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach ($pem_languages as $language)
|
||||||
|
{
|
||||||
|
if (preg_match('/^.*? \[[A-Z]{2}\]$/', $language['extension_name']))
|
||||||
|
{
|
||||||
|
$this->server_languages[$language['extension_id']] = $language;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@uasort($this->server_languages, array($this, 'extension_name_compare'));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract language files from archive
|
||||||
|
*
|
||||||
|
* @param string - install or upgrade
|
||||||
|
* @param string - remote revision identifier (numeric)
|
||||||
|
* @param string - language id or extension id
|
||||||
|
*/
|
||||||
|
function extract_language_files($action, $revision, $dest='')
|
||||||
|
{
|
||||||
|
if ($archive = tempnam( PHPWG_ROOT_PATH.'language', 'zip'))
|
||||||
|
{
|
||||||
|
$url = PEM_URL . '/download.php';
|
||||||
|
$get_data = array(
|
||||||
|
'rid' => $revision,
|
||||||
|
'origin' => 'piwigo_'.$action,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle, $get_data))
|
||||||
|
{
|
||||||
|
fclose($handle);
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
|
||||||
|
$zip = new PclZip($archive);
|
||||||
|
if ($list = $zip->listContent())
|
||||||
|
{
|
||||||
|
foreach ($list as $file)
|
||||||
|
{
|
||||||
|
// we search common.lang.php in archive
|
||||||
|
if (basename($file['filename']) == 'common.lang.php'
|
||||||
|
and (!isset($main_filepath)
|
||||||
|
or strlen($file['filename']) < strlen($main_filepath)))
|
||||||
|
{
|
||||||
|
$main_filepath = $file['filename'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isset($main_filepath))
|
||||||
|
{
|
||||||
|
$root = basename(dirname($main_filepath)); // common.lang.php path in archive
|
||||||
|
if (preg_match('/^[a-z]{2}_[A-Z]{2}$/', $root))
|
||||||
|
{
|
||||||
|
if ($action == 'install')
|
||||||
|
{
|
||||||
|
$dest = $root;
|
||||||
|
}
|
||||||
|
$extract_path = PHPWG_ROOT_PATH.'language/'.$dest;
|
||||||
|
if (
|
||||||
|
$result = $zip->extract(
|
||||||
|
PCLZIP_OPT_PATH, $extract_path,
|
||||||
|
PCLZIP_OPT_REMOVE_PATH, $root,
|
||||||
|
PCLZIP_OPT_REPLACE_NEWER
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
foreach ($result as $file)
|
||||||
|
{
|
||||||
|
if ($file['stored_filename'] == $main_filepath)
|
||||||
|
{
|
||||||
|
$status = $file['status'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($status == 'ok')
|
||||||
|
{
|
||||||
|
$this->get_fs_languages();
|
||||||
|
if ($action == 'install')
|
||||||
|
{
|
||||||
|
$this->perform_action('activate', $dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file_exists($extract_path.'/obsolete.list')
|
||||||
|
and $old_files = file($extract_path.'/obsolete.list', FILE_IGNORE_NEW_LINES)
|
||||||
|
and !empty($old_files))
|
||||||
|
{
|
||||||
|
$old_files[] = 'obsolete.list';
|
||||||
|
foreach($old_files as $old_file)
|
||||||
|
{
|
||||||
|
$path = $extract_path.'/'.$old_file;
|
||||||
|
if (is_file($path))
|
||||||
|
{
|
||||||
|
@unlink($path);
|
||||||
|
}
|
||||||
|
elseif (is_dir($path))
|
||||||
|
{
|
||||||
|
deltree($path, PHPWG_ROOT_PATH.'language/trash');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else $status = 'extract_error';
|
||||||
|
}
|
||||||
|
else $status = 'archive_error';
|
||||||
|
}
|
||||||
|
else $status = 'archive_error';
|
||||||
|
}
|
||||||
|
else $status = 'archive_error';
|
||||||
|
}
|
||||||
|
else $status = 'dl_archive_error';
|
||||||
|
}
|
||||||
|
else $status = 'temp_path_error';
|
||||||
|
|
||||||
|
@unlink($archive);
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort functions
|
||||||
|
*/
|
||||||
|
function extension_name_compare($a, $b)
|
||||||
|
{
|
||||||
|
return strcmp(strtolower($a['extension_name']), strtolower($b['extension_name']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
421
sources/admin/include/mysqldump.php
Normal file
421
sources/admin/include/mysqldump.php
Normal file
|
@ -0,0 +1,421 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Dump MySQL database
|
||||||
|
*
|
||||||
|
* Here is an inline example:
|
||||||
|
* <code>
|
||||||
|
* $connection = @mysql_connect($dbhost,$dbuser,$dbpsw);
|
||||||
|
* $dumper = new MySQLDump($dbname,'filename.sql',false,false);
|
||||||
|
* $dumper->doDump();
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* Special thanks to:
|
||||||
|
* - Andrea Ingaglio <andrea@coders4fun.com> helping in development of all class code
|
||||||
|
* - Dylan Pugh for precious advices halfing the size of the output file and for helping in debug
|
||||||
|
*
|
||||||
|
* @name MySQLDump
|
||||||
|
* @author Daniele Viganò - CreativeFactory.it <daniele.vigano@creativefactory.it>
|
||||||
|
* @version 2.20 - 02/11/2007
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
*/
|
||||||
|
|
||||||
|
class MySQLDump {
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $database = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $compress = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $hexValue = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The output filename
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $filename = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pointer of the output file
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $file = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $isWritten = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor
|
||||||
|
* @param string $db The database name
|
||||||
|
* @param string $filepath The file where the dump will be written
|
||||||
|
* @param boolean $compress It defines if the output file is compress (gzip) or not
|
||||||
|
* @param boolean $hexValue It defines if the outup values are base-16 or not
|
||||||
|
*/
|
||||||
|
function MYSQLDump($db = null, $filepath = 'dump.sql', $compress = false, $hexValue = false){
|
||||||
|
$this->compress = $compress;
|
||||||
|
if ( !$this->setOutputFile($filepath) )
|
||||||
|
return false;
|
||||||
|
return $this->setDatabase($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the database to work on
|
||||||
|
* @param string $db The database name
|
||||||
|
*/
|
||||||
|
function setDatabase($db){
|
||||||
|
$this->database = $db;
|
||||||
|
if ( !@mysql_select_db($this->database) )
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the database where the class is working on
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getDatabase(){
|
||||||
|
return $this->database;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the output file type (It can be made only if the file hasn't been already written)
|
||||||
|
* @param boolean $compress If it's true, the output file will be compressed
|
||||||
|
*/
|
||||||
|
function setCompress($compress){
|
||||||
|
if ( $this->isWritten )
|
||||||
|
return false;
|
||||||
|
$this->compress = $compress;
|
||||||
|
$this->openFile($this->filename);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the output file is or not compressed
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function getCompress(){
|
||||||
|
return $this->compress;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the output file
|
||||||
|
* @param string $filepath The file where the dump will be written
|
||||||
|
*/
|
||||||
|
function setOutputFile($filepath){
|
||||||
|
if ( $this->isWritten )
|
||||||
|
return false;
|
||||||
|
$this->filename = $filepath;
|
||||||
|
$this->file = $this->openFile($this->filename);
|
||||||
|
return $this->file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the output filename
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getOutputFile(){
|
||||||
|
return $this->filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes to file the $table's structure
|
||||||
|
* @param string $table The table name
|
||||||
|
*/
|
||||||
|
function getTableStructure($table){
|
||||||
|
if ( !$this->setDatabase($this->database) )
|
||||||
|
return false;
|
||||||
|
// Structure Header
|
||||||
|
$structure = "-- \n";
|
||||||
|
$structure .= "-- Table structure for table `{$table}` \n";
|
||||||
|
$structure .= "-- \n\n";
|
||||||
|
// Dump Structure
|
||||||
|
$structure .= 'DROP TABLE IF EXISTS `'.$table.'`;'."\n";
|
||||||
|
$structure .= "CREATE TABLE `".$table."` (\n";
|
||||||
|
$records = @mysql_query('SHOW FIELDS FROM `'.$table.'`');
|
||||||
|
if ( @mysql_num_rows($records) == 0 )
|
||||||
|
return false;
|
||||||
|
while ( $record = mysql_fetch_assoc($records) ) {
|
||||||
|
$structure .= '`'.$record['Field'].'` '.$record['Type'];
|
||||||
|
if ( isset($record['Default']) )
|
||||||
|
$structure .= ' DEFAULT \''.$record['Default'].'\'';
|
||||||
|
if ( @strcmp($record['Null'],'YES') != 0 )
|
||||||
|
$structure .= ' NOT NULL';
|
||||||
|
elseif ( is_null($record['Default']) )
|
||||||
|
$structure .= ' DEFAULT NULL';
|
||||||
|
if ( !empty($record['Extra']) )
|
||||||
|
$structure .= ' '.$record['Extra'];
|
||||||
|
$structure .= ",\n";
|
||||||
|
}
|
||||||
|
$structure = @ereg_replace(",\n$", null, $structure);
|
||||||
|
|
||||||
|
// Save all Column Indexes
|
||||||
|
$structure .= $this->getSqlKeysTable($table);
|
||||||
|
$structure .= "\n)";
|
||||||
|
|
||||||
|
//Save table engine
|
||||||
|
$records = @mysql_query("SHOW TABLE STATUS LIKE '".$table."'");
|
||||||
|
|
||||||
|
if ( $record = @mysql_fetch_assoc($records) ) {
|
||||||
|
if ( !empty($record['Engine']) )
|
||||||
|
$structure .= ' ENGINE='.$record['Engine'];
|
||||||
|
if ( !empty($record['Auto_increment']) )
|
||||||
|
$structure .= ' AUTO_INCREMENT='.$record['Auto_increment'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$structure .= ";\n\n-- --------------------------------------------------------\n\n";
|
||||||
|
$this->saveToFile($this->file,$structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes to file the $table's data
|
||||||
|
* @param string $table The table name
|
||||||
|
* @param boolean $hexValue It defines if the output is base 16 or not
|
||||||
|
*/
|
||||||
|
function getTableData($table,$hexValue = true) {
|
||||||
|
if ( !$this->setDatabase($this->database) )
|
||||||
|
return false;
|
||||||
|
// Header
|
||||||
|
$data = "-- \n";
|
||||||
|
$data .= "-- Dumping data for table `$table` \n";
|
||||||
|
$data .= "-- \n\n";
|
||||||
|
|
||||||
|
$records = mysql_query('SHOW FIELDS FROM `'.$table.'`');
|
||||||
|
$num_fields = @mysql_num_rows($records);
|
||||||
|
if ( $num_fields == 0 )
|
||||||
|
return false;
|
||||||
|
// Field names
|
||||||
|
$selectStatement = "SELECT ";
|
||||||
|
$insertStatement = "INSERT INTO `$table` (";
|
||||||
|
$hexField = array();
|
||||||
|
for ($x = 0; $x < $num_fields; $x++) {
|
||||||
|
$record = @mysql_fetch_assoc($records);
|
||||||
|
if ( ($hexValue) && ($this->isTextValue($record['Type'])) ) {
|
||||||
|
$selectStatement .= 'HEX(`'.$record['Field'].'`)';
|
||||||
|
$hexField [$x] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$selectStatement .= '`'.$record['Field'].'`';
|
||||||
|
$insertStatement .= '`'.$record['Field'].'`';
|
||||||
|
$insertStatement .= ", ";
|
||||||
|
$selectStatement .= ", ";
|
||||||
|
}
|
||||||
|
$insertStatement = @substr($insertStatement,0,-2).') VALUES'."\n";
|
||||||
|
$selectStatement = @substr($selectStatement,0,-2).' FROM `'.$table.'`';
|
||||||
|
|
||||||
|
$records = @mysql_query($selectStatement);
|
||||||
|
$num_rows = @mysql_num_rows($records);
|
||||||
|
$num_fields = @mysql_num_fields($records);
|
||||||
|
// Dump data
|
||||||
|
if ( $num_rows > 0 ) {
|
||||||
|
$data .= $insertStatement;
|
||||||
|
for ($i = 0; $i < $num_rows; $i++) {
|
||||||
|
$record = @mysql_fetch_assoc($records);
|
||||||
|
$data .= ' (';
|
||||||
|
for ($j = 0; $j < $num_fields; $j++) {
|
||||||
|
$field_name = @mysql_field_name($records, $j);
|
||||||
|
if ( @$hexField[$j] && (@strlen($record[$field_name]) > 0) )
|
||||||
|
$data .= "0x".$record[$field_name];
|
||||||
|
elseif (is_null($record[$field_name]))
|
||||||
|
$data .= "NULL";
|
||||||
|
else
|
||||||
|
$data .= "'".@str_replace('\"','"',@mysql_real_escape_string($record[$field_name]))."'";
|
||||||
|
$data .= ',';
|
||||||
|
}
|
||||||
|
$data = @substr($data,0,-1).")";
|
||||||
|
$data .= ( $i < ($num_rows-1) ) ? ',' : ';';
|
||||||
|
$data .= "\n";
|
||||||
|
//if data in greather than 1MB save
|
||||||
|
if (strlen($data) > 1048576) {
|
||||||
|
$this->saveToFile($this->file,$data);
|
||||||
|
$data = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$data .= "\n-- --------------------------------------------------------\n\n";
|
||||||
|
$this->saveToFile($this->file,$data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes to file all the selected database tables structure
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function getDatabaseStructure(){
|
||||||
|
$records = @mysql_query('SHOW TABLES');
|
||||||
|
if ( @mysql_num_rows($records) == 0 )
|
||||||
|
return false;
|
||||||
|
$structure = '';
|
||||||
|
while ( $record = @mysql_fetch_row($records) ) {
|
||||||
|
$structure .= $this->getTableStructure($record[0]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes to file all the selected database tables data
|
||||||
|
* @param boolean $hexValue It defines if the output is base-16 or not
|
||||||
|
*/
|
||||||
|
function getDatabaseData($hexValue = true){
|
||||||
|
$records = @mysql_query('SHOW TABLES');
|
||||||
|
if ( @mysql_num_rows($records) == 0 )
|
||||||
|
return false;
|
||||||
|
while ( $record = @mysql_fetch_row($records) ) {
|
||||||
|
$this->getTableData($record[0],$hexValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes to file the selected database dump
|
||||||
|
*/
|
||||||
|
function doDump() {
|
||||||
|
$this->saveToFile($this->file,"SET FOREIGN_KEY_CHECKS = 0;\n\n");
|
||||||
|
$this->getDatabaseStructure();
|
||||||
|
$this->getDatabaseData($this->hexValue);
|
||||||
|
$this->saveToFile($this->file,"SET FOREIGN_KEY_CHECKS = 1;\n\n");
|
||||||
|
$this->closeFile($this->file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Look at the doDump() method
|
||||||
|
*/
|
||||||
|
function writeDump($filename) {
|
||||||
|
if ( !$this->setOutputFile($filename) )
|
||||||
|
return false;
|
||||||
|
$this->doDump();
|
||||||
|
$this->closeFile($this->file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function getSqlKeysTable ($table) {
|
||||||
|
$primary = "";
|
||||||
|
$unique = array();
|
||||||
|
$index = array();
|
||||||
|
$fulltext = array();
|
||||||
|
$results = mysql_query("SHOW KEYS FROM `{$table}`");
|
||||||
|
if ( @mysql_num_rows($results) == 0 )
|
||||||
|
return false;
|
||||||
|
while($row = mysql_fetch_object($results)) {
|
||||||
|
if (($row->Key_name == 'PRIMARY') AND ($row->Index_type == 'BTREE')) {
|
||||||
|
if ( $primary == "" )
|
||||||
|
$primary = " PRIMARY KEY (`{$row->Column_name}`";
|
||||||
|
else
|
||||||
|
$primary .= ", `{$row->Column_name}`";
|
||||||
|
}
|
||||||
|
if (($row->Key_name != 'PRIMARY') AND ($row->Non_unique == '0') AND ($row->Index_type == 'BTREE')) {
|
||||||
|
if ( (empty($unique)) OR (empty($unique[$row->Key_name])) )
|
||||||
|
$unique[$row->Key_name] = " UNIQUE KEY `{$row->Key_name}` (`{$row->Column_name}`";
|
||||||
|
else
|
||||||
|
$unique[$row->Key_name] .= ", `{$row->Column_name}`";
|
||||||
|
}
|
||||||
|
if (($row->Key_name != 'PRIMARY') AND ($row->Non_unique == '1') AND ($row->Index_type == 'BTREE')) {
|
||||||
|
if ( (empty($index)) OR (empty($index[$row->Key_name])) )
|
||||||
|
$index[$row->Key_name] = " KEY `{$row->Key_name}` (`{$row->Column_name}`";
|
||||||
|
else
|
||||||
|
$index[$row->Key_name] .= ", `{$row->Column_name}`";
|
||||||
|
}
|
||||||
|
if (($row->Key_name != 'PRIMARY') AND ($row->Non_unique == '1') AND ($row->Index_type == 'FULLTEXT')) {
|
||||||
|
if ( (empty($fulltext)) OR (empty($fulltext[$row->Key_name])) )
|
||||||
|
$fulltext[$row->Key_name] = " FULLTEXT `{$row->Key_name}` (`{$row->Column_name}`";
|
||||||
|
else
|
||||||
|
$fulltext[$row->Key_name] .= ", `{$row->Column_name}`";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sqlKeyStatement = '';
|
||||||
|
// generate primary, unique, key and fulltext
|
||||||
|
if ( $primary != "" ) {
|
||||||
|
$sqlKeyStatement .= ",\n";
|
||||||
|
$primary .= ")";
|
||||||
|
$sqlKeyStatement .= $primary;
|
||||||
|
}
|
||||||
|
if (!empty($unique)) {
|
||||||
|
foreach ($unique as $keyName => $keyDef) {
|
||||||
|
$sqlKeyStatement .= ",\n";
|
||||||
|
$keyDef .= ")";
|
||||||
|
$sqlKeyStatement .= $keyDef;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($index)) {
|
||||||
|
foreach ($index as $keyName => $keyDef) {
|
||||||
|
$sqlKeyStatement .= ",\n";
|
||||||
|
$keyDef .= ")";
|
||||||
|
$sqlKeyStatement .= $keyDef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($fulltext)) {
|
||||||
|
foreach ($fulltext as $keyName => $keyDef) {
|
||||||
|
$sqlKeyStatement .= ",\n";
|
||||||
|
$keyDef .= ")";
|
||||||
|
$sqlKeyStatement .= $keyDef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $sqlKeyStatement;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function isTextValue($field_type) {
|
||||||
|
switch ($field_type) {
|
||||||
|
case "tinytext":
|
||||||
|
case "text":
|
||||||
|
case "mediumtext":
|
||||||
|
case "longtext":
|
||||||
|
case "binary":
|
||||||
|
case "varbinary":
|
||||||
|
case "tinyblob":
|
||||||
|
case "blob":
|
||||||
|
case "mediumblob":
|
||||||
|
case "longblob":
|
||||||
|
return True;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function openFile($filename) {
|
||||||
|
$file = false;
|
||||||
|
if ( $this->compress )
|
||||||
|
$file = @gzopen($filename, "w9");
|
||||||
|
else
|
||||||
|
$file = @fopen($filename, "w");
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function saveToFile($file, $data) {
|
||||||
|
if ( $this->compress )
|
||||||
|
@gzwrite($file, $data);
|
||||||
|
else
|
||||||
|
@fwrite($file, $data);
|
||||||
|
$this->isWritten = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function closeFile($file) {
|
||||||
|
if ( $this->compress )
|
||||||
|
@gzclose($file);
|
||||||
|
else
|
||||||
|
@fclose($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue