source: extensions/database_migration/include/tab_restore.inc.php @ 6222

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

Database migration plugin : first public version

File size: 2.7 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
22if (!empty($_GET['dl']) && file_exists($conf['local_data_dir'].'/dm_'.$_GET['dl']))
23{
24  $filename = $conf['local_data_dir'].'/dm_'.$_GET['dl'];
25  header('Cache-Control: no-cache, must-revalidate');
26  header('Pragma: no-cache');
27  header('Content-Disposition: attachment; filename="database.inc.php"');
28  header('Content-Transfer-Encoding: binary');
29  header('Content-Length: '.filesize($filename));
30  echo file_get_contents($filename);
31  unlink($filename);
32  exit();
33} 
34
35include_once DM_PLUGIN_ROOT . '/include/functions.inc.php';
36
37load_language('install.lang', PHPWG_ROOT_PATH);
38
39$connection = $me->getConnection('mysql');
40$file_content = get_config_file_content('mysql', $connection);
41$config_file = PHPWG_ROOT_PATH . 'local/config/database.inc.php';
42
43if ( !($fp=@fopen( $config_file, 'w' ))) {
44  $tmp_filename = md5(uniqid('', true));
45  $fh = @fopen( $conf['local_data_dir'] . '/dm_' . $tmp_filename, 'w' );
46  @fputs($fh, $file_content, strlen($file_content));
47  @fclose($fh);
48 
49  $template->assign(array('config_creation_failed' => true,
50                          'config_url' => $dm_base_url.'&amp;tab=migration&amp;dl='.$tmp_filename,
51                          'config_file_content' => $file_content,
52                          )
53                    );
54}
55@fputs($fp, $file_content, strlen($file_content));
56@fclose($fp);
57?>
Note: See TracBrowser for help on using the repository browser.