<?php
Verify Password
$password = "123456";
?>
<title>faisun_unzip-Pure Space-www.softpure.com</title>
<style type= "Text/css" > <!--
body,td{
font-size:14px;
Color: #000000;
}
A
Color: #000066;
Text-decoration:none;
}
a:hover {
Color: #FF6600;
Text-decoration:underline;
}
-->
</style>
<body >
<form name= "MyForm" method= "post" action= "<?=$_server[php_self";? > "enctype=" Multipart/form-data "onsubmit=" return Check_uploadobject (this); " >
?
if (!$_request["Myaction"]):
?>
<script language= "JavaScript" >
function Check_uploadobject (form) {
if (form.password.value== ') {
Alert (' Please enter a password. ');
return false;
}
return true;
}
</script>
<table width= "100%" border= "0" cellspacing= "0" cellpadding= "4" >
<tr>
<TD height= "colspan=" 2 "style=" color: #FF9900 "><p><font color=" #FF0000 ">faisun_unzip- Extract zip file online program v1.0</font></p>
<p> Reprint PLEASE note: This procedure by <a href= "http://www.softpure.com/" target= "_blank" > Pure space </a> (<a href= "http://" www.softpure.com/"target=" _blank ">http://www.softpure.com</a>), Author: Faisun (<a href=" mailto: Faisun@sina.com ">faisun@sina.com</a>) .</p>
<p> usage: Upload zip file to the same directory as this file via FTP, select Zip file, or click "Browse ..." to upload zip file. </p>
<p> the results of the decompression retain the original directory structure. </p>
<p> </p></td>
</tr>
<tr>
<TD width= "11%" > select Zip file: </td>
<TD width= "89%" ><select name= "ZipFile" >
<option value= "" selected>-Please choose-</option>
?
$fdir = Opendir ('./');
while ($file =readdir ($fdir)) {
if (!is_file ($file)) continue;
if (Preg_match ('/\.zip$/mis ', $file)) {
echo "<option value= ' $file ' > $file </option>\r\n";
}
}
?>
</select></td>
</tr>
<tr>
<TD width= "11%" nowrap> or upload file: </td>
<TD width= "89%" ><input name= "upfile" type= "file" id= "Upfile" size= "></td>"
</tr>
<tr>
<td> Extract to Directory: </td>
<td><input name= "Todir" type= "text" id= "Todir" value= "__unzipfiles__" size= ">"
(Leave blank for this directory, must have write permission) </td>
</tr>
<tr>
<td> Authentication Password: </td>
<td><input name= "password" type= "password" id= "password" size= ">"
(password set in source file) </td>
</tr>
<tr>
<td><input name= "myaction" type= "hidden" id= "myaction" value= "Dounzip" ></td>
<td><input type= "Submit" name= "submit" value= "decompression" ></td>
</tr>
</table>
?
ElseIf ($_request["myaction"]== "Dounzip"):
Class zip
{
var $total _files = 0;
var $total _folders = 0;
function Extract ($ZN, $to, $index = Array (-1))
{
$ok = 0; $zip = @fopen ($ZN, ' RB ');
if (! $zip) return (-1);
$cdir = $this->readcentraldir ($zip, $ZN);
$pos _entry = $cdir [' offset '];
if (!is_array ($index)) {$index = array ($index); }
for ($i =0; $index [$i]; $i + +) {
if (Intval ($index [$i])!= $index [$i]& #124;& #124; $index [$i]> $cdir [' entries ']]
Return (-1);
}
for ($i =0; $i < $cdir [' entries ']; $i + +)
{
@fseek ($zip, $pos _entry);
$header = $this->readcentralfileheaders ($zip);
$header [' index '] = $i; $pos _entry = Ftell ($zip);
@rewind ($zip); Fseek ($zip, $header [' offset ']);
if (In_array ("-1", $index) & #124;& #124; In_array ($i, $index))
$stat [$header [' filename ']]= $this->extractfile ($header, $to, $zip);
}
Fclose ($zip);
return $stat;
}
function Readfileheader ($zip)
{
$binary _data = fread ($zip, 30);
$data = Unpack (' vchk/vid/vversion/vflag/vcompression/vmtime/vmdate/vcrc/vcompressed_size/vsize/vfilename_len/ Vextra_len ', $binary _data);
$header [' filename '] = fread ($zip, $data [' Filename_len ']);
if ($data [' Extra_len ']!= 0) {
$header [' extra '] = Fread ($zip, $data [' Extra_len ']);
else {$header [' extra '] = ';}
$header [' compression '] = $data [' compression ']; $header [' size '] = $data [' Size '];
$header [' compressed_size '] = $data [' compressed_size '];
$header [' CRC '] = $data [' CRC ']; $header [' flag '] = $data [' flag '];
$header [' mdate '] = $data [' mdate ']; $header [' mtime '] = $data [' Mtime '];
if ($header [' mdate '] && $header [' mtime ']) {
$hour = ($header [' Mtime ']&0xf800] >>11; $minute = ($header [' Mtime ']&0x07e0) >>5;
$seconde = ($header [' Mtime ']&0x001f) *2; $year = ($header [' mdate ']&0xfe00] >>9) +1980;
$month = ($header [' mdate ']&0x01e0) >>5; $day = $header [' Mdate ']&0x001f;
$header [' mtime '] = Mktime ($hour, $minute, $seconde, $month, $day, $year);
}else{$header [' mtime '] = time ();}
$header [' stored_filename '] = $header [' filename '];
$header [' status '] = "OK";
return $header;
}
function Readcentralfileheaders ($zip) {
$binary _data = fread ($zip, 46);
$header = Unpack (' vchkid/vid/vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/vcrc/vcompressed_size/ Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/vexternal/voffset ', $binary _data);
if ($header [' Filename_len ']!= 0)
$header [' filename '] = fread ($zip, $header [' Filename_len ']);
else $header [' filename '] = ';
if ($header [' Extra_len ']!= 0)
$header [' extra '] = Fread ($zip, $header [' Extra_len ']);
else $header [' extra '] = ';
if ($header [' Comment_len ']!= 0)
$header [' comment '] = fread ($zip, $header [' Comment_len ']);
else $header [' comment '] = ';
if ($header [' mdate '] && $header [' mtime '])
{
$hour = ($header [' Mtime '] & 0xf800) >> 11;
$minute = ($header [' Mtime '] & 0x07e0) >> 5;
$seconde = ($header [' Mtime '] & 0x001f) *2;
$year = (($header [' Mdate '] & 0xfe00) >> 9) + 1980;
$month = ($header [' Mdate '] & 0x01e0) >> 5;
$day = $header [' mdate '] & 0x001f;
$header [' mtime '] = Mktime ($hour, $minute, $seconde, $month, $day, $year);
} else {
$header [' mtime '] = time ();
}
$header [' stored_filename '] = $header [' filename '];
$header [' status '] = ' OK ';
if (substr ($header [' filename '],-1) = = '/')
$header [' external '] = 0x41ff0010;
return $header;
}
function Readcentraldir ($zip, $zip _name) {
$size = filesize ($zip _name);
if ($size < 277) $maximum _size = $size;
else $maximum _size=277;
@fseek ($zip, $size-$maximum _size);
$pos = Ftell ($zip); $bytes = 0x00000000;
while ($pos < $size) {
$byte = @fread ($zip, 1); $bytes = ($bytes << 8) & #124; Ord ($byte);
if ($bytes = = 0x504b0506 or $bytes = = 0x2e706870504b0506) {$pos ++;break;} $pos + +;
}
$fdata =fread ($zip, 18);
$data = @unpack (' vdisk/vdisk_start/vdisk_entries/ventries/vsize/voffset/vcomment_size ', $fdata);
if ($data [' comment_size ']!= 0) $centd [' comment '] = fread ($zip, $data [' comment_size ']);
else $centd [' comment '] = '; $centd [' entries '] = $data [' Entries '];
$centd [' disk_entries '] = $data [' disk_entries '];
$centd [' offset '] = $data [' offset ']; $centd [' disk_start '] = $data [' Disk_start '];
$centd [' size '] = $data [' Size ']; $CENTD [' disk '] = $data [' Disk '];
return $CENTD;
}
function Extractfile ($header, $to, $zip) {
$header = $this->readfileheader ($zip);
if (substr ($to, -1)!= "/") $to. = "/";
if ($to = = './') $to = ';
$pth = Explode ("/", $to. $header [' filename ']);
$mydir = ';
For ($i =0 $i <count ($pth)-1; $i + +) {
if (! $pth [$i]) continue;
$mydir. = $pth [$i]. " /";
if (!is_dir ($mydir) && @mkdir ($mydir, 0777)) & #124;& #124; (($mydir = = $to. $header [' filename '] & #124;& #124; ($mydir = = $to && $this->total_folders==0)) && Is_dir ($mydir))) {
@chmod ($mydir, 0777);
$this->total_folders + +;
echo "<input name= ' dfile[] ' type= ' checkbox ' value= ' $mydir ' checked> <a ' href= ' $mydir ' target= ' _blank ' > directory: $ Mydir</a><br> ";
}
}
if (STRRCHR ($header [' filename '], '/') = = =/] return;
if (!) ( $header [' External ']==0x41ff0010) &&! ($header [' External ']==16)] {
if ($header [' compression ']==0) {
$fp = @fopen ($to. $header [' filename '], ' WB ');
if (! $fp) return (-1);
$size = $header [' compressed_size '];
while ($size!= 0) {
$read _size = ($size < 2048 $size: 2048);
$buffer = Fread ($zip, $read _size);
$binary _data = Pack (' a '. $read _size, $buffer);
@fwrite ($fp, $binary _data, $read _size);
$size-= $read _size;
}
Fclose ($FP);
Touch ($to. $header [' filename '], $header [' mtime ']);
}else{
$fp = @fopen ($to. $header [' filename ']. GZ ', ' WB ');
if (! $fp) return (-1);
$binary _data = Pack (' va1a1va1a1 ', 0x8b1f, Chr ($header [' compression ']),
CHR (0x00), Time (), Chr (0x00), CHR (3));
Fwrite ($fp, $binary _data, 10);
$size = $header [' compressed_size '];
while ($size!= 0) {
$read _size = ($size < 1024 $size: 1024);
$buffer = Fread ($zip, $read _size);
$binary _data = Pack (' a '. $read _size, $buffer);
@fwrite ($fp, $binary _data, $read _size);
$size-= $read _size;
}
$binary _data = Pack (' VV ', $header [' CRC '], $header [' size ']);
Fwrite ($fp, $binary _data,8); Fclose ($FP);
$gzp = @gzopen ($to. $header [' filename ']. GZ ', ' RB ') or die ("Cette archive est compress