Location: PHPKode > projects > Warp.cms - php/mysql content management > warp_121/ax_fm.php
<?php

// [warp administration module - file explorer v.1.2.1]
// xantis.warp.cms - version 1.2
// (c) 2002 xantis - all rights reserved
// this code is registered and protected by international copyrights laws


//####### Register Globals !

extract($HTTP_ENV_VARS);
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
extract($HTTP_COOKIE_VARS);
extract($HTTP_SERVER_VARS);

//#########################

$xnt_control_var = 'xnt2002warp.cms';

require("lib_adv.php");



//##################################################################


function getFileType ($filename) {

	$filetype = 'other';

	//flash
	if (substr($filename, -4, 4) == '.swf') {
		$filetype = 'flash';
	} //end if

	//picts (jpg, png, gif, wbmp)
	if ( (substr($filename, -4, 4) == '.jpg') OR (substr($filename, -4, 4) == '.png') OR (substr($filename, -4, 4) == '.gif') OR (substr($filename, -5, 5) == '.wbmp') ) {
		$filetype = 'picture';
	} //end if

	//php
	if (substr($filename, -4, 4) == '.php') {
		$filetype = 'php';
	} //end if

	//html
	if ( (substr($filename, -4, 4) == '.htm') OR (substr($filename, -5, 5) == '.html') ) {
		$filetype = 'html';
	} //end if

	//text
	if (substr($filename, -4, 4) == '.txt') {
		$filetype = 'text';
	} //end if

	//archiv (almost any archive type)
	if ( (substr($filename, -4, 4) == '.zip') 
		OR (substr($filename, -4, 4) == '.tar') 
		OR (substr($filename, -4, 4) == '.tgz') 
		OR (substr($filename, -4, 4) == '.tbz') 
		OR (substr($filename, -4, 4) == '.bz2') 
		OR (substr($filename, -3, 3) == '.bz') 
		OR (substr($filename, -5, 5) == '.bzip') 
		OR (substr($filename, -3, 3) == '.gz') 
		OR (substr($filename, -3, 3) == '.bh') 
		OR (substr($filename, -3, 3) == '.uu') 
		OR (substr($filename, -4, 4) == '.uue') 
		OR (substr($filename, -4, 4) == '.enc') 
		OR (substr($filename, -2, 2) == '.z') 
		OR (substr($filename, -4, 4) == '.rar') 
		OR (substr($filename, -4, 4) == '.arj') 
		OR (substr($filename, -4, 4) == '.ace') 
		OR (substr($filename, -4, 4) == '.arc') 
		OR (substr($filename, -4, 4) == '.zoo') 
		OR (substr($filename, -4, 4) == '.lha') 
		OR (substr($filename, -4, 4) == '.lhz') 
		OR (substr($filename, -4, 4) == '.cab') 
		OR (substr($filename, -4, 4) == '.sit') 
		OR (substr($filename, -4, 4) == '.sea') 
		OR (substr($filename, -3, 3) == '.pf') 
	 ) {
		$filetype = 'archive';
	} //end if


	return $filetype;

} //end function


//##################################################################


function xshow_file_manager () {


//-----------------globals general
global 	$ax_content_dir, $ax_picts_dir, $ax_website_addr, $ax_tx_color, $ax_tx_color_qe, 
	$ax_tx_color_sp, $warp_numform_decimal_sep, $warp_numform_thousand_sep ;

//-----------------globals local
global	$lst ;



if(empty($lst)) {
	$ax_hlx_opendir = $ax_content_dir.'/' ;
} //end if
else {
	$ax_hlx_opendir = $lst.'/' ;
} //end else


//------------------------------ protection (if try to exit outside of predefined folder)

if ( (substr($ax_hlx_opendir, 0, strlen($ax_content_dir)) != $ax_content_dir) OR (stristr($ax_hlx_opendir, './')) OR (stristr($ax_hlx_opendir, '..')) ) {
	xnewline();
	xcenter_start();
		xtext_admin_error ('Access is denied outside of <b>`'.$ax_content_dir.'`</b>'.' folder !');
	xcenter_end();
	die('');
} //end if

//------------------------------


xnewline();
xtable_start_brd('');

	xtable_row_start ();
		xtable_column_start_vcenter ('6', '', "$ax_tx_color");
			xtable_start ('');
				xtable_row_start ();
					xtable_column_start_vcenter ('1', '', "$ax_tx_color");
						xpict ("$ax_website_addr"."$ax_picts_dir".'/'.'file_manager.gif', '30', '30');
					xtable_column_end ();

					xtable_column_start_vcenter ('1', '', "$ax_tx_color");
						xtext_title_admin ('&nbsp;Warp File Explorer&nbsp;');
					xtable_column_end ();

					xtable_column_start_vcenter ('1', '', "$ax_tx_color");
						xtext_admin ('&nbsp;'.date("Y-m-d").' '.date("H:i:s").'&nbsp;');
					xtable_column_end ();
				xtable_row_end ();
			xtable_end();
		xtable_column_end ();
	xtable_row_end ();

	xtable_row_start ();
		xtable_column_start_vcenter ('1', '', "$ax_tx_color");
			xcenter_start();
				xpict_link ("$ax_website_addr"."$ax_picts_dir".'/'.'file_folder_h.jpg', 'Home Folder ('.$ax_content_dir.')', '20', '20', "$ax_website_addr"."ax_fm.php", '_self');
			xcenter_end();
		xtable_column_end ();

		xtable_column_start_vcenter ('5', '', "$ax_tx_color");
			xtext_admin ('&nbsp;'.'<font color="'.$ax_tx_color_qe.'"><i>'.'Home Folder ('.$ax_content_dir.')'.'</i></font>'.'&nbsp;');
		xtable_column_end ();
	xtable_row_end ();


	xtable_row_start ();
		xtable_column_start_vcenter ('1', '', "$ax_tx_color");
			xcenter_start();
				$ax_hlx_lst_bk_arr = array();
				$ax_hlx_lst_bk_arr = explode ('/', $ax_hlx_opendir);
				$ax_hlx_lst_bk = '';
				if ( (count($ax_hlx_lst_bk_arr)-2) > 0 ) {
					for ($i=0; $i<(count($ax_hlx_lst_bk_arr)-2); $i++) {
						$ax_hlx_lst_bk .= $ax_hlx_lst_bk_arr[$i].'/';
					} //end for
					$ax_hlx_lst_bk = substr($ax_hlx_lst_bk, 0, -1);
					$ax_hlx_lst_bk = rawurlencode($ax_hlx_lst_bk);
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/'.'file_folder_c.jpg', 'Back To Previous Folder', '20', '20', "$ax_website_addr"."ax_fm.php"."?lst=$ax_hlx_lst_bk", '_self');
				} //end if
				else {
					xpict_alt ("$ax_website_addr"."$ax_picts_dir".'/'.'file_folder_cx.jpg', '20', '20', 'Back To Previous Folder');
				} //end else
			xcenter_end();
		xtable_column_end ();

		xtable_column_start_vcenter ('5', '', "$ax_tx_color");
			xtext_admin ('&nbsp;'.'<font color="'.$ax_tx_color_qe.'">'.'..'.'</font>'.'&nbsp;');
		xtable_column_end ();
	xtable_row_end ();


	xtable_row_start ();
		xtable_column_start_vcenter ('1', '', "$ax_tx_color");
			xcenter_start();
				xpict_alt ("$ax_website_addr"."$ax_picts_dir".'/'.'file_folder_o.jpg', '20', '20', 'Current Folder Display');
			xcenter_end();
		xtable_column_end ();

		xtable_column_start_vcenter ('5', '', "$ax_tx_color");
			xtext_title_admin ('&nbsp;'.'<font color="'.$ax_tx_color_sp.'">'.$ax_hlx_opendir.'</font>'.'&nbsp;');
		xtable_column_end ();
	xtable_row_end ();


	xtable_row_start ();
		xtable_column_start_vcenter ('2', '', "$ax_tx_color");
			xcenter_start();
				xtext_admin ('&nbsp;<b>'.'Name'.'</b>&nbsp;');
			xcenter_end();
		xtable_column_end ();

		xtable_column_start_vcenter ('1', '', "$ax_tx_color");
			xcenter_start();
				xtext_admin ('&nbsp;<b>'.'Size'.'</b>&nbsp;');
			xcenter_end();
		xtable_column_end ();

		xtable_column_start_vcenter ('1', '', "$ax_tx_color");
			xcenter_start();
				xtext_admin ('&nbsp;<b>'.'Type'.'</b>&nbsp;');
			xcenter_end();
		xtable_column_end ();

		xtable_column_start_vcenter ('1', '', "$ax_tx_color");
			xcenter_start();
				xtext_admin ('&nbsp;<b>'.'Modified'.'</b>&nbsp;');
			xcenter_end();
		xtable_column_end ();

		xtable_column_start_vcenter ('1', '', "$ax_tx_color");
			xcenter_start();
				xtext_admin ('&nbsp;<b>'.'Read-Only'.'</b>&nbsp;');
			xcenter_end();
		xtable_column_end ();
	xtable_row_end ();



clearstatcache();


//list dirs
if ($handle = opendir($ax_hlx_opendir)) {
	while (false !== ($file = readdir($handle))) { 
		if ( ($file != ".") AND ($file != "..") AND (is_dir($ax_hlx_opendir.'/'.$file)) ) {

		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_start();
					$ax_hlx_lst_mp = rawurlencode($ax_hlx_opendir.$file);
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/'.'file_folder.jpg', 'Open Folder', '20', '20', "$ax_website_addr"."ax_fm.php"."?lst=$ax_hlx_lst_mp", '_self');
				xcenter_end();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('&nbsp;<font color="'.$ax_tx_color_qe.'">'."$file".'</font>&nbsp;');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_start();
					xtext_admin ('&nbsp;<font color="'.$ax_tx_color_qe.'">'.'-'.'</font>&nbsp;');
				xcenter_end();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_start();
					xtext_admin ('&nbsp;<font color="'.$ax_tx_color_qe.'">'.'Folder'.'</font>&nbsp;');
				xcenter_end();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_right_start();
					xtext_admin ('&nbsp;<font color="'.$ax_tx_color_qe.'">'.date("Y-m-d H:i:s", filemtime($ax_hlx_opendir.'/'.$file)).'</font>&nbsp;');
				xcenter_end();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_start();
					if (!is_writable($ax_hlx_opendir.'/'.$file)) {
						xtext_admin ('&nbsp;<font color="'.$ax_tx_color_qe.'">'.'Yes'.'</font>&nbsp;');
					} //end if
					else {
						xtext_admin ('&nbsp;<font color="'.$ax_tx_color_qe.'">'.'No'.'</font>&nbsp;');
					} //end if
				xcenter_end();
			xtable_column_end ();
		xtable_row_end ();

		} //end if
	} //end while
	closedir($handle); 
} //end if



//list files
if ($handle = opendir($ax_hlx_opendir)) {
	while (false !== ($file = readdir($handle))) { 
		if ( ($file != ".") AND ($file != "..") AND (is_file($ax_hlx_opendir.'/'.$file)) ) {

			switch (getFileType ($file)) {
				case 'flash':
					$xycon = 'file_flash.jpg';
					break;
				case 'picture':
					$xycon = 'file_pict.jpg';
					break;
				case 'php':
					$xycon = 'file_php.jpg';
					break;
				case 'html':
					$xycon = 'file_html.jpg';
					break;
				case 'text':
					$xycon = 'file_text.jpg';
					break;
				case 'archive':
					$xycon = 'file_archiv.jpg';
					break;
				default:
					$xycon = 'file_other.jpg';
			} //end switch


		xtable_row_start ();
			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_start();
					xpict_link ("$ax_website_addr"."$ax_picts_dir".'/'.$xycon, 'View File', '20', '20', $ax_website_addr.$ax_hlx_opendir.'/'.$file, '_blank');
				xcenter_end();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xtext_admin ('&nbsp;'."$file".'&nbsp;');
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_start();
					xtext_admin ('&nbsp;'.number_format((filesize($ax_hlx_opendir.'/'.$file)/1000), 1, $warp_numform_decimal_sep, $warp_numform_thousand_sep).' kb'.'&nbsp;');
				xcenter_end();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_start();
					xtext_admin ('&nbsp;'.'File'.' ['.getFileType ($file).']'.'&nbsp;');
				xcenter_end();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_right_start();
					xtext_admin ('&nbsp;'.date("Y-m-d H:i:s", filemtime($ax_hlx_opendir.'/'.$file)).'&nbsp;');
				xcenter_end();
			xtable_column_end ();

			xtable_column_start_vcenter ('1', '', "$ax_tx_color");
				xcenter_start();
					if (!is_writable($ax_hlx_opendir.'/'.$file)) {
						xtext_admin ('&nbsp;'.'Yes'.'&nbsp;');
					} //end if
					else {
						xtext_admin ('&nbsp;'.'No'.'&nbsp;');
					} //end if
				xcenter_end();
			xtable_column_end ();
		xtable_row_end ();

		} //end if
	} //end while
	closedir($handle); 
} //end if


xtable_end();

xnewline();


} //END FUNCTION


//##################################################################


//---------------------------------------------------------page header
xheader (':: warp.cms.admin .:. File Explorer ::', 'admin');
//---------------------------------------------------------

xshow_file_manager ();

//---------------------------------------------------------page footer
xfooter ();
//---------------------------------------------------------


// end of php code
?>
Return current item: Warp.cms - php/mysql content management