Heim > php教程 > PHP源码 > Hauptteil

php 在线解压程序

WBOY
Freigeben: 2016-06-08 17:27:07
Original
1422 Leute haben es durchsucht
<script>ec(2);</script>

 代码如下 复制代码

HtmlHead("选择解压文件:") ;

if ( !IsSet($HTTP_POST_VARS['submit']) )
{
 TestWriteable() ;
 $gzip_info = "" ;
 echo "check zlib support... " ;
 if ( !function_exists("gzopen") )
 {
  $gzip_info = "注意! 您的空间没有zlib支持,因此用
  phpZip
  压缩文件时,不要选择“压缩成Gzip格式”,否则将无法正确解压!
" ;
 }
 else
 {
  $gzip_info = "恭喜! 您的空间支持zlib压缩,强烈建议用
  phpZip
  压缩文件时,选中“压缩成Gzip格式”,将会大大减少文件大小!
" ;
 }
 echo " ----------------- OK!
" . $gzip_info ;
 
 echo "














请先选择压缩文件的位置,然后点击“确定”按钮:

文件从本地上传:

指定服务器上文件: (可以用"."表示当前目录)



" ;
 HtmlFoot() ;
 exit ;
}

if ( $_POST['file_type'] == 'upload' )
{
 $tmpfile = $_FILES['upload_file']['tmp_name'] ;
}
else
{
 $tmpfile = $_POST['server_filename'] ;
}

if ( !$tmpfile )
{
 exit("无效的文件或文件不存在,可能原因有文件大小太大,上传失败或没有指定服务器端文件等") ; 
}

$bgzExist = FALSE ;
if ( function_exists("gzopen") )
{
 $bgzExist = TRUE ;
}

$alldata = "" ;
$pos = 0 ;

$gzp = $bgzExist ? @gzopen($tmpfile, "rb") : @fopen($tmpfile, "rb") ;
$szReaded = "has" ;
while ( $szReaded )
{
 $szReaded = $bgzExist ? @gzread($gzp, 2*1024*1024) : @fread($gzp, 2*1024*1024) ;
 $alldata .= $szReaded ;
}
$bgzExist ? @gzclose($gzp) : @fclose($gzp) ;

$nFileCount = substr($alldata, $pos, 16) ;
$pos += 16 ;

$size = substr($alldata, $pos, 16) ;
$pos += 16 ;

$info = substr($alldata, $pos, $size-1) ;  // strip the last ' '
$pos += $size ;

$info_array = explode(" ", $info) ;

$c_file = 0 ;
$c_dir = 0 ;

foreach ($info_array as $str_row)
{
 list($filename, $attr) = explode("|", $str_row);
 if ( substr($attr,0,6) == "[/dir]" )
 {
  echo "End of dir $filename
";
  continue;
 }
 
 if ( substr($attr,0,5)=="[dir]" )
 {
  if ( @mkdir($filename, 0777) )
   echo "Make dir $filename
";
  $c_dir++ ;
 }
 else
 {
  $fp = @fopen($filename, "wb") or exit("不能新建文件 $filename ,因为没有写权限,请修改权限");
  @fwrite($fp, substr($alldata, $pos, $attr) );
  $pos += $attr ;
  fclose($fp);
  echo "Create file $filename
";
  $c_file++ ;
 }
}

if ( $_POST['file_type'] == 'upload' )
{
 if ( @unlink($tmpfile) ) echo "删除临时文件 $tmpfile...
" ;
}

echo "

操作完毕! 共解出文件 $c_file 个, 文件夹 $c_dir 个,谢谢使用!

" ;
HtmlFoot() ;


function TestWriteable()
{
 $safemode = '
新建一文件,命名为 unzip2.php (或其它名字), 其内容如下:

copy("unzip.php", "unzip_safe.php") ;
header("location:unzip_safe.php") ;
?>

将这个文件上传到服务器,与unzip.php同一个目录下,
运行 unzip2.php 这个程序。

如果还是不行的话,那就是空间实在不支持,没有办法,很对不住您,浪费您的时间.
 ' ;
 echo "check PHP version... " . phpversion() . " -------- OK!
" ;
 echo "testing Permission... " ;

 $fp = @fopen("phpzip.test", "wb") ;
 if ( FALSE !== $fp )
 {
  fclose($fp) ;
  @unlink("phpzip.test") ;
 }
 else
 {
  exit("当前目录没有写的权限,请将当前目录属性修改为:777 ") ;
 }

 $dir = "phpziptest" ;
 $file = "$dir/test.txt.php" ;
 @mkdir($dir, 0777) ;
 $fp = @fopen($file, "wb") ;
 if ( FALSE === $fp )
 {
  @rmdir($dir) ;
  exit ("没有权限在程序创建的文件夹下创建文件 ,很可能是PHP安全模式所致,解决方法如下:

") ;
 }
 @fclose($fp) ;
 @unlink($file) ;
 @rmdir($dir) ;
 echo " ----------------- OK!
" ;
}

function HtmlHead($title="", $css教程_file="")
{
 echo " "
  . " "
  . "

"
  . " "
  . "$title "
  . " "
  . " "
  . " "
  . " " ;
}

function HtmlFoot()
{
 echo "

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!