File "edit.php"

Full Path: /home/analogde/www/filetypes/zip/edit.php
File size: 8.24 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2003-2004 Tobias Bender (tobias@phpXplorer.org)
*  All rights reserved
*
*  This script is part of the phpXplorer project. The phpXplorer project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*  A copy is found in the textfile GPL.txt distributed with these scripts.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

require(dirname(dirname(__FILE__)) . "/defaultActionHead.php");

require($GC_other_Path . "/zip.lib.php");

$fileName = getRequestVar("fileName");
$submitAction = getRequestVar("submitAction");

$fileSelection = $HTTP_POST_VARS["fileSelection"];

if(!(strpos($fileName, "..") === FALSE))
	die($PXP_languages[$PXP_language]['accessDenied'] . " (804)");


$pInfo = checkFilePermissions($fileName);
if(!$pInfo["allowOpen"] or !$pInfo["allowEdit"])
	die($PXP_languages[$PXP_language]["accessDenied"] . " (809)");


$errors = "";

$archive = new zipfile();

switch($submitAction){
	case "extract":
		$archive->extract($currentDir . "/" . $fileName, $currentDir);
	break;
	case "extractSelection":
		if(sizeof($fileSelection) > 0)
			$archive->extract($currentDir . "/" . $fileName, $currentDir, $fileSelection);
	break;
}

$fileList = $archive->getContentList($currentDir . "/" . $fileName)

?>
<html>
<head>
<title><?php echo $PXP_languages[$PXP_language]['filetype.zip'] . " - " . str_replace($PXP_basedir, "", $currentDir) . "/" . $fileName ?></title>
<style type="text/css">
<!--
	body{margin:0px}
-->
</style>
<link rel="stylesheet" type="text/css" href="<?php echo $PXP_url ?>/styles/<?php echo $PXP_style ?>/main.css">
<script src="<?php echo $GC_coolmenu_URL ?>/coolmenus4.js" type="text/javascript" language="JavaScript"></script>
<script language="JavaScript" type="text/javascript">
<!--
function init(){ 
	<?php
	if(($submitAction == "extract" or $submitAction == "extractSelection") and trim($errors) == ""){
		echo "opener.refreshDir()\r\n";
		echo "window.close()\r\n";
		echo "return\r\n";
	}
	?>
	//<script>
}

function deleteSelection(){
	var f = document.frm1
	f.submitAction.value = "deleteSelection"
	f.submit()
}

function extractSelection(){
	var f = document.frm1
	f.submitAction.value = "extractSelection"
	f.submit()
}

function extract(){
	var f = document.frm1
	f.submitAction.value = "extract"
	f.submit()
}

function selectAll(){
	for(var e = 0; e < document.frm1.elements.length; e++){
	  if(document.frm1.elements[e].name == "fileSelection[]" || document.frm1.elements[e].name == "folderSelection[]")
			document.frm1.elements[e].checked = true
	}
}

function clearSelection(){
	for(var e = 0; e < document.frm1.elements.length; e++){
	  if(document.frm1.elements[e].name == "fileSelection[]" || document.frm1.elements[e].name == "folderSelection[]")
			document.frm1.elements[e].checked = false
	}
}

function invertSelection(){
	for(var e = 0; e < document.frm1.elements.length; e++){
	  if(document.frm1.elements[e].name == "fileSelection[]" || document.frm1.elements[e].name == "folderSelection[]")
			document.frm1.elements[e].checked =! document.frm1.elements[e].checked
	}
}

//-->
</script>
</head>
<body onLoad="init()">
<script src="<?php echo $PXP_url ?>/styles/<?php echo $PXP_style ?>/JSMenu.js" type="text/javascript" language="JavaScript"></script>
<script>
<!--

/******************************************
Menu item creation:
myCoolMenu.makeMenu(name, parent_name, text, link, target, width, height, regImage, overImage, regClass, overClass , align, rows, nolink, onclick, onmouseover, onmouseout) 
*************************************/

oCMenu.makeMenu('top0','','&nbsp;<?php echo $PXP_languages[$PXP_language]["menu.file"] ?>','','',43)
	oCMenu.makeMenu('sub01','top0','<?php echo $PXP_languages[$PXP_language]["menu.extract"] ?>','javascript:extract()')
	oCMenu.makeMenu('sub02','top0','<?php echo $PXP_languages[$PXP_language]["menu.extractSelection"] ?>','javascript:extractSelection()')
	oCMenu.makeMenu('sub03','top0','','',0,0,2)
	oCMenu.makeMenu('sub04','top0','<?php echo $PXP_languages[$PXP_language]["menu.close"] ?>','javascript:window.close()')

oCMenu.makeMenu('top1','','&nbsp;<?php echo $PXP_languages[$PXP_language]["menu.edit"] ?>','','',77)
	oCMenu.makeMenu('sub11','top1','&nbsp;<?php echo $PXP_languages[$PXP_language]["menu.selection"] ?>','')
		oCMenu.makeMenu('sub20','sub11','&nbsp;<?php echo $PXP_languages[$PXP_language]["menu.all"] ?>','javascript:selectAll()')
		oCMenu.makeMenu('sub21','sub11','&nbsp;<?php echo $PXP_languages[$PXP_language]["menu.invert"] ?>','javascript:invertSelection()')
		oCMenu.makeMenu('sub22','sub11','&nbsp;<?php echo $PXP_languages[$PXP_language]["menu.clear"] ?>','javascript:clearSelection()')
		oCMenu.makeMenu('sub23','sub11','&nbsp;<?php echo $PXP_languages[$PXP_language]["menu.delete"] ?>','javascript:deleteSelection()')

	oCMenu.makeMenu('sub12','top1','','',0,0,2)
	oCMenu.makeMenu('sub13','top1','<?php echo $PXP_languages[$PXP_language]["menu.extractSelection"] ?>','javascript:extractSelection()')

//Leave this line - it constructs the menu
oCMenu.construct()
//-->
</script>
<form name="frm1" action="./edit.php" method="post">
<input type="hidden" name="currentDir" value="<?php echo $currentDir ?>">
<input type="hidden" name="shareId" value="<?php echo $shareId ?>">
<input type="hidden" name="fileName" value="<?php echo $fileName ?>">
<input type="hidden" name="submitAction" value="">

<div style="height:26px">&nbsp;</div>

<?php 
if($errors != "")
	echo "<span class=\"error\">$errors</span>";
?>
<table border="0" cellspacing="0" cellpadding="0" style="border-top: 1px solid #999999"><tr><td>
<table border="0" cellspacing="0" cellpadding="0" bordercolor="#eeeeee">
<tr>
	<td class="head" colspan="2">&nbsp;</td>
	<td class="head">&nbsp;<?php echo $PXP_languages[$PXP_language]["caption.filename"] ?>&nbsp;</td>
	<td class="head">&nbsp;<?php echo $PXP_languages[$PXP_language]["caption.bytes"] ?>&nbsp;</td>
	<td class="head">&nbsp;<?php echo $PXP_languages[$PXP_language]["caption.compressed"] ?>&nbsp;</td>
	<td class="head">&nbsp;<?php echo $PXP_languages[$PXP_language]["caption.lastChanged"] ?>&nbsp;</td>
	<td class="head">&nbsp;<?php echo $PXP_languages[$PXP_language]["caption.comment"] ?>&nbsp;</td>
</tr>
<?php
#            [filename] => phpXplorer/doc/errorCodes.txt
#            [stored_filename] => phpXplorer/doc/errorCodes.txt
#            [size] => 570
#            [compressed_size] => 290
#            [crc] => FEA544A6
#            [mtime] => 1099514260
#            [comment] => 
#            [folder] => 0
#            [index] => 
#            [status] => ok

foreach($fileList as $file){

	$extKey = getTypeKeyByExtension($file["filename"]);

	echo "<tr>";
	echo '<td><input type="checkbox" name="fileSelection[]" value="' . $file["index"] . '">&nbsp;</td>';
	echo "<td>";
	
	if($file["folder"]){
		echo "<img src=\"" . $PXP_url . "/filetypes/folder/icon.png\" alt=\"" . $PXP_languages[$PXP_language]["filetype." . $extKey] . "\" title=\"" . $PXP_languages[$PXP_language]["filetype." . $extKey] . "\">";
	}else{
		echo "<img src=\"" . $PXP_url . "/filetypes/" . $extKey . "/icon.png\" alt=\"" . $PXP_languages[$PXP_language]["filetype." . $extKey] . "\" title=\"" . $PXP_languages[$PXP_language]["filetype." . $extKey] . "\" align=\"texttop\" border=\"0\">";
	}
	
	echo "</td>";
	echo "<td title=\"". $file["stored_filename"]. "\">&nbsp;" . $file["filename"] . "&nbsp;</td>";
	echo "<td>&nbsp;" . number_format($file["size"], 0, ",", ".") . "&nbsp;</td>";
	echo "<td>&nbsp;" . number_format($file["compressed_size"], 0, ",", ".") . "&nbsp;</td>";
	echo "<td>&nbsp;" . date ("d.m.y H:i:s", $file["mtime"]) . "&nbsp;</td>";
	echo "<td>&nbsp;" . $file["comment"] . "&nbsp;</td>";
	echo "</tr>";
} 

?>
</table>
</td></tr></table>
</form>
</body>
</html>