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>