Php online package program source code _ php instance

Source: Internet
Author: User
Tags php online ziparchive
Save the code in php format and then drop it under your site to open it ...... Package functions ~ Easy and convenient! Although the compression ratio is a little worse than winrar, it does not matter. after all, it is only packaged for download.
It saves you the trouble to package your site on the server. if the server is not your own, you have to ask someone to help you package.

The code is as follows:


// Compress the php directory into a zip package
// Author: Xiao Feng
$ Button = $ _ POST ['click'];
If ($ button = "start Packaging ")
{
$ 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 "compressed, compressed:". $ zip-> numFiles. "files ";
$ 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;
}
?>



Online packaging tools





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.