Location: PHPKode > projects > ChiCoMaS - Chilek CMS > chicomas/modules/filemanager/include/fun_list.php
<?php
/*------------------------------------------------------------------------------
     The contents of this file are subject to the Mozilla Public License
     Version 1.1 (the "License"); you may not use this file except in
     compliance with the License. You may obtain a copy of the License at
     http://www.mozilla.org/MPL/

     Software distributed under the License is distributed on an "AS IS"
     basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
     License for the specific language governing rights and limitations
     under the License.

     The Original Code is fun_list.php, released on 2003-03-31.

     The Initial Developer of the Original Code is The QuiX project.

     Alternatively, the contents of this file may be used under the terms
     of the GNU General Public License Version 2 or later (the "GPL"), in
     which case the provisions of the GPL are applicable instead of
     those above. If you wish to allow use of your version of this file only
     under the terms of the GPL and not to allow others to use
     your version of this file under the MPL, indicate your decision by
     deleting  the provisions above and replace  them with the notice and
     other provisions required by the GPL.  If you do not delete
     the provisions above, a recipient may use your version of this file
     under either the MPL or the GPL."
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
Author: The QuiX project
	hide@address.com
	http://www.quix.tk
	http://quixplorer.sourceforge.net

Comment:
	QuiXplorer Version 2.3
	Directory-Listing Functions
	
	Have Fun...
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// HELPER FUNCTIONS (USED BY MAIN FUNCTION 'list_dir', SEE BOTTOM)
function make_list($_list1, $_list2) {		// make list of files
	$list = array();

	if($GLOBALS["srt"]=="yes") {
		$list1 = $_list1;
		$list2 = $_list2;
	} else {
		$list1 = $_list2;
		$list2 = $_list1;
	}
	
	if(is_array($list1)) {
		while (list($key, $val) = each($list1)) {
			$list[$key] = $val;
		}
	}
	
	if(is_array($list2)) {
		while (list($key, $val) = each($list2)) {
			$list[$key] = $val;
		}
	}
	
	return $list;
}
//------------------------------------------------------------------------------
function make_tables($dir, &$dir_list, &$file_list, &$tot_file_size, &$num_items)
{
	// make table of files in dir
	// make tables & place results in reference-variables passed to function
	// also 'return' total filesize & total number of items
	$tot_file_size = $num_items = 0;
	
	// Open directory
	$handle = @opendir(get_abs_dir($dir));
	if($handle===false) show_error($dir.": ".$GLOBALS["error_msg"]["opendir"]);
	
	// Read directory
	while(($new_item = readdir($handle))!==false) {
		$abs_new_item = get_abs_item($dir, $new_item);
		
		if(!@file_exists($abs_new_item)) show_error($dir.": ".$GLOBALS["error_msg"]["readdir"]);
		if(!get_show_item($dir, $new_item)) continue;
		
		$new_file_size = filesize($abs_new_item);
		$tot_file_size += $new_file_size;
		$num_items++;
		
		if(get_is_dir($dir, $new_item)) {
			if($GLOBALS["order"]=="mod") {
				$dir_list[$new_item] =@filemtime($abs_new_item);
			}
			else {// order == "size", "type" or "name"
				$dir_list[$new_item] = $new_item;
			}
		}
		else {
			if($GLOBALS["order"]=="size") {
				$file_list[$new_item] = $new_file_size;
			} elseif($GLOBALS["order"]=="mod") {
				$file_list[$new_item] =
					@filemtime($abs_new_item);
			} elseif($GLOBALS["order"]=="type") {
				$file_list[$new_item] =
					get_mime_type($dir, $new_item, "type");
			} else {	// order == "name"
				$file_list[$new_item] = $new_item;
			}
		}
	}
	closedir($handle);

	// sort
	if(is_array($dir_list)) {
		if($GLOBALS["order"]=="mod") {
			if($GLOBALS["srt"]=="yes") arsort($dir_list);
			else asort($dir_list);
		} else {	// order == "size", "type" or "name"
			if($GLOBALS["srt"]=="yes") ksort($dir_list);
			else krsort($dir_list);
		}
	}
	
	// sort
	if(is_array($file_list)) {
		if($GLOBALS["order"]=="mod") {
			if($GLOBALS["srt"]=="yes") arsort($file_list);
			else asort($file_list);
		} elseif($GLOBALS["order"]=="size" || $GLOBALS["order"]=="type") {
			if($GLOBALS["srt"]=="yes") asort($file_list);
			else arsort($file_list);
		} else {	// order == "name"
			if($GLOBALS["srt"]=="yes") ksort($file_list);
			else krsort($file_list);
		}
	}
}

//------------------------------------------------------------------------------
function RecursivePageSelect($pageid, $recursivecount, $maindir){
	$content = null;

	$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_pagearray = $obj_pageengine->GetChildPages($pageid, -1);
	$num_rows = $obj_pagearray->count();

	if ($num_rows!=0){
		$recursivecount++;
		//echo "pageid:$pageid - recursivecount:$recursivecount<br>";
		for ( $counter = 1; $counter <= $recursivecount; $counter++)
			$braket = $braket."|--";
		while( $obj_page = $obj_pagearray->get() ){
			$thispageid=$obj_page->page_id;
			$thisactive=$obj_page->active;
			$obj_content = $obj_contentengine->GetContent(ActiveLanguage(), $thispageid, "name");
			$thisname = $obj_content->context;
			if ($thisactive==0)
				$activepage="style=\"background-color:gray;color:white\"";
			else
				$activepage="";
			if ($_SESSION['active_page']==$thispageid)
				$selected = "selected";
			else
				$selected = "";

			$content .= "<option value=\"$thispageid\" $activepage $selected>";
			$content .= "$braket";
			$content .= "$thisname</option>";;
			//echo "thisname(id):$thisname($thispageid)<br>";
			$content .= RecursivePageSelect($thispageid, $recursivecount, $maindir);
		}
	}
	else{
		$content = null;
		$recursivecount--;
		$braket = null;
	}

	return $content;
}

//------------------------------------------------------------------------------
function SelectPage($maindir){

	global $recursivecount;

	$content = null;

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

	$obj_subpage = new CPage();
	$obj_subpagearray = new CPageArray();
	$obj_subpageengine = new CPageEngine();

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

	if (!isset($f)) $f="filemanager";
	if (!isset($sf)) $sf="";

	$recursivecount = 0;
	$obj_pagearray = $obj_pageengine->GetParentPages(-1);
	$num_rows = $obj_pagearray->count();

	if ($num_rows!=0){
		$content = "
		<form action='".make_link("list",NULL,NULL)."' method='post'>
		<input type=\"hidden\" name=\"action\" value=\"list\" />
			<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">
			<tr>";
				if ($num_rows!=0){
					$content .= "
					<td align=\"left\">"._CP_FA_SELECT_PAGE_."</td>
					<td align=\"left\">
						<select name=\"maindir\">
						";
						while( $obj_page = $obj_pagearray->get() ){
							$thispageid = $obj_page->page_id;
							$thisactive=$obj_page->active;
							$obj_content = $obj_contentengine->GetContent(ActiveLanguage(), $thispageid, "name");
							$thisname = $obj_content->context;
							if ($thisactive==0)
								$activepage="style=\"background-color:gray;color:white\"";
							else
								$activepage="";
							if ($_SESSION['active_page']==$thispageid)
								$selected = "selected";
							else
								$selected = "";
							$content .= "<option value=\"$thispageid\" $activepage $selected>$thisname</option>";
			
							$recursivecount = 0;
							$content .= RecursivePageSelect($thispageid, $recursivecount, $maindir);
						}
						$content .= "
						</select>
						<input type=\"submit\" value=\""._CMN_SELECT_."\" style=\"float:center;\"/>
					</td>
				</tr>";
				}
			$content .= "
			</table>
		</form>";
	}

	return $content;
}

//------------------------------------------------------------------------------
function print_table($dir, $list, $allow) {	// print table of files
	$content = null;

	if(!is_array($list)) return;

	$dir_up = dirname($dir);
	if($dir_up==".") $dir_up = "";

	$content .= "
	<TR class=\"rowdata\">
		<TD nowrap>&nbsp;</TD>\n
		<TD nowrap><A HREF=\"".make_link("list",$dir_up,NULL)."\">
		<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"]."_up_.png\" ALT=\"\">&nbsp;..</A></TD>\n
		<TD nowrap>&nbsp;</TD>\n
		<TD nowrap>&nbsp;</TD>\n
		<TD nowrap>&nbsp;</TD>\n
		<TD nowrap>&nbsp;</TD>\n
		<TD nowrap>&nbsp;</TD>\n
	</TR>
	";

	while(list($item,) = each($list)){
		// link to dir / file
		$abs_item=get_abs_item($dir,$item);
		$target="";
		//$extra="";
		//if(is_link($abs_item)) $extra=" -> "hide@address.com($abs_item);
		if(is_dir($abs_item)) {
			$link = make_link("list",get_rel_item($dir, $item),NULL);
		} else { //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) {
			$link = $GLOBALS["home_url"]."/".get_rel_item($dir, $item);
			$target = "_blank";
		} //else $link = "";
		
		$content .= "<TR class=\"rowdata\"><TD><INPUT TYPE=\"checkbox\" name=\"selitems[]\" value=\"";
		$content .= htmlspecialchars($item)."\" onclick=\"javascript:Toggle(this);\"></TD>\n";
	// Icon + Link
		$content .= "<TD nowrap>";
		$content .="<A HREF=\"".$link."\" TARGET=\"".$target."\">";
		$content .= "<IMG border=\"0\" width=\"16\" height=\"16\" ";
		$content .= "align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"].get_mime_type($dir, $item, "img")."\" ALT=\"\">&nbsp;";

		$s_item=$item;

		if(strlen($s_item)>50) $s_item=substr($s_item,0,47)."...";

		$content .= htmlspecialchars($s_item)."</A></TD>\n";	// ...$extra...
	// Size
		$content .= "<TD>".parse_file_size(get_file_size($dir,$item))."</TD>\n";
	// Type
		$content .= "<TD>".get_mime_type($dir, $item, "type")."</TD>\n";
	// Modified
		$content .= "<TD>".parse_file_date(get_file_date($dir,$item))."</TD>\n";
	// Permissions
		$content .= "<TD>";
		if($allow) {
			$content .= "<A HREF=\"".make_link("chmod",$dir,$item)."\" TITLE=\"";
			$content .= $GLOBALS["messages"]["permlink"]."\">";
		}
		$content .= parse_file_type($dir,$item).parse_file_perms(get_file_perms($dir,$item));
		if($allow) $content .= "</A>";
		$content .= "</TD>\n";
	// Actions
		$content .= "<TD>\n<TABLE>\n";
		// EDIT
		if(get_is_editable($dir, $item)) {
			if($allow) {
				$content .= "<TD><A HREF=\"".make_link("edit",$dir,$item)."\">";
				$content .= "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
				$content .= "src=\"".$GLOBALS["img_url"]."_edit.gif\" ALT=\"".$GLOBALS["messages"]["editlink"]."\" TITLE=\"";
				$content .= $GLOBALS["messages"]["editlink"]."\"></A></TD>\n";
			} else {
				$content .= "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
				$content .= "src=\"".$GLOBALS["img_url"]."_edit_.gif\" ALT=\"".$GLOBALS["messages"]["editlink"]."\" TITLE=\"";
				$content .= $GLOBALS["messages"]["editlink"]."\"></TD>\n";
			}
		} else {
			$content .= "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
			$content .= "src=\"".$GLOBALS["img_url"]."_.gif\" ALT=\"\"></TD>\n";
		}
		// DOWNLOAD
		if(get_is_file($dir,$item)) {
			if($allow) {
				$content .= "<TD><A HREF=\"".make_link("download",$dir,$item)."\">";
				$content .= "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
				$content .= "src=\"".$GLOBALS["img_url"]."_download.gif\" ALT=\"".$GLOBALS["messages"]["downlink"];
				$content .= "\" TITLE=\"".$GLOBALS["messages"]["downlink"]."\"></A></TD>\n";
			} else if(!$allow) {
				$content .= "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
				$content .= "src=\"".$GLOBALS["img_url"]."_download_.gif\" ALT=\"".$GLOBALS["messages"]["downlink"];
				$content .= "\" TITLE=\"".$GLOBALS["messages"]["downlink"]."\"></TD>\n";
			}
		} else {
			$content .= "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
			$content .= "src=\"".$GLOBALS["img_url"]."_.gif\" ALT=\"\"></TD>\n";
		}
		$content .= "</TABLE>\n</TD></TR>\n";
	}
	return $content;
}
//------------------------------------------------------------------------------
// MAIN FUNCTION
function list_dir($dir) {			// list directory contents
	$content = null;

	$maindir = $_REQUEST['maindir'];

	if ($maindir!=""){
		if (is_numeric($maindir)){
			//$dir = $maindir;
			$_SESSION['active_page'] = $maindir;
			//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'];
			$dir = "";
			
		}
	}
	else{
		if (is_numeric($dir)){
			$maindir = $dir;
		}
		else{
			$maindir = substr($dir, 0, strpos($dir, '/'));
		}
	}

	$pageid = intval($_SESSION['active_page']);
	$s_page = Get_PageName($pageid);

	$allow=($GLOBALS["permissions"]&01)==01;
	$admin=((($GLOBALS["permissions"]&04)==04) || (($GLOBALS["permissions"]&02)==02));
	
	$dir_up = dirname($dir);
	if($dir_up==".") $dir_up = "";
	
	if(!get_show_item($dir_up,basename($dir))) show_error($dir." : ".$GLOBALS["error_msg"]["accessdir"]);
	
	// make file & dir tables, & get total filesize & number of items
	make_tables($dir, $dir_list, $file_list, $tot_file_size, $num_items);

	$subdir = strstr($dir, '/');

	$s_dir = $s_page."/".$dir;

	if(strlen($s_dir)>50) $s_dir="...".substr($s_dir,-47);

	$content .= show_header($GLOBALS["messages"]["actdir"].": /".get_rel_item("",$s_dir));
	
	// Javascript functions:
	include "./modules/filemanager/include/javascript.php";
	
	// Sorting of items
	$_img = "&nbsp;<IMG width=\"10\" height=\"10\" border=\"0\" align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"]."";
	if($GLOBALS["srt"]=="yes") {
		$_srt = "no";	$_img .= "_arrowup.gif\" ALT=\"^\">";
	} else {
		$_srt = "yes";	$_img .= "_arrowdown.gif\" ALT=\"v\">";
	}

	//Page Select	
	$content .= SelectPage($maindir);

	// Toolbar
	$content .= "<TABLE width=\"95%\"><TR><TD><TABLE><TR>\n";
	
	// PARENT DIR
	$content .= "<TD><A HREF=\"".make_link("list",$dir_up,NULL)."\">";
	$content .= "<IMG border=\"0\" width=\"24\" height=\"24\" align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"]."_up.png\" ";
	$content .= "ALT=\"".$GLOBALS["messages"]["uplink"]."\" TITLE=\"".$GLOBALS["messages"]["uplink"]."\"></A></TD>\n";
	// HOME DIR
	$content .= "<TD><A HREF=\"".make_link("list",NULL,NULL)."\">";
	$content .= "<IMG border=\"0\" width=\"24\" height=\"24\" align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"]."_home.png\" ";
	$content .= "ALT=\"".$GLOBALS["messages"]["homelink"]."\" TITLE=\"".$GLOBALS["messages"]["homelink"]."\"></A></TD>\n";
	// RELOAD
	$content .= "<TD><A HREF=\"javascript:location.reload();\"><IMG border=\"0\" width=\"24\" height=\"24\" ";
	$content .= "align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"]."_refresh.png\" ALT=\"".$GLOBALS["messages"]["reloadlink"];
	$content .= "\" TITLE=\"".$GLOBALS["messages"]["reloadlink"]."\"></A></TD>\n";
	// SEARCH
	$content .= "<TD><A HREF=\"".make_link("search",$dir,NULL)."\">";
	$content .= "<IMG border=\"0\" width=\"24\" height=\"24\" align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"]."_search.png\" ";
	$content .= "ALT=\"".$GLOBALS["messages"]["searchlink"]."\" TITLE=\"".$GLOBALS["messages"]["searchlink"];
	$content .= "\"></A></TD>\n";
	
	$content .= "<TD>::</TD>";
	
	if($allow) {
		// COPY
		$content .= "<TD><A HREF=\"javascript:Copy();\"><IMG border=\"0\" width=\"24\" height=\"24\" ";
		$content .= "align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"]."_copy.png\" ALT=\"".$GLOBALS["messages"]["copylink"];
		$content .= "\" TITLE=\"".$GLOBALS["messages"]["copylink"]."\"></A></TD>\n";
		// MOVE
		$content .= "<TD><A HREF=\"javascript:Move();\"><IMG border=\"0\" width=\"24\" height=\"24\" ";
		$content .= "align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"]."_move.png\" ALT=\"".$GLOBALS["messages"]["movelink"];
		$content .= "\" TITLE=\"".$GLOBALS["messages"]["movelink"]."\"></A></TD>\n";
		// DELETE
		$content .= "<TD><A HREF=\"javascript:Delete();\"><IMG border=\"0\" width=\"24\" height=\"24\" ";
		$content .= "align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"]."_delete.png\" ALT=\"".$GLOBALS["messages"]["dellink"];
		$content .= "\" TITLE=\"".$GLOBALS["messages"]["dellink"]."\"></A></TD>\n";
		// UPLOAD
		if(get_cfg_var("file_uploads")) {
			$content .= "<TD><A HREF=\"".make_link("upload",$dir,NULL)."\">";
			$content .= "<IMG border=\"0\" width=\"24\" height=\"24\" align=\"ABSMIDDLE\" ";
			$content .= "src=\"".$GLOBALS["img_url"]."_upload.png\" ALT=\"".$GLOBALS["messages"]["uploadlink"];
			$content .= "\" TITLE=\"".$GLOBALS["messages"]["uploadlink"]."\"></A></TD>\n";
		} else {
			$content .= "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
			$content .= "src=\"".$GLOBALS["img_url"]."_upload_.gif\" ALT=\"".$GLOBALS["messages"]["uploadlink"];
			$content .= "\" TITLE=\"".$GLOBALS["messages"]["uploadlink"]."\"></TD>\n";
		}
		// ARCHIVE
		if($GLOBALS["zip"] || $GLOBALS["tar"] || $GLOBALS["tgz"]) {
			$content .= "<TD><A HREF=\"javascript:Archive();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
			$content .= "align=\"ABSMIDDLE\" src=\"".$GLOBALS["img_url"]."_archive.gif\" ALT=\"".$GLOBALS["messages"]["comprlink"];
			$content .= "\" TITLE=\"".$GLOBALS["messages"]["comprlink"]."\"></A></TD>\n";
		}
	} else {
		// COPY
		$content .= "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
		$content .= "src=\"".$GLOBALS["img_url"]."_copy_.gif\" ALT=\"".$GLOBALS["messages"]["copylink"]."\" TITLE=\"";
		$content .= $GLOBALS["messages"]["copylink"]."\"></TD>\n";
		// MOVE
		$content .= "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
		$content .= "src=\"".$GLOBALS["img_url"]."_move_.gif\" ALT=\"".$GLOBALS["messages"]["movelink"]."\" TITLE=\"";
		$content .= $GLOBALS["messages"]["movelink"]."\"></TD>\n";
		// DELETE
		$content .= "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
		$content .= "src=\"".$GLOBALS["img_url"]."_delete_.gif\" ALT=\"".$GLOBALS["messages"]["dellink"]."\" TITLE=\"";
		$content .= $GLOBALS["messages"]["dellink"]."\"></TD>\n";
		// UPLOAD
		$content .= "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
		$content .= "src=\"".$GLOBALS["img_url"]."_upload_.gif\" ALT=\"".$GLOBALS["messages"]["uplink"];
		$content .= "\" TITLE=\"".$GLOBALS["messages"]["uplink"]."\"></TD>\n";
	}
	
	// ADMIN & LOGOUT
	if($GLOBALS["require_login"]) {
		$content .= "<TD>::</TD>";
		// ADMIN
		if($admin) {
			$content .= "<TD><A HREF=\"".make_link("admin",$dir,NULL)."\">";
			$content .= "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
			$content .= "src=\"".$GLOBALS["img_url"]."_admin.gif\" ALT=\"".$GLOBALS["messages"]["adminlink"]."\" TITLE=\"";
			$content .= $GLOBALS["messages"]["adminlink"]."\"></A></TD>\n";
		}
		// LOGOUT
		$content .= "<TD><A HREF=\"".make_link("logout",NULL,NULL)."\">";
		$content .= "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
		$content .= "src=\"".$GLOBALS["img_url"]."_logout.gif\" ALT=\"".$GLOBALS["messages"]["logoutlink"]."\" TITLE=\"";
		$content .= $GLOBALS["messages"]["logoutlink"]."\"></A></TD>\n";
	}
	$content .= "</TR></TABLE></TD>\n";
	
	// Create File / Dir
	if($allow) {
		$content .= "<TD align=\"right\"><TABLE><FORM action=\"".make_link("mkitem",$dir,NULL)."\" method=\"post\">\n<TR><TD>";
		$content .= "<SELECT name=\"mktype\"><option value=\"file\">".$GLOBALS["mimes"]["file"]."</option>";
		$content .= "<option value=\"dir\">".$GLOBALS["mimes"]["dir"]."</option></SELECT>\n";
		$content .= "<INPUT name=\"mkname\" type=\"text\" size=\"15\">";
		$content .= "<INPUT type=\"submit\" value=\"".$GLOBALS["messages"]["btncreate"];
		$content .= "\"></TD></TR></FORM></TABLE></TD>\n";
	}
	$content .= "</TR></TABLE>\n";
	
	// End Toolbar
	
	
	// Begin Table + Form for checkboxes
	$content .="<TABLE WIDTH=\"95%\"><FORM name=\"selform\" method=\"POST\" action=\"".make_link("post",$dir,NULL)."\">\n";
	$content .= "<INPUT type=\"hidden\" name=\"do_action\"><INPUT type=\"hidden\" name=\"first\" value=\"y\">\n";
	
	// Table Header
	$content .= "<TR><TD colspan=\"7\"><HR></TD></TR><TR><TD WIDTH=\"2%\" class=\"header\">\n";
	$content .= "<INPUT TYPE=\"checkbox\" name=\"toggleAllC\" onclick=\"javascript:ToggleAll(this);\"></TD>\n";
	$content .= "<TD WIDTH=\"44%\" class=\"header\"><B>\n";
	if($GLOBALS["order"]=="name") $new_srt = $_srt;	else $new_srt = "yes";
	$content .= "<A href=\"".make_link("list",$dir,NULL,"name",$new_srt)."\">".$GLOBALS["messages"]["nameheader"];
	if($GLOBALS["order"]=="name") $content .= $_img;
	$content .= "</A></B></TD>\n<TD WIDTH=\"10%\" class=\"header\"><B>";
	if($GLOBALS["order"]=="size") $new_srt = $_srt;	else $new_srt = "yes";
	$content .= "<A href=\"".make_link("list",$dir,NULL,"size",$new_srt)."\">".$GLOBALS["messages"]["sizeheader"];
	if($GLOBALS["order"]=="size") $content .= $_img;
	$content .= "</A></B></TD>\n<TD WIDTH=\"16%\" class=\"header\"><B>";
	if($GLOBALS["order"]=="type") $new_srt = $_srt;	else $new_srt = "yes";
	$content .= "<A href=\"".make_link("list",$dir,NULL,"type",$new_srt)."\">".$GLOBALS["messages"]["typeheader"];
	if($GLOBALS["order"]=="type") $content .= $_img;
	$content .= "</A></B></TD>\n<TD WIDTH=\"14%\" class=\"header\"><B>";
	if($GLOBALS["order"]=="mod") $new_srt = $_srt;	else $new_srt = "yes";
	$content .= "<A href=\"".make_link("list",$dir,NULL,"mod",$new_srt)."\">".$GLOBALS["messages"]["modifheader"];
	if($GLOBALS["order"]=="mod") $content .= $_img;
	$content .= "</A></B></TD><TD WIDTH=\"8%\" class=\"header\"><B>".$GLOBALS["messages"]["permheader"]."</B>\n";
	$content .= "</TD><TD WIDTH=\"6%\" class=\"header\"><B>".$GLOBALS["messages"]["actionheader"]."</B></TD></TR>\n";
	$content .= "<TR><TD colspan=\"7\"><HR></TD></TR>\n";
		
	// make & print Table using lists
	$content .= print_table($dir, make_list($dir_list, $file_list), $allow);

	// print number of items & total filesize
	$content .= "<TR><TD colspan=\"7\"><HR></TD></TR><TR>\n<TD class=\"header\"></TD>";
	$content .= "<TD class=\"header\">".$num_items." ".$GLOBALS["messages"]["miscitems"]." (";
	if(function_exists("disk_free_space")) {
		$free=parse_file_size(disk_free_space(get_abs_dir($dir)));
	} elseif(function_exists("diskfreespace")) {
		$free=parse_file_size(diskfreespace(get_abs_dir($dir)));
	} else $free="?";
	//$content .= "Total: ".parse_file_size(disk_total_space(get_abs_dir($dir))).", ";
	$content .= $GLOBALS["messages"]["miscfree"].": ".$free.")</TD>\n";
	$content .= "<TD class=\"header\">".parse_file_size($tot_file_size)."</TD>\n";
	for($i=0;$i<4;++$i) $content .="<TD class=\"header\"></TD>";
	$content .= "</TR>\n<TR><TD colspan=\"7\"><HR></TD></TR></FORM>\n";

	?>
	<script language="JavaScript1.2" type="text/javascript">
	<!--
		// Uncheck all items (to avoid problems with new items)
		var ml = document.selform;
		var len = ml.elements.length;
		for(var i=0; i<len; ++i) {
			var e = ml.elements[i];
			if(e.name == "selitems[]" && e.checked == true) {
				e.checked=false;
			}
		}
	// -->
	</script>
	<?php

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