<?php
/* Include Files ***************************/
require_once('../../db-config.php');
	if(  defined('LTDVERSION')  )
		die('0:DEMO VERSION!');
require_once('../../inc/config.php');
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('download',false) )
	die(__('Security Alert: Direct access not permitted!','recipeshelf'));

// Check for safe mode
if( ini_get('safe_mode') ){
   define('BACKUP_TEMP', dirname(__FILE__).'/../../photos' );    // overwrite TEMP folder with photos...which should be writeable
}
	
$f  = basename($_GET['f']);
$fn = BACKUP_TEMP.'/'.$f;

header("Content-Type: application/force-download");
header('Content-Disposition: attachment; filename="'.$f.'"');
header("Content-Length: ".filesize($fn));
header("Content-Transfer-Encoding: binary");
readfile($fn);

ob_start();
deleteFile( $fn );
ob_end_clean();
?>