2007-03-29 00:06:13 +02:00
|
|
|
<?php
|
|
|
|
// +-----------------------------------------------------------------------+
|
2011-01-18 01:02:52 +01:00
|
|
|
// | Piwigo - a PHP based photo gallery |
|
2008-04-05 00:57:23 +02:00
|
|
|
// +-----------------------------------------------------------------------+
|
2016-01-14 12:17:58 +01:00
|
|
|
// | Copyright(C) 2008-2016 Piwigo Team http://piwigo.org |
|
2008-04-05 00:57:23 +02:00
|
|
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
|
|
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
|
|
|
// | the Free Software Foundation |
|
|
|
|
// | |
|
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
2007-03-29 00:06:13 +02:00
|
|
|
// | General Public License for more details. |
|
|
|
|
// | |
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
// | USA. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
define('PHPWG_ROOT_PATH', './');
|
|
|
|
|
2008-11-12 13:40:20 +01:00
|
|
|
// load config file
|
2011-12-19 21:25:42 +01:00
|
|
|
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
|
|
|
|
@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
|
|
|
|
defined('PWG_LOCAL_DIR') or define('PWG_LOCAL_DIR', 'local/');
|
2011-01-17 19:48:13 +01:00
|
|
|
|
|
|
|
$config_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'config/database.inc.php';
|
2008-11-12 13:40:20 +01:00
|
|
|
$config_file_contents = @file_get_contents($config_file);
|
|
|
|
if ($config_file_contents === false)
|
2008-11-06 15:44:51 +01:00
|
|
|
{
|
2008-11-12 13:40:20 +01:00
|
|
|
die('Cannot load '.$config_file);
|
|
|
|
}
|
|
|
|
$php_end_tag = strrpos($config_file_contents, '?'.'>');
|
|
|
|
if ($php_end_tag === false)
|
|
|
|
{
|
|
|
|
die('Cannot find php end tag in '.$config_file);
|
2008-11-06 15:44:51 +01:00
|
|
|
}
|
|
|
|
|
2011-01-17 19:48:13 +01:00
|
|
|
include($config_file);
|
2007-03-29 00:06:13 +02:00
|
|
|
|
2010-03-26 17:49:23 +01:00
|
|
|
// $conf is not used for users tables - define cannot be re-defined
|
|
|
|
define('USERS_TABLE', $prefixeTable.'users');
|
2007-03-29 00:06:13 +02:00
|
|
|
include_once(PHPWG_ROOT_PATH.'include/constants.php');
|
|
|
|
define('PREFIX_TABLE', $prefixeTable);
|
2010-04-28 16:28:05 +02:00
|
|
|
define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db');
|
2007-03-29 00:06:13 +02:00
|
|
|
|
2010-05-08 01:08:51 +02:00
|
|
|
include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');
|
|
|
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
2015-09-15 19:28:05 +02:00
|
|
|
include_once(PHPWG_ROOT_PATH . 'include/template.class.php');
|
2010-05-08 01:08:51 +02:00
|
|
|
|
2007-03-29 00:06:13 +02:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | functions |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
/**
|
|
|
|
* list all tables in an array
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function get_tables()
|
|
|
|
{
|
|
|
|
$tables = array();
|
2008-03-23 01:04:46 +01:00
|
|
|
|
2007-03-29 00:06:13 +02:00
|
|
|
$query = '
|
|
|
|
SHOW TABLES
|
|
|
|
;';
|
2008-11-19 16:44:04 +01:00
|
|
|
$result = pwg_query($query);
|
2007-03-29 00:06:13 +02:00
|
|
|
|
2009-11-20 15:17:04 +01:00
|
|
|
while ($row = pwg_db_fetch_row($result))
|
2007-03-29 00:06:13 +02:00
|
|
|
{
|
|
|
|
if (preg_match('/^'.PREFIX_TABLE.'/', $row[0]))
|
|
|
|
{
|
2013-10-19 19:43:04 +02:00
|
|
|
$tables[] = $row[0];
|
2007-03-29 00:06:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $tables;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* list all columns of each given table
|
|
|
|
*
|
|
|
|
* @return array of array
|
|
|
|
*/
|
|
|
|
function get_columns_of($tables)
|
|
|
|
{
|
|
|
|
$columns_of = array();
|
|
|
|
|
|
|
|
foreach ($tables as $table)
|
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
DESC '.$table.'
|
|
|
|
;';
|
2008-11-19 16:44:04 +01:00
|
|
|
$result = pwg_query($query);
|
2007-03-29 00:06:13 +02:00
|
|
|
|
|
|
|
$columns_of[$table] = array();
|
|
|
|
|
2009-11-20 15:17:04 +01:00
|
|
|
while ($row = pwg_db_fetch_row($result))
|
2007-03-29 00:06:13 +02:00
|
|
|
{
|
2013-10-19 19:43:04 +02:00
|
|
|
$columns_of[$table][] = $row[0];
|
2007-03-29 00:06:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $columns_of;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
function print_time($message)
|
|
|
|
{
|
|
|
|
global $last_time;
|
2008-03-23 01:04:46 +01:00
|
|
|
|
2007-03-29 00:06:13 +02:00
|
|
|
$new_time = get_moment();
|
|
|
|
echo '<pre>['.get_elapsed_time($last_time, $new_time).']';
|
|
|
|
echo ' '.$message;
|
|
|
|
echo '</pre>';
|
|
|
|
flush();
|
|
|
|
$last_time = $new_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | playing zone |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
// echo implode('<br>', get_tables());
|
|
|
|
// echo '<pre>'; print_r(get_columns_of(get_tables())); echo '</pre>';
|
|
|
|
|
|
|
|
// foreach (get_available_upgrade_ids() as $upgrade_id)
|
|
|
|
// {
|
|
|
|
// echo $upgrade_id, '<br>';
|
|
|
|
// }
|
|
|
|
|
2008-11-03 20:52:33 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | language |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2010-03-26 17:49:23 +01:00
|
|
|
include(PHPWG_ROOT_PATH . 'admin/include/languages.class.php');
|
|
|
|
$languages = new languages('utf-8');
|
2008-11-03 20:52:33 +01:00
|
|
|
if (isset($_GET['language']))
|
|
|
|
{
|
|
|
|
$language = strip_tags($_GET['language']);
|
2012-04-07 23:00:51 +02:00
|
|
|
|
|
|
|
if (!in_array($language, array_keys($languages->fs_languages)))
|
|
|
|
{
|
|
|
|
$language = PHPWG_DEFAULT_LANGUAGE;
|
|
|
|
}
|
2008-11-03 20:52:33 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$language = 'en_UK';
|
|
|
|
// Try to get browser language
|
2011-03-04 11:41:36 +01:00
|
|
|
foreach ($languages->fs_languages as $language_code => $fs_language)
|
2008-11-03 20:52:33 +01:00
|
|
|
{
|
|
|
|
if (substr($language_code,0,2) == @substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2))
|
|
|
|
{
|
|
|
|
$language = $language_code;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-16 17:57:10 +01:00
|
|
|
if ('fr_FR' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'fr.piwigo.org');
|
|
|
|
}
|
2010-03-21 22:59:56 +01:00
|
|
|
else if ('it_IT' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'it.piwigo.org');
|
|
|
|
}
|
|
|
|
else if ('de_DE' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'de.piwigo.org');
|
|
|
|
}
|
|
|
|
else if ('es_ES' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'es.piwigo.org');
|
|
|
|
}
|
2010-02-01 19:53:59 +01:00
|
|
|
else if ('pl_PL' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'pl.piwigo.org');
|
|
|
|
}
|
|
|
|
else if ('zh_CN' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'cn.piwigo.org');
|
|
|
|
}
|
2010-03-21 22:59:56 +01:00
|
|
|
else if ('hu_HU' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'hu.piwigo.org');
|
|
|
|
}
|
|
|
|
else if ('ru_RU' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'ru.piwigo.org');
|
|
|
|
}
|
2010-05-09 22:51:01 +02:00
|
|
|
else if ('nl_NL' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'nl.piwigo.org');
|
|
|
|
}
|
2013-03-03 23:28:40 +01:00
|
|
|
else if ('tr_TR' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'tr.piwigo.org');
|
|
|
|
}
|
|
|
|
else if ('da_DK' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'da.piwigo.org');
|
|
|
|
}
|
2013-05-09 14:24:30 +02:00
|
|
|
else if ('pt_BR' == $language) {
|
|
|
|
define('PHPWG_DOMAIN', 'br.piwigo.org');
|
|
|
|
}
|
2009-03-16 17:57:10 +01:00
|
|
|
else {
|
|
|
|
define('PHPWG_DOMAIN', 'piwigo.org');
|
|
|
|
}
|
|
|
|
define('PHPWG_URL', 'http://'.PHPWG_DOMAIN);
|
|
|
|
|
2008-11-06 15:44:51 +01:00
|
|
|
load_language( 'common.lang', '', array('language'=>$language, 'target_charset'=>'utf-8', 'no_fallback' => true) );
|
|
|
|
load_language( 'admin.lang', '', array('language'=>$language, 'target_charset'=>'utf-8', 'no_fallback' => true) );
|
2009-03-16 17:57:10 +01:00
|
|
|
load_language( 'install.lang', '', array('language'=>$language, 'target_charset'=>'utf-8', 'no_fallback' => true) );
|
2008-11-06 15:44:51 +01:00
|
|
|
load_language( 'upgrade.lang', '', array('language'=>$language, 'target_charset'=>'utf-8', 'no_fallback' => true) );
|
2009-03-16 17:57:10 +01:00
|
|
|
// check php version
|
|
|
|
if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<'))
|
|
|
|
{
|
|
|
|
include(PHPWG_ROOT_PATH.'install/php5_apache_configuration.php');
|
|
|
|
}
|
|
|
|
|
2010-03-26 17:49:23 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | database connection |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php');
|
|
|
|
include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$conf['dblayer'].'.inc.php');
|
|
|
|
|
|
|
|
upgrade_db_connect();
|
|
|
|
pwg_db_check_charset();
|
|
|
|
|
2010-04-28 16:28:05 +02:00
|
|
|
list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
|
|
|
|
define('CURRENT_DATE', $dbnow);
|
|
|
|
|
2007-03-29 00:06:13 +02:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | template initialization |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
2011-03-10 11:12:40 +01:00
|
|
|
$template = new Template(PHPWG_ROOT_PATH.'admin/themes', 'clear');
|
2007-03-29 00:06:13 +02:00
|
|
|
$template->set_filenames(array('upgrade'=>'upgrade.tpl'));
|
2009-03-16 17:57:10 +01:00
|
|
|
$template->assign(array(
|
|
|
|
'RELEASE' => PHPWG_VERSION,
|
2013-10-19 13:04:11 +02:00
|
|
|
'L_UPGRADE_HELP' => l10n('Need help ? Ask your question on <a href="%s">Piwigo message board</a>.', PHPWG_URL.'/forum'),
|
2009-03-16 17:57:10 +01:00
|
|
|
)
|
|
|
|
);
|
2007-03-29 00:06:13 +02:00
|
|
|
|
2012-06-14 23:46:47 +02:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | Remote sites are not compatible with Piwigo 2.4+ |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
$has_remote_site = false;
|
|
|
|
|
|
|
|
$query = 'SELECT galleries_url FROM '.SITES_TABLE.';';
|
|
|
|
$result = pwg_query($query);
|
|
|
|
while ($row = pwg_db_fetch_assoc($result))
|
|
|
|
{
|
|
|
|
if (url_is_remote($row['galleries_url']))
|
|
|
|
{
|
|
|
|
$has_remote_site = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($has_remote_site)
|
|
|
|
{
|
|
|
|
include_once(PHPWG_ROOT_PATH.'admin/include/updates.class.php');
|
|
|
|
include_once(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
|
|
|
|
|
|
|
|
$page['errors'] = array();
|
|
|
|
$step = 3;
|
|
|
|
updates::upgrade_to('2.3.4', $step, false);
|
|
|
|
|
|
|
|
if (!empty($page['errors']))
|
|
|
|
{
|
|
|
|
echo '<ul>';
|
|
|
|
foreach ($page['errors'] as $error)
|
|
|
|
{
|
|
|
|
echo '<li>'.$error.'</li>';
|
|
|
|
}
|
|
|
|
echo '</ul>';
|
|
|
|
}
|
|
|
|
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2007-03-29 00:06:13 +02:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | upgrade choice |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
2007-05-04 23:56:58 +02:00
|
|
|
$tables = get_tables();
|
|
|
|
$columns_of = get_columns_of($tables);
|
|
|
|
|
2008-11-06 15:44:51 +01:00
|
|
|
// find the current release
|
|
|
|
if (!in_array('param', $columns_of[PREFIX_TABLE.'config']))
|
2007-03-29 00:06:13 +02:00
|
|
|
{
|
2008-11-06 15:44:51 +01:00
|
|
|
// we're in branch 1.3, important upgrade, isn't it?
|
|
|
|
if (in_array(PREFIX_TABLE.'user_category', $tables))
|
2007-03-29 00:06:13 +02:00
|
|
|
{
|
2008-11-06 15:44:51 +01:00
|
|
|
$current_release = '1.3.1';
|
2007-03-29 00:06:13 +02:00
|
|
|
}
|
2008-11-06 15:44:51 +01:00
|
|
|
else
|
2007-03-29 00:06:13 +02:00
|
|
|
{
|
2008-11-06 15:44:51 +01:00
|
|
|
$current_release = '1.3.0';
|
2007-03-29 00:06:13 +02:00
|
|
|
}
|
2008-11-06 15:44:51 +01:00
|
|
|
}
|
|
|
|
else if (!in_array(PREFIX_TABLE.'user_cache', $tables))
|
|
|
|
{
|
|
|
|
$current_release = '1.4.0';
|
|
|
|
}
|
|
|
|
else if (!in_array(PREFIX_TABLE.'tags', $tables))
|
|
|
|
{
|
|
|
|
$current_release = '1.5.0';
|
|
|
|
}
|
2008-11-11 14:41:27 +01:00
|
|
|
else if ( !in_array(PREFIX_TABLE.'plugins', $tables) )
|
2008-11-06 15:44:51 +01:00
|
|
|
{
|
|
|
|
if (!in_array('auto_login_key', $columns_of[PREFIX_TABLE.'user_infos']))
|
2008-10-17 22:39:30 +02:00
|
|
|
{
|
2008-11-06 15:44:51 +01:00
|
|
|
$current_release = '1.6.0';
|
2008-10-17 22:39:30 +02:00
|
|
|
}
|
2007-03-29 00:06:13 +02:00
|
|
|
else
|
|
|
|
{
|
2008-11-06 15:44:51 +01:00
|
|
|
$current_release = '1.6.2';
|
2007-03-29 00:06:13 +02:00
|
|
|
}
|
2008-11-06 15:44:51 +01:00
|
|
|
}
|
|
|
|
else if (!in_array('md5sum', $columns_of[PREFIX_TABLE.'images']))
|
|
|
|
{
|
|
|
|
$current_release = '1.7.0';
|
|
|
|
}
|
2010-04-28 16:28:05 +02:00
|
|
|
else if (!in_array(PREFIX_TABLE.'themes', $tables))
|
|
|
|
{
|
|
|
|
$current_release = '2.0.0';
|
|
|
|
}
|
2011-03-10 11:04:52 +01:00
|
|
|
else if (!in_array('added_by', $columns_of[PREFIX_TABLE.'images']))
|
|
|
|
{
|
|
|
|
$current_release = '2.1.0';
|
|
|
|
}
|
2011-10-02 00:56:33 +02:00
|
|
|
else if (!in_array('rating_score', $columns_of[PREFIX_TABLE.'images']))
|
|
|
|
{
|
|
|
|
$current_release = '2.2.0';
|
|
|
|
}
|
2013-03-02 22:02:42 +01:00
|
|
|
else if (!in_array('rotation', $columns_of[PREFIX_TABLE.'images']))
|
|
|
|
{
|
|
|
|
$current_release = '2.3.0';
|
|
|
|
}
|
2014-01-02 16:04:16 +01:00
|
|
|
else if (!in_array('website_url', $columns_of[PREFIX_TABLE.'comments']))
|
|
|
|
{
|
|
|
|
$current_release = '2.4.0';
|
|
|
|
}
|
2014-09-20 13:43:01 +02:00
|
|
|
else if (!in_array('nb_available_tags', $columns_of[PREFIX_TABLE.'user_cache']))
|
|
|
|
{
|
|
|
|
$current_release = '2.5.0';
|
|
|
|
}
|
2016-02-23 10:44:32 +01:00
|
|
|
else if (!in_array('activation_key_expire', $columns_of[PREFIX_TABLE.'user_infos']))
|
|
|
|
{
|
|
|
|
$current_release = '2.6.0';
|
|
|
|
}
|
2008-11-06 15:44:51 +01:00
|
|
|
else
|
|
|
|
{
|
2012-07-03 00:28:50 +02:00
|
|
|
// retrieve already applied upgrades
|
|
|
|
$query = '
|
|
|
|
SELECT id
|
|
|
|
FROM '.PREFIX_TABLE.'upgrade
|
|
|
|
;';
|
|
|
|
$applied_upgrades = array_from_query($query, 'id');
|
|
|
|
|
2016-02-23 10:44:32 +01:00
|
|
|
if (!in_array(148, $applied_upgrades))
|
2012-07-03 00:28:50 +02:00
|
|
|
{
|
2016-02-23 10:44:32 +01:00
|
|
|
$current_release = '2.7.0';
|
2012-07-03 00:28:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// confirm that the database is in the same version as source code files
|
|
|
|
conf_update_param('piwigo_db_version', get_branch_from_version(PHPWG_VERSION));
|
2014-01-02 16:04:16 +01:00
|
|
|
|
|
|
|
header('Content-Type: text/html; charset='.get_pwg_charset());
|
2012-07-03 00:28:50 +02:00
|
|
|
echo 'No upgrade required, the database structure is up to date';
|
|
|
|
echo '<br><a href="index.php">← back to gallery</a>';
|
|
|
|
exit();
|
|
|
|
}
|
2007-03-29 00:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | upgrade launch |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2008-11-06 15:44:51 +01:00
|
|
|
$page['infos'] = array();
|
|
|
|
$page['errors'] = array();
|
2008-11-12 13:40:20 +01:00
|
|
|
$mysql_changes = array();
|
2007-03-29 00:06:13 +02:00
|
|
|
|
2010-05-08 01:08:51 +02:00
|
|
|
check_upgrade_access_rights();
|
2008-03-06 01:25:47 +01:00
|
|
|
|
2010-05-08 01:08:51 +02:00
|
|
|
if ((isset($_POST['submit']) or isset($_GET['now']))
|
|
|
|
and check_upgrade())
|
2008-11-06 15:44:51 +01:00
|
|
|
{
|
|
|
|
$upgrade_file = PHPWG_ROOT_PATH.'install/upgrade_'.$current_release.'.php';
|
2007-03-29 00:06:13 +02:00
|
|
|
if (is_file($upgrade_file))
|
|
|
|
{
|
2014-09-20 13:43:01 +02:00
|
|
|
// reset SQL counters
|
|
|
|
$page['queries_time'] = 0;
|
|
|
|
$page['count_queries'] = 0;
|
|
|
|
|
2007-03-29 00:06:13 +02:00
|
|
|
$page['upgrade_start'] = get_moment();
|
|
|
|
$conf['die_on_sql_error'] = false;
|
|
|
|
include($upgrade_file);
|
2011-06-26 00:03:12 +02:00
|
|
|
conf_update_param('piwigo_db_version', get_branch_from_version(PHPWG_VERSION));
|
2007-03-29 00:06:13 +02:00
|
|
|
|
2010-03-21 13:32:49 +01:00
|
|
|
// Something to add in database.inc.php?
|
2008-11-12 13:40:20 +01:00
|
|
|
if (!empty($mysql_changes))
|
|
|
|
{
|
|
|
|
$config_file_contents =
|
|
|
|
substr($config_file_contents, 0, $php_end_tag) . "\r\n"
|
2008-11-12 14:49:13 +01:00
|
|
|
. implode("\r\n" , $mysql_changes) . "\r\n"
|
2008-11-12 13:40:20 +01:00
|
|
|
. substr($config_file_contents, $php_end_tag);
|
|
|
|
|
|
|
|
if (!@file_put_contents($config_file, $config_file_contents))
|
|
|
|
{
|
2013-10-19 19:43:04 +02:00
|
|
|
$page['infos'][] = l10n(
|
|
|
|
'In <i>%s</i>, before <b>?></b>, insert:',
|
|
|
|
PWG_LOCAL_DIR.'config/database.inc.php'
|
|
|
|
)
|
|
|
|
.'<p><textarea rows="4" cols="40">'
|
|
|
|
.implode("\r\n" , $mysql_changes).'</textarea></p>';
|
2008-11-12 13:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-22 14:55:01 +02:00
|
|
|
// Deactivate non standard extensions
|
|
|
|
deactivate_non_standard_plugins();
|
2011-03-10 11:50:11 +01:00
|
|
|
deactivate_non_standard_themes();
|
2012-04-17 16:09:05 +02:00
|
|
|
deactivate_templates();
|
2011-03-10 11:50:11 +01:00
|
|
|
|
2007-03-29 00:06:13 +02:00
|
|
|
$page['upgrade_end'] = get_moment();
|
|
|
|
|
2008-03-06 01:25:47 +01:00
|
|
|
$template->assign(
|
2007-03-29 00:06:13 +02:00
|
|
|
'upgrade',
|
|
|
|
array(
|
2008-11-06 15:44:51 +01:00
|
|
|
'VERSION' => $current_release,
|
2007-03-29 00:06:13 +02:00
|
|
|
'TOTAL_TIME' => get_elapsed_time(
|
|
|
|
$page['upgrade_start'],
|
|
|
|
$page['upgrade_end']
|
|
|
|
),
|
|
|
|
'SQL_TIME' => number_format(
|
|
|
|
$page['queries_time'],
|
|
|
|
3,
|
|
|
|
'.',
|
|
|
|
' '
|
|
|
|
).' s',
|
|
|
|
'NB_QUERIES' => $page['count_queries']
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2013-10-19 19:43:04 +02:00
|
|
|
$page['infos'][] = l10n('Perform a maintenance check in [Administration>Tools>Maintenance] if you encounter any problem.');
|
2008-03-23 01:04:46 +01:00
|
|
|
|
2009-01-13 19:53:00 +01:00
|
|
|
// Save $page['infos'] in order to restore after maintenance actions
|
|
|
|
$page['infos_sav'] = $page['infos'];
|
|
|
|
$page['infos'] = array();
|
|
|
|
|
2014-04-16 22:45:31 +02:00
|
|
|
$query = '
|
|
|
|
REPLACE INTO '.PLUGINS_TABLE.'
|
|
|
|
(id, state)
|
|
|
|
VALUES (\'TakeATour\', \'active\')
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
|
2014-09-20 13:43:01 +02:00
|
|
|
$template->assign(
|
|
|
|
array(
|
|
|
|
'button_label' => l10n('Home'),
|
|
|
|
'button_link' => 'index.php',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// if the webmaster has a session, let's give a link to discover new features
|
|
|
|
if (!empty($_SESSION['pwg_uid']))
|
|
|
|
{
|
|
|
|
$version_ = str_replace('.', '_', get_branch_from_version(PHPWG_VERSION).'.0');
|
|
|
|
|
|
|
|
if (file_exists(PHPWG_PLUGINS_PATH .'TakeATour/tours/'.$version_.'/config.inc.php'))
|
|
|
|
{
|
|
|
|
// we need the secret key for get_pwg_token()
|
|
|
|
load_conf_from_db();
|
|
|
|
|
|
|
|
$template->assign(
|
|
|
|
array(
|
2016-06-06 16:39:29 +02:00
|
|
|
'button_label' => l10n('Discover what\'s new in Piwigo %s', get_branch_from_version(PHPWG_VERSION)),
|
2014-09-20 13:43:01 +02:00
|
|
|
'button_link' => 'admin.php?submited_tour_path=tours/'.$version_.'&pwg_token='.get_pwg_token(),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-19 21:03:49 +01:00
|
|
|
// Delete cache data
|
|
|
|
invalidate_user_cache(true);
|
|
|
|
$template->delete_compiled_templates();
|
|
|
|
|
2009-01-13 19:53:00 +01:00
|
|
|
// Restore $page['infos'] in order to hide informations messages from functions calles
|
|
|
|
// errors messages are not hide
|
|
|
|
$page['infos'] = $page['infos_sav'];
|
|
|
|
|
2007-03-29 00:06:13 +02:00
|
|
|
}
|
2008-11-06 15:44:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | start template output |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
else
|
|
|
|
{
|
2010-04-28 16:28:05 +02:00
|
|
|
if (!defined('PWG_CHARSET'))
|
|
|
|
{
|
|
|
|
define('PWG_CHARSET', 'utf-8');
|
|
|
|
}
|
|
|
|
|
|
|
|
include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php');
|
|
|
|
$languages = new languages();
|
|
|
|
|
2011-03-04 11:41:36 +01:00
|
|
|
foreach ($languages->fs_languages as $language_code => $fs_language)
|
2007-03-29 00:06:13 +02:00
|
|
|
{
|
2008-11-06 15:44:51 +01:00
|
|
|
if ($language == $language_code)
|
|
|
|
{
|
|
|
|
$template->assign('language_selection', $language_code);
|
|
|
|
}
|
2011-03-04 11:41:36 +01:00
|
|
|
$languages_options[$language_code] = $fs_language['name'];
|
2007-03-29 00:06:13 +02:00
|
|
|
}
|
2008-11-06 15:44:51 +01:00
|
|
|
$template->assign('language_options', $languages_options);
|
|
|
|
|
|
|
|
$template->assign('introduction', array(
|
|
|
|
'CURRENT_RELEASE' => $current_release,
|
|
|
|
'F_ACTION' => 'upgrade.php?language=' . $language));
|
|
|
|
|
|
|
|
if (!check_upgrade())
|
|
|
|
{
|
|
|
|
$template->assign('login', true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count($page['errors']) != 0)
|
|
|
|
{
|
|
|
|
$template->assign('errors', $page['errors']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count($page['infos']) != 0)
|
|
|
|
{
|
|
|
|
$template->assign('infos', $page['infos']);
|
2007-03-29 00:06:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | sending html code |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
$template->pparse('upgrade');
|
|
|
|
?>
|