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