<?php

	if (!$demo) {

	// save the current directory so we can return to it later, then set the working directory so the file management script thinks it's running from its own location
	$cwd = getcwd();
	chdir("thirdparty/rbfm/");
	
	// run the file management script and capture its output
	ob_start();
	eval(include_namespace("file_manager.php"));
	$fm_script = ob_get_contents();
	ob_end_clean();
	
	// change the image paths in the script output (we could do this with an HTML base tag, but then that would break our image and link paths)
	// change the include paths in the script output
	// change the script path in the script output
	$fm_script = str_replace("rbfmimg/", EDITOR_SUBDIRECTORY."/thirdparty/rbfm/rbfmimg/", $fm_script);
	$fm_script = str_replace("rbfminc/", EDITOR_SUBDIRECTORY."/thirdparty/rbfm/rbfminc/", $fm_script);
	$fm_script = str_replace("file_manager.php?", $wrapper_page."?page=files_manage&", $fm_script);
	
	// unless the user is an administrator, remove the download and edit options
	if ($role < 3) {
		//$fm_script = preg_replace("/<td>.*?rbfminc\/download.php.*?<\/td>/", "", $fm_script);
		//$fm_script = preg_replace("/\[.*?rbfmimg/ico_download.png.*?&nbsp; &nbsp;/", "", $fm_script);
		$fm_script = hide_content($fm_script, "download controls");
		$fm_script = hide_content($fm_script, "edit controls");
	}

	// return to the original working directory
	chdir($cwd);
	
	} else {
		$fm_script = "This page is not available in the demo. For a screen shot, please visit <a href=\"http://www.arlomedia.com/software/meditate/assembled/documentation_uploading.html\">http://www.arlomedia.com/software/meditate/assembled/documentation_uploading.html</a></p>";
	}
	
?>

<html>

	<head>
		<title><?php print EDITOR_NAME; ?></title>
		<?php eval(include_namespace(HEAD_FILE)); ?>
		<link href="<?php print EDITOR_SUBDIRECTORY; ?>/thirdparty/rbfm/rbfminc/file_editor_style.css" rel="stylesheet" type="text/css" />
	</head>
	
	<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
	
		<?php eval(include_namespace(HEADER_FILE)); ?>

		<p class="title">Manage files</p>
		
		<div id="feedback"></div>
		
		<?php print $fm_script; ?>
		
		<?php eval(include_namespace(FOOTER_FILE)); ?>

	</body>
	
</html>