PHP Online Packaging program Source _php Example

Source: Internet
Author: User
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= "" >
&LT;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>

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.