PHP online package source code

Source: Internet
Author: User

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.

CopyCode The Code is as follows: <? PHP
// 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 \ 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">
<HTML>
<Head>
<Title> online packaging tool </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
</Head>
<Body>
<Form name = "form1" method = "Post" Action = "">
<HR size = "1">
<H3> <a href = "? "> Online packaging tool </a>
<P> <input type = "Submit" name = "button" value = "Start packaging"/> </P>
<P> Note: After packaging starts, wait patiently until the packaging is completed. Depending on the number of website files, it may take a long time. After the package is completed, the package is stored in the directory of the site to be packaged, and named in the format of <span style = 'color: red; '> packaging time when the packet is not long and random, and the string is jackfeng.zip </span>, please log on to FTP and download it. </P>
</Form>
</Body>
</Html>

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.