source: trunk/upgrade_feed.php @ 2096

Last change on this file since 2096 was 2096, checked in by rub, 17 years ago

Resolved 0000748: Name configuration of all the tables
Resolved 0000750: Check anomalies after upgrade (Feature proposition)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2007-09-19 05:26:58 +0000 (Wed, 19 Sep 2007) $
10// | last modifier : $Author: rub $
11// | revision      : $Revision: 2096 $
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
28define('PHPWG_ROOT_PATH', './');
29
30include_once(PHPWG_ROOT_PATH.'include/functions.inc.php');
31include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
32include_once(PHPWG_ROOT_PATH.'admin/include/functions_upgrade.php');
33include(PHPWG_ROOT_PATH.'include/template.php');
34include(PHPWG_ROOT_PATH.'include/mysql.inc.php');
35
36// +-----------------------------------------------------------------------+
37// | Check Access and exit when it is not ok                               |
38// +-----------------------------------------------------------------------+
39check_upgrade();
40
41prepare_conf_upgrade();
42
43define('PREFIX_TABLE', $prefixeTable);
44define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db');
45
46// +-----------------------------------------------------------------------+
47// |                         Database connection                           |
48// +-----------------------------------------------------------------------+
49
50mysql_connect($cfgHote, $cfgUser, $cfgPassword)
51or die("Could not connect to database server");
52mysql_select_db($cfgBase)
53or die("Could not connect to database");
54
55// +-----------------------------------------------------------------------+
56// |                              Upgrades                                 |
57// +-----------------------------------------------------------------------+
58
59// retrieve already applied upgrades
60$query = '
61SELECT id
62  FROM '.PREFIX_TABLE.'upgrade
63;';
64$applied = array_from_query($query, 'id');
65
66// retrieve existing upgrades
67$existing = get_available_upgrade_ids();
68
69// which upgrades need to be applied?
70$to_apply = array_diff($existing, $applied);
71
72echo '<pre>';
73echo count($to_apply).' upgrades to apply';
74
75foreach ($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 = '
89INSERT INTO '.PREFIX_TABLE.'upgrade
90  (id, applied, description)
91  VALUES
92  (\''.$upgrade_id.'\', NOW(), \''.$upgrade_description.'\')
93;';
94  pwg_query($query);
95}
96
97echo '</pre>';
98?>
Note: See TracBrowser for help on using the repository browser.