<?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-importexport-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('import-export', false) )
	die('0|'.__('Security Alert: Direct access not permitted!','recipeshelf'));

if(  $_GET['action'] == 'export'  ){

	$e = new exportRecipe((int)$_GET['recipe-id']);
	$r = $e->export();

} else if(  $_GET['action'] == 'exportall'  ){

	$e = new exportRecipe('all');
	$r = $e->export();

} else if( $_POST['action'] == 'rs-import' && $_FILES  ){

	$i = new importRecipe();
	$r = $i->importXML();

    if( $r > 0 )
    	echo $r.'|'.__('Recipe data successfully imported.','recipeshelf');
    else
    	echo '0|'.__('ERROR! No data imported.','recipeshelf');

} else if( $_POST['action'] == 'cookml-import' && $_FILES  ){

	$i = new importRecipe();
	$r = $i->importCookML();

    if( $r > 0 )
    	echo $r.'|'.__('Recipe data successfully imported.','recipeshelf');
    else
    	echo '0|'.__('ERROR! No data imported.','recipeshelf');
}
?>