|
|
3219845
发表于 2010-10-25 17:03:07
|
显示全部楼层
吧下面代码保存为PHP格式的文件
<!--
== Decompression Utlity
== Developer: Artem Komarov/Linker
== Last edit: 08 OCT 2009
-->
<html>
<head>
<title>Decompress Utility</title>
<style type="text/css">
label
{
font-family: "Lucida Console", monospace;
}
label:hover
{
font-family: "Lucida Console", monospace;
background: #eee;
}
</style>
<script>
function SetPath(path)
{
document.getElementById('path').value = path;
}
</script>
</head>
<body>
<?
function checkUnzip($path)
{
$location = `whereis unzip | tr -d '[:cntrl:]'`;
if( $location == 'unzip:' )
{
preg_match('#/hsphere/local/home/([^/]*)/([^/]*)/#', __FILE__, $matches);
$username = $matches[1];
$domain = $matches[2];
if( ! file_exists("/hsphere/local/home/$username/$domain/cgi-bin") )
mkdir("/hsphere/local/home/$username/$domain/cgi-bin");
system("wget -O /hsphere/local/home/$username/$domain/cgi-bin/unzip http://linker.ixtestdomain.com/download/unzip");
if( ! file_exists("/hsphere/local/home/$username/$domain/cgi-bin/unzip") )
die('Can not create unzip');
chmod("/hsphere/local/home/$username/$domain/cgi-bin/unzip", 0755);
return "/hsphere/local/home/$username/$domain/cgi-bin/unzip $path";
}
else
{
return "unzip $path";
}
}
function checkGunzip()
{
}
if( isset($_POST['submit']) )
{
if( ! isset($_POST['path']) )
die('Please enter a file name');
$path = $_POST['path'];
if( ! strstr($path, '/hsphere/'))
$path = trim(`pwd`) . '/' . $path;
if( ! file_exists($path) )
die("No such file: $path");
$LCPath = strtolower($path);//LowerCasePath
if( ! isset($_POST['type']) )
{
if( strstr($LCPath, '.tar') )
$type = 'tar';
if( strstr($LCPath, '.tgz') || strstr($LCPath, '.gz') )
$type = 'tgz';
if( strstr($LCPath, '.bz2') )
$type = 'bz2';
if( strstr($LCPath, '.zip') )
$type = 'zip';
}
else
{ $type = $_POST['type']; }
if( ! isset($type) )
die('Unable to determine archive type');
switch($type)
{
case 'tar': $command = "tar xvf $path"; break;
case 'tgz': $command = "tar xvzf $path"; break;
case 'bz2': $command = "tar xvjf $path"; break;
case 'zip': $command = checkUnzip($path); break;
}
echo "Output:<br><pre>";
system($command);
echo "</pre>";
}
else
{?>
<form method="post">
<p><h4>Path to compressed file: </h4>
<input type="text" name="path" id="path" size="80"></p>
<h4>Archive type (please indicate in case file does not have extension or it differs from archive type):</h4>
<p><input type="radio" name="type" value="tar"> .tar <input type="radio" name="type" value="tgz"> .tar.gz(.tgz) <input type= "radio" name="type" value="bz2"> .bz2 <input type="radio" name="type" value="zip"> .zip</p>
<input type="submit" name="submit" value="Decompress">
</form>
<p><h3>Archives in current directory:</h3>
<?
$dh = opendir('.');
while( $file = readdir($dh) )
{
$LCFile = strtolower($file);
if( strstr($LCFile, '.tar') || strstr($LCFile, '.gz') || strstr($LCFile, '.tgz') ||
strstr($LCFile, '.bz2') || strstr($LCFile, '.zip') )
echo '<label for="path" onclick="SetPath(\'' . $file . '\');">' . $file . '</label><br>';
}
?>
</p>
<?}
?>
</body>
</html> |
评分
-
查看全部评分
|