First commit

This commit is contained in:
Nathan
2026-09-18 20:29:17 -06:00
commit 3b09abe571
2840 changed files with 467153 additions and 0 deletions
@@ -0,0 +1,82 @@
-- initial configuration for Piwigo
INSERT INTO piwigo_config (param,value,comment) VALUES ('activate_comments','false','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 ('comments_enable_website','true','Enable "website" field on add comment form');
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','false','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','none','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');
INSERT INTO piwigo_config (param,value) VALUES ('picture_sizes_icon','true');
INSERT INTO piwigo_config (param,value) VALUES ('index_sizes_icon','true');
INSERT INTO piwigo_config (param,value) VALUES ('index_edit_icon','true');
INSERT INTO piwigo_config (param,value) VALUES ('index_caddie_icon','true');
INSERT INTO piwigo_config (param,value) VALUES ('display_fromto','false');
INSERT INTO piwigo_config (param,value) VALUES ('picture_edit_icon','true');
INSERT INTO piwigo_config (param,value) VALUES ('picture_caddie_icon','true');
INSERT INTO piwigo_config (param,value) VALUES ('picture_representative_icon','true');
INSERT INTO piwigo_config (param,value) VALUES ('show_mobile_app_banner_in_admin','true');
INSERT INTO piwigo_config (param,value) VALUES ('show_mobile_app_banner_in_gallery','false');
INSERT INTO piwigo_config (param,value) VALUES ('index_search_in_set_button','false');
INSERT INTO piwigo_config (param,value) VALUES ('index_search_in_set_action','true');
INSERT INTO piwigo_config (param,value) VALUES ('upload_detect_duplicate','true');
INSERT INTO piwigo_config (param,value) VALUES ('webmaster_id','1');
INSERT INTO piwigo_config (param,value) VALUES ('use_standard_pages','true');
@@ -0,0 +1,37 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add high_width and high_height fields into IMAGES_TABLE';
if ('mysql' == $conf['dblayer'])
{
$query = 'ALTER TABLE '.IMAGES_TABLE.'
ADD COLUMN `high_width` smallint(9) unsigned default NULL,
ADD COLUMN `high_height` smallint(9) unsigned default NULL;';
}
if (in_array($conf['dblayer'], array('pgsql', 'sqlite', 'pdo-sqlite')))
{
$query = 'ALTER TABLE '.IMAGES_TABLE.'
ADD COLUMN "high_width" INTEGER,
ADD COLUMN "high_height" INTEGER;';
}
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,50 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'merge nb_line_page and nb_image_line into nb_image_page';
// add column
if ('mysql' == $conf['dblayer'])
{
pwg_query('
ALTER TABLE '.USER_INFOS_TABLE.'
ADD COLUMN `nb_image_page` smallint(3) unsigned NOT NULL default \'15\'
;');
}
else if (in_array($conf['dblayer'], array('pgsql', 'sqlite', 'pdo-sqlite')))
{
pwg_query('
ALTER TABLE '.USER_INFOS_TABLE.'
ADD COLUMN "nb_image_page" INTEGER default 15 NOT NULL
;');
}
// merge datas
pwg_query('
UPDATE '.USER_INFOS_TABLE.'
SET nb_image_page = nb_line_page*nb_image_line
;');
// delete old columns
pwg_query('
ALTER TABLE '.USER_INFOS_TABLE.'
DROP `nb_line_page`,
DROP `nb_image_line`
;');
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,30 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'change nb_image_page into smallint(3)';
// add column
if ('mysql' == $conf['dblayer'])
{
pwg_query('
ALTER TABLE '.USER_INFOS_TABLE.'
CHANGE `nb_image_page` `nb_image_page` SMALLINT(3) UNSIGNED NOT NULL DEFAULT 15
;');
}
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,27 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Extensions ignored for update';
$query = '
INSERT INTO '.PREFIX_TABLE.'config (param,value,comment)
VALUES (\'updates_ignored\',\'a:3:{s:7:"plugins";a:0:{}s:6:"themes";a:0:{}s:9:"languages";a:0:{}}\', \''.$upgrade_description.'\')
;';
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,71 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add upload form parameters in database';
global $conf;
load_conf_from_db();
$upload_form_config = array(
'websize_resize' => true,
'websize_maxwidth' => 800,
'websize_maxheight' => 600,
'websize_quality' => 95,
'thumb_maxwidth' => 128,
'thumb_maxheight' => 96,
'thumb_quality' => 95,
'thumb_crop' => false,
'thumb_follow_orientation' => true,
'hd_keep' => true,
'hd_resize' => false,
'hd_maxwidth' => 2000,
'hd_maxheight' => 2000,
'hd_quality' => 95,
);
$inserts = array();
foreach ($upload_form_config as $param_shortname => $param)
{
$param_name = 'upload_form_'.$param_shortname;
if (!isset($conf[$param_name]))
{
$conf[$param_name] = $param;
array_push(
$inserts,
array(
'param' => $param_name,
'value' => boolean_to_string($param),
)
);
}
}
if (count($inserts) > 0)
{
mass_inserts(
CONFIG_TABLE,
array_keys($inserts[0]),
$inserts
);
}
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,27 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Show menubar on picture page';
$query = '
INSERT INTO '.PREFIX_TABLE.'config (param,value,comment)
VALUES (\'picture_menu\',\'false\', \''.$upgrade_description.'\')
;';
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add order parameters to bdd';
$query = '
INSERT INTO '.PREFIX_TABLE.'config(param,value,comment)
VALUES (\'order_by\', \''.$conf['order_by'].'\', \'default photos order\')
;';
pwg_query($query);
$query = '
INSERT INTO '.PREFIX_TABLE.'config(param,value,comment)
VALUES (\'order_by_inside_category\', \''.$conf['order_by_inside_category'].'\', \'default photos order inside category\')
;';
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,27 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Display new icons next albums and pictures';
$query = '
INSERT INTO '.PREFIX_TABLE.'config (param,value,comment)
VALUES (\'index_new_icon\',\'true\',\'Display new icons next albums and pictures\')
;';
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,112 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add order parameters to bdd #2';
$order_regex = '#^(( *)(id|file|name|date_available|date_creation|hit|average_rate|comment|author|filesize|width|height|high_filesize|high_width|high_height|rank) (ASC|DESC),{1}){1,}$#';
// local file is writable
if ( is_writable($local_file = PHPWG_ROOT_PATH. 'local/config/config.inc.php') )
{
$order_by = str_ireplace(
array('order by ', 'asc', 'desc'),
array(null, 'ASC', 'DESC'),
trim($conf['order_by_inside_category'])
);
// for a simple patern
if ( preg_match($order_regex, $order_by.',') )
{
$order_by = 'ORDER BY '.$order_by;
// update database
$query = '
UPDATE '.PREFIX_TABLE.'config
SET value = \''.preg_replace('# rank (ASC|DESC)(,?)#', null, $order_by).'\'
WHERE param = \'order_by\'
;';
pwg_query($query);
$query = '
UPDATE '.PREFIX_TABLE.'config
SET value = \''.$order_by.'\'
WHERE param = \'order_by_inside_category\'
';
pwg_query($query);
// update local file (delete lines)
$local_config = file($local_file);
$new_local_config = array();
foreach ($local_config as $line)
{
if (strpos($line, 'order_by') === false)
{
$new_local_config[] = $line;
}
}
var_dump($new_local_config);
file_put_contents(
$local_file,
implode("", $new_local_config)
);
}
// for a complex patern
else
{
// update database with default param
$query = '
UPDATE '.PREFIX_TABLE.'config
SET value = \'ORDER BY date_available DESC, file ASC, id ASC\'
WHERE param = \'order_by\'
;';
pwg_query($query);
$query = '
UPDATE '.PREFIX_TABLE.'config
SET value = \'ORDER BY date_available DESC, file ASC, id ASC\'
WHERE param = \'order_by_inside_category\'
';
pwg_query($query);
// update local file (rename lines)
$local_config = file_get_contents($local_file);
$new_local_config = str_replace(
array("['order_by']", "['order_by_inside_category']"),
array("['order_by_custom']", "['order_by_inside_category_custom']"),
$local_config
);
file_put_contents($local_file, $new_local_config);
}
}
// local file is locked
else
{
// update database with default param
$query = '
UPDATE '.PREFIX_TABLE.'config
SET value = \'ORDER BY date_available DESC, file ASC, id ASC\'
WHERE param = \'order_by\'
;';
pwg_query($query);
$query = '
UPDATE '.PREFIX_TABLE.'config
SET value = \'ORDER BY date_available DESC, file ASC, id ASC\'
WHERE param = \'order_by_inside_category\'
';
pwg_query($query);
}
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,26 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
$upgrade_description = 'Rename #images.average_rate to ratingscore.';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
if ('mysql' == $conf['dblayer'])
$q = 'ALTER TABLE '.IMAGES_TABLE.' CHANGE average_rate rating_score float(5,2) unsigned default NULL';
else
$q = 'ALTER TABLE '.IMAGES_TABLE.' RENAME average_rate TO rating_score';
pwg_query($q);
$q="UPDATE ".CATEGORIES_TABLE." SET image_order=REPLACE(image_order, 'average_rate', 'rating_score')";
pwg_query($q);
$q="UPDATE ".CONFIG_TABLE." SET value=REPLACE(value, 'average_rate', 'rating_score')
WHERE param IN ('picture_informations', 'order_by', 'order_by_inside_category')";
pwg_query($q);
?>
@@ -0,0 +1,102 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
$upgrade_description = 'Move "gallery_url" parameter from config table to local configuration file';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
if (!isset($page))
{
$page = array();
}
if (!isset($page['errors']))
{
$page['errors'] = array();
}
$query = '
SELECT
value
FROM '.CONFIG_TABLE.'
WHERE param =\'gallery_url\'
;';
list($gallery_url) = pwg_db_fetch_row(pwg_query($query));
if (!empty($gallery_url))
{
// let's try to write it in the local configuration file
$local_conf = PHPWG_ROOT_PATH. 'local/config/config.inc.php';
if (isset($conf['local_dir_site']))
{
$local_conf = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'config/config.inc.php';
}
$conf_line = '$conf[\'gallery_url\'] = \''.$gallery_url.'\';';
if (!is_file($local_conf))
{
$config_file_contents_new = "<?php\n".$conf_line."\n?>";
}
else
{
// we have to update the local conf
$config_file_contents = @file_get_contents($local_conf);
if ($config_file_contents === false)
{
$error = 'Cannot load '.$local_conf.', add by hand: '.$conf_line;
array_push($page['errors'], $error);
echo $error;
}
else
{
$php_end_tag = strrpos($config_file_contents, '?'.'>');
if ($php_end_tag === false)
{
// the file is empty
$config_file_contents_new = "<?php\n".$conf_line."\n?>";
}
else
{
$config_file_contents_new =
substr($config_file_contents, 0, $php_end_tag) . "\n"
.$conf_line."\n"
.substr($config_file_contents, $php_end_tag)
;
}
}
}
if (isset($config_file_contents_new))
{
if (!@file_put_contents($local_conf, $config_file_contents_new))
{
$error = 'Cannot write into local configuration file '.$local_conf.', add by hand: '.$conf_line;
array_push($page['errors'], $error);
echo $error;
}
}
}
$query = '
DELETE
FROM '.CONFIG_TABLE.'
WHERE param =\'gallery_url\'
;';
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,38 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'New colum user_infos.activation_key';
// Add column
$query = 'ALTER TABLE '.USER_INFOS_TABLE.' ADD COLUMN ';
if ('mysql' == $conf['dblayer'])
{
$query.= ' `activation_key` char(20) default NULL';
}
if (in_array($conf['dblayer'], array('pgsql', 'sqlite', 'pdo-sqlite')))
{
$query.= ' "activation_key" CHAR(20) default NULL';
}
$query.= ';';
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,39 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Change combined dir';
// Add column
$query = 'DELETE FROM '.CONFIG_TABLE.'
WHERE param IN (\'local_data_dir_checked\', \'combined_dir_checked\') ';
pwg_query($query);
$dir=PHPWG_ROOT_PATH.'local/combined/';
if (is_dir($dir))
{
foreach (glob($dir.'*.css') as $file)
{
@unlink($file);
}
foreach (glob($dir.'*.js') as $file)
@unlink($file);
@unlink($dir.'index.htm');
@rmdir($dir);
}
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,26 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'New settings for resizing original photo (related to multiple sizes feature)';
conf_update_param('original_resize', 'false');
conf_update_param('original_resize_maxwidth', 2016);
conf_update_param('original_resize_maxheight', 2016);
conf_update_param('original_resize_quality', 95);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,23 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'new parameter: Activate comments';
conf_update_param('activate_comments', 'true');
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,23 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'New setting for comments order on picture page';
conf_update_param('comments_order', 'ASC');
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add #images.coi';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = '
ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN coi CHAR(4) DEFAULT NULL COMMENT \'center of interest\' AFTER height
';
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,50 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'fill empty images name with filename';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = 'SELECT id, file FROM '.IMAGES_TABLE.' WHERE name IS NULL;';
$images = pwg_query($query);
$updates = array();
while ($row = pwg_db_fetch_assoc($images))
{
$updates[] = array(
'id' => $row['id'],
'name' => get_name_from_file($row['file']),
);
}
mass_updates(
IMAGES_TABLE,
array(
'primary' => array('id'),
'update' => array('name'),
),
$updates
);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,26 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Automatically activate mobile theme.';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php');
$themes = new themes();
$themes->perform_action('activate', 'smartpocket');
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Reset derivative configuration to include XXS and XS sizes.';
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
clear_derivative_cache();
$derivative_conf_file = PHPWG_ROOT_PATH.$conf['data_location'].'derivatives.dat';
if (is_file($derivative_conf_file))
{
unlink($derivative_conf_file);
}
conf_update_param('derivatives', '');
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,24 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'rotation mode (code, not angle) is stored in the database';
$query = 'ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN rotation tinyint unsigned DEFAULT NULL';
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,24 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
// see http://piwigo.org/doc/doku.php?id=user_documentation:htaccess_and_hotlink_in_2.4
$upgrade_description = 'add/append htaccess for hotlinks (cancelled, see plugin "Hotlink Compatibility")';
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,68 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'derivatives: new organization of "upload" and "galleries" directories';
$query = '
SELECT
id,
path,
tn_ext,
has_high,
high_filesize,
high_width,
high_height
FROM '.IMAGES_TABLE.'
;';
$result = pwg_query($query);
$starttime = get_moment();
$updates = array();
while ($row = pwg_db_fetch_assoc($result))
{
if ('true' == $row['has_high'])
{
$high_path = dirname($row['path']).'/pwg_high/'.basename($row['path']);
rename($high_path, $row['path']);
array_push(
$updates,
array(
'id' => $row['id'],
'width' => $row['high_width'],
'height' => $row['high_height'],
'filesize' => $row['high_filesize'],
)
);
}
}
if (count($updates) > 0)
{
mass_updates(
IMAGES_TABLE,
array(
'primary' => array('id'),
'update' => array('width', 'height', 'filesize'),
),
$updates
);
}
echo
"\n"
. $upgrade_description.sprintf(' (execution in %.3fs)', (get_moment() - $starttime))
."\n"
;
?>
@@ -0,0 +1,203 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'convert 2.3 resize settings into 2.4 derivative settings';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
$dbconf = array();
$conf_orig = $conf;
load_conf_from_db();
$dbconf = $conf;
$conf = $conf_orig;
//
// Piwigo 2.3 "HD resize" settings become "original resize" settings in Piwigo 2.4
//
if ($dbconf['upload_form_hd_keep'])
{
if ($dbconf['upload_form_hd_resize'])
{
conf_update_param('original_resize', 'true');
conf_update_param('original_resize_maxwidth', $dbconf['upload_form_hd_maxwidth']);
conf_update_param('original_resize_maxheight', $dbconf['upload_form_hd_maxheight']);
conf_update_param('original_resize_quality', $dbconf['upload_form_hd_quality']);
}
}
else
{
// The user has decided to remove the high quality. In Piwigo 2.4, this
// setting does not exists anymore, but we can simulate it by an original
// resize with 2.3 websize dimensions
conf_update_param('original_resize', 'true');
conf_update_param(
'original_resize_maxwidth',
is_numeric($dbconf['upload_form_websize_maxwidth']) ? $dbconf['upload_form_websize_maxwidth'] : 800
);
conf_update_param(
'original_resize_maxheight',
is_numeric($dbconf['upload_form_websize_maxheight']) ? $dbconf['upload_form_websize_maxheight'] : 600
);
conf_update_param('original_resize_quality', $dbconf['upload_form_hd_quality']);
}
$types = ImageStdParams::get_default_sizes();
//
// Piwigo 2.3 "thumbnail" becomes "thumb" size in Piwigo 2.4
//
$thumb_width_min = 128; // the default value in Piwigo 2.3
$thumb_width_max = 300; // slightly bigger than XXS default maxwidth
$thumb_height_min = 96; // the default value in Piwigo 2.3
$thumb_height_max = 300; // slightly bigger than XXS default maxheight
$thumb_is_square = false;
if ($dbconf['upload_form_thumb_crop'])
{
if ($dbconf['upload_form_thumb_maxwidth'] == $dbconf['upload_form_thumb_maxheight'])
{
$thumb_is_square = true;
}
}
if ($dbconf['upload_form_thumb_maxwidth'] < $thumb_width_min)
{
$dbconf['upload_form_thumb_maxwidth'] = $thumb_width_min;
}
if ($dbconf['upload_form_thumb_maxwidth'] > $thumb_width_max)
{
$dbconf['upload_form_thumb_maxwidth'] = $thumb_width_max;
}
if ($dbconf['upload_form_thumb_maxheight'] < $thumb_height_min)
{
$dbconf['upload_form_thumb_maxheight'] = $thumb_height_min;
}
if ($dbconf['upload_form_thumb_maxheight'] > $thumb_height_max)
{
$dbconf['upload_form_thumb_maxheight'] = $thumb_height_max;
}
if ($thumb_is_square)
{
$dbconf['upload_form_thumb_maxheight'] = $dbconf['upload_form_thumb_maxwidth'];
}
$size = array($dbconf['upload_form_thumb_maxwidth'], $dbconf['upload_form_thumb_maxheight']);
$thumb = new DerivativeParams(
new SizingParams(
$size,
$dbconf['upload_form_thumb_crop'] ? 1 : 0,
$dbconf['upload_form_thumb_crop'] ? $size : null
)
);
$types[IMG_THUMB] = $thumb;
// slightly enlarge XSS to be bigger than thumbnail size (but smaller than XS)
if ($dbconf['upload_form_thumb_maxwidth'] >= $types[IMG_XXSMALL]->sizing->ideal_size[0]
or $dbconf['upload_form_thumb_maxheight'] >= $types[IMG_XXSMALL]->sizing->ideal_size[1])
{
$xxs_maxwidth = $types[IMG_XXSMALL]->sizing->ideal_size[0];
if ($dbconf['upload_form_thumb_maxwidth'] >= $xxs_maxwidth)
{
$xxs_maxwidth = 350;
}
$xxs_maxheight = $types[IMG_XXSMALL]->sizing->ideal_size[1];
if ($dbconf['upload_form_thumb_maxheight'] >= $xxs_maxheight)
{
$xxs_maxheight = 310;
}
$xxs = new DerivativeParams(new SizingParams(array($xxs_maxwidth, $xxs_maxheight)));
$types[IMG_XXSMALL] = $xxs;
}
//
// Piwigo 2.3 "websize" becomes "medium" size in Piwigo 2.4
//
// if there was no "websize resize" on Piwigo 2.3, we can't take the resize
// settings into account, we keep the default settings of Piwigo 2.4.
if ($dbconf['upload_form_websize_resize'])
{
$medium_width_min = 577; // default S maxwidth + 1 pixel
$medium_width_max = 1007; // default L maxwidth - 1 pixel
$medium_height_min = 433; // default S maxheight + 1 pixel
$medium_height_max = 755; // default L maxheight - 1 pixel
// width
if (!is_numeric($dbconf['upload_form_websize_maxwidth'])) // sometimes maxwidth="false"
{
$dbconf['upload_form_websize_maxwidth'] = $medium_width_max;
}
if ($dbconf['upload_form_websize_maxwidth'] < $medium_width_min)
{
$dbconf['upload_form_websize_maxwidth'] = $medium_width_min;
}
if ($dbconf['upload_form_websize_maxwidth'] > $medium_width_max)
{
$dbconf['upload_form_websize_maxwidth'] = $medium_width_max;
}
// height
if (!is_numeric($dbconf['upload_form_websize_maxheight'])) // sometimes maxheight="false"
{
$dbconf['upload_form_websize_maxheight'] = $medium_height_max;
}
if ($dbconf['upload_form_websize_maxheight'] < $medium_height_min)
{
$dbconf['upload_form_websize_maxheight'] = $medium_height_min;
}
if ($dbconf['upload_form_websize_maxheight'] > $medium_height_max)
{
$dbconf['upload_form_websize_maxheight'] = $medium_height_max;
}
$medium = new DerivativeParams(
new SizingParams(
array(
$dbconf['upload_form_websize_maxwidth'],
$dbconf['upload_form_websize_maxheight']
)
)
);
$types[IMG_MEDIUM] = $medium;
}
//
// Save derivative new settings
//
ImageStdParams::set_and_save($types);
pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param = \'disabled_derivatives\'');
clear_derivative_cache();
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,45 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'derivatives: remove useless configuration settings and columns';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
//
// Clean useless configuration settings
//
pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param like \'upload_form_%\';');
//
// Remove useless columns
//
$query = '
ALTER TABLE '.USER_INFOS_TABLE.'
DROP `maxwidth`,
DROP `maxheight`
;';
pwg_query($query);
$query = '
ALTER TABLE '.IMAGES_TABLE.'
DROP `high_width`,
DROP `high_height`,
DROP `high_filesize`,
DROP `has_high`,
DROP `tn_ext`
;';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,182 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'derivatives: search and replace hotlinks inside Piwigo (page_banner';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
if (!isset($conf['prefix_thumbnail']))
{
$conf['prefix_thumbnail'] = 'TN-';
}
if (!isset($conf['dir_thumbnail']))
{
$conf['dir_thumbnail'] = 'thumbnail';
}
$dbconf = array();
$conf_orig = $conf;
load_conf_from_db();
$dbconf = $conf;
$conf = $conf_orig;
$banner_orig = $dbconf['page_banner'];
$banner_new = replace_hotlinks($dbconf['page_banner']);
if ($banner_orig != $banner_new)
{
conf_update_param('page_banner', pwg_db_real_escape_string($banner_new));
}
//
// Additional Pages
//
$is_plugin_installed = false;
$plugin_table = $prefixeTable.'additionalpages';
$query = 'SHOW TABLES LIKE \''.$plugin_table.'\';';
$result = pwg_query($query);
while ($row = pwg_db_fetch_row($result))
{
if ($plugin_table == $row[0])
{
$is_plugin_installed = true;
}
}
if ($is_plugin_installed)
{
$query = '
SELECT
id,
content
FROM '.$plugin_table.'
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
$content_orig = $row['content'];
$content_new = replace_hotlinks($content_orig);
if ($content_orig != $content_new)
{
single_update(
$plugin_table,
array('content' => pwg_db_real_escape_string($content_new)),
array('id' => $row['id'])
);
}
}
$upgrade_description.= ', Additional Pages';
}
//
// PWG Stuffs
//
$is_plugin_installed = false;
$plugin_table = $prefixeTable.'stuffs';
$query = 'SHOW TABLES LIKE \''.$plugin_table.'\';';
$result = pwg_query($query);
while ($row = pwg_db_fetch_row($result))
{
if ($plugin_table == $row[0])
{
$is_plugin_installed = true;
}
}
if ($is_plugin_installed)
{
$query = '
SELECT
id,
datas
FROM '.$plugin_table.'
WHERE path LIKE \'%plugins/PWG_Stuffs/modules/Personal%\'
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
$content_orig = $row['datas'];
$content_new = serialize(replace_hotlinks(unserialize($content_orig)));
if ($content_orig != $content_new)
{
single_update(
$plugin_table,
array('datas' => pwg_db_real_escape_string($content_new)),
array('id' => $row['id'])
);
}
}
$upgrade_description.= ', PWG Stuffs';
}
$upgrade_description.= ')';
echo "\n".$upgrade_description."\n";
// +-----------------------------------------------------------------------+
// | Functions |
// +-----------------------------------------------------------------------+
function replace_hotlinks($string)
{
global $conf;
// websize 2.3 = medium 2.4
$string = preg_replace(
'#(upload/\d{4}/\d{2}/\d{2}/\d{14}-\w{8})(\.(jpg|png))#',
'i.php?/$1-me$2',
$string
);
// I've tried but I didn't find the way to do it correctly
// $string = preg_replace(
// '#(galleries/.*?/)(?!:(pwg_high|'.$conf['dir_thumbnail'].')/)([^/]*?)(\.[a-z0-9]{3,4})([\'"])#',
// 'i.php?/(1=$1)(2=$2)-me(3=$3)(4=$4)', // 'i.php?/$1$2-me$3',
// $string
// );
// thumbnail 2.3 = th size 2.4
$string = preg_replace(
'#(upload/\d{4}/\d{2}/\d{2}/)'.$conf['dir_thumbnail'].'/'.$conf['prefix_thumbnail'].'(\d{14}-\w{8})(\.(jpg|png))#',
'i.php?/$1$2-th$3',
$string
);
$string = preg_replace(
'#(galleries/.*?/)'.$conf['dir_thumbnail'].'/'.$conf['prefix_thumbnail'].'(.*?)(\.[a-z0-9]{3,4})([\'"])#',
'i.php?/$1$2-th$3$4',
$string
);
// HD 2.3 = original 2.4
$string = preg_replace(
'#(upload/\d{4}/\d{2}/\d{2}/)pwg_high/(\d{14}-\w{8}\.(jpg|png))#',
'$1$2',
$string
);
$string = preg_replace(
'#(galleries/.*?)/pwg_high(/.*?\.[a-z0-9]{3,4})#',
'$1$2',
$string
);
return $string;
}
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'rename language sl_SL into sl_SI';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
$query = '
UPDATE '.USER_INFOS_TABLE.'
SET language = \'sl_SI\'
WHERE language = \'sl_SL\'
;';
pwg_query($query);
$query = '
UPDATE '.LANGUAGES_TABLE.'
SET id = \'sl_SI\'
WHERE id = \'sl_SL\'
;';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'rename language no_NO into nb_NO';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
$query = '
UPDATE '.USER_INFOS_TABLE.'
SET language = \'nb_NO\'
WHERE language = \'no_NO\'
;';
pwg_query($query);
$query = '
UPDATE '.LANGUAGES_TABLE.'
SET id = \'nb_NO\'
WHERE id = \'no_NO\'
;';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,23 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add anonymous_id in comments table';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
$query = 'ALTER TABLE `'.COMMENTS_TABLE.'` ADD `anonymous_id` VARCHAR( 45 ) DEFAULT NULL;';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,23 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add "website_url" field in comments table';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
$query = 'ALTER TABLE `'.COMMENTS_TABLE.'` ADD `website_url` varchar(255) DEFAULT NULL;';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,26 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add "email" field in comments table';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
$query = 'ALTER TABLE `'.COMMENTS_TABLE.'` ADD `email` varchar(255) default NULL;';
pwg_query($query);
conf_update_param('comments_author_mandatory', 'false');
conf_update_param('comments_email_mandatory', 'false');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,20 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add "nb_categories_page" parameter';
conf_update_param('nb_categories_page', '50');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,21 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
$upgrade_description = 'Enlarge #users.password to increase security.';
global $prefixeTable;
// we don't use USERS_TABLE because it might be an external table, here we
// want to change to users table specific to Piwigo
$query = 'ALTER TABLE '.$prefixeTable.'users CHANGE password password varchar(255) default NULL';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,20 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
$upgrade_description = '#categories.site_id default value.';
$query = 'ALTER TABLE '.CATEGORIES_TABLE.' CHANGE site_id site_id tinyint(4) unsigned default NULL';
pwg_query($query);
$query = 'UPDATE '.CATEGORIES_TABLE.' SET site_id=NULL WHERE dir IS NULL';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,28 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
$upgrade_description = 'replace dblayer to "mysqli" if available.';
global $conf;
$config_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'config/database.inc.php';
if ( extension_loaded('mysqli') and $conf['dblayer']=='mysql' and is_writable($config_file) )
{
$file_content = file_get_contents($config_file);
$file_content = preg_replace(
'#\$conf\[\'dblayer\'\]( *)=( *)\'mysql\';#',
'$conf[\'dblayer\']$1=$2\'mysqli\';',
$file_content);
file_put_contents($config_file, $file_content);
}
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,32 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
$upgrade_description = 'add nb available comments/tags';
$query = 'ALTER TABLE '.USER_INFOS_TABLE.'
ADD PRIMARY KEY (`user_id`)
, DROP INDEX `user_infos_ui1`';
pwg_query($query);
$query = 'ALTER TABLE '.USER_CACHE_TABLE.'
ADD COLUMN `last_photo_date` datetime DEFAULT NULL AFTER `nb_total_images`';
pwg_query($query);
invalidate_user_cache();
$query = 'ALTER TABLE '.USER_CACHE_TABLE.'
ADD COLUMN `nb_available_tags` INT(5) DEFAULT NULL AFTER `last_photo_date`';
pwg_query($query);
$query = 'ALTER TABLE '.USER_CACHE_TABLE.'
ADD COLUMN `nb_available_comments` INT(5) DEFAULT NULL AFTER `nb_available_tags`';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,22 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
$upgrade_description = 'add nb direct child categories';
$query = '
ALTER TABLE '.USER_CACHE_CATEGORIES_TABLE.'
ADD COLUMN nb_categories mediumint(8) unsigned NOT NULL default 0 AFTER count_images';
pwg_query($query);
invalidate_user_cache();
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,47 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
$upgrade_description = 'add ASC keyword to categories image_order field';
$query = '
SELECT id, image_order
FROM '.CATEGORIES_TABLE.'
WHERE image_order != ""
;';
$cats = hash_from_query($query, 'id');
foreach ($cats as $id => &$data)
{
$image_order = explode(',',$data['image_order']);
foreach ($image_order as &$order)
{
if (strpos($order, ' ASC')===false && strpos($order, ' DESC')===false)
{
$order.= ' ASC';
}
}
unset($order);
$data['image_order'] = implode(',',$image_order);
}
unset($data);
mass_updates(CATEGORIES_TABLE,
array(
'primary' => array('id'),
'update' => array('image_order'),
),
$cats
);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,20 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add "mail_theme" parameter';
conf_update_param('mail_theme', 'clear');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,49 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add "latitude" and "longitude" fields';
// add fields
$query = '
ALTER TABLE '. IMAGES_TABLE .'
ADD `latitude` DOUBLE(8, 6) DEFAULT NULL,
ADD `longitude` DOUBLE(9, 6) DEFAULT NULL
;';
pwg_query($query);
// add index
$query = '
ALTER TABLE '. IMAGES_TABLE .'
ADD INDEX `images_i6` (`latitude`)
;';
pwg_query($query);
// search for old "lat" field
$query = 'SHOW COLUMNS FROM '. IMAGES_TABLE .' LIKE "lat";';
if (pwg_db_num_rows(pwg_query($query)))
{
// duplicate non-null values
$query = '
UPDATE '. IMAGES_TABLE .'
SET latitude = lat,
longitude = lon
WHERE lat IS NOT NULL
AND lon IS NOT NULL
;';
pwg_query($query);
}
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,22 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = '#tags.name is not binary';
// add fields
$query = 'ALTER TABLE '.TAGS_TABLE.' CHANGE COLUMN `name` `name` VARCHAR(255) NOT NULL DEFAULT \'\'';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,30 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
$upgrade_description = 'add lastmodified field for categories, images, groups, users, tags';
$tables = array(
CATEGORIES_TABLE,
GROUPS_TABLE,
IMAGES_TABLE,
TAGS_TABLE,
USER_INFOS_TABLE
);
foreach ($tables as $table)
{
pwg_query('
ALTER TABLE '. $table .'
ADD `lastmodified` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
ADD INDEX `lastmodified` (`lastmodified`)
;');
}
echo "\n".$upgrade_description."\n";
@@ -0,0 +1,20 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add "comments_enable_website" parameter';
conf_update_param('comments_enable_website', 'true');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,45 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'enlarge your user_id (16 millions possible users)';
// we use PREFIX_TABLE, in case Piwigo uses an external user table
pwg_query('ALTER TABLE '.PREFIX_TABLE.'users CHANGE id id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT;');
pwg_query('ALTER TABLE '.IMAGES_TABLE.' CHANGE added_by added_by MEDIUMINT UNSIGNED NOT NULL DEFAULT \'0\';');
pwg_query('ALTER TABLE '.COMMENTS_TABLE.' CHANGE author_id author_id MEDIUMINT UNSIGNED DEFAULT NULL;');
$tables = array(
USER_ACCESS_TABLE,
USER_CACHE_TABLE,
USER_FEED_TABLE,
USER_GROUP_TABLE,
USER_INFOS_TABLE,
USER_CACHE_CATEGORIES_TABLE,
USER_MAIL_NOTIFICATION_TABLE,
RATE_TABLE,
CADDIE_TABLE,
FAVORITES_TABLE,
HISTORY_TABLE,
);
foreach ($tables as $table)
{
pwg_query('
ALTER TABLE '.$table.'
CHANGE user_id user_id MEDIUMINT UNSIGNED NOT NULL DEFAULT \'0\'
;');
}
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,28 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add activation_key_expire';
// we use PREFIX_TABLE, in case Piwigo uses an external user table
pwg_query('
ALTER TABLE '.USER_INFOS_TABLE.'
CHANGE activation_key activation_key VARCHAR(255) DEFAULT NULL,
ADD COLUMN activation_key_expire DATETIME DEFAULT NULL AFTER activation_key
;');
// purge current expiration keys
pwg_query('UPDATE '.USER_INFOS_TABLE.' SET activation_key = NULL;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,29 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add image formats table';
// we use PREFIX_TABLE, in case Piwigo uses an external user table
pwg_query('
CREATE TABLE `'.PREFIX_TABLE.'image_format` (
`format_id` int(11) unsigned NOT NULL auto_increment,
`image_id` mediumint(8) unsigned NOT NULL DEFAULT \'0\',
`ext` varchar(255) NOT NULL,
`filesize` mediumint(9) unsigned DEFAULT NULL,
PRIMARY KEY (`format_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,24 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add format_id in history table';
// we use PREFIX_TABLE, in case Piwigo uses an external user table
pwg_query('
ALTER TABLE `'.PREFIX_TABLE.'history`
ADD COLUMN `format_id` int(11) unsigned DEFAULT NULL
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,31 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add user authentication keys table';
// we use PREFIX_TABLE, in case Piwigo uses an external user table
pwg_query('
CREATE TABLE `'.PREFIX_TABLE.'user_auth_keys` (
`auth_key_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`auth_key` varchar(255) NOT NULL,
`user_id` mediumint(8) unsigned NOT NULL,
`created_on` datetime NOT NULL,
`duration` int(11) unsigned DEFAULT NULL,
`expired_on` datetime NOT NULL,
PRIMARY KEY (`auth_key_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,24 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add auth_key_id in history table';
// we use PREFIX_TABLE, in case Piwigo uses an external user table
pwg_query('
ALTER TABLE `'.PREFIX_TABLE.'history`
ADD COLUMN `auth_key_id` int(11) unsigned DEFAULT NULL
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,25 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add last_visit+last_visit_from_history in user_infos table';
// we use PREFIX_TABLE, in case Piwigo uses an external user table
pwg_query('
ALTER TABLE `'.PREFIX_TABLE.'user_infos`
ADD COLUMN `last_visit` datetime default NULL,
ADD COLUMN `last_visit_from_history` enum(\'true\',\'false\') NOT NULL default \'false\'
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,65 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add history_id_from+history_id_to in history_summary table';
// we use PREFIX_TABLE, in case Piwigo uses an external user table
pwg_query('
ALTER TABLE `'.PREFIX_TABLE.'history_summary`
ADD COLUMN `history_id_from` int(10) unsigned default NULL,
ADD COLUMN `history_id_to` int(10) unsigned default NULL
;');
$query = '
SELECT
*
FROM '.PREFIX_TABLE.'history
WHERE summarized = \'true\'
ORDER BY id DESC
LIMIT 1
;';
// note : much faster than searching MAX(ID), ie on my big sample 14 seconds Vs 2 seconds
$history_lines = query2array($query);
if (count($history_lines) > 0)
{
$last_summarized = $history_lines[0];
list($year, $month, $day) = explode('-', $last_summarized['date']);
list($hour) = explode(':', $last_summarized['time']);
single_update(
PREFIX_TABLE.'history_summary',
array(
'history_id_to' => $last_summarized['id'],
),
array(
'year' => $year,
'month' => $month,
'day' => $day,
'hour' => $hour,
)
);
// in case this script would update no summary line, it would mean the
// summary has been purged and will be rebuild from scratch, based on the
// content of history table
}
// for now, we keep column history.summarized even if Piwigo 2.9 no longer
// uses it. We will remove it in a future version. First we need to have
// "less" lines in history table. This will be possible with the automatic
// purge implemented in Piwigo 2.9.
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,21 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add "picture_sizes_icon" and "index_sizes_icon" parameters';
conf_update_param('index_sizes_icon', 'true');
conf_update_param('picture_sizes_icon', 'true');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,25 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add 5 parameters to show/hide icons (edit/caddie/repressentative)';
conf_update_param('index_edit_icon','true');
conf_update_param('index_caddie_icon','true');
conf_update_param('picture_edit_icon','true');
conf_update_param('picture_caddie_icon','true');
conf_update_param('picture_representative_icon','true');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,44 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Show date period of an album';
function value_display_fromto()
{
$file = PHPWG_ROOT_PATH.'local/config/config.inc.php';
if (file_exists($file))
{
$conf = array();
include($file);
if (isset($conf['display_fromto']) and $conf['display_fromto'])
{
return 'true';
}
}
return 'false';
}
$value = value_display_fromto();
$query = '
INSERT INTO '.PREFIX_TABLE.'config (param,value,comment)
VALUES (\'display_fromto\',\''.$value.'\', \''.$upgrade_description.'\')
;';
pwg_query($query);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,31 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add activity table';
pwg_query('
CREATE TABLE `'.PREFIX_TABLE.'activity` (
`activity_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`object` varchar(255) NOT NULL,
`object_id` int(11) unsigned NOT NULL,
`action` varchar(255) NOT NULL,
`performed_by` mediumint(8) unsigned NOT NULL,
`occured_on` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`details` varchar(255) DEFAULT NULL,
PRIMARY KEY (`activity_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,21 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add columns session_idx+ip_address in activity table';
pwg_query('alter table `'.PREFIX_TABLE.'activity` add column `session_idx` varchar(255) NOT NULL after `performed_by`;');
pwg_query('alter table `'.PREFIX_TABLE.'activity` add column `ip_address` varchar(50) default null after session_idx;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,25 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'bug fixing, change column type for activity.occured_on';
$row = pwg_db_fetch_assoc(pwg_query('SHOW COLUMNS FROM `'.PREFIX_TABLE.'activity` LIKE "occured_on";'));
if (!preg_match('/^TIMESTAMP/i', $row['Type']))
{
$query = 'ALTER TABLE `'.PREFIX_TABLE.'activity` CHANGE `occured_on` `occured_on` TIMESTAMP DEFAULT CURRENT_TIMESTAMP;';
pwg_query($query);
}
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,21 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add config parameters to display smart app banner';
conf_update_param('show_mobile_app_banner_in_admin', true);
conf_update_param('show_mobile_app_banner_in_gallery', false);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'set default date to 1970-01-01';
$queries = array(
'ALTER TABLE `'.PREFIX_TABLE.'comments` CHANGE `date` `date` datetime NOT NULL default \'1970-01-01 00:00:00\';',
'ALTER TABLE `'.PREFIX_TABLE.'history` CHANGE `date` `date` date NOT NULL default \'1970-01-01\';',
'ALTER TABLE `'.PREFIX_TABLE.'images` CHANGE `date_available` `date_available` datetime NOT NULL default \'1970-01-01 00:00:00\';',
'ALTER TABLE `'.PREFIX_TABLE.'old_permalinks` CHANGE `date_deleted` `date_deleted` datetime NOT NULL default \'1970-01-01 00:00:00\';',
'ALTER TABLE `'.PREFIX_TABLE.'rate` CHANGE `date` `date` date NOT NULL default \'1970-01-01\';',
'ALTER TABLE `'.PREFIX_TABLE.'sessions` CHANGE `expiration` `expiration` datetime NOT NULL default \'1970-01-01 00:00:00\';',
'ALTER TABLE `'.PREFIX_TABLE.'upgrade` CHANGE `applied` `applied` datetime NOT NULL default \'1970-01-01 00:00:00\';',
'ALTER TABLE `'.PREFIX_TABLE.'user_infos` CHANGE `registration_date` `registration_date` datetime NOT NULL default \'1970-01-01 00:00:00\';',
);
foreach ($queries as $query)
{
pwg_query($query);
}
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,24 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add index on images.path';
$query = '
ALTER TABLE '. IMAGES_TABLE .'
ADD INDEX `images_i7` (`path`)
;';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,26 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add lounge table';
pwg_query('
CREATE TABLE `'.PREFIX_TABLE.'lounge` (
`image_id` mediumint(8) unsigned NOT NULL,
`category_id` smallint(5) unsigned NOT NULL,
PRIMARY KEY (`image_id`,`category_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,53 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'remove doubled activities on tag addition';
$tag_ids_added = array();
$to_delete_activities = array();
$query = '
SELECT
*
FROM '.PREFIX_TABLE.'activity
WHERE object = "tag"
AND action = "add"
ORDER BY activity_id ASC
;';
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
if (isset($tag_ids_added[ $row['object_id'] ]))
{
array_push($to_delete_activities, $row['activity_id']);
}
else
{
$tag_ids_added[ $row['object_id'] ] = 1;
}
}
if (count($to_delete_activities) > 0)
{
$query = '
DELETE
FROM '.PREFIX_TABLE.'activity
WHERE activity_id IN ('.implode(',', $to_delete_activities).')
;';
pwg_query($query);
}
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,25 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'change activity.performed_by for logout';
$query = '
UPDATE '.PREFIX_TABLE.'activity
SET performed_by = object_id
WHERE action = \'logout\'
;';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,23 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add user_infos.preferences';
pwg_query('
ALTER TABLE `'.PREFIX_TABLE.'user_infos`
ADD COLUMN `preferences` TEXT default NULL
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,23 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Create dedicated user agent column for activity.';
pwg_query('
ALTER TABLE `'.PREFIX_TABLE.'activity`
ADD COLUMN `user_agent` varchar(255) default NULL
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,31 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add more options to email_admin_on_new_user';
list($old_value) = pwg_db_fetch_row(pwg_query('SELECT value FROM '.PREFIX_TABLE.'config WHERE param = "email_admin_on_new_user"'));
$new_value = 'all';
if ('false' == $old_value)
{
$new_value = 'none';
}
conf_update_param('email_admin_on_new_user', $new_value);
echo
"\n"
. $upgrade_description
."\n"
;
?>
@@ -0,0 +1,26 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Create new columns for search (search_uuid, created_on, user_idx, forked_from).';
pwg_query('
ALTER TABLE `'.PREFIX_TABLE.'search`
ADD COLUMN `search_uuid` CHAR(23) DEFAULT NULL,
ADD COLUMN `created_on` DATETIME DEFAULT NULL,
ADD COLUMN `created_by` MEDIUMINT(8) UNSIGNED,
ADD COLUMN `forked_from` INT(10) UNSIGNED
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,21 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add config parameters to display "search in this set" action and button';
conf_update_param('index_search_in_set_button', true);
conf_update_param('index_search_in_set_action', true);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,20 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Create new column search_id in visits history table.';
pwg_query('ALTER TABLE `'.PREFIX_TABLE.'history` ADD COLUMN `search_id` int(10) unsigned default NULL AFTER `category_id`;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,21 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Delete old column search.last_seen, never really used.';
pwg_query('UPDATE `'.PREFIX_TABLE.'search` SET `created_on` = `last_seen` where `created_on` IS NULL AND `last_seen` IS NOT NULL;');
pwg_query('ALTER TABLE `'.PREFIX_TABLE.'search` DROP COLUMN `last_seen`;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,22 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add config parameter to handle duplicate on upload';
// we set it to false in this upgrade script, as opposed to the default value
// for a new installation, because it was the default behavior before Piwigo 14
conf_update_param('upload_detect_duplicate', false);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,22 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'convert file configuration setting webmaster_id to database';
// If the webmaster_id has been modified, it must be present in local/config/config.inc.php
// so we retrieve it and insert it into the database.
conf_update_param('webmaster_id', $conf['webmaster_id'] ?? 1);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,20 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'reduce sessions.id length to 50 chars';
$query = 'ALTER TABLE `'.PREFIX_TABLE.'sessions` CHANGE `id` `id` varchar(50) binary NOT NULL default \'\';';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,20 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'increase history.IP length from VARCHAR(16) to CHAR(39), IPv6 compatible';
$query = 'ALTER TABLE `'.PREFIX_TABLE.'history` CHANGE `IP` `IP` char(39) NOT NULL default \'\';';
pwg_query($query);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,20 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'increase security on secret_key';
conf_update_param('secret_key', sha1(random_bytes(1000)), true);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,21 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add config parameter to override Theme Login & Registration Pages';
// Force use of standard pages on update
conf_update_param('use_standard_pages', true);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,36 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Modification to the user_auth_key table to match the api keys';
// we are modifying the "auth_key" table structure to support the new API key system.
// the existing structure was too limited for our needs, this update ensures better
// flexibility and security for managing API access tokens in the future.
pwg_query(
'ALTER TABLE `'.PREFIX_TABLE.'user_auth_keys`
ADD COLUMN `apikey_secret` VARCHAR(255) DEFAULT NULL AFTER auth_key,
ADD COLUMN `apikey_name` VARCHAR(100) DEFAULT NULL,
ADD COLUMN `key_type` VARCHAR(40) DEFAULT NULL,
ADD COLUMN `revoked_on` datetime DEFAULT NULL,
ADD COLUMN `last_used_on` datetime DEFAULT NULL
;');
// For rows that already exist in the table, we add a key_type
pwg_query(
'UPDATE `'.PREFIX_TABLE.'user_auth_keys`
SET `key_type` = \'auth_key\'
WHERE `key_type` IS NULL
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,35 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add 3XL and 4XL sizes (disabled by default)';
load_conf_from_db();
//get default sizes from derivative_std_params
$default_sizes = ImageStdParams::get_default_sizes();
// set new derivatives to add
$new_derivatives = array(IMG_3XLARGE, IMG_4XLARGE);
// get current disabled derivative_std_params
$disabled_derivatives = safe_unserialize(ImageStdParams::get_disabled_type_map());
// get the new derivative_std_params and merge with current disabled derivative_std_params
$new_disabled_derivatives = array_intersect_key($default_sizes, array_flip($new_derivatives));
$disabled = array_merge($disabled_derivatives, $new_disabled_derivatives);
// set and set new derivative_std_params in disabled list
ImageStdParams::set_and_save_disabled($disabled);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,22 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add config parameters to the gallery filters';
// let the $conf['filters_views'] be written in config table when the admin will change settings in administration.
//
// conf_update_param('filters_views', $conf['default_filters_views']);
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,24 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Modification to the user_auth_key table to add last_notified_on';
// For API KEY, add a column last_notified_on, to know when the last email (for the moment)
// notifying of an upcoming expiration date was sent.
pwg_query(
'ALTER TABLE `'.PREFIX_TABLE.'user_auth_keys`
ADD COLUMN `last_notified_on` datetime DEFAULT NULL
;');
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,22 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add config parameters to display by default or not "related tags" [Aborted] ';
//The contents of the database upgrade have been emptied
//due to the fact that we decicded to not use this configuration
//in the end for the related tags display
//We need to keep this database ugrapde to avoid errors
//for those that have already passed the "180"th upgrade.
//This database upgrade now does nothing.
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'add "expert mode" in filters_views for gallery search';
load_conf_from_db();
// if the filters_views is not already registered in the config table, no need
// to update it because it will be initialized with all filters
if (isset($conf['filters_views']))
{
$conf['filters_views'] = safe_unserialize($conf['filters_views']);
if (!isset($conf['filters_views']['expert']))
{
$conf['filters_views']['expert'] = $conf['default_filters_views']['expert'];
conf_update_param('filters_views', $conf['filters_views']);
}
}
echo "\n".$upgrade_description."\n";
?>
@@ -0,0 +1,35 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add unique index on #_groups for name';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = "
alter table ".GROUPS_TABLE."
add UNIQUE KEY `groups_ui1` (`name`)
;";
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add obligatory_user_mail config';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = "
INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('obligatory_user_mail_address','false','Mail address is obligatory for users');
";
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,58 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add #user_infos.level, #images.level and #user_cache.forbidden_images';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = '
ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN level TINYINT UNSIGNED NOT NULL DEFAULT 0
';
pwg_query($query);
$query = '
ALTER TABLE '.USER_INFOS_TABLE.' ADD COLUMN level TINYINT UNSIGNED NOT NULL DEFAULT 0
';
pwg_query($query);
$query = '
ALTER TABLE '.USER_CACHE_TABLE.' ADD COLUMN image_access_type enum("NOT IN","IN") NOT NULL default "NOT IN"
';
pwg_query($query);
$query = '
ALTER TABLE '.USER_CACHE_TABLE.' ADD COLUMN image_access_list TEXT DEFAULT NULL
';
pwg_query($query);
$query = '
UPDATE '.USER_INFOS_TABLE.' SET level=8 WHERE status="webmaster"
';
pwg_query($query);
$query = '
UPDATE '.USER_CACHE_TABLE.' SET need_update=true
';
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,35 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Activation of c13_upgrade plugin';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = '
REPLACE INTO '.PLUGINS_TABLE.'
(id, state)
VALUES (\'c13y_upgrade\', \'active\')
;';
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,285 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
function upgrade65_change_table_to_blob($table, $field_definitions)
{
$types = array('varchar' => 'varbinary',
'text' => 'blob',
'mediumtext' => 'mediumblob',
'longtext' => 'longblob');
$changes=array();
foreach( $field_definitions as $row)
{
if ( !isset($row['Collation']) or $row['Collation']=='NULL' )
continue;
list ($type) = explode('(', $row['Type']);
if (!isset($types[$type]))
continue; // no need
$binaryType = preg_replace('/'. $type .'/i', $types[$type], $row['Type'] );
$changes[] = 'MODIFY COLUMN '.$row['Field'].' '.$binaryType;
}
if (count($changes))
{
$query = 'ALTER TABLE '.$table.' '.implode(', ', $changes);
pwg_query($query);
}
}
function upgrade65_change_table_to_charset($table, $field_definitions, $db_charset)
{
$changes=array();
foreach( $field_definitions as $row)
{
if ( !isset($row['Collation']) or $row['Collation']=='NULL' )
continue;
$query = $row['Field'].' '.$row['Type'];
$query .= ' CHARACTER SET '.$db_charset;
if (strpos($row['Collation'],'_bin')!==false)
{
$query .= ' BINARY';
}
if ($row['Null']!='YES')
{
$query.=' NOT NULL';
if (isset($row['Default']))
$query.=' DEFAULT "'.addslashes($row['Default']).'"';
}
else
{
if (!isset($row['Default']))
$query.=' DEFAULT NULL';
else
$query.=' DEFAULT "'.addslashes($row['Default']).'"';
}
if ($row['Extra']=='auto_increment')
{
$query.=' auto_increment';
}
$changes[] = 'MODIFY COLUMN '.$query;
}
if (count($changes))
{
$query = 'ALTER TABLE `'.$table.'` '.implode(', ', $changes);
pwg_query($query);
}
}
$upgrade_description = 'PWG charset migration';
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
if ( !defined('PWG_CHARSET') )
{
$upgrade_log = '';
// +-----------------------------------------------------------------------+
// load all the user languages
$all_langs=array();
$query='
SELECT language, COUNT(user_id) AS count FROM '.USER_INFOS_TABLE.'
GROUP BY language';
$result = pwg_query($query);
while ( $row=pwg_db_fetch_assoc($result) )
{
$language = $row["language"];
$lang_def = explode('.', $language);
if ( count($lang_def)==2 )
{
$new_lang = $lang_def[0];
$charset = strtolower($lang_def[1]);
}
else
{
$new_lang = 'en_UK';
$charset = 'iso-8859-1';
}
$all_langs[$language] = array(
'count' => $row['count'],
'new_lang' => $new_lang,
'charset' => $charset,
);
$upgrade_log .= ">>user_lang\t".$language."\t".$row['count']."\n";
}
$upgrade_log .= "\n";
// +-----------------------------------------------------------------------+
// get admin charset
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
$admin_charset='iso-8859-1';
$query='
SELECT language FROM '.USER_INFOS_TABLE.'
WHERE user_id='.$conf['webmaster_id'];
$result = pwg_query($query);
if (pwg_db_num_rows($result)==0)
{
$query='
SELECT language FROM '.USER_INFOS_TABLE.'
WHERE status="webmaster" and adviser="false"
LIMIT 1';
$result = pwg_query($query);
}
if ( $row=pwg_db_fetch_assoc($result) )
{
$admin_charset = $all_langs[$row['language']]['charset'];
}
$upgrade_log .= ">>admin_charset\t".$admin_charset."\n";
// +-----------------------------------------------------------------------+
// get mysql version and structure of tables
$mysql_version = mysql_get_server_info();
$upgrade_log .= ">>mysql_ver\t".$mysql_version."\n";
$all_tables = array();
$query = 'SHOW TABLES LIKE "'.$prefixeTable.'%"';
$result = pwg_query($query);
while ( $row=pwg_db_fetch_row($result) )
{
array_push($all_tables, $row[0]);
}
$all_tables_definition = array();
foreach( $all_tables as $table)
{
$query = 'SHOW FULL COLUMNS FROM '.$table;
$result = pwg_query($query);
$field_definitions=array();
while ( $row=pwg_db_fetch_assoc($result) )
{
if ( !isset($row['Collation']) or $row['Collation']=='NULL' )
continue;
array_push($field_definitions, $row);
}
$all_tables_definition[$table] = $field_definitions;
}
// +-----------------------------------------------------------------------+
// calculate the result and convert the tables
//tables that can be converted without going through binary (they contain only ascii data)
$safe_tables=array('history','history_backup','history_summary','old_permalinks','plugins','rate','upgrade','user_cache','user_feed','user_infos','user_mail_notification', 'users', 'waiting','ws_access');
$safe_tables=array_flip($safe_tables);
$pwg_charset = 'iso-8859-1';
$db_charset = 'latin1';
$db_collate = '';
if ( version_compare($mysql_version, '4.1', '<') )
{ // below 4.1 no charset support
$upgrade_log .= "< conversion\tnothing\n";
}
elseif ($admin_charset=='iso-8859-1')
{
$pwg_charset = 'utf-8';
$db_charset = 'utf8';
foreach($all_tables as $table)
{
upgrade65_change_table_to_charset($table, $all_tables_definition[$table], 'utf8' );
$query = 'ALTER TABLE '.$table.' DEFAULT CHARACTER SET utf8';
pwg_query($query);
}
$upgrade_log .= "< conversion\tchange utf8\n";
}
/*ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name; (or change column character set)
Warning: The preceding operation converts column values between the character sets. This is not what you want if you have a column in one character set (like latin1) but the stored values actually use some other, incompatible character set (like utf8). In this case, you have to do the following for each such column:
ALTER TABLE t1 CHANGE c1 c1 BLOB;
ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8;
*/
elseif ( $admin_charset=='utf-8')
{
$pwg_charset = 'utf-8';
$db_charset = 'utf8';
foreach($all_tables as $table)
{
if ( !isset($safe_tables[ substr($table, strlen($prefixeTable)) ]) )
upgrade65_change_table_to_blob($table, $all_tables_definition[$table] );
upgrade65_change_table_to_charset($table, $all_tables_definition[$table], 'utf8' );
$query = 'ALTER TABLE '.$table.' DEFAULT CHARACTER SET utf8';
pwg_query($query);
}
$upgrade_log .= "< conversion\tchange binary\n";
$upgrade_log .= "< conversion\tchange utf8\n";
}
elseif ( $admin_charset=='iso-8859-2'/*Central European*/)
{
$pwg_charset = 'utf-8';
$db_charset = 'utf8';
foreach($all_tables as $table)
{
if ( !isset($safe_tables[ substr($table, strlen($prefixeTable)) ]) )
{
upgrade65_change_table_to_blob($table, $all_tables_definition[$table] );
upgrade65_change_table_to_charset($table, $all_tables_definition[$table], 'latin2' );
}
upgrade65_change_table_to_charset($table, $all_tables_definition[$table], 'utf8' );
$query = 'ALTER TABLE '.$table.' DEFAULT CHARACTER SET utf8';
pwg_query($query);
}
$upgrade_log .= "< conversion\tchange binary\n";
$upgrade_log .= "< conversion\tchange latin2\n";
$upgrade_log .= "< conversion\tchange utf8\n";
}
// +-----------------------------------------------------------------------+
// changes to write in database.inc.php
array_push($mysql_changes,
'define(\'PWG_CHARSET\', \''.$pwg_charset.'\');
define(\'DB_CHARSET\', \''.$db_charset.'\');
define(\'DB_COLLATE\', \'\');'
);
foreach ($all_langs as $old_lang=>$lang_data)
{
$query='
UPDATE '.USER_INFOS_TABLE.' SET language="'.$lang_data['new_lang'].'"
WHERE language="'.$old_lang.'"';
pwg_query($query);
}
define('PWG_CHARSET', $pwg_charset);
define('DB_CHARSET', $db_charset);
define('DB_COLLATE', '');
if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') and DB_CHARSET!='' )
{
pwg_query('SET NAMES "'.DB_CHARSET.'"');
}
echo $upgrade_log;
$fp = @fopen( PHPWG_ROOT_PATH.'upgrade65.log', 'w' );
if ($fp)
{
@fputs($fp, $upgrade_log, strlen($upgrade_log));
@fclose($fp);
}
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
}
else
{
echo 'PWG_CHARSET already defined - nada';
}
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add c13y_ignore config';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = "
INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('c13y_ignore',null,'List of ignored anomalies');
";
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Uninstall dew plugin';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = "
delete from ".PLUGINS_TABLE." where id ='dew';
";
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,40 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Change type from text to mediumtext for #sessions.data #user_cache.forbidden_categories and #user_cache.image_access_list';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = '
ALTER TABLE '.SESSIONS_TABLE.'
MODIFY COLUMN data MEDIUMTEXT NOT NULL';
pwg_query($query);
$query = '
ALTER TABLE '.USER_CACHE_TABLE.'
MODIFY COLUMN forbidden_categories MEDIUMTEXT,
MODIFY COLUMN image_access_list MEDIUMTEXT
';
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,43 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Move #categories.date_last and nb_images to #user_cache_categories';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = '
ALTER TABLE '.USER_CACHE_CATEGORIES_TABLE.'
ADD COLUMN date_last datetime default NULL AFTER cat_id,
ADD COLUMN nb_images mediumint(8) unsigned NOT NULL default 0 AFTER max_date_last';
pwg_query($query);
$query = '
ALTER TABLE '.CATEGORIES_TABLE.'
DROP COLUMN date_last,
DROP COLUMN nb_images
';
pwg_query($query);
invalidate_user_cache(); // just to force recalculation
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,38 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add upload config';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = "
replace into ".CONFIG_TABLE."
(param, value, comment)
values
('upload_link_everytime','false','Show Upload link every time'),
('upload_user_access',".ACCESS_CLASSIC.",'Minimal user status allowed to upload pictures')
;";
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,43 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Delete unnecessary #history_summary.id, #history.year, #history.month, #history.day and #history.hour';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = 'ALTER TABLE '.HISTORY_SUMMARY_TABLE.'
DROP PRIMARY KEY,
DROP COLUMN id,
ADD UNIQUE KEY history_summary_ymdh (`year`, `month`, `day`, `hour`)
;';
pwg_query($query);
$query = 'ALTER TABLE '.HISTORY_TABLE.'
DROP COLUMN year,
DROP COLUMN month,
DROP COLUMN day,
DROP COLUMN hour
;';
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add extents_for_templates config';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = "
INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('extents_for_templates','a:0:{}','Actived template-extension(s)');
";
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,31 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add #user_cache.cache_update_time';
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = '
ALTER TABLE '.USER_CACHE_TABLE.' ADD COLUMN `cache_update_time` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER need_update';
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,33 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add blk_menubar config';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = "
INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('blk_menubar','','Menubar options');
";
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,31 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add blk_menubar config';
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = 'DROP TABLE IF EXISTS '.$prefixeTable.'ws_access';
pwg_query($query);
$upgrade_description = $query;
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,31 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Add image_category.rank column';
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = 'ALTER TABLE '.IMAGE_CATEGORY_TABLE.' add column `rank` mediumint(8) unsigned default NULL';
pwg_query($query);
$upgrade_description = $query;
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>
@@ -0,0 +1,39 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'images.file categories.permalink old_permalinks.permalink - become binary';
// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+
$query = 'ALTER TABLE '.CATEGORIES_TABLE.'
MODIFY COLUMN permalink varchar(64) binary default NULL';
pwg_query($query);
$query = 'ALTER TABLE '.OLD_PERMALINKS_TABLE.'
MODIFY COLUMN permalink varchar(64) binary NOT NULL default ""';
pwg_query($query);
$query = 'ALTER TABLE '.IMAGES_TABLE.'
MODIFY COLUMN file varchar(255) binary NOT NULL default ""';
pwg_query($query);
echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;
?>

Some files were not shown because too many files have changed in this diff Show More