<?php
	
	/*
	osCommerce, Open Source E-Commerce Solutions 
	http://www.oscommerce.com 
	
	Copyright (c) 2003 osCommerce 
	
	osCommRes, Services Oline 
	http://www.oscommres.com 
	Copyright (c) 2005 osCommRes 
	
	Freeway eCommerce 
	http://www.zac-ware.com/freeway 
	Copyright (c) 2007 ZacWare
	
	Released under the GNU General Public License
	*/
	// Set flag that this is a parent file
	define( '_FEXEC', 1 );
	require('includes/application_top.php');
	include('includes/languages/'. $language .'/shop_file_manager.php');
	$current_path=DIR_FS_DOCUMENT_ROOT;
	  $command=isset($HTTP_GET_VARS['command'])?$HTTP_GET_VARS['command']:'';
	  $goto=isset($HTTP_GET_VARS['goto'])?$HTTP_GET_VARS['goto']:''; 
	  $current_id=isset($HTTP_GET_VARS['current_id'])?$HTTP_GET_VARS['current_id']:'';
	  $delete_folder_path=isset($HTTP_GET_VARS['delete_folder_path'])?$HTTP_GET_VARS['delete_folder_path']:'';
	  $filename=isset($HTTP_POST_VARS['filename'])?$HTTP_POST_VARS['filename']:$HTTP_POST_VARS['filename'];
	  $path_id=isset($HTTP_GET_VARS['path_id'])?$HTTP_GET_VARS['path_id']:'';
	  $action=isset($HTTP_GET_VARS['action'])?$HTTP_GET_VARS['action']:'';
	  
	  if($action=='download') {
		$filename=isset($HTTP_GET_VARS['filename'])?$HTTP_GET_VARS['filename']:$HTTP_GET_VARS['filename'];
		header('Content-type: application/x-octet-stream');
		header('Content-Disposition: attachment; filename="' . $filename . '"');
		readfile($path_id); 
		exit;
	  }
	  
	if($command!=''){
		switch($command) {
			case 'load_files':
				$current_path=$goto;
				echo 'load_files{[^]}';
				echo $HTTP_GET_VARS['current_id'] . "{[^]}";
				echo load_details($current_path,$current_id);
			break;
			case 'show_file_popup':
				$filename=(isset($HTTP_GET_VARS['filename'])?$HTTP_GET_VARS['filename']:'');
				$view=(isset($HTTP_GET_VARS['view'])?$HTTP_GET_VARS['view']:'false');
				show_file_popup();
			break;
			case 'save_file_details':
				$path_array=array();
				$path_array=split('{}',$current_id);
				$filename=(isset($HTTP_GET_VARS['filename'])?$HTTP_GET_VARS['filename']:'');
				$file_contents=isset($HTTP_POST_VARS['file_contents'])?$HTTP_POST_VARS['file_contents']:'';
				$file_contents=str_replace('#${*}$#','&',$file_contents);
				if (is_writeable($path_array[0])) {
				 if ($fp = @fopen($path_array[0], 'w+')) {
					fputs($fp, stripslashes($file_contents));
					fclose($fp);
				}
				echo 'save_success{[^]}';
				echo $current_id . '{[^]}';
				echo save_details();
				} else {
					  $file_writeable = false;
					  echo 'error_exists{[^]}';
					  echo $current_id . '{[^]}';
					  $edit=false;
					  $error='File has no write permission';
					  error_details();
				}
			break;
			case 'save_new_file':
				  $f_name=isset($HTTP_POST_VARS['new_filename'])?$HTTP_POST_VARS['new_filename']:'';
				  $filename=str_replace('#${*}$#','&',$f_name);
				  $f_content=isset($HTTP_POST_VARS['file_contents'])?$HTTP_POST_VARS['file_contents']:'';	
				  $f_content=str_replace('#${*}$#','&',$f_content);
				$path_array=array();
				$path_array=split('{}',$current_id);
				$directory_writeable = true;
				if (!is_writeable($path_array[0])) {
					echo 'error_exists{[^]}';
					echo $current_id . '{[^]}';
					$error='Directory has no write permission';
					$edit=false;
					error_details();
				}
				else { 
					if(file_exists($path_array[0] . '/' . $filename)) {
						echo 'error_exists{[^]}';
						//if($path_array[0]==substr(DIR_FS_DOCUMENT_ROOT,0,-1))
					//		echo $path_array[0] . '{}' . ($path_array[1] -1) . '{[^]}';
					//	else 
							echo $current_id . '{[^]}';
						//echo $current_id . '{[^]}' ;
						$error='Filename already exists';
						$edit=true;
						error_details();
					}
					else {
						if ($fp = fopen($path_array[0] . '/' . $filename, 'w+')) {
							 fputs($fp, stripslashes($f_content));
							 fclose($fp);
						}
						echo 'save_new_file_success{[^]}';
						if($path_array[0]==substr(DIR_FS_DOCUMENT_ROOT,0,-1))
							$temp_id=$path_array[0] . '{}' . ($path_array[1] +1) . '{[^]}';
						else 
							$temp_id=$current_id . '{[^]}';
						echo $temp_id ;
						
						echo load_details($path_array[0],$current_id);
					}
				}	
			break;
			case 'file_delete_confirm':
				$filename=(isset($HTTP_GET_VARS['filename'])?$HTTP_GET_VARS['filename']:'');
				show_delete();
			break;
			case 'file_delete':
				$delete_file_path=array();
				$delete_file_path=split('{}',$current_id);
				tep_remove($delete_file_path[0]);
				if (!$tep_remove_error) {
					echo 'delete_success{[^]}';
					echo $current_id;
				}
				else {
					echo 'delete_error_exists{[^]}';
					echo $current_id . '{[^]}';
					$type='file';
					$error='File has no write permission to delete';
					file_delete_error();
				}
			break;
			case 'show_folder_popup':
				show_folder_popup();
			break;
			case 'save_folder_details':
				$new_folder_name=isset($HTTP_POST_VARS['new_foldername'])?$HTTP_POST_VARS['new_foldername']:'';
				$save_folder_path=isset($HTTP_GET_VARS['path_id'])?$HTTP_GET_VARS['path_id']:'';
				$path_array=split('{}',$current_id);;
					$directory_writeable = true;
					//	if($path_array[0]==substr(DIR_FS_DOCUMENT_ROOT,0,-1))
					//		$tem_cur_id=$path_array[0] . '{}' . ($path_array[1] +1) . '{[^]}';
					//	else 
							$tem_cur_id= $current_id . '{[^]}';
					
					if (!is_writeable($save_folder_path)) {
					  $directory_writeable = false;
					  echo 'folder_error_exists{[^]}';
					  echo $tem_cur_id;
					  $save=false;
					  $error='The Folder has no write permission';
					  folder_error_details();
					}
					else {
						if(is_dir($save_folder_path . '/' . $new_folder_name)) {
							echo 'folder_error_exists{[^]}';
							echo $tem_cur_id;
							$save=true;
							$error='Folder name already exists';
							 folder_error_details();
						}
						else {
							if (mkdir($save_folder_path . '/' . $new_folder_name, 0777)) {
								echo 'save_new_folder_success{[^]}';
								if($path_array[0]==substr(DIR_FS_DOCUMENT_ROOT,0,-1))
									$tem_cur_id=$path_array[0] . '{}' . ($path_array[1]-1) ;
								else 
									$tem_cur_id=	$current_id;
								//if($path_array[1]<=0)	
								//	echo $path_array[0] . '{}' . ($path_array[1]+1) . '{[^]}';
								//else 	
									echo $current_id .'{[^]}' ;
								echo load_details($save_folder_path,$tem_cur_id);
							 }
							else { 
								echo 'folder_error_exists{[^]}';
								echo $tem_cur_id . '{[^]}';
								$save=false;
								$error='Creating new folder is failure';
								 folder_error_details();
							}
						}	
					}	 
			break;
			case 'folder_delete_confirm':
				$filename=(isset($HTTP_GET_VARS['new_foldername'])?$HTTP_GET_VARS['new_foldername']:'');
				show_folder_delete();
			break;
			case 'folder_delete':
				$path_array=split('{}',$current_id);
				if($path_array[1]<=0)
					$temp_cur_id=$path_array[0] . '{}1';
				else 
					$temp_cur_id=$current_id;	 
				if($path_id==substr(DIR_FS_DOCUMENT_ROOT,0,-1)) {
					echo 'delete_error_exists{[^]}';
					echo $temp_cur_id . '{[^]}';
					$type='folder';
					$error='Folder has no permission to delete';
					file_delete_error();
				} else {	
				 tep_remove($path_id);
				  if (!$tep_remove_error) {
					echo 'delete_folder_success{[^]}';
					echo $temp_cur_id;
				  }
				  else {
					echo 'delete_error_exists{[^]}';
					echo $temp_cur_id . '{[^]}';
					$type='folder';
					$error='Folder has no permission to delete';
					file_delete_error();
				   }	
				 }  
			break;
		}	
		
		exit;		
	}
?>
	<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
	<html <?php echo HTML_PARAMS; ?>>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
		<title><?php echo TITLE; ?></title>
		<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
		<script language="javascript" src="includes/menu.js"></script>
		<script language="javascript" src="includes/general.js"></script>
		<script language="javascript" src="includes/http.js"></script>
		<script language="javascript">
			var img_src="<?php echo HTTP_SERVER.DIR_WS_ADMIN.'images/';?>";
			var open_id='<?php echo substr($current_path,0,-1) . '{}1'; ?>';
			var path_id="";
			var curr_path="";
			var type='folder';
			var cur_id='';
			var prev_row_id='';
			var prev_fold_id='';
			var root_path='<?php echo substr(DIR_FS_DOCUMENT_ROOT ,0,-1)?>';
			
			
			function load_files(params, current_id, filetype,obj) {
				var path=new Array();
				path=current_id.split('{}');
				document.shop_file.curr_path.value=path[0];
				
				curr_path=document.shop_file.curr_path.value;
				document.shop_file.file_id.value=current_id;
				type=filetype;
				if(document.getElementById("pop_common_file_save_display")){
					document.getElementById("pop_common_file_save_display").style.display="none";
					document.getElementById("pop_common_file_save_display").innerHTML='';	
				}			
				
				if(filetype=='folder') {
					document.getElementById('cur_path').innerHTML='<b>' + path[0] + '</b>';
					if(document.getElementById('content_'+current_id) && document.getElementById('content_'+current_id).style.display=="") {
							document.getElementById('img_folder_' + current_id).innerHTML="<img border='0' title=' Folder ' alt='Folder' src='images/template/FoldIn.gif'>";
							document.getElementById('content_' + current_id).style.display="none";
					} else {
						if(document.getElementById('content_' + current_id).innerHTML!=''){
							document.getElementById('content_' + current_id).style.display="";
							document.getElementById('img_folder_' + current_id).innerHTML="<img border='0' title=' Folder ' alt='Folder' src='images/template/FoldOut.gif'>";
						} else {
							document.getElementById('content_' + current_id).style.display="";
							document.getElementById('content_' + current_id).innerHTML=document.getElementById('loading').innerHTML;
							command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=load_files&');?>&path_id="+path[0]+"&current_id="+current_id+ "&" +params;
							do_get_command(command);
						}
					}
					document.getElementById('row_' + current_id).className="dataTableRowSelected";
					if(prev_row_id!=''){
						document.getElementById('row_' + prev_row_id).className="dataTableRowEven";
						prev_row_id='';
					}	
					
					if(prev_fold_id!='' && current_id!=prev_fold_id) {
						if(document.getElementById('row_' + prev_fold_id))
						document.getElementById('row_' + prev_fold_id).className="dataTableRowEven";
					}	
					prev_fold_id=current_id;
					
				} else if(filetype=='file') { 
						var pos_file_id=path[0].lastIndexOf('/');
						var fid=path[0].substr(0,pos_file_id);
						document.getElementById('cur_path').innerHTML='<b>' + fid + '</b>';
					if(prev_fold_id!='' ) {
						if(document.getElementById('row_' + prev_fold_id))
							document.getElementById('row_' + prev_fold_id).className="dataTableRowEven";
						prev_fold_id='';
					}	
					document.getElementById('row_' + current_id).className="dataTableRowSelected";
					if(prev_row_id!='' && prev_row_id!=current_id)
						document.getElementById('row_' + prev_row_id).className="dataTableRowEven";
					document.shop_file.filename.value=params;
					
					prev_row_id=current_id;
				}	
				
				cur_id=current_id;
				
			}
			
			function do_result(result) {
				var token = Array();
				token=result.split('{[^]}');
				ids=token[1].split('{}');
				file_id=document.shop_file.file_id.value;
				path_id=document.shop_file.curr_path.value;
				
				switch(token[0]) {
					case 'load_files':
						if(type=='folder'){
							document.getElementById('img_folder_' + token[1]).innerHTML="<img border='0' title=' Folder ' alt='Folder' src='images/template/FoldOut.gif'>";
						}	
						document.getElementById('content_'+token[1]).innerHTML='';
						document.getElementById('content_'+token[1]).innerHTML=token[2];
						
					break;
					case 'show_file_popup':
					case 'error_exists':
						if(document.getElementById("pop_common_file_save_display")){
							document.getElementById("pop_common_file_save_display").innerHTML=token[2];	
							document.getElementById('pop_common_file_save_display').style.width="500px";
							document.getElementById('pop_common_file_save_display').style.height="300px";
						}	
					break;
					case 'folder_error_exists': 
					case 'folder_delete_confirm':
					case 'file_delete_confirm': 
					case 'show_folder_popup':
					case 'delete_error_exists':
						if(document.getElementById("pop_common_file_save_display")){
							document.getElementById("pop_common_file_save_display").innerHTML=token[2];	
							document.getElementById('pop_common_file_save_display').style.width="450px";
							document.getElementById('pop_common_file_save_display').style.height="100px";
						}	
					break;
					case 'save_success':
						if(document.getElementById("pop_common_file_save_display")){
							document.getElementById("pop_common_file_save_display").style.display="none";
						}
						display_mess('The file updated successfully');
						document.getElementById('head_'+token[1]).innerHTML=token[2];
					break;
					case 'delete_success':
						if(document.getElementById("pop_common_file_save_display")){
							document.getElementById("pop_common_file_save_display").style.display="none";
						}
						display_mess('The file deleted successfully');
						var splt=new Array();
						splt=token[1].split('{}');
						var pos_file_id=splt[0].lastIndexOf('/');
						var fid=splt[0].substr(0,pos_file_id);
						if(root_path==fid)
							fileid=fid+'{}1';
						else 	
							fileid=fid+'{}'+(splt[1]-1);
						prev_row_id='';
						
						document.shop_file.file_id.value=fileid;
						document.shop_file.curr_path.value=fid;
						cur_id=fileid;
						curr_path=fid;
						prev_fold_id=cur_id;
						type='folder';
						if(document.getElementById('row_' + cur_id))
						document.getElementById('row_' + cur_id).className="dataTableRowSelected";
						document.shop_file.filename.value='';
						document.getElementById('content_'+token[1]).innerHTML="";	
						document.getElementById('content_'+token[1]).style.display="none";
						document.getElementById('head_'+token[1]).innerHTML="";
						document.getElementById('head_'+token[1]).style.display="none";
					break;
					case 'delete_folder_success':
						if(document.getElementById("pop_common_file_save_display")){
							document.getElementById("pop_common_file_save_display").style.display="none";
						}
						display_mess('The folder deleted successfully');
						var splt=new Array();
						splt=token[1].split('{}');
						var pos_file_id=splt[0].lastIndexOf('/');
						var fid=splt[0].substr(0,pos_file_id);
						if(root_path==fid)
							fileid=fid+'{}1';
						else 	
							fileid=fid+'{}'+(splt[1]-1);
						prev_row_id='';
						
						document.shop_file.file_id.value=fileid;
						document.shop_file.curr_path.value=fid;
						cur_id=fileid;
						curr_path=fid; 
						prev_fold_id=cur_id;
						type='folder';
						if(document.getElementById('row_' + cur_id))
						document.getElementById('row_' + cur_id).className="dataTableRowSelected";
						document.shop_file.filename.value='';
						document.getElementById('content_'+token[1]).innerHTML="";	
						document.getElementById('content_'+token[1]).style.display="none";
						document.getElementById('head_'+token[1]).innerHTML="";
						document.getElementById('head_'+token[1]).style.display="none";
						document.getElementById('cur_path').innerHTML='<b>' + fid + '</b>';
					break;
					case 'save_new_file_success':
						var token_splt=new Array();
						token_splt=token[1].split('{}');
						document.getElementById('content_'+token[1]).innerHTML=token[2];
						document.getElementById("pop_common_file_save_display").style.display="none";
						display_mess("The file is successfully created");
					break;
					case 'save_new_folder_success':
						var token_splt=new Array();
						token_splt=token[1].split('{}');
						document.getElementById('content_'+token[1]).innerHTML=token[2];
						document.getElementById("pop_common_file_save_display").style.display="none";
						display_mess("The folder is successfully created");
					break;
				}	 
			}
var display_flag=1;			
			function do_hover_change(element,mode,display){
				if (element.mode && mode==element.mode) return;
				var url=element.src;
				if(display) {
					if (mode==2) {
						var pos=url.lastIndexOf('_');
						var img_name=url.substr(pos);
						if(img_name!='_hover.gif' && display_flag==1)
							element.src=element.src.replace(".gif","_hover.gif");
						show_cpopup('sort_display',0,20);
					}	
					else if(display_flag==1) {
						element.src=element.src.replace("_hover.gif",".gif");
					}
				}
				else {
					if (mode==2)
						element.firstChild.src=element.firstChild.src.replace(".gif","_hover.gif");
					else
						element.firstChild.src=element.firstChild.src.replace("_hover.gif",".gif");
				}		
				element.mode=mode;
			}
			function change_new_image(){
			display_flag=0;
			document.getElementById('pop_common_sort_display_con').src=document.getElementById('pop_common_sort_display_con').src.replace(".gif","_hover.gif");
			}	
			function do_page_fetch(action){ 
				var command;
				if(cur_id==''){
					var splt=new Array();
					var temp_id=document.shop_file.file_id.value;
					splt=temp_id.split('{}');
					cur_id=splt[0]+'{}'+(splt[1]-1);
					curr_path=splt[0];
				}	
				if(document.shop_file.filename.value=='' && type=='file') {
					alert('please select any file');
					return;
				}	
				if(action!=''){
					switch(action){
						case 'file_edit':
						case 'file_view':
							if(type=='folder')
								return;
							var view=false;
							if(action=='file_view')
								view=true;
									
							//document.shop_file.file_action.value='edit';	
							document.getElementById("pop_common_file_save_display").style.display="";
							document.getElementById("pop_common_file_save_display").innerHTML='Loading ...';
							command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=show_file_popup');?>&path_id="+curr_path+"&current_id="+cur_id + "&filename=" + document.shop_file.filename.value + '&view=' + view;
						break;
						case 'file_delete_confirm':
							document.getElementById("pop_common_file_save_display").style.display="";
							document.getElementById("pop_common_file_save_display").innerHTML='Loading ...';
							if(type=='file') {
								command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=file_delete_confirm');?>&path_id="+curr_path+"&current_id="+cur_id + "&filename=" + document.shop_file.filename.value;
							} else if(type=='folder')	 {
								command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=folder_delete_confirm');?>&path_id="+curr_path+"&current_id="+cur_id;
							}
						break;
						case 'do_expand':
							display_flag=1;
							document.getElementById('pop_common_sort_display_con').src=document.getElementById('pop_common_sort_display_con').src.replace("_hover.gif",".gif");
							if(document.getElementById('pop_common_file_save_display'))
								document.getElementById('pop_common_file_save_display').style.display="none";
							return;	
						break;
						case 'file_delete':
								if(document.shop_file.filename.value=='')
									return;
								command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=file_delete');?>&path_id="+curr_path+"&current_id="+cur_id + "&filename=" + document.shop_file.filename.value;
						break;
						case 'create_file':
							change_new_image();
							if(prev_row_id!=''){
								var spt_array=new Array();
								spt_array=prev_row_id.split('{}');
								var pos_fid=spt_array[0].lastIndexOf('/');
								var f_id=spt_array[0].substr(0,pos_fid);
								fileid=f_id+'{}'+(spt_array[1]-1);
								document.shop_file.file_id.value=fileid;
								document.shop_file.curr_path.value=f_id;
								curr_path=f_id;
								cur_id=fileid;
							}
							var spl_array=Array();
							spl_array=cur_id.split('{}'); 
							if(spl_array[0]==root_path && spl_array[1]==1){
								var spl_array=Array();
								spl_array=cur_id.split('{}');
								cur_id=spl_array[0] + '{}' + (spl_array[1]-1); 
							}
							if(prev_row_id!=''){
								document.getElementById('row_' + prev_row_id).className="dataTableRowEven";
								prev_row_id='';
							}	
							if(document.getElementById('row_' + cur_id))	
								document.getElementById('row_' + cur_id).className="dataTableRowSelected";
							type='folder';
							prev_fold_id=cur_id;
							//document.shop_file.file_action.value='new';
							document.getElementById("pop_common_file_save_display").style.display="";
							document.getElementById("pop_common_file_save_display").innerHTML='Loading ...';
							command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=show_file_popup');?>&path_id="+curr_path+"&current_id="+cur_id+"&view=false";
							
						break;
						case 'create_folder':
							change_new_image();
							var fid=document.shop_file.file_id.value;
							var spt_array=new Array();
							spt_array=fid.split('{}');
							document.shop_file.curr_path.value=spt_array[0];
							curr_path=document.shop_file.curr_path.value;
							cur_id=document.shop_file.file_id.value;
							if(prev_row_id!=''){
								var spt_array=new Array();
								spt_array=prev_row_id.split('{}');
								var pos_fid=spt_array[0].lastIndexOf('/');
								var f_id=spt_array[0].substr(0,pos_fid);
								fileid=f_id+'{}'+(spt_array[1]-1);
								document.shop_file.file_id.value=fileid;
								document.shop_file.curr_path.value=f_id;
								curr_path=f_id;
								cur_id=fileid;
							}
							var spl_array=Array();
							spl_array=cur_id.split('{}'); 
							if(spl_array[0]==root_path && spl_array[1]==1){
								var spl_array=Array();
								spl_array=cur_id.split('{}');
								cur_id=spl_array[0] + '{}' + (spl_array[1]); 
							}
							
							document.getElementById("pop_common_file_save_display").style.display="";
							document.getElementById("pop_common_file_save_display").innerHTML='Loading ...';
							command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=show_folder_popup');?>&path_id="+curr_path+"&current_id="+cur_id ;
						break;
						case 'folder_delete':
							command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=folder_delete');?>&path_id="+curr_path+"&current_id="+cur_id + "&filename=" + document.shop_file.filename.value;
						break;
						
					}
					do_get_command(command);
				}
			}
			
			function display_mess(mess) {
				if(document.getElementById('show_mess')) {
					document.getElementById('show_mess').style.display="";
					document.getElementById('show_mess').innerHTML=mess;
					setTimeout('drop_mess()',2000);
				}
			}
			
			function drop_mess() {
				document.getElementById('show_mess').innerHTML="";
				document.getElementById('show_mess').style.display="none";
			}
			
			function save(){
				var f_content=document.shop_file.elements['file_contents'].value;
				var params='';
				f_content=f_content.replace(/&/g,'#${*}$#');
				
				curr_path=document.shop_file.curr_path.value;
				var err_mess="";
				if(document.getElementById('new_filename')){
				var f_name=document.getElementById('new_filename').value;
				f_name=f_name.replace(/&/g,'#${*}$#');
				if(f_name=="") 
					err_mess='Please Enter File Name';
				else if(f_name!="") {
					var index_val=f_name.lastIndexOf('.');
					if(index_val>0) {
						var exten=f_name.substr(parseInt(index_val)+1);
						if(exten.length<3 || exten.length>4) 
							err_mess="Please enter correct extension";
					}
					else
						err_mess='Please Enter Extension Name';
				}	
				}	
				if(f_content=="") 
					err_mess='Please Enter File Contents';
				
				if(err_mess!="") {
					alert(err_mess);
				}
				else {
				document.getElementById('pop_common_sort_display_con').src=document.getElementById('pop_common_sort_display_con').src.replace("_hover.gif",".gif");
				display_flag=1;
					document.shop_file.elements['file_contents'].value=f_content;
					if(document.getElementById('edit_file_name'))
						params="&filename=" + document.getElementById('edit_file_name').value;
					if(document.getElementById('new_filename'))
					document.shop_file.elements['new_filename'].value=f_name;
					
					//if(document.shop_file.file_action.value=='new')
					if(document.getElementById('edit_file_name'))
						command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=save_file_details');?>&path_id="+curr_path+"&current_id="+cur_id + params;		 	
					else 	
						command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=save_new_file');?>&path_id="+curr_path+"&current_id="+cur_id;
					do_post_command('shop_file',command);
				}	
			}
			
			function save_folder(){
				if(document.shop_file.new_foldername.value=='')	
					alert('Folder Name should not be empty');
				else {
					display_flag=1;
					document.getElementById('pop_common_sort_display_con').src=document.getElementById('pop_common_sort_display_con').src.replace("_hover.gif",".gif");
					var command='';
					command="<?php echo tep_href_link(FILENAME_FILE_MANAGER,'command=save_folder_details');?>&path_id="+curr_path+"&current_id="+cur_id;
					do_post_command('shop_file',command);
				}		
			}
			
			function file_download(){
				if(type=='folder')	
					return;
				if(document.shop_file.filename.value==''){
					alert('* Please select any file to download');
					return;
				}	
				document.shop_file.action='<?php echo tep_href_link(FILENAME_FILE_MANAGER,'action=download')?>' + '&path_id=' + curr_path + '&filename=' + document.shop_file.filename.value;
				document.shop_file.submit();
			}
			
	</script>
	</head>
	<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
		<!-- header //-->
		<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
		<!-- header_eof //-->
		<!-- body //-->
		<table border="0" width="100%" cellspacing="5" cellpadding="3">
			<tr> 
			<!-- body_text //-->
				<td width="100%" valign="top">
				<div id="loading" style="display:none"><div style="height:30px;margin-left:30px"><img src="images/24-1.gif"></div></div>
				<?php
					$contents = array();
					$dir = dir($current_path);
					while ($file = $dir->read()) {
						if ($file != "." && $file != "..") {
							$file_size = number_format(filesize($current_path . '/' . $file)) . ' bytes';
							
							$permissions = tep_get_file_permissions(fileperms($current_path . '/' . $file));
							$contents[] = array('name' => $file,
							'is_dir' => is_dir($current_path . '/' . $file),
							'last_modified' => strftime(DATE_TIME_FORMAT, filemtime($current_path . '/' . $file)),
							'size' => $file_size,
							'permissions' => $permissions);
						}
					}
					
					function tep_cmp($a, $b) {
						return strcmp( ($a['is_dir'] ? 'D' : 'F') . $a['name'], ($b['is_dir'] ? 'D' : 'F') . $b['name']);
					}
					usort($contents, 'tep_cmp');
					$row=0;
				?>
					<table border="0" width="100%" cellspacing="0" cellpadding="2">
						<tr>
							<td><form name="shop_file" action="filename.php" method="post">
								<table border="0" width="100%" cellspacing="0" cellpadding="0" >
									<div id="show_mess" style="display:none; color:#ff0000;"></div>
									<tr class="dataTableHeadingRow">
										<td width="20" >
										<?php 
											echo tep_image(DIR_WS_IMAGES.'template/img_new.gif','New','22','22',' id="pop_common_sort_display_con" onMouseOut="javascript:do_hover_change(this,1,true);" onMouseOver="javscript:do_hover_change(this,2,true);"');
											echo "<div id='pop_common_sort_display' style='position:absolute;display:none;width:100px;height:50px;z-index:999;border:1px solid;border-color:#6883CA;background-color:#FFFFFF;padding:3px;'>";
											echo tep_draw_separator('pixel_trans.gif','10','5');
											echo '<br><table class="main" cellpadding="0" cellspacing="0" border="0">';
											
											echo '<tr height="20" class="tableMenuItem" onMouseOver="javascript:rowOverEffect(this)" onMouseOut="javascript:rowOutEffect(this)">';
											echo '<td ><a  href="javascript:do_page_fetch(\'create_folder\');">&nbsp;New Folder</a></td></tr>';
											echo '<tr height="20" class="tableMenuItem" onMouseOver="javascript:rowOverEffect(this)" onMouseOut="javascript:rowOutEffect(this)">';
											echo '<td><a href="javascript:do_page_fetch(\'create_file\');">&nbsp;New File</a></td></tr>';
											
											echo "</td></tr></table></div>";
										?>
										</td>
									</tr>	
									<tr>      
										<td width="100%">
											<table border="0" width="100%" cellspacing="0" cellpadding="2">
												<tr class="dataTableRow">
													<td class="main" id="cur_path"><?php echo '<b>' . str_replace("//","/",$current_path) . '</b>'; ?></td>
													<td id="edit_operation_icon" align="right">
														<?php 
															echo   '<a href="javascript:file_download();" onMouseOver="javascript:do_hover_change(this,2,false);" onMouseOut="javascript:do_hover_change(this,1,false);">'.tep_image(DIR_WS_IMAGES . 'template/img_download.gif','Download').'</a>&nbsp;';
															echo '<a href="javascript:do_page_fetch(\'file_edit\');" onMouseOver="javascript:do_hover_change(this,2,false);" onMouseOut="javascript:do_hover_change(this,1,false);">'.tep_image(DIR_WS_IMAGES.'template/img_edit.gif','Edit').'</a>&nbsp;';
															echo '<a style="cursor:pointer;" onclick="javascript: do_page_fetch(\'file_delete_confirm\');" onMouseOver="javascript:do_hover_change(this,2,false);" onMouseOut="javascript:do_hover_change(this,1,false);">'.tep_image(DIR_WS_IMAGES.'template/img_trash.gif','Delete').'</a>'; 
															echo '&nbsp;&nbsp;<a style="cursor:pointer;" href="javascript: do_page_fetch(\'file_view\');" onMouseOver="javascript:do_hover_change(this,2,false);" onMouseOut="javascript:do_hover_change(this,1,false);">'.tep_image(DIR_WS_IMAGES.'template/img_view.gif','View','','','').'</a>';
															echo tep_draw_separator('pixel_trans.gif','10','10');
														?>
													</td> 
												 </tr>
												 <tr>
													<td class="main" align="center">
													<?php
														echo "<div align='center' id='pop_common_file_save_display' style='position:absolute;display:none;width:500px;height:300px;z-index:999;border:1px solid;border-color:#CCCCCC;background-color:#FFFFFF;padding:1px;'>" ;
														echo "		</div>";
													?></td>
												</tr>	
											</table>
										</td>
									</tr>	
									<tr class="dataTableHeadingRow">
										<td>
											<table cellpadding="0" cellspacing="0" border="0" width="100%">
												<tr>
													<td class="dataTableHeadingContent" width="350"><?php echo TABLE_HEADING_FILENAME; ?></td>
													<td class="dataTableHeadingContent" align="right" width="100"><?php echo TABLE_HEADING_SIZE; ?></td>
													<td class="dataTableHeadingContent" align="center" width="100"><?php echo TABLE_HEADING_PERMISSIONS; ?></td>
													<td class="dataTableHeadingContent" align="center" width="150"><?php echo TABLE_HEADING_LAST_MODIFIED; ?></td>
												</tr>
											</table>
										</td>			
									</tr>
									<tr>
										<td valign="top">
										
											<div id="content_<?php echo substr($current_path,0,-1) . '{}1'; ?>" style="width:auto; height:500px; overflow:auto">
												<?php echo list_files($contents,$row,$current_path); ?>
											</div>
											<input type="hidden" name="filename">
											<input type="hidden" name="file_id" value="<?php echo substr($current_path,0,-1).'{}1'; ?>">
											<input type="hidden" name="curr_path" value="<?php echo substr($current_path,0,-1); ?>">
											<input type="hidden" name="file_action">
											<input type="hidden" id="filetype" name="filetype">
										
										</td>
									</tr>
								</table>
								</form>
							</td>
						</tr>
					</table>
				</td>
			<!-- body_text_eof //-->
			</tr>
		</table>
		<!-- body_eof //-->
		<!-- footer //-->
		<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
		<!-- footer_eof //-->
	</body>
	</html>
	<?php require(DIR_WS_INCLUDES . 'application_bottom.php');
	
	
	function load_details($current_path,$current_id) {
		$ids=split('{}',$current_id);
		
		$row=$ids[1];
		
		if (!is_dir($current_path)) { 
		$current_path =  DIR_FS_DOCUMENT_ROOT;
		}
		$contents = array();
		$dir = dir($current_path);
		while ($file = $dir->read()) {
			if ($file != "." && $file != "..") {
				$file_size = number_format(filesize($current_path . '/' . $file)) . ' bytes';
				$permissions = tep_get_file_permissions(fileperms($current_path . '/' . $file));
				$contents[] = array('name' => $file,
				'is_dir' => is_dir($current_path . '/' . $file),
				'last_modified' => strftime(DATE_TIME_FORMAT, filemtime($current_path . '/' . $file)),
				'size' => $file_size,
				'permissions' => $permissions);
			}
		} 
		usort($contents, 'tep_cmp'); 
		$width="100%";
		$class_top="";
		$class_bottom="";
		$root_path=DIR_FS_DOCUMENT_ROOT;
		$root_path=substr($root_path,0,-1);
	?>
		<table border="0"  width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td valign="top" align="center">
					<table cellpadding="2" cellspacing="0" width="<?php echo $width; ?>" border="0" >
						<tr>
							<td colspan="3"><div style="vertical-align:top"><?php echo list_files($contents,$row,$current_path); ?></div></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>		
	<?php	
	}
	
	function list_files($contents,$row,$current_path) { 
		global $path_id;
		$current_path=str_replace("//","/",$current_path);
		
		if($path_id=="") {
			$path_id=$current_path;
			$path_id=substr($path_id, 0, -1);  
		}	
		$row++;
		if(sizeof($contents)>0) {
	?>
		<table border="0" width="100%" cellspacing="0" cellpadding="0" >
	<?php $root_path=DIR_FS_DOCUMENT_ROOT;
	?>
	<?php 	$i=1; 
		if($row>1){
			$space_width=($row-1) * 20;
			$space=tep_draw_separator('pixel_trans.gif',$space_width,'10');
		}	
		
		for ($i=0, $n=sizeof($contents); $i<$n; $i++) {
			$goto_link = $path_id . '/' . $contents[$i]['name'];
			$current_id=$goto_link;
			$current_id=str_replace("//","/",$current_id);
			
			if ($contents[$i]['is_dir']) {
				$icon = '<span id="img_folder_' . $current_id . '{}' . $row . '">' .tep_image(DIR_WS_IMAGES . 'template/FoldIn.gif', ICON_FOLDER) . '</span>';
				$link = 'goto=' . str_replace("//","/",urlencode($goto_link));
				$file_type='folder';
			} else {
				$icon = tep_image(DIR_WS_ICONS . 'file_download.gif', 'File');
				$link = urlencode($contents[$i]['name']);
				$file_type='file';
			} 
			echo '<tr class="dataTableRowEven"  >' . "\n";
						
	?>
				<td>
					<div id="head_<?php echo $current_id . '{}' . $row;?>">
						<table cellpadding="0" cellspacing="0" border="0" width="100%">
							<tr class="dataTableRowEven" onMouseOver="rowOverEffect(this)" id="row_<?php echo $current_id . '{}' . $row;?>" onMouseOut="rowOutEffect(this)" onClick="javascript:load_files('<?php echo $link;?>','<?php echo $current_id . '{}' . $row ;?>','<?php echo $file_type;?>',this);">
								<td class="dataTableContent" width="350"><?php echo  $space. $icon . '&nbsp;' . $contents[$i]['name']; ?></td>
								<td class="dataTableContent" align="right" width="100"><?php echo ($contents[$i]['is_dir'] ? '&nbsp;' : $contents[$i]['size']); ?></td>
								<td class="dataTableContent" align="center" width="100"><tt><?php echo $contents[$i]['permissions']; ?></tt></td>
								<td class="dataTableContent" align="center" width="150">
	<?php   $ldate=substr($contents[$i]['last_modified'],0,10); 
			$ldatee = substr($ldate,6,10);
			$ldatee .='/'. substr($ldate,3,3);
			$ldatee .= substr($ldate,0,2); 
			echo $ldatee; 
	?>
								</td>
							</tr>
						</table>
					</div>
					<div id="pop_save_<?php echo $current_id . '{}' . $row;?>" style="display:none"></div>
					<div id="content_<?php echo $current_id . '{}' . $row;?>" style="display:none"></div>
				</td>			
			</tr>
	<?php 
		} 
		$row++;
	} else { ?>
		<table cellpadding="2" cellspacing="0" width="100%" border="0">
			<tr>
				<td class="dataTableContent" align="center">No files and folders found</td>
			</tr>
		</table>
	<?php } 
	} 
	
	function show_file_popup(){
		global $current_id,$path_id,$filename,$view;
		$path_array=array();
		$path_array=split('{}',$current_id);
		$file_writeable = true;
		 if (!is_writeable($path_array[0]) && $view=='false') {
			  $file_writeable = false;
		 }
		 
		echo 'show_file_popup{[^]}';
		echo $current_id . '{[^]}'; 
		if (!isset($file_writeable)) $file_writeable = true;
		$file_contents = '';
		if($filename!=''){
		  if ($file_array = file($path_array[0])) {
			$file_contents = str_replace('#${*}$#','&',implode('', $file_array));
		  }
		  
		}  

		$return= "<table border='0' cellspacing='0' cellpadding='0' width='100%'>
					<tr><td colspan='2'><table cellpadding='0' cellspacing='0' border='0' width='100%'>
				<tr bgcolor='#CCCCCC' height='20'>
					<td class='main'>&nbsp;<b>" .(($filename!='')?$filename:'New File');
		$return.=	"</b></td><td  valign='top' align='right'>";
							if($file_writeable==true && $view=='false') $return.=" <a href='javascript:save(0);'>" . tep_image(DIR_WS_IMAGES . 'template/img_savel.gif').  "</a>&nbsp;";
				$return.="<a href='javascript:do_page_fetch(\"do_expand\");'>" . tep_image(DIR_WS_IMAGES . 'template/img_closel.gif').  "</a></td>
				</tr> </table></td></tr>
				<tr><td>" . tep_draw_separator('pixel_trans.gif','10','10') . "</td></tr>" ;
			if($file_writeable==false)
				$return.="<tr><td class='main' align='center' colspan='2'>" .'<font color="#ff0000"> File has no write permission</font>'  . "</td></tr>";
			if($filename=='')	{
				
		$return.=		"<tr height='30'>
					<td align='left' class='main'>" . TEXT_FILE_NAME . "</td>
					<td class='main'>".(tep_draw_input_field('new_filename'))."</td>
				</tr>	";
			}	
			if($filename!='') $return.=tep_draw_hidden_field('edit_file_name', $filename);
		$return.="		<tr >
					<td class='main' colspan='2' align='center'>".tep_draw_textarea_field('file_contents', 'soft', '77', '15', $file_contents, (($file_writeable) ? '' : 'readonly') . ' style="border:none"')."</td>
				</tr>
			</table>";
			echo  $return;
	}		
	
	function show_delete(){
		global $current_id,$path_id,$filename;
		$path_array=array();
		$path_array=split('{}',$current_id);
		$file_writeable = true;
		 if (!is_writeable($path_array[0])) {
			  $file_writeable = false;
		 }
		echo 'file_delete_confirm{[^]}';
		echo $current_id . '{[^]}'; 
		if (!isset($file_writeable)) $file_writeable = true;
		
		$return= "<table border='0' cellspacing='0' cellpadding='0' width='100%'>
					<tr><td colspan='2'><table cellpadding='0' cellspacing='0' border='0' width='100%'>
				<tr bgcolor='#CCCCCC' height='20'>
					<td class='main'>&nbsp;<b>" .$filename;
		$return.=	"</b></td><td  valign='top' align='right'>";
							if($file_writeable==true) $return.=" <a href='javascript:do_page_fetch(\"file_delete\");'>" . tep_image(DIR_WS_IMAGES . 'template/img_savel.gif').  "</a>&nbsp;";
				$return.="<a href='javascript:do_page_fetch(\"do_expand\");'>" . tep_image(DIR_WS_IMAGES . 'template/img_closel.gif').  "</a></td>
				</tr> </table></td></tr>
				<tr><td>" . tep_draw_separator('pixel_trans.gif','10','10') . "</td></tr>" ;
			if($file_writeable==false)
				$return.="<tr><td class='main' align='center' colspan='2'>" .'<font color="#ff0000"> File has no write permission</font>'  . "</td></tr>";
		$return.="		<tr >
					<td class='main' colspan='2' align='center'><b>".TEXT_DELETE_INTRO."</b></td>
				</tr>
			</table>";
			echo  $return;
	}		
	
	function save_details(){
		global $current_id,$path_id,$filename;
		$path_array=array();
		$path_array=split('{}',$current_id);	
		$last_modified=strftime(DATE_TIME_FORMAT, filemtime($path_array[0]));
 		$ldate=substr($last_modified,0,10); 
	  	$ldatee = substr($ldate,6,10);
	  	$ldatee .='/'. substr($ldate,3,3);
	  	$ldatee .= substr($ldate,0,2); 
	  	$permissions = tep_get_file_permissions(fileperms($path_array[0]));
		$space='';
		
		if($path_array[1]>1) { 
			$space_width= ($path_array[1]-1) * 20 ; 
			$space=tep_draw_separator('pixel_trans.gif',$space_width,'10');
		}
		$file_array = file($path_array[0]);
		  
		$icon = tep_image(DIR_WS_ICONS . 'file_download.gif', 'File');
		$file_size = number_format(filesize($path_array[0])) . ' bytes';
		
		$return='<table cellpadding="0" cellspacing="0" border="0" width="100%">'.
					'<tr class="dataTableRowSelected" onMouseOver="rowOverEffect(this)" id="row_' . $current_id. '" onMouseOut="rowOutEffect(this)" onClick="javascript:load_files(\''. $filename .'\',\'' . $current_id .'\',\'file\');">
						 <td class="dataTableContent" width="350">'.  $space. $icon . '&nbsp;' . $filename . '</td>
						 <td class="dataTableContent" align="right" width="100">' . $file_size . '</td>
						 <td class="dataTableContent" align="center" width="100"><tt>' . $permissions . '</tt></td>
						 <td class="dataTableContent" align="center" width="150">' . $ldatee . '</td>
					</tr>
				</table>';
		return $return;			 
	}	
	
	function error_details(){
		global $filename,$file_contents,$edit,$error;

		$return= "<table border='0' cellspacing='0' cellpadding='0' width='100%'>
					<tr><td colspan='2'><table cellpadding='0' cellspacing='0' border='0' width='100%'>
				<tr bgcolor='#CCCCCC' height='20'>
					<td class='main'>&nbsp;<b>" . (($edit==true)?'New File':$filename);
		$return.=	"</b></td><td  valign='top' align='right'>";
							if($edit==true) $return.=" <a href='javascript:save(0);'>" . tep_image(DIR_WS_IMAGES . 'template/img_savel.gif').  "</a>&nbsp;";
				$return.="<a href='javascript:do_page_fetch(\"do_expand\");'>" . tep_image(DIR_WS_IMAGES . 'template/img_closel.gif').  "</a></td>
				</tr> </table></td></tr>
				<tr><td>" . tep_draw_separator('pixel_trans.gif','10','10') . "</td></tr>" ;
			
				$return.="<tr><td class='main' align='center' colspan='2'>" .'<font color="#ff0000"> ' . $error . ' </font>'  . "</td></tr>";
			if($edit==true)	{
				
		$return.=		"<tr height='30'>
					<td align='left' class='main'>" . TEXT_FILE_NAME . "</td>
					<td class='main'>".(tep_draw_input_field('new_filename',$filename))."</td>
				</tr>	";
			}	
		$return.="		<tr >
					<td class='main' colspan='2' align='center'>".tep_draw_textarea_field('file_contents', 'soft', '77', '15', $file_contents, (($edit==true) ? '' : 'readonly') . ' style="border:none"')."</td>
				</tr>
			</table>";
			echo  $return;
	}		
	
	function file_delete_error(){
		global $filename,$error,$type,$delete_file_path,$path_id; 
		$return= "<table border='0' cellspacing='0' cellpadding='0' width='100%'>
					<tr><td colspan='2'><table cellpadding='0' cellspacing='0' border='0' width='100%'>
				<tr bgcolor='#CCCCCC' height='20'>
					<td class='main'>&nbsp;<b>Delete Error";
		$return.=	"</b></td><td  valign='top' align='right'>";
				$return.="<a href='javascript:do_page_fetch(\"do_expand\");'>" . tep_image(DIR_WS_IMAGES . 'template/img_closel.gif').  "</a></td>
				</tr> </table></td></tr>
				<tr><td>" . tep_draw_separator('pixel_trans.gif','10','10') . "</td></tr>" ;
				if($type=='folder'){
				$return.="<tr>
					<td class='main' width='100'>" . TEXT_FOLDER_NAME . " </td> 
					<td class='main'>" . $path_id . "</td>
				</tr>	" ;
				}else if($type=='file'){
				$return.="<tr>
					<td class='main' width='100'>" . TEXT_FILE_NAME . " </td> 
					<td class='main'>" . $delete_file_path[0] . "</td>
				</tr>	" ;
				} 
			if($file_writeable==false)
				$return.="<tr><td>" . tep_draw_separator('pixel_trans.gif','10','10') . "</td></tr><tr><td class='main' align='center' colspan='2'>" .'<font color="#ff0000"> ' . $error . '</font>'  . "</td></tr>";
		$return.="</table>";
			echo  $return;
	}		
	
	function show_folder_popup(){
		global $current_id,$path_id,$filename,$view;
		$path_array=array();
		$path_array=split('{}',$current_id);
		$folder_writeable = true;
		 if (!is_writeable($path_array[0])) {
			  $folder_writeable = false;
		 }
		 
		echo 'show_folder_popup{[^]}';
		echo $current_id . '{[^]}'; 
		if (!isset($folder_writeable)) $folder_writeable = true;

		$return= "<table border='0' cellspacing='0' cellpadding='0' width='100%'>
					<tr><td colspan='2'><table cellpadding='0' cellspacing='0' border='0' width='100%'>
				<tr bgcolor='#CCCCCC' height='20'>
					<td class='main'>&nbsp;<b>Create New Folder" ;
		$return.=	"</b></td><td  valign='top' align='right'>";
							if($folder_writeable==true ) $return.=" <a href='javascript:save_folder();'>" . tep_image(DIR_WS_IMAGES . 'template/img_savel.gif').  "</a>&nbsp;";
				$return.="<a href='javascript:do_page_fetch(\"do_expand\");'>" . tep_image(DIR_WS_IMAGES . 'template/img_closel.gif').  "</a></td>
				</tr> </table></td></tr>
				<tr><td>" . tep_draw_separator('pixel_trans.gif','10','10') . "</td></tr>" ;
			if($folder_writeable==false)
				$return.="<tr><td class='main' align='center' colspan='2'>" .'<font color="#ff0000">  Folder has no write permission</font>'  . "</td></tr>";
				
		$return.=		"<tr height='30'>
					<td align='left' class='main'>" . TEXT_FOLDER_NAME . "</td>
					<td class='main'>".(tep_draw_input_field('new_foldername'))."</td>
				</tr>	
			</table>";
			echo  $return;
	}		
	
	function show_folder_delete(){
		global $current_id,$path_id;
		$path_array=array();
		$fcnt=0;
		$path_array=split('{}',$current_id);
		$folder_writeable = true;
		 if (!is_writeable($path_array[0])) {
			  $folder_writeable = false;
		 }
		$del_dir = dir($path_id);
		while ($del_file = $del_dir->read()) {
			if ($del_file != "." && $del_file != "..") {
				$fcnt++;
			}
		} 
		echo 'folder_delete_confirm{[^]}';
		echo $current_id . '{[^]}'; 
		if (!isset($folder_writeable)) $folder_writeable = true;
		$return= "<table border='0' cellspacing='0' cellpadding='0' width='100%'>
					<tr><td colspan='2'><table cellpadding='0' cellspacing='0' border='0' width='100%'>
				<tr bgcolor='#CCCCCC' height='20'>
					<td class='main'>&nbsp;<b>Delete Folder" ;
		$return.=	"</b></td><td  valign='top' align='right'>";
							if($folder_writeable==true) $return.=" <a href='javascript:do_page_fetch(\"folder_delete\");'>" . tep_image(DIR_WS_IMAGES . 'template/img_savel.gif').  "</a>&nbsp;";
				$return.="<a href='javascript:do_page_fetch(\"do_expand\");'>" . tep_image(DIR_WS_IMAGES . 'template/img_closel.gif').  "</a></td>
				</tr> </table></td></tr>
				<tr><td>" . tep_draw_separator('pixel_trans.gif','10','10') . "</td></tr>" ;
			if($folder_writeable==false)
				$return.="<tr><td class='main' align='center' colspan='2'>" .'<font color="#ff0000"> File has no write permission</font>'  . "</td></tr>";
				
		$return.=		"<tr height='30'>
					<td align='left' class='main'>" . TEXT_FOLDER_NAME . "</td>
					<td class='main'>".$path_array[0]."</td>
				</tr>	";
		$return.="		<tr >
					<td class='main' colspan='2' align='center'><b>".(($fcnt>0)? TEXT_FOLDER_HAS_FILE:TEXT_FOLDER_DELETE_INTRO)."</b></td>
				</tr>
			</table>";
			echo  $return;
	}		
	
	function folder_error_details(){
		global $error,$save; 
		$return= "<table border='0' cellspacing='0' cellpadding='0' width='100%'>
					<tr><td colspan='2'><table cellpadding='0' cellspacing='0' border='0' width='100%'>
				<tr bgcolor='#CCCCCC' height='20'>
					<td class='main'>&nbsp;<b>Folder Save Error" ;
		$return.=	"</b></td><td  valign='top' align='right'>";
							if($save==true) $return.=" <a href='javascript:save_folder();'>" . tep_image(DIR_WS_IMAGES . 'template/img_savel.gif').  "</a>&nbsp;";
				$return.="<a href='javascript:do_page_fetch(\"do_expand\");'>" . tep_image(DIR_WS_IMAGES . 'template/img_closel.gif').  "</a></td>
				</tr> </table></td></tr>
				<tr><td>" . tep_draw_separator('pixel_trans.gif','10','10') . "</td></tr>" ;
		
				$return.="<tr><td class='main' align='center' colspan='2'>" .'<font color="#ff0000"> '. $error .'</font>'  . "</td></tr>";
				
		$return.=		"<tr height='30'>
					<td align='left' class='main'>" . TEXT_FOLDER_NAME . "</td>
					<td class='main'>".tep_draw_input_field('new_foldername')."</td>
				</tr>	</table>";
			echo  $return;
	}		
	?>