[6222] | 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 | |
---|
| 22 | if (!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 | |
---|
| 35 | include_once DM_PLUGIN_ROOT . '/include/functions.inc.php'; |
---|
| 36 | |
---|
| 37 | load_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 | |
---|
| 43 | if ( !($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.'&tab=migration&dl='.$tmp_filename, |
---|
| 51 | 'config_file_content' => $file_content, |
---|
| 52 | ) |
---|
| 53 | ); |
---|
| 54 | } |
---|
| 55 | @fputs($fp, $file_content, strlen($file_content)); |
---|
| 56 | @fclose($fp); |
---|
| 57 | ?> |
---|