<?php
  /**
   * Controller
   *
   * @package CMS Pro
   * @author wojoscripts.com
   * @copyright 2010
   * @version $Id: controller.php, v2.00 2011-04-20 10:12:05 gewa Exp $
   */
   
  define("_VALID_PHP", true);
  
  require_once("../../init.php");

  if (!$user->is_Admin())
      redirect_to("../../login.php");
  
  require("class_fm.php");
  $fm = new Filemanager();
?>
<?php
  $action = (isset($_REQUEST['action'])) ? sanitize($_REQUEST['action']) : '';
  
  switch ($action) {
      case "delete":
          $fm->delete($_POST['name']);
          break;

      case "rename":
          if (empty($_POST['falias'])) {
              $core->msgError('<span>Error!</span>Please enter new File Alias');
		  } elseif(empty($_POST['name'])) {
			  $core->msgError('<span>Error!</span>Please select file to rename.');
          } else {
			  $fm->arename($_POST['name'],$_POST['falias']);
          }
          break;
		  
      case "upload":
          if (empty($_FILES['newfile']['name'])) {
              $core->msgError('<span>Error!</span>Please select file to upload');
		  } elseif(empty($_POST['alias'])) {
			  $core->msgError('<span>Error!</span>Please enter File Alias');
          } else {
              $filename = $_FILES['newfile']['name'];
			  $fm->uploadFile($filename);
          }
          break;
		  		  	            
      default:
          $fm->renderThumbs();
          break;
  }
?>