raksmart活动促销

分享

写回答

发帖

[提问] IX如何在线解压?

回答|共 16 个

gypworks526

发表于 2010-10-25 16:46:08 | 显示全部楼层

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>

评分

参与人数 1金币 +2 银币 +5 收起 理由
gypworks526 + 2 + 5 助人为乐

查看全部评分

RAKSmart

gypworks526

发表于 2010-10-25 17:08:43 | 显示全部楼层

gypworks526

发表于 2010-10-25 17:18:16 | 显示全部楼层

已测试可用,为了方便大家使用.变成PHP文件了 .
下载后,解压即可..
unzip.zip (1.42 KB, 下载次数: 271)
RAKSmart

ilinbxu

发表于 2010-10-26 10:41:30 | 显示全部楼层

回复 14# 的帖子

感谢分享

gypworks526

发表于 2010-10-26 10:50:40 | 显示全部楼层

求知者

发表于 2010-10-26 11:36:47 | 显示全部楼层

下载看看
您需要登录后才可以回帖 登录 | 注册

本版积分规则