[953] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[1903] | 5 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[953] | 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | // | branch : BSF (Best So Far) |
---|
| 8 | // | file : $RCSfile$ |
---|
[1912] | 9 | // | last update : $Date: 2007-09-19 05:26:58 +0000 (Wed, 19 Sep 2007) $ |
---|
| 10 | // | last modifier : $Author: rub $ |
---|
| 11 | // | revision : $Revision: 2096 $ |
---|
[953] | 12 | // +-----------------------------------------------------------------------+ |
---|
| 13 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 14 | // | it under the terms of the GNU General Public License as published by | |
---|
| 15 | // | the Free Software Foundation | |
---|
| 16 | // | | |
---|
| 17 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 20 | // | General Public License for more details. | |
---|
| 21 | // | | |
---|
| 22 | // | You should have received a copy of the GNU General Public License | |
---|
| 23 | // | along with this program; if not, write to the Free Software | |
---|
| 24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 25 | // | USA. | |
---|
| 26 | // +-----------------------------------------------------------------------+ |
---|
| 27 | |
---|
| 28 | define('PHPWG_ROOT_PATH', './'); |
---|
| 29 | |
---|
| 30 | include_once(PHPWG_ROOT_PATH.'include/functions.inc.php'); |
---|
| 31 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[1075] | 32 | include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php'); |
---|
[953] | 33 | include(PHPWG_ROOT_PATH.'include/template.php'); |
---|
| 34 | include(PHPWG_ROOT_PATH.'include/mysql.inc.php'); |
---|
| 35 | |
---|
[1075] | 36 | // +-----------------------------------------------------------------------+ |
---|
| 37 | // | Check Access and exit when it is not ok | |
---|
| 38 | // +-----------------------------------------------------------------------+ |
---|
| 39 | check_upgrade(); |
---|
| 40 | |
---|
[2096] | 41 | prepare_conf_upgrade(); |
---|
| 42 | |
---|
[953] | 43 | define('PREFIX_TABLE', $prefixeTable); |
---|
| 44 | define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db'); |
---|
| 45 | |
---|
| 46 | // +-----------------------------------------------------------------------+ |
---|
| 47 | // | Database connection | |
---|
| 48 | // +-----------------------------------------------------------------------+ |
---|
| 49 | |
---|
| 50 | mysql_connect($cfgHote, $cfgUser, $cfgPassword) |
---|
| 51 | or die("Could not connect to database server"); |
---|
| 52 | mysql_select_db($cfgBase) |
---|
| 53 | or die("Could not connect to database"); |
---|
| 54 | |
---|
| 55 | // +-----------------------------------------------------------------------+ |
---|
| 56 | // | Upgrades | |
---|
| 57 | // +-----------------------------------------------------------------------+ |
---|
| 58 | |
---|
| 59 | // retrieve already applied upgrades |
---|
| 60 | $query = ' |
---|
| 61 | SELECT id |
---|
| 62 | FROM '.PREFIX_TABLE.'upgrade |
---|
| 63 | ;'; |
---|
| 64 | $applied = array_from_query($query, 'id'); |
---|
| 65 | |
---|
| 66 | // retrieve existing upgrades |
---|
[1027] | 67 | $existing = get_available_upgrade_ids(); |
---|
[953] | 68 | |
---|
| 69 | // which upgrades need to be applied? |
---|
| 70 | $to_apply = array_diff($existing, $applied); |
---|
| 71 | |
---|
| 72 | echo '<pre>'; |
---|
| 73 | echo count($to_apply).' upgrades to apply'; |
---|
| 74 | |
---|
| 75 | foreach ($to_apply as $upgrade_id) |
---|
| 76 | { |
---|
| 77 | unset($upgrade_description); |
---|
| 78 | |
---|
| 79 | echo "\n\n"; |
---|
| 80 | echo '=== upgrade '.$upgrade_id."\n"; |
---|
| 81 | |
---|
| 82 | // include & execute upgrade script. Each upgrade script must contain |
---|
| 83 | // $upgrade_description variable which describe briefly what the upgrade |
---|
| 84 | // script does. |
---|
| 85 | include(UPGRADES_PATH.'/'.$upgrade_id.'-database.php'); |
---|
| 86 | |
---|
| 87 | // notify upgrade |
---|
| 88 | $query = ' |
---|
| 89 | INSERT INTO '.PREFIX_TABLE.'upgrade |
---|
| 90 | (id, applied, description) |
---|
| 91 | VALUES |
---|
| 92 | (\''.$upgrade_id.'\', NOW(), \''.$upgrade_description.'\') |
---|
| 93 | ;'; |
---|
| 94 | pwg_query($query); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | echo '</pre>'; |
---|
[1903] | 98 | ?> |
---|