[12296] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | Piwigo - a PHP based photo gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[26461] | 5 | // | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org | |
---|
[12296] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
| 23 | |
---|
| 24 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 25 | { |
---|
| 26 | die ('This page cannot be loaded directly, load upgrade.php'); |
---|
| 27 | } |
---|
| 28 | else |
---|
| 29 | { |
---|
| 30 | if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE) |
---|
| 31 | { |
---|
| 32 | die ('Hacking attempt!'); |
---|
| 33 | } |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | // +-----------------------------------------------------------------------+ |
---|
| 37 | // | Fill upgrade table without applying upgrade | |
---|
| 38 | // +-----------------------------------------------------------------------+ |
---|
| 39 | |
---|
| 40 | // retrieve already applied upgrades |
---|
| 41 | $query = ' |
---|
| 42 | SELECT id |
---|
| 43 | FROM '.PREFIX_TABLE.'upgrade |
---|
| 44 | ;'; |
---|
| 45 | $applied = array_from_query($query, 'id'); |
---|
| 46 | |
---|
| 47 | // retrieve existing upgrades |
---|
| 48 | $existing = get_available_upgrade_ids(); |
---|
| 49 | |
---|
| 50 | // which upgrades need to be applied? |
---|
| 51 | $to_apply = array_diff($existing, $applied); |
---|
| 52 | $inserts = array(); |
---|
| 53 | foreach ($to_apply as $upgrade_id) |
---|
| 54 | { |
---|
| 55 | if ($upgrade_id >= 98) |
---|
| 56 | { |
---|
| 57 | break; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | array_push( |
---|
| 61 | $inserts, |
---|
| 62 | array( |
---|
| 63 | 'id' => $upgrade_id, |
---|
| 64 | 'applied' => CURRENT_DATE, |
---|
| 65 | 'description' => '[migration from 2.2.0 to '.PHPWG_VERSION.'] not applied', |
---|
| 66 | ) |
---|
| 67 | ); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | if (!empty($inserts)) |
---|
| 71 | { |
---|
| 72 | mass_inserts( |
---|
| 73 | '`'.UPGRADE_TABLE.'`', |
---|
| 74 | array_keys($inserts[0]), |
---|
| 75 | $inserts |
---|
| 76 | ); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | // +-----------------------------------------------------------------------+ |
---|
| 80 | // | Perform upgrades | |
---|
| 81 | // +-----------------------------------------------------------------------+ |
---|
| 82 | |
---|
| 83 | ob_start(); |
---|
| 84 | echo '<pre>'; |
---|
| 85 | |
---|
| 86 | for ($upgrade_id = 98; $upgrade_id <= 111; $upgrade_id++) |
---|
| 87 | { |
---|
| 88 | if (!file_exists(UPGRADES_PATH.'/'.$upgrade_id.'-database.php')) |
---|
| 89 | { |
---|
| 90 | break; |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | unset($upgrade_description); |
---|
| 94 | |
---|
| 95 | echo "\n\n"; |
---|
| 96 | echo '=== upgrade '.$upgrade_id."\n"; |
---|
| 97 | |
---|
| 98 | // include & execute upgrade script. Each upgrade script must contain |
---|
| 99 | // $upgrade_description variable which describe briefly what the upgrade |
---|
| 100 | // script does. |
---|
| 101 | include(UPGRADES_PATH.'/'.$upgrade_id.'-database.php'); |
---|
| 102 | |
---|
| 103 | // notify upgrade |
---|
| 104 | $query = ' |
---|
| 105 | INSERT INTO `'.PREFIX_TABLE.'upgrade` |
---|
| 106 | (id, applied, description) |
---|
| 107 | VALUES |
---|
| 108 | (\''.$upgrade_id.'\', NOW(), \'[migration from 2.2.0 to '.PHPWG_VERSION.'] '.$upgrade_description.'\') |
---|
| 109 | ;'; |
---|
| 110 | pwg_query($query); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | echo '</pre>'; |
---|
| 114 | ob_end_clean(); |
---|
| 115 | |
---|
[15679] | 116 | // now we upgrade from 2.3.0 |
---|
| 117 | include_once(PHPWG_ROOT_PATH.'install/upgrade_2.3.0.php'); |
---|
[12296] | 118 | ?> |
---|