source: trunk/install/db/84-database.php @ 4423

Revision 4423, 3.0 KB checked in by nikrou, 9 years ago (diff)

Feature 1255 : migration script

Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2009 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 = 'Update configuration filename for database.
30configuration variables will change too.';
31
32$old_config_file = PHPWG_ROOT_PATH .'include/mysql.inc.php';
33$new_config_file = PHPWG_ROOT_PATH .'include/config_database.inc.php';
34
35include_once $old_config_file;
36
37$file_content = '<?php
38$conf[\'dblayer\'] = \'mysql\';
39$conf[\'db_base\'] = \''.$cfgBase.'\';
40$conf[\'db_user\'] = \''.$cfgUser.'\';
41$conf[\'db_password\'] = \''.$cfgPassword.'\';
42$conf[\'db_host\'] = \''.$cfgHote.'\';
43
44$prefixeTable = \''.$prefixeTable.'\';
45
46define(\'PHPWG_INSTALLED\', true);
47define(\'PWG_CHARSET\', \''.PWG_CHARSET.'\');
48define(\'DB_CHARSET\', \''.DB_CHARSET.'\');
49define(\'DB_COLLATE\', \''.DB_COLLATE.'\');
50
51?'.'>';
52
53@umask(0111);
54// writing the configuration file
55if ( !($fp = @fopen( $config_file, 'w' )))
56{
57  $html_content = htmlentities( $file_content, ENT_QUOTES, 'utf-8' );
58  $html_content = nl2br( $html_content );
59  $error_copy = l10n('step1_err_copy');
60  $error_copy .= '<br>--------------------------------------------------------------------<br>';
61  $error_copy .= '<span class="sql_content">' . $html_content . '</span>';
62  $error_copy .= '<br>--------------------------------------------------------------------<br>';
63}
64@fputs($fp, $file_content, strlen($file_content));
65@fclose($fp);
66
67if (isset($error_copy)) 
68{
69  array_push($page['errors'], $error_copy);
70}
71
72echo
73"\n"
74. $upgrade_description
75."\n"
76;
77?>
Note: See TracBrowser for help on using the repository browser.