aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2006-04-20 19:31:12 +0000
committerplegall <plg@piwigo.org>2006-04-20 19:31:12 +0000
commitc64da384ea354a194cfdcbd552340261b5d547d9 (patch)
treecb0f49c53ec9c918e453b7f0dbfed757121a6743
parentc4b59049c205677432e69c585e003c5bea1c85e6 (diff)
partial merge -r1173:1174 from branch-1_6 to trunk: new configuration
parameter die_on_sql_error (upgrade.php and install/upgrade_*.php not concerned on BSF) partial merge -r1208:1209 from branch-1_6 to trunk (only bug fix on incorrect insertion of complex upgrade identifiers) deletions: upgrade.php and all install/upgrade_*.php because these script are never up to date on BSF. Anyway, they are only required on a stable branch. git-svn-id: http://piwigo.org/svn/trunk@1221 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--include/config_default.inc.php3
-rw-r--r--include/functions.inc.php12
-rw-r--r--install.php24
-rw-r--r--install/upgrade_1.4.0.php302
-rw-r--r--install/upgrade_1.4.1.php302
-rw-r--r--template/yoga/upgrade.tpl45
-rw-r--r--upgrade.php213
7 files changed, 31 insertions, 870 deletions
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index e441de35a..0a5a8e551 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -333,6 +333,9 @@ $conf['show_gt'] = true;
// accessed
$conf['debug_l10n'] = false;
+// die_on_sql_error: if an SQL query fails, should everything stop?
+$conf['die_on_sql_error'] = true;
+
// +-----------------------------------------------------------------------+
// | authentication |
// +-----------------------------------------------------------------------+
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 5e5b1ab9c..35b1e7935 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -651,12 +651,22 @@ function get_thumbnail_src($path, $tn_ext = '', $with_rewrite = true)
// error occured for the last mysql query.
function my_error($header)
{
+ global $conf;
+
$error = '<pre>';
$error.= $header;
$error.= '[mysql error '.mysql_errno().'] ';
$error.= mysql_error();
$error.= '</pre>';
- die ($error);
+
+ if ($conf['die_on_sql_error'])
+ {
+ die($error);
+ }
+ else
+ {
+ echo $error;
+ }
}
/**
diff --git a/install.php b/install.php
index 8fe5b03ae..70d698147 100644
--- a/install.php
+++ b/install.php
@@ -166,6 +166,7 @@ include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
include(PHPWG_ROOT_PATH . 'include/constants.php');
include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
+include(PHPWG_ROOT_PATH . 'admin/include/functions.php');
include(PHPWG_ROOT_PATH . 'include/template.php');
if ( isset( $_POST['language'] ))
@@ -332,16 +333,25 @@ INSERT INTO '.USER_INFOS_TABLE.'
// Available upgrades must be ignored after a fresh installation. To
// make PWG avoid upgrading, we must tell it upgrades have already been
// made.
+ list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
+ define('CURRENT_DATE', $dbnow);
+ $datas = array();
foreach (get_available_upgrade_ids() as $upgrade_id)
{
- $query = '
-INSERT INTO '.UPGRADE_TABLE.'
- (id, applied, description)
- VALUES
- ('.$upgrade_id.', NOW(), \'upgrade included in installation\')
-';
- mysql_query($query);
+ array_push(
+ $datas,
+ array(
+ 'id' => $upgrade_id,
+ 'applied' => CURRENT_DATE,
+ 'description' => 'upgrade included in installation',
+ )
+ );
}
+ mass_inserts(
+ UPGRADE_TABLE,
+ array_keys($datas[0]),
+ $datas
+ );
}
}
diff --git a/install/upgrade_1.4.0.php b/install/upgrade_1.4.0.php
deleted file mode 100644
index a5f8f38c6..000000000
--- a/install/upgrade_1.4.0.php
+++ /dev/null
@@ -1,302 +0,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | PhpWebGallery - a PHP based picture gallery |
-// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
-// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
-// | file : $RCSfile$
-// | last update : $Date$
-// | last modifier : $Author$
-// | revision : $Revision$
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify |
-// | it under the terms of the GNU General Public License as published by |
-// | the Free Software Foundation |
-// | |
-// | This program is distributed in the hope that it will be useful, but |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
-// | General Public License for more details. |
-// | |
-// | You should have received a copy of the GNU General Public License |
-// | along with this program; if not, write to the Free Software |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA. |
-// +-----------------------------------------------------------------------+
-
-if (!defined('PHPWG_ROOT_PATH'))
-{
- die ('This page cannot be loaded directly, load upgrade.php');
-}
-else
-{
- if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
- {
- die ('Hacking attempt!');
- }
-}
-
-$last_time = get_moment();
-
-// will the user have to edit include/config_local.inc.php for
-// prefix_thumbnail configuration parameter
-$query = '
-SELECT value
- FROM '.CONFIG_TABLE.'
- WHERE param = \'prefix_thumbnail\'
-;';
-list($prefix_thumbnail) = mysql_fetch_array(pwg_query($query));
-
-// delete obsolete configuration
-$query = '
-DELETE
- FROM '.PREFIX_TABLE.'config
- WHERE param IN (
- \'prefix_thumbnail\',
- \'mail_webmaster\',
- \'upload_maxfilesize\',
- \'upload_maxwidth\',
- \'upload_maxheight\',
- \'upload_maxwidth_thumbnail\',
- \'upload_maxheight_thumbnail\',
- \'mail_notification\',
- \'use_iptc\',
- \'use_exif\',
- \'show_iptc\',
- \'show_exif\',
- \'authorize_remembering\'
- )
-;';
-mysql_query($query);
-
-$queries = array(
-
- "
-ALTER TABLE phpwebgallery_categories
- CHANGE COLUMN date_last date_last datetime default NULL
-;",
-
- "
-ALTER TABLE phpwebgallery_comments
- ADD COLUMN validation_date datetime default NULL
-;",
-
- "
-UPDATE phpwebgallery_comments
- SET validation_date = date
-",
-
- "
-ALTER TABLE phpwebgallery_comments
- ADD INDEX comments_i1 (image_id)
-;",
-
- "
-ALTER TABLE phpwebgallery_comments
- ADD INDEX comments_i2 (validation_date)
-;",
-
- "
-ALTER TABLE phpwebgallery_favorites
- CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
-;",
-
- "
-ALTER TABLE phpwebgallery_images
- CHANGE COLUMN date_available
- date_available datetime NOT NULL default '0000-00-00 00:00:00'
-;",
-
- "
-ALTER TABLE phpwebgallery_rate
- CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
-;",
-
- "
-ALTER TABLE phpwebgallery_sessions
- CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
-;",
-
- "
-ALTER TABLE phpwebgallery_user_access
- CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
-;",
-
- "
-DROP TABLE phpwebgallery_user_forbidden
-;",
-
- "
-ALTER TABLE phpwebgallery_user_group
- CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
-;",
-
- "
-ALTER TABLE phpwebgallery_users
- CHANGE COLUMN id id smallint(5) NOT NULL auto_increment
-;",
-
- "
-CREATE TABLE phpwebgallery_caddie (
- user_id smallint(5) NOT NULL default '0',
- element_id mediumint(8) NOT NULL default '0',
- PRIMARY KEY (user_id,element_id)
-) TYPE=MyISAM
-;",
-
- "
-CREATE TABLE phpwebgallery_user_cache (
- user_id smallint(5) NOT NULL default '0',
- need_update enum('true','false') NOT NULL default 'true',
- forbidden_categories text,
- PRIMARY KEY (user_id)
-) TYPE=MyISAM
-;",
-
- "
-CREATE TABLE phpwebgallery_user_feed (
- id varchar(50) binary NOT NULL default '',
- user_id smallint(5) NOT NULL default '0',
- last_check datetime default NULL,
- PRIMARY KEY (id)
-) TYPE=MyISAM
-;",
-
- "
-CREATE TABLE phpwebgallery_user_infos (
- user_id smallint(5) NOT NULL default '0',
- nb_image_line tinyint(1) unsigned NOT NULL default '5',
- nb_line_page tinyint(3) unsigned NOT NULL default '3',
- status enum('admin','guest') NOT NULL default 'guest',
- language varchar(50) NOT NULL default 'english',
- maxwidth smallint(6) default NULL,
- maxheight smallint(6) default NULL,
- expand enum('true','false') NOT NULL default 'false',
- show_nb_comments enum('true','false') NOT NULL default 'false',
- recent_period tinyint(3) unsigned NOT NULL default '7',
- template varchar(255) NOT NULL default 'yoga',
- registration_date datetime NOT NULL default '0000-00-00 00:00:00',
- UNIQUE KEY user_infos_ui1 (user_id)
-) TYPE=MyISAM
-;"
- );
-
-foreach ($queries as $query)
-{
- $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
- pwg_query($query);
-}
-
-$new_time = get_moment();
-echo '<pre>['.get_elapsed_time($last_time, $new_time).']';
-echo ' Basic database structure upgrade done</pre>';
-flush();
-$last_time = $new_time;
-
-// user datas migration from phpwebgallery_users to phpwebgallery_user_infos
-$query = '
-SELECT *
- FROM '.USERS_TABLE.'
-;';
-
-$datas = array();
-list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
-
-$result = pwg_query($query);
-while ($row = mysql_fetch_array($result))
-{
- $row['user_id'] = $row['id'];
- $row['registration_date'] = $dbnow;
- array_push($datas, $row);
-}
-
-include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
-mass_inserts(
- USER_INFOS_TABLE,
- array(
- 'user_id',
- 'nb_image_line',
- 'nb_line_page',
- 'status',
- 'language',
- 'maxwidth',
- 'maxheight',
- 'expand',
- 'show_nb_comments',
- 'recent_period',
- 'template',
- 'registration_date'
- ),
- $datas
- );
-
-$queries = array(
-
- "
-UPDATE ".USER_INFOS_TABLE."
- SET template = 'yoga'
-;",
-
- "
-UPDATE ".USER_INFOS_TABLE."
- SET language = 'en_UK.iso-8859-1'
- WHERE language NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
-;",
-
- "
-UPDATE ".CONFIG_TABLE."
- SET value = 'en_UK.iso-8859-1'
- WHERE param = 'default_language'
- AND value NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
-;",
-
- "
-UPDATE ".CONFIG_TABLE."
- SET value = 'yoga'
- WHERE param = 'default_template'
-;",
-
- "
-INSERT INTO ".CONFIG_TABLE."
- (param,value,comment)
- VALUES
- (
- 'gallery_title',
- 'PhpWebGallery demonstration site',
- 'Title at top of each page and for RSS feed'
- )
-;",
-
- "
-INSERT INTO ".CONFIG_TABLE."
- (param,value,comment)
- VALUES
- (
- 'gallery_description',
- 'My photos web site',
- 'Short description displayed with gallery title'
- )
-;"
-
- );
-
-foreach ($queries as $query)
-{
- $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
- pwg_query($query);
-}
-
-$infos = array();
-
-if ($prefix_thumbnail != 'TN-')
-{
- array_push(
- $infos,
- 'the thumbnail prefix configuration parameter was moved to configuration
-file, copy config_local.inc.php from "tools" directory to "include" directory
-and edit $conf[\'prefix_thumbnail\'] = '.$prefix_thumbnail
- );
-}
-
-?> \ No newline at end of file
diff --git a/install/upgrade_1.4.1.php b/install/upgrade_1.4.1.php
deleted file mode 100644
index a5f8f38c6..000000000
--- a/install/upgrade_1.4.1.php
+++ /dev/null
@@ -1,302 +0,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | PhpWebGallery - a PHP based picture gallery |
-// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
-// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
-// | file : $RCSfile$
-// | last update : $Date$
-// | last modifier : $Author$
-// | revision : $Revision$
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify |
-// | it under the terms of the GNU General Public License as published by |
-// | the Free Software Foundation |
-// | |
-// | This program is distributed in the hope that it will be useful, but |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
-// | General Public License for more details. |
-// | |
-// | You should have received a copy of the GNU General Public License |
-// | along with this program; if not, write to the Free Software |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA. |
-// +-----------------------------------------------------------------------+
-
-if (!defined('PHPWG_ROOT_PATH'))
-{
- die ('This page cannot be loaded directly, load upgrade.php');
-}
-else
-{
- if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
- {
- die ('Hacking attempt!');
- }
-}
-
-$last_time = get_moment();
-
-// will the user have to edit include/config_local.inc.php for
-// prefix_thumbnail configuration parameter
-$query = '
-SELECT value
- FROM '.CONFIG_TABLE.'
- WHERE param = \'prefix_thumbnail\'
-;';
-list($prefix_thumbnail) = mysql_fetch_array(pwg_query($query));
-
-// delete obsolete configuration
-$query = '
-DELETE
- FROM '.PREFIX_TABLE.'config
- WHERE param IN (
- \'prefix_thumbnail\',
- \'mail_webmaster\',
- \'upload_maxfilesize\',
- \'upload_maxwidth\',
- \'upload_maxheight\',
- \'upload_maxwidth_thumbnail\',
- \'upload_maxheight_thumbnail\',
- \'mail_notification\',
- \'use_iptc\',
- \'use_exif\',
- \'show_iptc\',
- \'show_exif\',
- \'authorize_remembering\'
- )
-;';
-mysql_query($query);
-
-$queries = array(
-
- "
-ALTER TABLE phpwebgallery_categories
- CHANGE COLUMN date_last date_last datetime default NULL
-;",
-
- "
-ALTER TABLE phpwebgallery_comments
- ADD COLUMN validation_date datetime default NULL
-;",
-
- "
-UPDATE phpwebgallery_comments
- SET validation_date = date
-",
-
- "
-ALTER TABLE phpwebgallery_comments
- ADD INDEX comments_i1 (image_id)
-;",
-
- "
-ALTER TABLE phpwebgallery_comments
- ADD INDEX comments_i2 (validation_date)
-;",
-
- "
-ALTER TABLE phpwebgallery_favorites
- CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
-;",
-
- "
-ALTER TABLE phpwebgallery_images
- CHANGE COLUMN date_available
- date_available datetime NOT NULL default '0000-00-00 00:00:00'
-;",
-
- "
-ALTER TABLE phpwebgallery_rate
- CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
-;",
-
- "
-ALTER TABLE phpwebgallery_sessions
- CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
-;",
-
- "
-ALTER TABLE phpwebgallery_user_access
- CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
-;",
-
- "
-DROP TABLE phpwebgallery_user_forbidden
-;",
-
- "
-ALTER TABLE phpwebgallery_user_group
- CHANGE COLUMN user_id user_id smallint(5) NOT NULL default '0'
-;",
-
- "
-ALTER TABLE phpwebgallery_users
- CHANGE COLUMN id id smallint(5) NOT NULL auto_increment
-;",
-
- "
-CREATE TABLE phpwebgallery_caddie (
- user_id smallint(5) NOT NULL default '0',
- element_id mediumint(8) NOT NULL default '0',
- PRIMARY KEY (user_id,element_id)
-) TYPE=MyISAM
-;",
-
- "
-CREATE TABLE phpwebgallery_user_cache (
- user_id smallint(5) NOT NULL default '0',
- need_update enum('true','false') NOT NULL default 'true',
- forbidden_categories text,
- PRIMARY KEY (user_id)
-) TYPE=MyISAM
-;",
-
- "
-CREATE TABLE phpwebgallery_user_feed (
- id varchar(50) binary NOT NULL default '',
- user_id smallint(5) NOT NULL default '0',
- last_check datetime default NULL,
- PRIMARY KEY (id)
-) TYPE=MyISAM
-;",
-
- "
-CREATE TABLE phpwebgallery_user_infos (
- user_id smallint(5) NOT NULL default '0',
- nb_image_line tinyint(1) unsigned NOT NULL default '5',
- nb_line_page tinyint(3) unsigned NOT NULL default '3',
- status enum('admin','guest') NOT NULL default 'guest',
- language varchar(50) NOT NULL default 'english',
- maxwidth smallint(6) default NULL,
- maxheight smallint(6) default NULL,
- expand enum('true','false') NOT NULL default 'false',
- show_nb_comments enum('true','false') NOT NULL default 'false',
- recent_period tinyint(3) unsigned NOT NULL default '7',
- template varchar(255) NOT NULL default 'yoga',
- registration_date datetime NOT NULL default '0000-00-00 00:00:00',
- UNIQUE KEY user_infos_ui1 (user_id)
-) TYPE=MyISAM
-;"
- );
-
-foreach ($queries as $query)
-{
- $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
- pwg_query($query);
-}
-
-$new_time = get_moment();
-echo '<pre>['.get_elapsed_time($last_time, $new_time).']';
-echo ' Basic database structure upgrade done</pre>';
-flush();
-$last_time = $new_time;
-
-// user datas migration from phpwebgallery_users to phpwebgallery_user_infos
-$query = '
-SELECT *
- FROM '.USERS_TABLE.'
-;';
-
-$datas = array();
-list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
-
-$result = pwg_query($query);
-while ($row = mysql_fetch_array($result))
-{
- $row['user_id'] = $row['id'];
- $row['registration_date'] = $dbnow;
- array_push($datas, $row);
-}
-
-include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
-mass_inserts(
- USER_INFOS_TABLE,
- array(
- 'user_id',
- 'nb_image_line',
- 'nb_line_page',
- 'status',
- 'language',
- 'maxwidth',
- 'maxheight',
- 'expand',
- 'show_nb_comments',
- 'recent_period',
- 'template',
- 'registration_date'
- ),
- $datas
- );
-
-$queries = array(
-
- "
-UPDATE ".USER_INFOS_TABLE."
- SET template = 'yoga'
-;",
-
- "
-UPDATE ".USER_INFOS_TABLE."
- SET language = 'en_UK.iso-8859-1'
- WHERE language NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
-;",
-
- "
-UPDATE ".CONFIG_TABLE."
- SET value = 'en_UK.iso-8859-1'
- WHERE param = 'default_language'
- AND value NOT IN ('en_UK.iso-8859-1', 'fr_FR.iso-8859-1')
-;",
-
- "
-UPDATE ".CONFIG_TABLE."
- SET value = 'yoga'
- WHERE param = 'default_template'
-;",
-
- "
-INSERT INTO ".CONFIG_TABLE."
- (param,value,comment)
- VALUES
- (
- 'gallery_title',
- 'PhpWebGallery demonstration site',
- 'Title at top of each page and for RSS feed'
- )
-;",
-
- "
-INSERT INTO ".CONFIG_TABLE."
- (param,value,comment)
- VALUES
- (
- 'gallery_description',
- 'My photos web site',
- 'Short description displayed with gallery title'
- )
-;"
-
- );
-
-foreach ($queries as $query)
-{
- $query = str_replace('phpwebgallery_', PREFIX_TABLE, $query);
- pwg_query($query);
-}
-
-$infos = array();
-
-if ($prefix_thumbnail != 'TN-')
-{
- array_push(
- $infos,
- 'the thumbnail prefix configuration parameter was moved to configuration
-file, copy config_local.inc.php from "tools" directory to "include" directory
-and edit $conf[\'prefix_thumbnail\'] = '.$prefix_thumbnail
- );
-}
-
-?> \ No newline at end of file
diff --git a/template/yoga/upgrade.tpl b/template/yoga/upgrade.tpl
deleted file mode 100644
index 40b2ede4c..000000000
--- a/template/yoga/upgrade.tpl
+++ /dev/null
@@ -1,45 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <title>PhpWebGallery : Upgrade to {RELEASE}</title>
- </head>
-
- <body>
- <!-- BEGIN choices -->
- <h1>Welcome to PhpWebGallery upgrade page.</h1>
- <p>This page proposes to upgrade your database corresponding to your old version
- of PhpWebGallery to the current version. Select the version you wish to upgrade
- :</p>
-
- <ul>
- <!-- BEGIN choice -->
- <li><a href="{choices.choice.URL}">{choices.choice.VERSION}</a></li>
- <!-- END choice -->
- </ul>
- <!-- END choices -->
-
- <!-- BEGIN upgrade -->
- <h1>Upgrade from version {upgrade.VERSION} to {RELEASE}</h1>
-
- <p>Statistics</p>
- <ul>
- <li>total upgrade time : {upgrade.TOTAL_TIME}</li>
- <li>total SQL time : {upgrade.SQL_TIME}</li>
- <li>SQL queries : {upgrade.NB_QUERIES}</li>
- </ul>
-
- <!-- BEGIN infos -->
- <p>Upgrade informations</p>
-
- <ul>
- <!-- BEGIN info -->
- <li>{upgrade.infos.info.CONTENT}</li>
- <!-- END info -->
- </ul>
- <!-- END infos -->
- <!-- END upgrade -->
- </body>
-
-</html>
diff --git a/upgrade.php b/upgrade.php
deleted file mode 100644
index 8871ebc88..000000000
--- a/upgrade.php
+++ /dev/null
@@ -1,213 +0,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | PhpWebGallery - a PHP based picture gallery |
-// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
-// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
-// | file : $RCSfile$
-// | last update : $Date$
-// | last modifier : $Author$
-// | revision : $Revision$
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify |
-// | it under the terms of the GNU General Public License as published by |
-// | the Free Software Foundation |
-// | |
-// | This program is distributed in the hope that it will be useful, but |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
-// | General Public License for more details. |
-// | |
-// | You should have received a copy of the GNU General Public License |
-// | along with this program; if not, write to the Free Software |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA. |
-// +-----------------------------------------------------------------------+
-
-define('PHPWG_ROOT_PATH', './');
-
-include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');
-include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
-include(PHPWG_ROOT_PATH.'include/template.php');
-
-include(PHPWG_ROOT_PATH.'include/mysql.inc.php');
-
-// +-----------------------------------------------------------------------+
-// | Check Access and exit when it is not ok |
-// +-----------------------------------------------------------------------+
-check_upgrade();
-
-// concerning upgrade, we use the default users table
-$conf['users_table'] = $prefixeTable.'users';
-
-include_once(PHPWG_ROOT_PATH.'include/constants.php');
-define('PREFIX_TABLE', $prefixeTable);
-
-$conf['show_queries'] = false;
-
-// Database connection
-mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
-or die ( "Could not connect to database server" );
-mysql_select_db( $cfgBase )
-or die ( "Could not connect to database" );
-// +-----------------------------------------------------------------------+
-// | tricky output |
-// +-----------------------------------------------------------------------+
-echo '<!-- This is an HTML comment given in order to make IE outputs';
-echo ' the code.'."\n";
-echo ' Indeed, IE doesn\'t start to send output until a limit';
-echo ' of XXX bytes '."\n";
-echo str_repeat( ' ', 80 )."\n";
-echo str_repeat( ' ', 80 )."\n";
-echo str_repeat( ' ', 80 )."\n";
-echo '-->'."\n";
-flush();
-// +-----------------------------------------------------------------------+
-// | functions |
-// +-----------------------------------------------------------------------+
-
-/**
- * loads an sql file and executes all queries
- *
- * Before executing a query, $replaced is... replaced by $replacing. This is
- * useful when the SQL file contains generic words. Drop table queries are
- * not executed.
- *
- * @param string filepath
- * @param string replaced
- * @param string replacing
- * @return void
- */
-function execute_sqlfile($filepath, $replaced, $replacing)
-{
- $sql_lines = file($filepath);
- $query = '';
- foreach ($sql_lines as $sql_line)
- {
- $sql_line = trim($sql_line);
- if (preg_match('/(^--|^$)/', $sql_line))
- {
- continue;
- }
- $query.= ' '.$sql_line;
- // if we reached the end of query, we execute it and reinitialize the
- // variable "query"
- if (preg_match('/;$/', $sql_line))
- {
- $query = trim($query);
- $query = str_replace($replaced, $replacing, $query);
- // we don't execute "DROP TABLE" queries
- if (!preg_match('/^DROP TABLE/i', $query))
- {
- mysql_query($query);
- }
- $query = '';
- }
- }
-}
-// +-----------------------------------------------------------------------+
-// | template initialization |
-// +-----------------------------------------------------------------------+
-
-$template = new Template(PHPWG_ROOT_PATH.'template/yoga');
-$template->set_filenames(array('upgrade'=>'upgrade.tpl'));
-$template->assign_vars(array('RELEASE'=>PHPWG_VERSION));
-
-// +-----------------------------------------------------------------------+
-// | versions upgradable |
-// +-----------------------------------------------------------------------+
-$versions = array();
-$path = PHPWG_ROOT_PATH.'install';
-if ($contents = opendir($path))
-{
- while (($node = readdir($contents)) !== false)
- {
- if (is_file($path.'/'.$node)
- and preg_match('/^upgrade_(.*?)\.php$/', $node, $match))
- {
- array_push($versions, $match[1]);
- }
- }
-}
-natcasesort($versions);
-// +-----------------------------------------------------------------------+
-// | upgrade choice |
-// +-----------------------------------------------------------------------+
-if (!isset($_GET['version']))
-{
- $template->assign_block_vars('choices', array());
- foreach ($versions as $version)
- {
- $template->assign_block_vars(
- 'choices.choice',
- array(
- 'URL' => PHPWG_ROOT_PATH.'upgrade.php?version='.$version,
- 'VERSION' => $version
- ));
- }
-}
-// +-----------------------------------------------------------------------+
-// | upgrade launch |
-// +-----------------------------------------------------------------------+
-else
-{
- $upgrade_file = $path.'/upgrade_'.$_GET['version'].'.php';
- if (is_file($upgrade_file))
- {
- $page['upgrade_start'] = get_moment();
- include($upgrade_file);
- $page['upgrade_end'] = get_moment();
-
- $template->assign_block_vars(
- 'upgrade',
- array(
- 'VERSION' => $_GET['version'],
- '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']
- ));
-
- if (!isset($infos))
- {
- $infos = array();
- }
- array_push(
- $infos,
- '[security] delete files "upgrade.php", "install.php" and "install"
-directory'
- );
-
- array_push(
- $infos,
- 'in include/mysql.inc.php, remove
-<pre style="background-color:lightgray">
-define(\'PHPWG_IN_UPGRADE\', true);
-</pre>'
- );
-
- array_push(
- $infos,
- 'Perform a maintenance check in [Administration>General>Maintenance]
-if you encounter any problem.'
- );
-
- $template->assign_block_vars('upgrade.infos', array());
-
- foreach ($infos as $info)
- {
- $template->assign_block_vars('upgrade.infos.info',
- array('CONTENT' => $info));
- }
- }
- else
- {
- die('Hacking attempt');
- }
-}
-// +-----------------------------------------------------------------------+
-// | sending html code |
-// +-----------------------------------------------------------------------+
-$template->pparse('upgrade');
-?> \ No newline at end of file