Location: PHPKode > projects > ChiCoMaS - Chilek CMS > chicomas/modules/filemanager/filemanager_operation.php
<?
//*****************************************************************************
function Create_Tab_Menu($request){

	global $module;
	global $module_path;

	$sf = $request['sf'];

	$content = "
	<div id=\"navcontainer\">
	<ul id=\"navlist\">";

	$current = "id=\"current\"";
	$active = "id=\"active\"";


	$content .= "<li><a href=\"".basename($PHP_SELF)."?mode=admin\">"._CONTROL_PANEL_."</a></li>";

	$content .= "<li $active><a href=\"".basename($PHP_SELF)."?f=filemanager\" $current>"._CP_FILE_ADMINISTRATION_."</a></li>";

	$content .= "
	</ul>
	</div>";

	return $content;
};

//------------------------------------------------------------------------------
function Get_PageName($pageid){
	$obj_page = new CPage();
	$obj_pagearray = new CPageArray();
	$obj_pageengine = new CPageEngine();

	$obj_content = new CContent();
	$obj_contentarray = new CContentArray();
	$obj_contentengine = new CContentEngine();

	$obj_page = $obj_pageengine->GetPage($pageid);
	$obj_content = $obj_contentengine->GetContent(ActiveLanguage(), $pageid, "name");

	return $obj_content->context;
}

//------------------------------------------------------------------------------
function Begin_FieldSet(){
	$content = null;
	$content .= "
	<center>
	<fieldset>
	<img style=\"float:right;\" src=\"./images/icon48/files.png\" width=\"48\" height=\"48\" border=\"0\"><br>
	<legend>"._CP_FILE_ADMINISTRATION_."</legend>
	<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">
	<tr><td align=\"center\">
	";
	return $content;
}

//------------------------------------------------------------------------------
function End_FieldSet(){
	$content = null;
	$content .= "
	</td></tr>
	</table>
	</fieldset>
	</center>
	";
	return $content;
}

//------------------------------------------------------------------------------
function GetFirstPage(){
	$content = null;

	$obj_page = new CPage();
	$obj_pagearray = new CPageArray();
	$obj_pageengine = new CPageEngine();

	$obj_pagearray = $obj_pageengine->GetParentPages(-1);
	$obj_page = $obj_pagearray->get();
	$thispageid = $obj_page->page_id;
	$firstpageid = $thispageid;

	return $firstpageid;
}

//------------------------------------------------------------------------------
function CheckActivePage($pageid){
	$content = null;

	$obj_page = new CPage();
	//$obj_pagearray = new CPageArray();
	$obj_pageengine = new CPageEngine();

	$obj_page = $obj_pageengine->GetPage($pageid);
	if ($obj_page)
		return true;
	else
		return false;
}


//------------------------------------------------------------------------------
function FileManager_Operation($request){
	$content = null;

	$obj_page = new CPage();
	$obj_pagearray = new CPageArray();
	$obj_pageengine = new CPageEngine();

	$sf = $request['sf'];
	$action = $request['action'];
	$operation = $request['operation'];

	$content .= Create_Tab_Menu($request);

	$obj_pagearray = $obj_pageengine->GetPagesByPageType(1);
	$num_rows = $obj_pagearray->count();

	if ($num_rows==0){

		$content .= "
		<div class=note>
			<h3>"._CMN_NOTE_."</h3>
			<p>";
			$content .= "<img src=\"./images/icon48/warning.png\" alt=\"\" width=\"48\" height=\"48\" border=\"0\">";
			$content .= "<br><br>";
			$content .= _CP_NO_PAGE_FOUND_;
			$content .= "<br><br>";
			$content .= go_back();
			$content .= "
			</p>
		</div>
		";

		$_SESSION['active_page'] = "";
	}
	else{
	
		$content .= Begin_FieldSet();

		umask(002); // Added to make created files/dirs group writable
	
		// Config Sections
		if ($_SESSION['active_page']==""){
			$_SESSION['active_page'] = GetFirstPage();
		}
		else{
			if (!CheckActivePage($_SESSION['active_page']))
				$_SESSION['active_page'] = GetFirstPage();
		}
	
		//Remove http://
		$sub_directory = substr($GLOBALS['thisurl'], 7, strlen($GLOBALS['thisurl']));
		//Get sub-directory
		$sub_directory = substr($sub_directory, strlen($_SERVER['HTTP_HOST']), strlen($sub_directory));
		$GLOBALS['home_dir'] = $_SERVER['DOCUMENT_ROOT'].$sub_directory."/sections/".$_SESSION['active_page'];
		$GLOBALS["home_url"] = "http://".$_SERVER['HTTP_HOST'].$sub_directory."/sections/".$_SESSION['active_page'];

		$GLOBALS["img_url"] = "http://".$_SERVER['HTTP_HOST'].$sub_directory."/modules/filemanager/images/";
		
		include "include/init.php";	// Init
	
	
		if ($action=="post")
			$action = $GLOBALS['__POST']["do_action"];
		if ($action=="get")
			$action = $GLOBALS['__GET']["do_action"];
	
		switch ($action){
		//------------------------------------------------------------------------------
		// DEFAULT: LIST FILES & DIRS
		default:
		//------------------------------------------------------------------------------
		case 'list':
			require "include/fun_list.php";
			$content .= list_dir($GLOBALS["dir"]);
		break;
		//------------------------------------------------------------------------------
		// CREATE DIR/FILE
		case "mkitem":
			require "include/fun_mkitem.php";
			$content .= make_item($GLOBALS["dir"]);
		break;
		//------------------------------------------------------------------------------
		// DELETE FILE(S)/DIR(S)
		case 'delete':
			require "include/fun_del.php";
			$content .= del_items($GLOBALS["dir"]);
		break;
		//------------------------------------------------------------------------------
		// EDIT FILE
		case "edit":
			require "include/fun_edit.php";
			$content .= edit_file($GLOBALS["dir"], $GLOBALS["item"]);
		break;
		//------------------------------------------------------------------------------
		// COPY/MOVE FILE(S)/DIR(S)
		case "copy":
		case "move":
			require "include/fun_copy_move.php";
			$content .= copy_move_items($GLOBALS["dir"]);
		break;
		//------------------------------------------------------------------------------
		// DOWNLOAD FILE
		case "download":
			ob_start(); // prevent unwanted output
			require "include/fun_down.php";
			ob_end_clean(); // get rid of cached unwanted output
			download_item($GLOBALS["dir"], $GLOBALS["item"]);
			ob_start(false); // prevent unwanted output
			exit;
		break;
		//------------------------------------------------------------------------------
		// UPLOAD FILE(S)
		case "upload":
			require "include/fun_up.php";
			$content .= upload_items($GLOBALS["dir"]);
		break;
		//------------------------------------------------------------------------------
		// CHMOD FILE/DIR
		case "chmod":
			require "include/fun_chmod.php";
			$content .= chmod_item($GLOBALS["dir"], $GLOBALS["item"]);
		break;
		//------------------------------------------------------------------------------
		// SEARCH FOR FILE(S)/DIR(S)
		case "search":
			require "include/fun_search.php";
			$content .= search_items($GLOBALS["dir"]);
		break;
		//------------------------------------------------------------------------------
		// CREATE ARCHIVE
		//case "arch":
			//require "include/fun_archive.php";
			//$content .= archive_items($GLOBALS["dir"]);
		//break;
		//------------------------------------------------------------------------------
		// USER-ADMINISTRATION
		//case "admin":
			//require "include/fun_admin.php";
			//$content .= show_admin($GLOBALS["dir"]);
		//break;
		//------------------------------------------------------------------------------
	
		}
		$content .= End_FieldSet();
	}


	return $content;
}
?>
Return current item: ChiCoMaS - Chilek CMS