source: trunk/install/db/8-database.php @ 2127

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

Change headers with team email

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 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// | file          : $Id: 8-database.php 2059 2007-07-10 05:30:01Z rub $
8// | last update   : $Date: 2007-07-10 05:30:01 +0000 (Tue, 10 Jul 2007) $
9// | last modifier : $Author: rub $
10// | revision      : $Revision: 2059 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27if (!defined('PHPWG_ROOT_PATH'))
28{
29  die('Hacking attempt!');
30}
31
32$upgrade_description = 'Move rate, rate_anonymous and gallery_url from config file to database';
33
34$params = array(
35  'gallery_url' => array('http://demo.phpwebgallery.net','URL given in RSS feed'),
36  'rate' => array('true','Rating pictures feature is enabled') ,
37  'rate_anonymous' => array('true','Rating pictures feature is also enabled for visitors')
38  );
39
40
41
42// +-Get real values from config file--------------------------------------+
43
44$conf_save = $conf;
45unset($conf);
46@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
47if ( isset($conf['gallery_url']) )
48{
49  $params['gallery_url'][0] = $conf['gallery_url'];
50}
51if ( isset($conf['rate']) and is_bool($conf['rate']) )
52{
53  $params['rate'][0] = $conf['rate'] ? 'true' : 'false';
54}
55if ( isset($conf['rate_anonymous']) and is_bool($conf['rate_anonymous']) )
56{
57  $params['rate_anonymous'][0] = $conf['rate_anonymous'] ? 'true' : 'false';
58}
59$conf = $conf_save;
60
61
62
63// +-Do I already have them in DB ?----------------------------------------+
64$query = 'SELECT param FROM '.PREFIX_TABLE.'config';
65$result = pwg_query($query);
66while ($row = mysql_fetch_array($result))
67{
68  unset( $params[ $row['param'] ] );
69}
70
71// +-Perform the insert query----------------------------------------------+
72foreach ($params as $param_key => $param_values)
73{
74  $query = '
75INSERT INTO '.PREFIX_TABLE.'config (param,value,comment) VALUES (' .
76"'$param_key','$param_values[0]','$param_values[1]');";
77  pwg_query($query);
78}
79
80
81echo
82"\n"
83.'Table '.PREFIX_TABLE.'config upgraded'
84."\n"
85;
86?>
Note: See TracBrowser for help on using the repository browser.