<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/


	
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_backup.gif" width="20" height="21" align="middle"> '.$MsgText[0][595];
	$BrowserTitle = $MsgText[0][595];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[0][595];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[22] == 'y') {
		
			$FileSource = './backups/'.$Arguments3;
		
			if (file_exists($FileSource)) {
							
				$disposition = "attachment"; // "inline" to view file in browser or "attachment" to download to hard disk
		
				$mime = "application/octet-stream";
		
		 		$name = $Arguments3; // file name
		
				header("Content-type: $mime");
				header("Content-Disposition:$disposition; filename=\"".trim(htmlentities($name))."\"");
				header("Content-Description: ".trim(htmlentities($name)));
				header("Content-Length: ".(string)(filesize($FileSource)));
		
		
				if (is_file($FileSource)) {
					$fp = fopen($FileSource, "rb");
					while (!feof($fp)) {
					    $buffer = fgets($fp, 4096);
					    echo $buffer;
					}
					fclose ($fp);
				}
				
				
				exit();
				
				
			}
			else {
			
				$PageContents = '<br>'.$MsgText[0][596];
			
			}
						
		
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}



?>
