1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008 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 | // +-----------------------------------------------------------------------+ |
---|
24 | // | PhpWebGallery - a PHP based picture gallery | |
---|
25 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
26 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
27 | // +-----------------------------------------------------------------------+ |
---|
28 | // | file : $Id: 8-database.php 2297 2008-04-04 22:57:23Z plg $ |
---|
29 | // | last update : $Date: 2008-04-04 22:57:23 +0000 (Fri, 04 Apr 2008) $ |
---|
30 | // | last modifier : $Author: plg $ |
---|
31 | // | revision : $Revision: 2297 $ |
---|
32 | // +-----------------------------------------------------------------------+ |
---|
33 | // | This program is free software; you can redistribute it and/or modify | |
---|
34 | // | it under the terms of the GNU General Public License as published by | |
---|
35 | // | the Free Software Foundation | |
---|
36 | // | | |
---|
37 | // | This program is distributed in the hope that it will be useful, but | |
---|
38 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
39 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
40 | // | General Public License for more details. | |
---|
41 | // | | |
---|
42 | // | You should have received a copy of the GNU General Public License | |
---|
43 | // | along with this program; if not, write to the Free Software | |
---|
44 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
45 | // | USA. | |
---|
46 | // +-----------------------------------------------------------------------+ |
---|
47 | |
---|
48 | if (!defined('PHPWG_ROOT_PATH')) |
---|
49 | { |
---|
50 | die('Hacking attempt!'); |
---|
51 | } |
---|
52 | |
---|
53 | $upgrade_description = 'Move rate, rate_anonymous and gallery_url from config file to database'; |
---|
54 | |
---|
55 | $params = array( |
---|
56 | 'gallery_url' => array('http://demo.phpwebgallery.net','URL given in RSS feed'), |
---|
57 | 'rate' => array('true','Rating pictures feature is enabled') , |
---|
58 | 'rate_anonymous' => array('true','Rating pictures feature is also enabled for visitors') |
---|
59 | ); |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | // +-Get real values from config file--------------------------------------+ |
---|
64 | |
---|
65 | $conf_save = $conf; |
---|
66 | unset($conf); |
---|
67 | @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php'); |
---|
68 | if ( isset($conf['gallery_url']) ) |
---|
69 | { |
---|
70 | $params['gallery_url'][0] = $conf['gallery_url']; |
---|
71 | } |
---|
72 | if ( isset($conf['rate']) and is_bool($conf['rate']) ) |
---|
73 | { |
---|
74 | $params['rate'][0] = $conf['rate'] ? 'true' : 'false'; |
---|
75 | } |
---|
76 | if ( isset($conf['rate_anonymous']) and is_bool($conf['rate_anonymous']) ) |
---|
77 | { |
---|
78 | $params['rate_anonymous'][0] = $conf['rate_anonymous'] ? 'true' : 'false'; |
---|
79 | } |
---|
80 | $conf = $conf_save; |
---|
81 | |
---|
82 | |
---|
83 | |
---|
84 | // +-Do I already have them in DB ?----------------------------------------+ |
---|
85 | $query = 'SELECT param FROM '.PREFIX_TABLE.'config'; |
---|
86 | $result = pwg_query($query); |
---|
87 | while ($row = mysql_fetch_array($result)) |
---|
88 | { |
---|
89 | unset( $params[ $row['param'] ] ); |
---|
90 | } |
---|
91 | |
---|
92 | // +-Perform the insert query----------------------------------------------+ |
---|
93 | foreach ($params as $param_key => $param_values) |
---|
94 | { |
---|
95 | $query = ' |
---|
96 | INSERT INTO '.PREFIX_TABLE.'config (param,value,comment) VALUES (' . |
---|
97 | "'$param_key','$param_values[0]','$param_values[1]');"; |
---|
98 | pwg_query($query); |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | echo |
---|
103 | "\n" |
---|
104 | .'Table '.PREFIX_TABLE.'config upgraded' |
---|
105 | ."\n" |
---|
106 | ; |
---|
107 | ?> |
---|