source: branches/gettext/install/upgrade_1.7.0.php @ 6491

Last change on this file since 6491 was 4325, checked in by nikrou, 15 years ago

Feature 1244 resolved
Replace all mysql functions in core code by ones independant of database engine

Fix small php code synxtax : hash must be accessed with [ ] and not { }.

  • Property svn:eol-style set to LF
File size: 3.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
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
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die ('This page cannot be loaded directly, load upgrade.php');
27}
28else
29{
30  if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE)
31  {
32    die ('Hacking attempt!');
33  }
34}
35
36define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db');
37
38list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
39define('CURRENT_DATE', $dbnow);
40
41// +-----------------------------------------------------------------------+
42// |             Fill upgrade table without applying upgrade               |
43// +-----------------------------------------------------------------------+
44
45// retrieve already applied upgrades
46$query = '
47SELECT id
48  FROM '.PREFIX_TABLE.'upgrade
49;';
50$applied = array_from_query($query, 'id');
51
52// retrieve existing upgrades
53$existing = get_available_upgrade_ids();
54
55// which upgrades need to be applied?
56$to_apply = array_diff($existing, $applied);
57$inserts = array();
58foreach ($to_apply as $upgrade_id)
59{
60  if ($upgrade_id > 60)
61  {
62    break;
63  }
64 
65  array_push(
66    $inserts,
67    array(
68      'id' => $upgrade_id,
69      'applied' => CURRENT_DATE,
70      'description' => '[migration from 1.7.0 to '.PHPWG_VERSION.'] not applied',
71      )
72    );
73}
74
75if (!empty($inserts))
76{
77  mass_inserts(
78    '`'.UPGRADE_TABLE.'`',
79    array_keys($inserts[0]),
80    $inserts
81    );
82}
83
84// +-----------------------------------------------------------------------+
85// |                          Perform upgrades                             |
86// +-----------------------------------------------------------------------+
87
88ob_start();
89echo '<pre>';
90
91for ($upgrade_id = 61; ; $upgrade_id++)
92{
93  if (!file_exists(UPGRADES_PATH.'/'.$upgrade_id.'-database.php'))
94  {
95    break;
96  }
97 
98  unset($upgrade_description);
99
100  echo "\n\n";
101  echo '=== upgrade '.$upgrade_id."\n";
102
103  // include & execute upgrade script. Each upgrade script must contain
104  // $upgrade_description variable which describe briefly what the upgrade
105  // script does.
106  include(UPGRADES_PATH.'/'.$upgrade_id.'-database.php');
107
108  // notify upgrade
109  $query = '
110INSERT INTO `'.PREFIX_TABLE.'upgrade`
111  (id, applied, description)
112  VALUES
113  (\''.$upgrade_id.'\', NOW(), \'[migration from 1.7.0 to '.PHPWG_VERSION.'] '.$upgrade_description.'\')
114;';
115  pwg_query($query);
116}
117
118echo '</pre>';
119ob_end_clean();
120
121// now we upgrade from 2.0.0
122// include_once(PHPWG_ROOT_PATH.'install/upgrade_2.0.0.php');
123?>
Note: See TracBrowser for help on using the repository browser.