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

Last change on this file since 5920 was 5215, checked in by patdenice, 15 years ago

feature 1522: Move config_local.inc.php to local/config/config.inc.php

  • Property svn:eol-style set to LF
File size: 3.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2010 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('Hacking attempt!');
27}
28
29$upgrade_description = 'Move rate, rate_anonymous and gallery_url from config file to database';
30
31$params = array(
32  'gallery_url' => array('http://demo.phpwebgallery.net','URL given in RSS feed'),
33  'rate' => array('true','Rating pictures feature is enabled') ,
34  'rate_anonymous' => array('true','Rating pictures feature is also enabled for visitors')
35  );
36
37
38
39// +-Get real values from config file--------------------------------------+
40
41$conf_save = $conf;
42unset($conf);
43@include(PHPWG_ROOT_PATH. 'local/config/config.inc.php');
44if ( isset($conf['gallery_url']) )
45{
46  $params['gallery_url'][0] = $conf['gallery_url'];
47}
48if ( isset($conf['rate']) and is_bool($conf['rate']) )
49{
50  $params['rate'][0] = $conf['rate'] ? 'true' : 'false';
51}
52if ( isset($conf['rate_anonymous']) and is_bool($conf['rate_anonymous']) )
53{
54  $params['rate_anonymous'][0] = $conf['rate_anonymous'] ? 'true' : 'false';
55}
56$conf = $conf_save;
57
58
59
60// +-Do I already have them in DB ?----------------------------------------+
61$query = 'SELECT param FROM '.PREFIX_TABLE.'config';
62$result = pwg_query($query);
63while ($row = pwg_db_fetch_assoc($result))
64{
65  unset( $params[ $row['param'] ] );
66}
67
68// +-Perform the insert query----------------------------------------------+
69foreach ($params as $param_key => $param_values)
70{
71  $query = '
72INSERT INTO '.PREFIX_TABLE.'config (param,value,comment) VALUES (' .
73"'$param_key','$param_values[0]','$param_values[1]');";
74  pwg_query($query);
75}
76
77
78echo
79"\n"
80.'Table '.PREFIX_TABLE.'config upgraded'
81."\n"
82;
83?>
Note: See TracBrowser for help on using the repository browser.