HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/OneDrive/Desktop/wordpress/wp-content/pluginsBK/myeasybackup/myeasybackup.php
<?php
/*
Plugin Name: myEASYbackup
Plugin URI: http://myeasywp.com
Description: Backup your WordPress site (code and database) with a click.
Version: 0.1.0
Author: Ugo Grandolini aka "camaleo"
Author URI: http://myeasywp.com
*/
/*	Backup your WordPress site (code and database) with a click.
	Copyright (C) 2010 Ugo Grandolini  (email : [email protected])

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
	*/

if(!isset($_SESSION)) { session_start(); $_SESSION['id'] = session_id(); }

require_once('meb-config.php');

wp_enqueue_script( 'myeasybackup_core_js', MYEASYBACKUP_LINK.'js/myeasybackup.js', '', '20100313', false );

define('MEBAK_POPWIN', '<div id="myeasybackup_popWin" style="display:none;padding-top:12.5%;z-index:9999;font-size:150%;color:#fff;background:#000;text-align:center;opacity:.8;-moz-opacity:.8;filter:alpha(opacity=80);position:absolute;top:0;left:0;">'

		#
		#	0.0.6: BEG
		#-------------
		.'<div id="wait_backup" style="display:none;">'
			.'<img src="http://myeasywp.com/service/meb-img/adding-files.png" /><br />'

			.'<p style="margin:12px 0;">' . __( 'Please wait, backup in progress...', MEBAK_LOCALE ) . '</p>'

			.'<img src="http://myeasywp.com/service/meb-img/wait.gif" /><br />'
		.'</div>'
		.'<div id="wait_upload" style="display:none;">'
			.'<img src="http://myeasywp.com/service/meb-img/uploading.png" /><br />'

			.'<p style="margin:12px 0;">' . __( 'Please wait, uploading in progress...', MEBAK_LOCALE ) . '</p>'

			.'<img src="http://myeasywp.com/service/meb-img/wait.gif" /><br />'
		.'</div>'
		.'<div id="wait_progress" style="margin:12px 0;"></div>'
		#-------------
		#	0.0.6: BEG
		#

	.'</div>'
);

define('MEBAK_BACK_BUTTON',
		'<div>'
			.'<input type="button" class="button-secondary" style="cursor:pointer;" value="'
						. __( 'Back to the main page', MEBAK_LOCALE )
						. '" onclick="javascript:window.location=\''.$_SERVER['PHP_SELF'].'?page=myEASYbackup_tools\';" />'
		.'</div>'
);

//echo 'MYEASYBACKUP_LINK:'.MYEASYBACKUP_LINK.'<br>';

#
#	hook for adding admin menus
#
add_action('admin_menu', 'myEASYbackup_add_pages');

load_plugin_textdomain( MEBAK_LOCALE, 'wp-content/plugins/langs/' . $myEASYbackup_dir, $myEASYbackup_dir .'/langs/' );	#	0.0.5


#
#	support functions
#
function checkvariables() {
	#
	#	check the variables
	#
	$error = false;

	while(list($key, $val) = each($_POST))
	{
		if( ereg( '[;&<>]+' , $val ) )
		{
			$error = true;
		}
		else
		{
			$key = trim( $val );
		}
	}
	if($error==true)
	{
		echo '<div class="error">'
				. __( 'Invalid characters in one of your variables.', MEBAK_LOCALE )
		.'</div>';
		return true;
	}
	return false;
}

//define('isZIPARCHIVE', false); # debug


if(class_exists(ZipArchive))									#	0.0.2
{
	if(version_compare(PHP_VERSION, '5', '<'))					#	0.0.5
	{
		#	PHP 4
		#
		class Zipper extends ZipArchive {
			#
			#	Add directories recursiverly
			#
			function addDir($path)								#	0.0.5
			{
				echo '<br />'
					.__('Adding folder ', MEBAK_LOCALE ) . '<b>' . $path . '</b><br />';

				$source = realpath($path);

				if(is_dir($source) === true)
				{
					$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);

					foreach($files as $file)
					{
						$file = realpath($file);

						if(is_dir($file) === true)
						{
							echo '<br />' . __('Adding folder ', MEBAK_LOCALE ) . '<b>' . $file . '</b><br />';
							$this->addEmptyDir(str_replace($source . '/', '', $file . '/'));
						}
						else if(is_file($file) === true)
						{
							echo $file . '<br />';
							$this->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
						}
					}
				}
				else if(is_file($source) === true)
				{
					$this->addFromString(basename($source), file_get_contents($source));
				}
			}
		}
	}
	else
	{
		#	PHP 5
		#
		class Zipper extends ZipArchive {
			#
			#	Add directories recursiverly
			#
			public function addDir($path)							#	0.0.4
			{
				echo '<br />'
					.__('Adding folder ', MEBAK_LOCALE ) . '<b>' . $path . '</b><br />';

				$source = realpath($path);

				if(is_dir($source) === true)
				{
					$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);

					foreach($files as $file)
					{
						$file = realpath($file);

						if(is_dir($file) === true)
						{
							echo '<br />'
								.__('Adding folder ', MEBAK_LOCALE ) . '<b>' . $file . '</b><br />';
							$this->addEmptyDir(str_replace($source . '/', '', $file . '/'));
						}
						else if(is_file($file) === true)
						{
							echo $file . '<br />';
							$this->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
						}
					}
				}
				else if(is_file($source) === true)
				{
					$this->addFromString(basename($source), file_get_contents($source));
				}
			}
		}
	}
	define('isZIPARCHIVE', true);				#	0.0.2
}
else
{
	define('isZIPARCHIVE', false);				#	0.0.2
}


#
#	core functions
#
function myEASYbackup_add_pages() {
	#
	#	settings submenu
	#
	add_options_page(__( 'myEASYbackup', MEBAK_LOCALE ), __( 'myEASYbackup', MEBAK_LOCALE ), 'administrator', 'myEASYbackup_options', 'myEASYbackup_options_page');	#	0.0.5

	#
	#	Add the main page
	#
	add_management_page(__( 'myEASYbackup', MEBAK_LOCALE ), __( 'myEASYbackup', MEBAK_LOCALE ), 'administrator', 'myEASYbackup_tools', 'myEASYbackup_tools_page');
}

function myEASYbackup_options_page() {
	#
	#	Settings page	@since 0.0.5
	#
	echo '<div class="wrap">'
		.'<div id="icon-options-general" class="icon32"><br /></div>'
		.'<h2>' . __( 'myEASYbackup: Settings', MEB_LOCALE ) . '</h2>'
	;

	require(MEBAK_PATH . 'meb_settings.php');

	echo '</div>';
}

function has_data($value)
{
	if(is_array($value))
	{
		return (sizeof($value) > 0) ? true : false;
	}
	else
	{
		return (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) ? true : false;
	}
}

function myEASYbackup_tools_page() {
	#
	#	Main page
	#
	global $table_prefix;								#	0.0.6

	echo '<div class="wrap">'
			.'<div id="icon-options-general" class="icon32"><br /></div>'
			.'<h2>myEASYbackup: ' . __( 'Backup, restore and migrate your WordPress installation', MEBAK_LOCALE )
	;

	if(defined('isLINUX') && isLINUX==true)
	{
		echo ' <img src="'.MYEASYBACKUP_LINK.'img/linux.png" alt="' . __( 'This is a Linux server', MEBAK_LOCALE ) . '" title="' . __( 'This is a Linux server', MEBAK_LOCALE ) . '" align="absmiddle" width="24" />';
	}
	else if(defined('isWINDOWS') && isWINDOWS==true)
	{
		echo ' <img src="'.MYEASYBACKUP_LINK.'img/windows.png" alt="' . __( 'This is a Windows server', MEBAK_LOCALE ) . '" title="' . __( 'This is a Windows server', MEBAK_LOCALE ) . '" align="absmiddle" width="24" />';
	}

	if(!isset($_POST['upload_restore_tool']))		#	0.0.6
	{
		$_POST['upload_restore_tool'] = 1;
	}

	echo '</h2>'
			.'<form id="ftp_upload" name="ftp_upload" method="post" action="'.$_SERVER['PHP_SELF'].'?page=myEASYbackup_tools">'
				.'<input type="hidden" id="ftp_pwd" name="ftp_pwd" value="'.$_POST['ftp_pwd'].'" />'
				.'<input type="hidden" id="ftp_action" name="ftp_action" value="'.$_POST['ftp_action'].'" />'
				.'<input type="hidden" id="ftp_file" name="ftp_file" value="'.$_POST['ftp_file'].'" />'
				.'<input type="hidden" id="upload_restore_tool_" name="upload_restore_tool" value="'.$_POST['upload_restore_tool'].'" />'	#	0.0.6
			.'</form>'

#
#	0.1.0: BEG
#-------------
			.'<form id="dwn_backup" name="dwn_backup" method="post" action="'.$_SERVER['PHP_SELF'].'?page=myEASYbackup_tools">'
				.'<input type="hidden" id="dwn_action" name="dwn_action" value="'.$_POST['dwn_action'].'" />'
				.'<input type="hidden" id="dwn_file" name="dwn_file" value="'.$_POST['dwn_file'].'" />'
			.'</form>'
			.'<form id="dwn_exec_form" name="dwn_exec_form" method="post" action="'.MYEASYBACKUP_LINK.'meb_download.php">'
				.'<input type="hidden" id="dwn_exec" name="dwn_action" value="'.$_POST['dwn_action'].'" />'
				.'<input type="hidden" id="dwn_exec_file" name="dwn_file" value="'.$_POST['dwn_file'].'" />'
			.'</form>'
#-------------
#	0.1.0: END
#

			.'<form method="post" name="exec_backup" id="exec_backup" action="'.$_SERVER['PHP_SELF'].'?page=myEASYbackup_tools">'
				.'<input type="hidden" id="_action" name="_action" value="" />'
				.MEBAK_POPWIN
	;

//var_dump($_POST);
//var_dump($_SERVER);echo '<hr>';
//echo 'HTTP_REFERER:'.$_SERVER['HTTP_REFERER'].'<br>';


	$disabled = ini_get('disable_functions');		#	0.0.5


//echo 'disabled['.$disabled.']<br>';	#	debug


	if((defined('isWINDOWS') && isWINDOWS==true						#	0.0.4
			&& defined('isZIPARCHIVE') && isZIPARCHIVE==false)		#	0.0.2
	) {
		#	ZipArchive is not installed on the server :/
		#
		?><img src="<?php echo MYEASYBACKUP_LINK; ?>img/warning.png"
						alt="WARNING" align="absmiddle" /> <?php

		echo '<span style="font-weight:bold;color:orange;">'

				. __( 'Missing the ZipArchive class', MEBAK_LOCALE )

			. '</span>'
		;

		?><div id="id"><?php

			echo __( 'Current PHP version on this server', MEBAK_LOCALE )

					. ': <b>' . phpversion() . '</b><br />'
			;

			if(version_compare(PHP_VERSION, '4.1.0', '<='))
			{
				echo '<p>'
						. __( 'You are running your site on a server that is not updated since 2001!', MEBAK_LOCALE )
					. '</p>'
				;
				echo '<p>'
						. __( 'Please consider to take one of the following actions as soon as possible:', MEBAK_LOCALE )
					. '<ul>'
						. '<li> &raquo; '
							. __( 'ask your provider to update the server configuration', MEBAK_LOCALE )
						. '</li>'
						. '<li> &raquo; '
							. __( 'change provider, can you trust a provider running such an old configuration still in the ', MEBAK_LOCALE )
							. date('Y', time())
							.'?'
						. '</li>'
					. '</ul>'
					. '</p>'
				;
			}
			else if(version_compare(PHP_VERSION, '5', '<'))
			{
				echo '<p>'
						. __( 'Instructions to install the ZipArchive class are', MEBAK_LOCALE )
						. ' <a href="http://php.net/manual/zip.installation.php" target="_blank"><b>'

							. __( 'available here', MEBAK_LOCALE )

						. '</b></a>'
					. '</p>'
				;

				echo '<p>'
						. __( 'However ', MEBAK_LOCALE )
						.'<span style="font-style:italic;">&laquo;'

							. __( "PHP 4 shows its age. Most of PHP 4's shortcomings have been addressed by PHP 5,", MEBAK_LOCALE )

							.' <b>'
								. __( "released on 2004...", MEBAK_LOCALE )
							.'</b>'

						. '&raquo;</span>'
					. '</p>'
				;

				echo '<p>'
						. __( 'For further information about why you should consider to ask your provider to update the server configuration, visit ', MEBAK_LOCALE )

						. ' <a href="http://gophp5.org" target="_blank"><b>'

							. __( 'gophp5.org', MEBAK_LOCALE )

						. '</b></a>'
					. '</p>'
				;

			}
			else
			{
				echo '<p>'
						. __( 'Instructions to install the ZipArchive class are', MEBAK_LOCALE )
						. ' <a href="http://php.net/manual/zip.installation.php" target="_blank"><b>'

							. __( 'available here', MEBAK_LOCALE )

						. '</b></a>'
					. '</p>'
				;
			}

			echo CHANGE_HOST;

		?></div><?php

		return;
	}

	if(isSAFEMODE==true)											#	0.0.5
	{
		#	its not possible to write files on a safe_mode enabled server :/
		#
		echo '<div class="error">'
			. '<h3>'
				. __( 'WARNING: SAFE_MODE is enabled on your server PHP configuration!', MEBAK_LOCALE )
			. '<br />'
				. __( 'Due to this setting myEASYbackup is not able to write the data set on your server.', MEBAK_LOCALE )
			. '</h3>'

			. '<p>' . __( 'This setting was an attempt to solve the shared-server security problem, is deprecated since in PHP 5.3.0 and will be removed in PHP 6.0.0.', MEBAK_LOCALE ) . '</p>'

			. '<p>'
				.'<a href="http://forums.digitalpoint.com/showthread.php?t=916" target="_blank">'
					. __( 'Click here for further info about the SAFE_MODE setting', MEBAK_LOCALE )
				.'</a>'

				.' | <a href="http://php.net/manual/features.safe-mode.php" target="_blank">'
					. __( 'Read more about SAFE_MODE on the PHP site', MEBAK_LOCALE )
				.'</a>'
			. '</p>'

			.CHANGE_HOST

		.'</div>';
		return;
	}


	#
	#	create the backup folder if not present			#	0.0.5: revised for safe_mode enabled servers
	#
	if(!file_exists(MEBAK_BACKUP_PATH))
	{
		$result = mkdir(MEBAK_BACKUP_PATH);
		chmod(MEBAK_BACKUP_PATH, 0777);

		if($result==true)
		{
			?><div class="updated">
				<?php echo MEBAK_BACKUP_PATH . ': ' . __('successfully created!', MEBAK_LOCALE); ?>
			</div><?php
		}
		else
		{
			echo '<div class="error">'
				. __( 'Error when creating ', MEBAK_LOCALE ) . '<b>' . MEBAK_BACKUP_PATH . '</b>'

#
#	0.1.0: BEG
#-------------
				. '<br />'
				. __( 'Please manually create the', MEBAK_LOCALE ) . ' <b>' . MEBAK_BACKUP_FOLDER . '</b> '
				. __( 'in your', MEBAK_LOCALE ) . ' <b>' . MEBAK_BACKUP_ROOT . '</b> '
				. __( 'folder using your preferred FTP program.', MEBAK_LOCALE ) . '<br />'
				. __( 'Then give it full privileges (0777) and reload this page.', MEBAK_LOCALE )
#-------------
#	0.1.0: END
#

			.'</div>';
			echo MEBAK_BACK_BUTTON;
			return;
		}
	}

	#
	#	the backup folder is still not present :/
	#
	if(!file_exists(MEBAK_BACKUP_PATH))
	{
		echo '<div class="error">'
			. __( 'The backup folder does not exist ', MEBAK_LOCALE ) . '<b>' . MEBAK_BACKUP_PATH . '</b>'

#
#	0.1.0: BEG
#-------------
				. '<br />'
				. __( 'Please manually create the', MEBAK_LOCALE ) . ' <b>' . MEBAK_BACKUP_FOLDER . '</b> '
				. __( 'in your', MEBAK_LOCALE ) . ' <b>' . MEBAK_BACKUP_ROOT . '</b> '
				. __( 'folder using your preferred FTP program.', MEBAK_LOCALE ) . '<br />'
				. __( 'Then give it full privileges (0777) and reload this page.', MEBAK_LOCALE )
#-------------
#	0.1.0: END
#

		.'</div>';
		echo MEBAK_BACK_BUTTON;
		return;
	}

	//if($_GET['dwnfile']!='')													#	0.1.0
	if($_POST['dwn_action']=='download' && strlen($_POST['dwn_file'])>0)		#	0.1.0
	{
		#	download a data set
		#
		echo '<div class="updated">'
			. __( 'Downloading', MEBAK_LOCALE ) .'... '. MEBAK_BACKUP_PATH.'/'.$_POST['dwn_file']		#	0.1.0: added the file name
		.'</div>';
		echo MEBAK_BACK_BUTTON;

		?><script type="text/javascript">
			//window.location='<?php echo MYEASYBACKUP_LINK.'meb_download.php?dwnfile=' . $_GET['dwnfile']; ?>';	//	0.1.0
			document.dwn_exec_form.submit();				//	0.1.0
		</script><?php

		return;
	}

	if(isset($_POST['ftp_pwd']) && isset($_POST['ftp_action']) && isset($_POST['ftp_file']))					#	0.0.5
	{
		#	upload a data set by ftp
		#
		if(!defined('FTP_SERVER') || strlen(FTP_SERVER)==0
				||
			!defined('FTP_USER_NAME') || strlen(FTP_USER_NAME)==0
			//	||
			//!defined('FTP_USER_PASS') || strlen(FTP_USER_PASS)==0
		) {
			echo ''
				.'<div class="error">'
					.'<b>'
						. __( 'It looks like you have not defined the FTP credentials', MEBAK_LOCALE )
					.'</b><br /><br />'

					.'<div>'
						.'<input type="button" class="button-secondary" style="cursor:pointer;" value="'
									. __( 'Set the FTP credentials', MEBAK_LOCALE )
									. '" onclick="javascript:window.location=\''.'options-general.php?page=myEASYbackup_options\';" />'
					.'</div><br />'
				.'</div>'
			;
			return;
		}

		echo MEBAK_POPWIN . '<script>set_waiting_message(\'up\');</script>';	#	0.0.7
		flush();																#	0.0.7

		echo ''
			//.MEBAK_POPWIN
			//.'<script>set_waiting_message(\'up\');</script>'
			.'<div class="updated">'
			.'<h2>'
				. __( 'Uploading a data set', MEBAK_LOCALE )
			.'</h2>'
		;


		$source_file = MEBAK_BACKUP_PATH . '/' . $_POST['ftp_file'];
		$destination_file = $_POST['ftp_file'];

		#
		#	set up basic ftp connection
		#
		$conn_id = @ftp_connect(FTP_SERVER, 21);
		$login_result = '';

		if($conn_id)
		{
			$login_result = @ftp_login($conn_id, FTP_USER_NAME, $_POST['ftp_pwd']);
		}

		if((!$conn_id) || (!$login_result))
		{
			echo '<h3 style="color:red;">'
				. __( 'FTP connection has failed!', MEBAK_LOCALE )
				. '</h3>'

				. '<p>' . __( 'Server', MEBAK_LOCALE )
					. ': <b>' . FTP_SERVER . '</b>'
				.'</p>'

				. '<p>' . __( 'User', MEBAK_LOCALE )
					. ': <b>' . FTP_USER_NAME . '</b>'
				.'</p>'
				.'</div>'
				.MEBAK_BACK_BUTTON
			;
			return;
		}
		else
		{
			echo '<h3 style="color:green;">'
				.__( 'Connected to', MEBAK_LOCALE )
					. ': <b>' . FTP_SERVER . '</b>'
				. ' '
				. __( 'as user', MEBAK_LOCALE )
					. ': <b>' . FTP_USER_NAME . '</b>'
				.'</h3>'
			;
		}

		if($conn_id)
		{
			#	upload the file
			#
			ftp_pasv($conn_id, true);	#	0.0.6

			#
			#	0.0.7: BEG
			#-------------
			//$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);		#	0.0.5

			$local_file_size = filesize($source_file);
			$started = time();
			//$upload = false;

			$fh = fopen($source_file, 'r');
			$ret = ftp_nb_fput($conn_id, $destination_file, $fh, FTP_BINARY);
			while($ret==FTP_MOREDATA)
			{
				$now = time();
				$transferred_size = ftell($fh);
				$percentage = (int)(($transferred_size/$local_file_size)*100);

				$passed = $now - $started;
				if($passed<1) { $passed = 1; }

				$transfer_rate = (int)($transferred_size/$passed/1024);

				$est = (($local_file_size-$transferred_size)/$transfer_rate/1000);

				$estimated = '';
				$time = false;
				if(date('H', $est)>0)
				{
					$estimated = '<b>' . ltrim(date('H', $est), '0') . '</b> ' . __( 'hours', MEBAK_LOCALE ) . ' ';
					$time = true;
				}
				if(date('i', $est)>0 || $time==true)
				{
					$estimated .= '<b>' . ltrim(date('i', $est), '0') . '</b> ' . __( 'minutes', MEBAK_LOCALE ) . ' ';
					$time = true;
				}
				//if(date('s', $est)>0 || $time==true)
				//{
					$estimated .= '<b>' . (int)ltrim(date('s', $est), '0') . '</b> ' . __( 'seconds', MEBAK_LOCALE ) . ' ';
					$time = true;
				//}

				echo '<script>document.getElementById(\'wait_progress\').innerHTML=\''

						. '<b>' . $percentage . '</b>%'

						. '<p>'
							. __( 'estimated remaining time', MEBAK_LOCALE ) . ' ' . $estimated
						. '</p>'

						. '<p>'
							. __( 'transfer rate', MEBAK_LOCALE ) . ' <b>' . $transfer_rate . ' kb/sec</b>'
						. '</p>'

					. '\';</script>'
				;
				flush();

				$ret = ftp_nb_continue($conn_id);
			}

			### if($ret==FTP_FINISHED) { $upload = true; }	/*---| this one sometimes gives you a wrong result and made me loose a lot of time... |---*/

			fclose($fh);

			#
			#	get the data set size on the ftp server
			#
			$conn_id = @ftp_connect(FTP_SERVER, 21);
			$login_result = @ftp_login($conn_id, FTP_USER_NAME, $_POST['ftp_pwd']);

			clearstatcache();
			$remote_file_size = ftp_size($conn_id, $destination_file);

			#
			#	if the data set size is the same we can consider the upload successfull
			#
			$upload = false;
			if($remote_file_size==$local_file_size)
			{
				$upload = true;
			}

			echo '<p>'
					. __( 'Data set size on this system:', MEBAK_LOCALE ) . ' <b>' . number_format($local_file_size, 0) . '</b>'
				.'</p>'
				.'<p>'
					.__( 'Data set size on ', MEBAK_LOCALE ) . FTP_SERVER . ': <b>' . number_format($remote_file_size, 0) . '</b>'
				.'</p>'
			;
			#-------------
			#	0.0.7: END
			#

			#
			#	0.0.6: BEG
			#-------------
			#
			#	upload the myeasyrestore tool on demand
			#
			if($upload==true)
			{
				if($_POST['upload_restore_tool']==1)
				{
					echo '<script>document.getElementById(\'wait_progress\').innerHTML=\''

							. '<p>'
								. __( 'Uploading the myEASYrestore tool...', MEBAK_LOCALE )
							. '</p>'

						. '\';</script>'
					;												#	0.0.7
					flush();										#	0.0.7

					$source_tool_file = MEBAK_PATH . 'service/myEASYrestore';
					$destination_tool_file = 'myEASYrestore.php';

					$upload_tool = ftp_put($conn_id, $destination_tool_file, $source_tool_file, FTP_ASCII);
				}
			}
			#-------------
			#	0.0.6: END
			#

			#
			#	close the ftp stream
			#
			ftp_close($conn_id);
		}

		#
		#	upload result
		#
		if(!$upload)
		{
			echo '<h3 style="color:red;">'
					. __( 'FTP upload has failed!', MEBAK_LOCALE )
				. '</h3>'
			;
		}
		else
		{
			echo '<h3 style="color:green;">'
				.__( 'Upload completed successfully!', MEBAK_LOCALE )
				.'</h3>'
				.'<p>'
					. __( 'FTP server', MEBAK_LOCALE )
					. ': <b>' . FTP_SERVER . '</b>'
				.'</p>'
				.'<p>'
					. __( 'File on this server', MEBAK_LOCALE )
					. ': <b>' . $source_file . '</b>'
				.'</p>'
				.'<p>'
					. __( 'File on the remote server', MEBAK_LOCALE )
					. ': <b>' . $destination_file . '</b>'
				.'</p>'
			;

			if($_POST['upload_restore_tool']==1)		#	0.0.6
			{
				if(!$upload_tool)
				{
					echo '<h3 style="color:red;">'
							. __( 'Unable to upload the myEASYrestore tool!', MEBAK_LOCALE )
						. '</h3>'
					;
				}
				else
				{
					echo '<h3 style="color:green;">'
							. __( 'myEASYrestore tool successfully uploaded!', MEBAK_LOCALE )
						. '</h3>'
					;
				}
			}
			else
			{
				echo '<h3>'
						. __( 'You decided NOT to upload the myEASYrestore tool.', MEBAK_LOCALE )
					. '</h3>'
				;
			}
		}

		echo '</div>'
				.MEBAK_BACK_BUTTON
		;

 		?><script type="text/javascript">
			hide_waiting_message();
		</script><?php

		echo '<script>document.getElementById(\'myeasybackup_popWin\').style.display=\'none\';</script>';	#	0.0.7
		flush();																							#	0.0.7

		return;
	}

	if($_GET['dltfile']!='')
	{
		#	delete a data set
		#
		if(file_exists(MEBAK_BACKUP_PATH . '/' . $_GET['dltfile']))
		{
			unlink(MEBAK_BACKUP_PATH . '/' . $_GET['dltfile']);
			echo '<div class="updated">'
					.'<b>' . $_GET['dltfile'] . '</b> '
					. __( 'deleted', MEBAK_LOCALE )
				.'</div>'
			;
		}

		?><meta http-equiv="refresh" content="0; URL=<?php echo $_SERVER['PHP_SELF']; ?>?page=myEASYbackup_tools"><?php
		return;
	}

	#
	#	set variables
	#
	if(trim($_POST['server'])=='')		{ $_POST['server'] = DB_HOST; }
	if(trim($_POST['database'])=='')	{ $_POST['database'] = DB_NAME; }
	if(trim($_POST['username'])=='')	{ $_POST['username'] = DB_USER; }
	if(trim($_POST['password'])=='')	{ $_POST['password'] = DB_PASSWORD; }
	if(trim($_POST['filename'])=='')	{ $_POST['filename'] = 'myEASYbackup__'.date('Y-m-d_H-i-s', time()); }

	if(trim($_POST['cdatabase'])=='')	{ $cdatabase = ' checked="checked"'; }
	if(trim($_POST['cwordpress'])=='')	{ $cwordpress = ' checked="checked"'; }

	if(!array_key_exists('_action', $_POST))
	{
		?>
		<!--<form enctype="multipart/form-data" method="post" name="myeasybackup" id="myeasybackup" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=myEASYbackup_tools">-->
		<!--	<input type="hidden" id="_action" name="_action" value="" />-->
			<div style="margin-bottom:20px;">
			<?php

			_e( 'Check this to add the database tables to the data set', MEBAK_LOCALE );

			?> &raquo; <input id="cdb" type="checkbox" name="cdatabase"<?php echo $cdatabase; ?> /><label for="cdb">
				<img src="<?php echo MYEASYBACKUP_LINK; ?>img/database.png" alt="Add database" align="absmiddle" />
			</label>
			<br />
			<?php

			_e( 'Check this to add the WordPress installation folder to the data set', MEBAK_LOCALE );

			?> &raquo; <input id="cwp" type="checkbox" name="cwordpress"<?php echo $cwordpress; ?> /><label for="cwp">
				<img src="<?php echo MYEASYBACKUP_LINK; ?>img/wordpress-folder.png" alt="Add WordPress folder" align="absmiddle" />
			</label>
			<br />
			<?php

			_e( 'The full path of the new data set will be', MEBAK_LOCALE );

			?>:
			<div style="padding:8px;background-color:#B3EFB5;margin-bottom:20px;-moz-border-radius:6px;border-radius:6px;width:auto;">
				<b><?php echo MEBAK_BACKUP_PATH . '/' . $_POST['filename'] . '.zip'; ?></b>
			</div><?php

			_e( 'Click on the briefcase to create a new data set', MEBAK_LOCALE );

			?> &raquo; <img src="<?php echo MYEASYBACKUP_LINK; ?>img/dataset-off.png" width="48px" height="48px"
							onmouseover="javascript:this.src='<?php echo MYEASYBACKUP_LINK; ?>img/dataset.png';"
							onmouseout="javascript:this.src='<?php echo MYEASYBACKUP_LINK; ?>img/dataset-off.png';"
							onclick="javascript:set_waiting_message();
												document.exec_backup._action.value='backup';
												document.exec_backup.submit();

												return false;"
							alt="<?php _e( 'BRIEFCASE', MEBAK_LOCALE ); ?>" align="absmiddle" />
			<br />
		</div>
		<input type="hidden" name="filename" value="<?php echo $_POST['filename']; ?>" /><?php

		$datasets = scandir(MEBAK_BACKUP_PATH);

		if(count($datasets)<=2)
		{
			#	if the directory is empty there are at least two dirs: '.' and '..'
			#
			echo '<code>* ' . __( 'There are no data sets on the server', MEBAK_LOCALE ) . ' *</code>';
		}
		else
		{
			echo '<h3 style="margin-bottom:0;">' . __( 'Data sets on the server', MEBAK_LOCALE ) . '</h3>';

			#
			#	0.0.6: BEG
			#-------------
			_e( 'Click on the wrench to include the myEASYrestore tool when uploading a data set', MEBAK_LOCALE );

			if($_POST['upload_restore_tool']==1)
			{
				$tool_img = MYEASYBACKUP_LINK . 'img/mer-tool.png';
			}
			else
			{
				$tool_img = MYEASYBACKUP_LINK . 'img/mer-tool-off.png';
			}

			?> &raquo; <img src="<?php echo $tool_img; ?>" id="upload_restore_tool_img" style="cursor:pointer;" width="48px" height="48px"
							onclick="javascript:var el=document.getElementById('upload_restore_tool_');
												if(el.value==0) {
													el.value=1;
													this.src='<?php echo MYEASYBACKUP_LINK . 'img/mer-tool.png'; ?>';
												}else{
													el.value=0;
													this.src='<?php echo MYEASYBACKUP_LINK . 'img/mer-tool-off.png'; ?>';
												};"
							alt="<?php _e( 'WRENCH', MEBAK_LOCALE ); ?>" align="absmiddle" />
			<br /><?php
			#-------------
			#	0.0.6: END
			#

			echo
				__( 'A data set (each suitcase) is a compressed (.zip) file including your backup.', MEBAK_LOCALE )
				. '<br />' . __( 'Its content depends on what options you selected when doing the backup', MEBAK_LOCALE )

				.':<ul>'

					. '<li> * ' . __( 'Tables', MEBAK_LOCALE ) . '</li>'
					. '<li> * ' . __( 'WordPress installation folder', MEBAK_LOCALE ) . '</li>'
					. '<li> * ' . __( 'BOTH', MEBAK_LOCALE ) . '</li>'

				.'</ul>';							#	0.0.9


			echo '<table border="1" cellspacing="4" cellpadding="4" style="margin-bottom:40px;">';

			$totalsize = 0;

			foreach($datasets as $ds)
			{
				if($ds!='.' && $ds!='..'
					&& substr($ds,0,12)=='myEASYbackup'			#	0.1.0
					&& substr($ds,-4)=='.zip'					#	0.0.9
				) {
					$filesize = filesize(MEBAK_BACKUP_PATH . '/' . $ds);
					$totalsize += $filesize;

					echo '<tr>'
							.'<td>'
								.'<input type="image" name="download" value="download" '
										.'src="'.MYEASYBACKUP_LINK.'img/download-off.png" '
										.'onmouseover="javascript:this.src=\''.MYEASYBACKUP_LINK.'img/download.png\';" '
										.'onmouseout="javascript:this.src=\''.MYEASYBACKUP_LINK.'img/download-off.png\';" '

										#
										#	0.1.0: BEG
										#-------------
										//.'onclick="javascript:window.location=\''.$_SERVER['PHP_SELF'].'?page=myEASYbackup_tools&dwnfile='.$ds.'\';return false;" '
										.'onclick="javascript:'
											.'document.getElementById(\'dwn_action\').value=\'download\';'
											.'document.getElementById(\'dwn_file\').value=\''.$ds.'\';'
											.'document.dwn_backup.submit();'
											.'return false;'
										.'"'
										#-------------
										#	0.1.0: BEG
										#

										.'alt="DOWNLOAD" '
										.'title="DOWNLOAD" '								#	0.1.0
										.'align="absmiddle" />'
							.'</td>'
							#
							#	0.0.5: BEG
							#-------------
							.'<td>'
									.'<img name="ftpupload" value="ftpupload" '
										.'src="'.MYEASYBACKUP_LINK.'img/upload-off.png" '
										.'style="cursor:pointer;" '							#	0.1.0
										.'onmouseover="javascript:this.src=\''.MYEASYBACKUP_LINK.'img/upload.png\';" '
										.'onmouseout="javascript:this.src=\''.MYEASYBACKUP_LINK.'img/upload-off.png\';" '
										.'onclick="javascript:'
															.'var pwd=prompt(\''
																.__( 'Please type the password to connect to', MEBAK_LOCALE )
																.'\n'.FTP_SERVER.'\n'
															.'\');'
															.'if(pwd && pwd.length>0){'
//																.'set_waiting_message(\'up\');'
																//.'window.location=\''.$_SERVER['PHP_SELF'].'?page=myEASYbackup_tools&ftpfile='.$ds.'\';'
																.'document.getElementById(\'ftp_pwd\').value=pwd;'
																.'document.getElementById(\'ftp_action\').value=\'ftpupload\';'
																.'document.getElementById(\'ftp_file\').value=\''.$ds.'\';'
																.'document.ftp_upload.submit();'
																.'return false;'
															.'};'
															.'return false;" '
										.'alt="FTP UPLOAD" '
										.'title="FTP UPLOAD" '								#	0.1.0
										.'align="absmiddle" />'
							.'</td>'
							#-------------
							#	0.0.5: END
							#
							.'<td>'
								.'<input type="image" name="delete" value="delete" '
										.'src="'.MYEASYBACKUP_LINK.'img/delete-dataset-off.png" '
										.'onmouseover="javascript:this.src=\''.MYEASYBACKUP_LINK.'img/delete-dataset.png\';" '
										.'onmouseout="javascript:this.src=\''.MYEASYBACKUP_LINK.'img/delete-dataset-off.png\';" '
										.'onclick="javascript:'
													.'if(confirm(\''.__( 'Are you sure that you want to delete this data set?', MEBAK_LOCALE ).'\')==false) {'
														.'return false;'
													.'};'
													.'window.location=\''.$_SERVER['PHP_SELF'].'?page=myEASYbackup_tools&dltfile='.$ds.'\';return false;" '
										.'alt="DELETE" '
										.'title="DELETE" '									#	0.1.0
										.'align="absmiddle" />'
							.'</td>'
							.'<td>'
								.$ds
							.'</td>'
							.'<td align="right">'
								.number_format($filesize, 0, '', ',')
							.'</td>'
							.'<td>'
								.' '
								.__( 'bytes', MEBAK_LOCALE )
							.'</td>'
						.'</tr>'
					;
				}
			}

			echo '<tr>'
					.'<td colspan="3"></td>'				#	0.0.5
					.'<td align="right">'
						.__( 'Total space used by data sets', MEBAK_LOCALE )
						.':'
					.'</td>'
					.'<td align="right">'
						.'<b>'
							.number_format($totalsize, 0, '', ',')
						.'</b> '
					.'</td>'
					.'<td>'
						.__( 'bytes', MEBAK_LOCALE )
					.'</td>'
				.'</tr>'
				.'</table>'
			;
		}
	}
	else if($_POST['_action']=='backup')
	{
		#	perform backup
		#
		$errors = checkvariables();

		if($_POST['cdatabase'])
		{
			$dbh = @mysql_connect($_POST['server'], $_POST['username'], $_POST['password']);
			if($dbh=='') {
				echo '<div class="error">'
					.__( 'Impossible to connect to the MySQL server', MEBAK_LOCALE )
					.':<br />'
					.__( 'MySQL Error', MEBAK_LOCALE )
					.' ('.@mysql_errno().'): '.@mysql_error()
				.'</div>';
				$errors = true;
			}

			$dbs = @mysql_select_db($_POST['database'], $dbh);
			if($dbs=='') {
				echo '<div class="error">'
					.__( 'Impossible to connect to the database', MEBAK_LOCALE )
					.':<br />'
					.__( 'MySQL Error', MEBAK_LOCALE )
					.' ('.@mysql_errno().'): '.@mysql_error()
				.'</div>';
				$errors = true;
			}
		}

		if($_POST['filename']=='') {
			echo '<div class="error">'
					.__( 'File name is mandatory!', MEBAK_LOCALE )
			.'</div>';
			$errors = true;
		}

		if($errors==true)
		{
			echo MEBAK_BACK_BUTTON;
			return;
		}

		#
		#	configuration is fine
		#
		if(file_exists(MEBAK_BACKUP_PATH . '/' . $_POST['filename'] . '.sql'))								#	0.0.4
		{
			echo '<div class="error">'
					.__( 'Backup file', MEBAK_LOCALE )
					.' ' . MEBAK_BACKUP_PATH . '/' . $_POST['filename'] . '.sql '							#	0.0.4
					.__( 'does already exists: please try again with a different name.', MEBAK_LOCALE )
			.'</div>';
			echo MEBAK_BACK_BUTTON;
			return;
		}
		else
		{
			echo '<div id="backingup">'
					.__( 'Backing up...', MEBAK_LOCALE )
				.'</div>'

				.'<div class="updated">'
			;

			$result = 0;

			#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			#	backup the database - beg
			#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			if($_POST['cdatabase'])
			{
				echo __( 'Extracting database tables...', MEBAK_LOCALE ) . '<br /><br />';	#	0.0.5

				$user = $_POST['username'];
				$pwd = $_POST['password'];
				$host = $_POST['server'];
				$file = MEBAK_BACKUP_PATH .'/' . $_POST['filename'] . '.sql';
				$db = $_POST['database'];

				if(isSYSTEM==true && FORCE_PHPCODE==false)									#	0.0.5
				{
					#	using mysqldump
					#
					$tmpfile = tempnam( '/tmp', 'mebak_plugin' );

					echo '<pre>';
						system( 'mysqldump --opt --no-create-db '
									.' -u' . $user
									.' -p' . $pwd
									.' -h' . $host
									//.' -r' . escapeshellarg(MEBAK_BACKUP_PATH) . '/' . escapeshellarg($_POST['filename']) . '.sql ' . escapeshellarg($_POST['database']) . ' 1> ' . escapeshellarg($tmpfile) .' 2>&1',
									.' -r' . escapeshellarg($file) . ' ' . escapeshellarg($db) . ' 1> ' . escapeshellarg($tmpfile) .' 2>&1',
									#
									#	0.0.5:	added escapeshellarg() to ensure that users cannot trick
									#			the system into executing arbitrary commands
									#
									$result );
					echo '</pre><br />';
				}
				else
				{
					#	getting database data with queries
					#
					#	0.0.5: added for servers not able to execute system()
					#
					$query = mysql_query('SHOW TABLES');
					$table = '';
					$i = 0;
					while($tables = mysql_fetch_array($query, MYSQL_ASSOC))
					{
						list(,$table) = each($tables);
						$table_select[$i] = $table;
						$i++;
					}

					$fp = fopen($file, 'w');					#	0.0.5

					if(!$fp)
					{
						echo '<div class="error">'
								.__( 'Impossible to create', MEBAK_LOCALE )
								.': <b>' . $file . '</b> '
						.'</div>';
						echo MEBAK_BACK_BUTTON;
						return;
					}

#
#	0.0.9: BEG
#-------------
					//$data = 	 '/*************************************************' . "\n"
					//			.' * MySQL backup' . "\n"
					//			.' * ' . "\n"
					//			.' * Database: '. $_POST['database'] . "\n"
					//			.' * Site: ' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . "\n"
					//			.' * ' . "\n"
					//			.' * Backup started: ' . date('r U', time()) . "\n"
					//			.' *' . "\n"
					//			.' * Host: '. mysql_get_host_info() . "\n"
					//			.' * MySQL server version: '. mysql_get_server_info() . "\n"
					//			.' * MySQL protocol: '. mysql_get_proto_info() . "\n"
					//			.' *' . "\n"
					//			.' * Created with myEASYbackup version ' . MYEASYBACKUP_VERSION . "\n"
					//			.' * http://myeasywp.com' . "\n"
					//			.' *' . "\n"
					//			.' */' . "\n"
					//;
					$data = 	 '/*'
								.' MySQL backup'
								.' Database: '. $_POST['database']
								.' Site: ' . str_replace('www.', '', $_SERVER['HTTP_HOST'])
								.' Backup started: ' . date('r U', time())
								.' Host: '. mysql_get_host_info()
								.' MySQL server version: '. mysql_get_server_info()
								.' MySQL protocol: '. mysql_get_proto_info()
								.' Created with myEASYbackup version ' . MYEASYBACKUP_VERSION
								.' http://myeasywp.com'
								.' */' . "/*[[EOR]]*/\n"
					;
#-------------
#	0.0.9: END
#

					fwrite($fp, $data);

					$i = 0;

					foreach ($table_select as $table)
					{
						$i++;

						echo __('Getting contents of table ') . ' <b>' . $table .'</b>...<br />';

#
#	0.0.9: BEG
#-------------
						//$data =  "\n" . '/******' . "\n"
						//		  .' * Structure for table `' . $table . '`' . "\n"
						//		  .' */' . "\n"
#-------------
#	0.0.9: END
#
						$data =  "\n" . '/******'
								  .' * Structure for table `' . $table . '`'
								  .' */' . "/*[[EOR]]*/\n"

									. 'DROP TABLE IF EXISTS `' . $table . '`;' . "/*[[EOR]]*/\n\n";

						$rows_query = mysql_query('SHOW CREATE TABLE `' . $table . '`');
						$tables = mysql_fetch_array($rows_query);

#
#	0.0.9: BEG
#-------------
						//$data .= $tables[1] . ";\n"
								//."\n" . '/******' . "\n"
								//  .' * Contents for table `' . $table . '`' . "\n"
								//  .' */' . "\n";

						$data .= str_replace("\n", ' ', $tables[1]) . ";/*[[EOR]]*/\n"
								."\n" . '/******'
								  .' * Contents for table `' . $table . '`'
								  .' */' . "/*[[EOR]]*/\n";
#-------------
#	0.0.9: END
#

						fwrite($fp, $data);

						$table_list = array();
						$fields_query = mysql_query('SHOW FIELDS FROM  `' . $table . '`');

						while($fields = mysql_fetch_array($fields_query))
						{
							$table_list[] = $fields['Field'];
						}

						$rows_query = mysql_query('SELECT * FROM `' . $table . '` ');
						$tr = 0;

//if($table=='wp_options')
//{
//	echo '$table_list[<br>';
//	var_dump($table_list);
//	echo ']<hr>'
//	.$rows_query.'<br>';
//}

						while($rows = mysql_fetch_array($rows_query))
						{

//if($table=='wp_options' && ($rows['option_id']>2730 && $rows['option_id']<2740))
//if($table=='wp_options' && $rows['option_id']==2735)
//{
//	echo '$rows[<br>';
//	var_dump($rows);
//	echo ']<hr>';
//}

							$tr++;
							$data = 'INSERT INTO `' . $table . '` (`' . implode('`, `', $table_list) . '`) VALUES (';

							fwrite($fp, $data);
							$comma = '';

							reset($table_list);
							while(list(,$i) = each($table_list))
							{

//if($table=='wp_options' && $rows['option_id']==2735)
//{
//	echo '$i['.$i.']<br>';
//	echo '$rows['.$i.']['.$rows[$i].']<br>';
//}

								$data = '';

								if(!isset($rows[$i]))
								{
									//$data .= 'NULL, ';			#	0.0.9
									$data .= 'NULL ';				#	0.0.9

//if($table=='wp_options' && $rows['option_id']==2735)
//{
//	echo '!isset($rows[$i])<br>';
//}

								}
								elseif(has_data($rows[$i]))
								{
									$row = addslashes($rows[$i]);
									$row = str_replace("\n#", "\n".'\#', $row);

									$data .= '\'' . $row . '\'';

//if($table=='wp_options' && $rows['option_id']==2735)
//{
//	echo 'has_data($rows[$i])<br>';
//}
								}
								else
								{
									$data .= '\'\'';

//if($table=='wp_options' && $rows['option_id']==2735)
//{
//	echo 'else<br>';
//}
								}


//if($table=='wp_options' && $rows['option_id']==2735)
//{
//	echo '<hr>';
//}


								fwrite($fp, $comma . $data);
								$comma = ', ';
							}

							fwrite($fp, ");/*[[EOR]]*/\n");
						}
						if($tr<1)
						{
							fwrite($fp, '/* Table `' . $table . '` is empty' .' */' . "/*[[EOR]]*/\n");
						}
					}

#
#	0.0.9: BEG
#-------------
					//$data = '/*************************************************' . "\n"
					//		.' * Backup ended: ' . date('r U', time()) . "\n"
					//		.' *************************************************/' . "\n"
					//;
					$data = '/* Backup ended: ' . date('r U', time()) . ' */' . "/*[[EOR]]*/\n"
					;
#-------------
#	0.0.9: END
#
					fwrite($fp, $data);
					fclose($fp);
				}
			}

			$finfo = stat($file);

			if(file_exists($file) && $finfo['size']>0)
			{
				echo '<br />'
					.__( 'Your database has been saved as', MEBAK_LOCALE )
					.': <b>'.$_POST['filename'] . '.sql'
					. '</b><br />';
			}
			else
			{
				echo '<div class="error">'
						.'<b>'
							.__( 'Error while trying to extract database data', MEBAK_LOCALE )
						.'</b>, '
				;

				if(isSYSTEM==true && FORCE_PHPCODE==false)					#	0.0.5
				{
					echo ''
						.__( 'using the following command', MEBAK_LOCALE )

						.':<br />'
						."mysqldump --opt --no-create-db -u$user -p$pwd -h$host "
								.' -r' . escapeshellarg($file) . ' ' . escapeshellarg($db) . ' 1> ' . escapeshellarg($tmpfile) .' 2>&1'
						;
				}
				else
				{
					echo ''
						.__( 'extracting data with queries', MEBAK_LOCALE );
				}

				echo '</div>'
					.MEBAK_BACK_BUTTON;
				return;
			}

			#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
			#	backup the database - end
			#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

			chmod($file, 0777);

			#
			#	compress the data set
			#
			chdir(MEBAK_BACKUP_PATH);

			$dwnfilename	= '';
			$dest_file_zip	= $_POST['filename']  . '.zip';

			#
			#	0.0.6: BEG
			#-------------
			#
			#	create the restore configuration file within the WordPress folder
			#
			//$ini_file = ABSPATH .'/myEASYrestore.ini';					#	0.0.9
			$ini_file = ABSPATH .'/myEASYrestore_ini.php';					#	0.1.0

			$fp = fopen($ini_file, 'w');									#	0.0.9
			if($fp)
			{
				$data = '<?php return; ?>' . "\n"							#	0.1.0
						.';---------------------------------------------------------' . "\n"
						.'; myEASYbackup data set restore/migrate configuration file' . "\n"
						.'; do NOT touch to avoid issues with myEASYrestore!' . "\n"
						.';' . "\n"
						.'; Created by myEASYbackup version ' . MYEASYBACKUP_VERSION . "\n"
						.'; http://myeasywp.com' . "\n"
						.';---------------------------------------------------------' . "\n\n"

						.'[mysql_src]' . "\n"
						.'DB_DB = "' .  DB_NAME . '"' . "\n"
						.'DB_USER = "' .  DB_USER . '"' . "\n"
						.'DB_PASSWORD = "' .  DB_PASSWORD . '"' . "\n"
						.'DB_CHARSET = "' .  DB_CHARSET . '"' . "\n"
						.'DB_COLLATE = "' .  DB_COLLATE . '"' . "\n"
						.'TBL_PREFIX = "' .  $table_prefix . '"' . "\n"
						."\n"

						.'[siteinfo_src]' . "\n"
						.'Root_path = "' . ABSPATH . '"' . "\n"
						.'Site = "' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . '"' . "\n"
						.'Host = "'. mysql_get_host_info() . '"' . "\n"
						.'Server_info = "'. mysql_get_server_info() . '"' . "\n"
						.'Server_protocol = "'. mysql_get_proto_info() . '"' . "\n"
						."\n"

						.'[options]' . "\n"
						.'Use_PHP_code = "' . FORCE_PHPCODE . '"' . "\n"

						.'; END OF DATA' . "\n"
						.';---------------------------------------------------------' . "\n"
				;
				fwrite($fp, $data);
				fclose($fp);

				echo '<b>'

						. __( 'The restore configuration file was successfully created.', MEBAK_LOCALE )

					.'</b><br /><br />';
			}
			else
			{
				echo '<p style="color:red;font-weight:bold;">'

						. __( 'Unable to create the restore configuration file, it will NOT be possible to use the myEASYrestore tool with this data set.', MEBAK_LOCALE )

					.'</p><p>'

						. __( 'However you will be able to manually restore the data set.', MEBAK_LOCALE )

					.'</p><br /><br />';

			}
			#-------------
			#	0.0.6: END
			#

			if(defined('isLINUX') && isLINUX==true && isSYSTEM==true && FORCE_PHPCODE==false)		#	0.0.5
			{
				#	Linux & system() is allowed
				#
				if($_POST['cdatabase'])
				{
					echo '<pre>';
						system( 'zip -rv' . COMPRESSION_LEVEL . ' '
									. MEBAK_BACKUP_PATH . '/' . $dest_file_zip
									. ' ' . $_POST['filename'] . '.sql',
									$result );
#
#	0.0.9: BEG
#-------------
						chdir(ABSPATH);
						system( 'zip -rv' . COMPRESSION_LEVEL . ' '
									. MEBAK_BACKUP_PATH . '/' . $dest_file_zip
									. ' wp-config.php'
									. ' ' . basename($ini_file),
									$result );
#-------------
#	0.0.9: END
#
					echo '</pre><br />';

					echo ''
						.__( 'Your database has been added to', MEBAK_LOCALE )
						.': <b>'.$dest_file_zip
						. '</b><br />';

					if(file_exists(MEBAK_BACKUP_PATH . '/' . $_POST['filename'] . '.sql'))
					{
						unlink(MEBAK_BACKUP_PATH . '/' . $_POST['filename'] . '.sql');
						echo __( 'The uncompressed MySQL backup file has been removed.', MEBAK_LOCALE )
								.'<br /><br />';
					}
				}

				if($_POST['cwordpress'])
				{
					echo '<br />' . __( 'Saving your WordPress installation...', MEBAK_LOCALE ) . '<br />';

					chdir(MEBAK_WP_PATH);

					echo '<pre>';
						system( 'zip -rv' . COMPRESSION_LEVEL . ' '
									. MEBAK_BACKUP_PATH . '/' . $dest_file_zip
									//. ' ' . MEBAK_WP_PATH,					#	0.0.6
									. ' . ',									#	0.0.6
									$result );
					echo '</pre><br />';

					echo ''
						.__( 'Your WordPress installation has been added to', MEBAK_LOCALE )
						.': <b>'.$dest_file_zip
						. '</b><br />';
				}

				$dwnfilename = $dest_file_zip;

			}
			else if((defined('isWINDOWS') && isWINDOWS==true) || isSYSTEM==false || FORCE_PHPCODE==true)		#	0.0.5
			{
				#	Windows or system() is not allowed
				#
				chdir(MEBAK_BACKUP_PATH);

				//$zip = new ZipArchive();
				$zip = new Zipper();

				if($zip->open(MEBAK_BACKUP_PATH . '/' . $dest_file_zip, ZIPARCHIVE::OVERWRITE) === true)
				{
					if($_POST['cdatabase'])
					{
						if(file_exists($_POST['filename'] . '.sql'))
						{
							$zip->addFile(basename($_POST['filename'] . '.sql'));

#
#	0.0.9: BEG
#-------------
							chdir(ABSPATH);
							$zip->addFile('wp-config.php');
							$zip->addFile(basename($ini_file));
#-------------
#	0.0.9: END
#

							echo ''
								.__( 'Your database has been added to', MEBAK_LOCALE )
								.': <b>'.$dest_file_zip
								. '</b><br />';
						}
					}

					if($_POST['cwordpress'])
					{
						echo '<br />' . __( 'Saving your WordPress installation...', MEBAK_LOCALE ) . '<br />';

						$zip->addDir(substr(MEBAK_WP_PATH, 0, -1));

						echo '<br />'
							.__( 'Your WordPress installation has been added to', MEBAK_LOCALE )
							.': <b>'.$dest_file_zip
							. '</b><br /><br />';
					}

					$zip->close();

					echo '<b>'
						.__( 'Your backup data set was successfully compressed.', MEBAK_LOCALE )
						.'</b><br />';

					$finfo = stat(MEBAK_BACKUP_PATH . '/' . $dest_file_zip);
					echo __( 'The compressed file size is', MEBAK_LOCALE )
								.': <b>'.number_format($finfo['size']).'</b> bytes<br /><br />';

					$dwnfilename = $dest_file_zip;
				}
				else
				{
					echo '<div class="error">'
							.__( 'Error when trying to compress your backup', MEBAK_LOCALE )
							.':<br />'
#
#	0.1.0: BEG
#-------------
							//.$zip->status
							.$zip->getStatusString

							. '<br />' . __( 'While trying to create the file', MEBAK_LOCALE ) . ':<br />'
							.MEBAK_BACKUP_PATH . '/' . $dest_file_zip
#-------------
#	0.1.0: END
#
						.'</div>';
					echo MEBAK_BACK_BUTTON;
				}
			}


			if(file_exists(MEBAK_BACKUP_PATH . '/' . $_POST['filename'] . '.sql'))
			{
				unlink(MEBAK_BACKUP_PATH . '/' . $_POST['filename'] . '.sql');
				echo __( 'The uncompressed MySQL backup file has been removed.', MEBAK_LOCALE )
						.'<br /><br />';
			}

			echo '</div>';

			if(file_exists(MEBAK_BACKUP_PATH . '/' . $dest_file_zip))
			{
				chmod(MEBAK_BACKUP_PATH . '/' . $dest_file_zip, 0777);

				echo __( 'Click to download', MEBAK_LOCALE );

				?> &raquo;
					<input type="image" name="download" value="download"
										src="<?php echo MYEASYBACKUP_LINK; ?>img/download-off.png"
										onmouseover="javascript:this.src='<?php echo MYEASYBACKUP_LINK; ?>img/download.png';"
										onmouseout="javascript:this.src='<?php echo MYEASYBACKUP_LINK; ?>img/download-off.png';"
										onclick="javascript:window.location='<?php echo $_SERVER['PHP_SELF'].'?page=myEASYbackup_tools&dwnfile='.$dwnfilename?>';return false;"
										alt="DOWNLOAD"
										align="absmiddle" />

				<br /><br /><?php
			}
			else									#	0.0.5
			{
				echo '<div class="error">'

						. '<h2>' . __( 'Something went wrong!', MEBAK_LOCALE ) . '</h2>'

						. __( 'Please open the plugin settings page then', MEBAK_LOCALE )

							. ':<br /><br />&raquo; ' . __( 'enable the show debug option', MEBAK_LOCALE )
							. '<br />&raquo; ' . __( 'disable the prodution server option', MEBAK_LOCALE )
							. '<br />&raquo; ' . __( 'save the options', MEBAK_LOCALE )
							. '<br />&raquo; ' . __( 'copy the information shown in the "myEASYbackup debug info" box', MEBAK_LOCALE )
							. '<br />&raquo; ' . __( 'paste and send the information to', MEBAK_LOCALE )
								.': <a href="mailto:[email protected]">[email protected]</a>'
								.'<br /><br />'

						. __( 'The author will get in touch if he needs further info to be able to fix the problem.', MEBAK_LOCALE )
						. '<br />' . __( 'Thank you!', MEBAK_LOCALE )
						. '<br /><br />'
					.'</div>'
				;
			}

			?><script type="text/javascript">
				document.getElementById('backingup').style.display='none';
			</script><?php

			echo MEBAK_BACK_BUTTON;
		}
	}

	?></form><?php

	echo '<h3 style="margin-bottom:0;">'.__('Donation', MEBAK_LOCALE).'</h3>'
		.__('myEASYbackup was created to make your life easier.', MEBAK_LOCALE).' '
		.__('If you find it useful please make a donation, even a small amount, you will recognize my work and encourage me to go on with the development and support of this and all my other plugins!', MEBAK_LOCALE)

		.'<div align="center" style="margin-top:12px;text-align:center;">'
			.'<form action="https://www.paypal.com/cgi-bin/webscr" method="post">'
				.'<input type="hidden" name="cmd" value="_s-xclick">'
				.'<input type="hidden" name="hosted_button_id" value="7P3YH6G2MLTVU">'
				.'<input type="image" src="https://www.paypal.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">'
				.'<img alt="" border="0" src="https://www.paypal.com/it_IT/i/scr/pixel.gif" width="1" height="1">'
			.'</form>'
		.'</div>'

		.'<p><b><i>'.__('Thank you so much!', MEBAK_LOCALE).'</i></b></p>'

		.'<div style="margin:0;">'
			.'<img style="margin-right:8px;" src="http://myeasywp.com/common/img/camaleo.gif" align="absmiddle" /> '
			.'<a href="http://wordpress.org/extend/plugins/profile/camaleo" target="_blank">'.__('Camaleo\'s plugins page at WordPress.org', MEBAK_LOCALE).'</a>'
			.' | '
			.'<a href="http://myeasywp.com" target="_blank">myeasywp.com: '.__('Camaleo\'s plugins official site', MEBAK_LOCALE).'</a>'
		.'</div>'
	;

	echo '</div>';
}

?>