📄 swzip.php
字号:
<?php
$admin_pass="admin"; //管理员密码
error_reporting(E_ERROR | E_PARSE);
set_magic_quotes_runtime(0);
set_time_limit(0);
session_start();
if(PHP_VERSION < '4.1.0') {
$_GET = &$HTTP_GET_VARS;
$_POST = &$HTTP_POST_VARS;
$_COOKIE = &$HTTP_COOKIE_VARS;
$_SERVER = &$HTTP_SERVER_VARS;
$_ENV = &$HTTP_ENV_VARS;
$_FILES = &$HTTP_POST_FILES;
}
unset($_ENV,$HTTP_ENV_VARS,$_REQUEST,$HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_POST_FILES,$HTTP_COOKIE_VARS);
ob_start();
header("Content-Type: text/html; charset=gbk");
$version="1.0.2";
define("SCRIPT_DIR", realpath('./').'/'); //取得文件夹
//取得php_self
$PHP_SELF = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
require_once("zip.php");
daddslashes($_POST);
if(!session_is_registered("admin")){
if(!$_POST['password']){
heardhtml();
echo '<form action="'.$PHP_SELF.'" method="post" name="login">';
echo '<tr><td align="center">请输入管理员密码:<input type="text" name="password">
<input type="button" value="提 交" onclick="check1(this.form)" /></form></td></tr>
<script language="JavaScript">document.login.password.focus();</script>';
footer();
}else if($_POST['password']===$admin_pass){
session_register("admin");
}else{
die('<script language="javascript">alert("密码不正确");history.back(-1);</script>');
}
}
$_step=!empty($_GET['step']) ? $_GET['step'] : $_POST['step'];
if(!$_step){
$cresult=phpTest();
heardhtml();
echo "<tr><td height='100' style='color: red'>{$cresult}<p align='center'>
<input type='button' value='开始在线解压缩' onclick=\"top.location.replace('{$php_self}?step=1')\" /></td></tr>";
footer();
}
$action_result='';
if($_step==2){
$action_result.= "<tr><td colspan='2' class='yesbox'>\r\n";
if($_POST['file_type']==1){
$file_atype=array("application/x-zip-compressed","application/x-gzip-compressed");
$tmpfile=$_FILES['upload_file']['tmp_name'];
$tmptype=$_FILES['upload_file']['type'];
}else{
$file_atype=array("zip",".gz");
$tmpfile=$_POST['server_filename'];
$tmptype=substr($tmpfile,-3);
}
if($tmpfile && in_array($tmptype, $file_atype)){
$archive=new PHPZip($_POST['chmod777']);
$headers=$archive->Extract_File($tmpfile);
if($headers){
$zip_result=$archive->get_List($tmpfile);
$action_result.= "<b>本次解压缩结果: 解压缩出文件和文件夹共 <font color='red'>".count($zip_result)."</font> 个<br /></b>";
foreach($zip_result as $zp){
if($zp['folder'])
$action_result.= "文件夹: {$zp['filename']} 解压成功......大小: {$zp['size']}字节;<br />";
else
$action_result.= "文件: {$zp['filename']} 解压成功......大小: {$zp['size']}字节;<br />";
}
}else{
$action_result.= "本次解压缩失败!可能原因为压缩文件不合法或过大等。";
}
}else{
$action_result.= '上传文件无效或尺寸太大!(只能解zip和gz文件哦)';
}
$action_result.= "</td></tr>";
}elseif($_step==3){
$oldname=preg_replace("#[/?*><:|\"]#", "", $_POST['dirname']);
$oldname=str_replace("\\", "", $oldname);
$newname=preg_replace("#[/?*><:|\"]#", "", $_POST['rename']);
$newname=str_replace("\\", "", $newname);
$action_result.= "<tr><td colspan='2' class='yesbox'>\r\n";
if($oldname && $newname){
@rename($oldname, $newname);
$action_result.= "重命名完成!";
}elseif($oldname){
DeltreeDir($oldname);
if($delresult){
$action_result.= "<b><font color='red'>本次操作删除的文件(夹): </font><br /></b>";
$action_result.= $delresult;
}
}else
$action_result.= "Please choose the folder";
$action_result.= "</td></tr>";
}
//取得当前路径所有文件夹
$hand=opendir(SCRIPT_DIR);
while($file=readdir($hand)){
if($file=='.' || $file=='..') continue;
if(is_dir($file) && !is_link($file)){
$dnames.="<option value={$file}>{$file}</option>";
}
}
closedir($hand);
heardhtml();
print <<<MYCJQ
<tr><td width='55%'><form action="{$PHP_SELF}" method="post" enctype="multipart/form-data">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr><td height="20" colspan="2"><b>请先选择压缩文件的位置,然后点击“确定”按钮: </b></td></tr>
<tr>
<td width="27%"><input type="radio" name="file_type" value="1" checked onclick="this.form.upload_file.disabled=false; this.form.server_filename.disabled=true" />文件从本地上传: </td>
<td><input name="upload_file" type="file" style="color:#0000ff" />
</td>
</tr>
<tr><td colspan='2' height='10'></td></tr>
<tr>
<td><input type="radio" name="file_type" value="0" onclick="this.form.upload_file.disabled=true; this.form.server_filename.disabled=false" />指定服务器上文件:</td>
<td><input name="server_filename" value="data.zip" style="color:#0000ff" disabled /> (可以用"./"表示当前目录)</td>
</tr>
<tr><td colspan="2" ><br><input type="checkbox" name="chmod777" value="chmod777" />将解压出的所有文件及文件夹属性改成777(慎用)</td></tr>
<tr><td colspan="2" align="center"><input type="hidden" value="2" name="step" />
<br><input type="button" value="确 定" onclick="check2(this.form, this)" /></td></tr></table></form></td>
<td width=45%><form action="{$PHP_SELF}" method="post">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr><td height="20" colspan="2"><b>请先选择文件夹,然后点击“删除”按钮: </b></td></tr>
<tr>
<td width="25%">选择文件夹: </td>
<td><select size="1" name="dirname"><option value=''>选择文件夹</option>
{$dnames}
</select></td></tr>
<tr><td colspan='2' height='10'></td></tr>
<tr>
<td>重命名为 :</td>
<td><input type="text" value="" name="rename" maxlength="25" /> (留空为删除该目录)</td>
</tr>
<tr><td colspan="2" ><br>
<font color='red'>将删除文件夹及其内所有文件(夹),删除后不能恢复!</font></td></tr>
<tr><td colspan="2" align="center"><input type="hidden" value="3" name="step" />
<br><input type="button" value="删 除" onclick="check3(this.form, this)" /></td></tr></table></form></td>
</td></tr>
{$action_result}
MYCJQ;
footer();
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -