Realize packaging function ~ Easy and convenient! Compression is worse than WinRAR, but it doesn't matter. After all, just pack and do the download
Save yourself to the server to pack the site if the server is not their own more trouble to let others help lay the bag
Copy Code code as follows:
<?php
PHP compressed directory into ZIP package
Author: Xiao Feng
$button =$_post[' button '];
if ($button = = "Start packing")
{
$zip = new Ziparchive ();
$filename = "./". Date ("y-m-d"). " _ ". MD5 (Time ())." _jackfeng.zip ";
if ($zip->open ($filename, ziparchive::create)!==true) {
Exit ("Cannot create < $filename >\n");
}
$files = Listdir ();
foreach ($files as $path)
{
$zip->addfile ($path, Str_replace ("./", "", Str_replace ("\", "/", $path));
}
echo "Compression complete, total compression:". $zip->numfiles. "File \ n";
$zip->close ();
}
Function listdir ($start _dir= '. ') {
$files = Array ();
if (Is_dir ($start _dir)) {
$fh = Opendir ($start _dir);
while (($file = Readdir ($FH))!== false) {
if (strcmp ($file, '. ') ==0 | | strcmp ($file, '.. ') ==0) continue;
$filepath = $start _dir. '/' . $file;
if (Is_dir ($filepath))
$files = Array_merge ($files, Listdir ($filepath));
Else
Array_push ($files, $filepath);
}
Closedir ($FH);
} else {
$files = false;
}
return $files;
}
?>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title> Online Packaging Tools </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<form name= "Form1" method= "Post" action= "" >
<HR size= "1" >
<P> <input type= "Submit" name= "button" value= "Start packing"/></p>
<P> Note: The point starts packing, after that, is patiently waits for the packing completes, according to the website document how many, may need the time to be very long. After the package is complete, the package will be stored in the directory to be packaged to <span style= ' color:red; > Packing time + indefinite length random string +jackfeng.zip</span> This name, please login ftp download. </P>
</form>
</body>