<?php
/* Include Files ***************************/
require_once('../../db-config.php');
	if(  defined('LTDVERSION')  )
		die('0:DEMO VERSION!');
require_once('../../inc/lib-compat-class.php');
require_once('../../inc/lib-db-class.php');
require_once('../../inc/lib-login-class.php');
/*******************************************/
global $rSdb;

$user	= new userManagement();
if(  !$user->_logged_in  )
	die(__('Access denied.','recipeshelf'));

if( ! check_ajax_referer('backup-restore', false) )
	die('0|'.__('Security Alert: Direct access not permitted!','recipeshelf'));

if(  $_POST['action'] == 'backup'  ){

	$r = $rSdb->backup();

    if( $r[0] )
    	echo '1|'.$r[1].'|'.$r[2];
    else
    	echo '0|'.$r[1];


} else if(  $_FILES  ){


	chmod($_FILES['sqlupload']['tmp_name'], 0755);

	$r = $rSdb->restore( $_FILES['sqlupload']['tmp_name'],$_FILES['sqlupload']['name'] );

    if( $r[0] )
    	echo '1|'.$r[1];
    else
    	echo '0|'.$r[1];

}
?>