PHP Online Decompression Program

Source: Internet
Author: User
Tags explode mkdir php online php tutorial

<?php Tutorial

The code is as follows Copy Code

HtmlHead ("Select Extract file:");

if (! IsSet ($HTTP _post_vars[' submit '))
{
Testwriteable ();
$gzip _info = "";
echo "Check zlib support ... " ;
if (!function_exists ("Gzopen"))
{
$gzip _info = "<font color=" red "> Attention! There is no zlib support for your space, so use
<a href= "http://www.111cn.net/" target= "_blank" ><font color= "Blue" >phpZip</font></a>
When compressing a file, do not select "compress into gzip format", otherwise will not be able to decompress!</font> correctly ";
}
Else
{
$gzip _info = "<font color=" Blue "> Congratulations! Your space supports zlib compression, strongly recommended
<a href= "http://www.111cn.net/" ><font color= "red" target= "_blank" >phpZip</font></a>
When compressing files, select "Compress into gzip format", will greatly reduce file size!</font> ";
}
echo "-----------------ok!<br>". $gzip _info;

echo "<br><br><br><br>
<form action= "{$_server[" php_self "]}" method= "Post" enctype= "Multipart/form-data" >
<table align= "center" width= "450" >
&LT;TR&GT;&LT;TD height= colspan= "2" > Please select the location of the compressed file, then click "OK" button: <p></td></tr>
<tr>
<td><input type= "Radio" name= "File_type" value= "upload" checked onclick= "this.form.upload_file.disabled=" False This.form.server_filename.disabled=true "> Files from local upload: </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= "Server" onclick= "This.form.upload_file.disabled=true"; This.form.server_filename.disabled=false > Specify the files on the server:</td>
<td><input name= "Server_filename" value= "data.dat.gz" style= "color: #0000ff" Disabled > (can be used "." Represents the current directory) </td>
</tr>

<TR><TD colspan= "2" align=center><br><input type= "Submit" name= "Submit" value= "OK" ></td ></tr>
</table>
</form>
" ;
Htmlfoot ();
Exit;
}

if ($_post[' file_type '] = = ' upload ')
{
$tmpfile = $_files[' upload_file '] [' tmp_name '];
}
Else
{
$tmpfile = $_post[' server_filename '];
}

if (! $tmpfile)
{
Exit ("Invalid file or file does not exist, possibly due to file size too large, upload failed or no server-side file specified");
}

$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 <br>";
Continue
}

if (substr ($attr, 0,5) = = "[dir]")
{
if (@mkdir ($filename, 0777))
echo "Make dir $filename <br>";
$c _dir++;
}
Else
{
$fp = @fopen ($filename, "WB") or exit ("Cannot create a new file $filename because you do not have write permission, modify permissions");
@fwrite ($fp, substr ($alldata, $pos, $attr));
$pos + + $attr;
Fclose ($FP);
echo "Create file $filename <br>";
$c _file++;
}
}

if ($_post[' file_type '] = = ' upload ')
{
if (@unlink ($tmpfile)) echo "deletes the temporary file $tmpfile ...<br>";
}

echo "Htmlfoot ();


function testwriteable ()
{
$safemode = '
Create a new file, named unzip2.php (or other name), which reads as follows:

<?php
Copy ("unzip.php", "unzip_safe.php");
Header ("location:unzip_safe.php");
?>

Upload this file to the server, in the same directory as unzip.php,
Run unzip2.php this program.

If still not, that is space is not support, there is no way, very sorry to you, wasting your time.
' ;
echo Check PHP version ... " . Phpversion (). "--------ok!<br>";
echo "Testing Permission ... " ;

$fp = @fopen ("Phpzip.test", "WB");
if (FALSE!== $fp)
{
Fclose ($FP);
@unlink ("Phpzip.test");
}
Else
{
Exit ("The current directory does not have write permission, please modify the current directory property to: 777");
}

  $dir = "Phpziptest";
  $file = "$dir/test.txt.php";
  @mkdir ($dir, 0777);
  $fp = @fopen ($file, "WB");
 if (FALSE = = $fp)
 {
   @rmdir ($dir)
  exit ("There is no permission to create a file under a folder created by the program, most likely PHP security mode, the solution is as follows: <p><center><textarea cols=110 rows=15> $safemode </textarea></center > ");
 }
  @fclose ($FP);
  @unlink ($file);
  @rmdir ($dir);
 echo "-----------------ok!<br>";
}

Function HtmlHead ($title = "", $css Tutorial _file= "")
{
 echo '   . "
  ."   ." <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">"
  . <title> $title </title> "
  ." <style type= "Text/css" > "
  ." BODY,PRE,TD {font-size:12px background-color: #fcfcfc; font-family:tahoma,verdana,arial} "
  ." input,textarea{font-size:12px background-color: #f0f0f0; font-family:tahoma,verdana,arial} "
  ." </style> "
  ."   ." "
  ." <body> ";
}

function Htmlfoot ()
{
echo "<center><font size=" 5 "face=" italics _gb2312 "color=" red "> Please delete this file immediately to avoid being found by others!</font></ Center> "
. "<br>. "<center>"
. "<p style=" Font-family:verdana; Font-size:12px ">contact Us:"
. "<a href=" http://www.111cn.net/"target=" _blank ">http://www.111cn.net/</a></p>"
. "</center>"
. "</body>"
. " "
. "}

?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.