source: extensions/database_migration/include/functions.inc.php @ 6552

Last change on this file since 6552 was 6222, checked in by nikrou, 14 years ago

Database migration plugin : first public version

File size: 2.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | database_migration - a plugin for Piwigo                              |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2010 Nicolas Roudaire             http://www.nikrou.net  |
6// +-----------------------------------------------------------------------+
7// | This program is free software; you can redistribute it and/or modify  |
8// | it under the terms of the GNU General Public License version 2 as     |
9// | published by the Free Software Foundation                             |
10// |                                                                       |
11// | This program is distributed in the hope that it will be useful, but   |
12// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
13// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
14// | General Public License for more details.                              |
15// |                                                                       |
16// | You should have received a copy of the GNU General Public License     |
17// | along with this program; if not, write to the Free Software           |
18// | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,            |
19// | MA 02110-1301 USA                                                     |
20// +-----------------------------------------------------------------------+
21
22function get_config_file_content($dblayer, $connection) {
23  global $conf;
24 
25  $content = '<?php
26$conf[\'dblayer\'] = \''.$dblayer.'\';
27$conf[\'db_base\'] = \''.$connection['db_base'].'\';
28$conf[\'db_user\'] = \''.$connection['db_user'].'\';
29$conf[\'db_password\'] = \''.$connection['db_password'].'\';
30$conf[\'db_host\'] = \''.$connection['db_host'].'\';
31
32$prefixeTable = \''.$connection['prefix'].'\';
33
34define(\'PHPWG_INSTALLED\', true);
35define(\'PWG_CHARSET\', \'utf-8\');
36define(\'DB_CHARSET\', \'utf8\');
37define(\'DB_COLLATE\', \'\');
38?>';
39
40  return $content;
41}
42
43function save_mysql_config() {
44  global $me, $conf, $prefixeTable;
45
46  $connection['db_host'] = $conf['db_host'];
47  $connection['db_user'] = $conf['db_user'];
48  $connection['db_password'] = $conf['db_password'];
49  $connection['db_base'] = $conf['db_base'];
50  $connection['prefix'] = $prefixeTable;
51  $me->addConnection('mysql', $connection);
52  $me->save_config();
53}
54?>
Note: See TracBrowser for help on using the repository browser.