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 = '
'; $error.= $header; $error.= '[mysql error '.mysql_errno().'] '; $error.= mysql_error(); $error.= ''; - 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 @@ -['.get_elapsed_time($last_time, $new_time).']'; -echo ' Basic database structure upgrade done'; -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 @@ -['.get_elapsed_time($last_time, $new_time).']'; -echo ' Basic database structure upgrade done'; -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 @@ - - - - - -
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 - :
- -Statistics
-Upgrade informations
- --define(\'PHPWG_IN_UPGRADE\', true); -' - ); - - 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