php中文网 | cnphp.com

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 125|回复: 0

php整站打包工具

[复制链接]

2627

主题

2634

帖子

9336

积分

管理员

Rank: 9Rank: 9Rank: 9

UID
1
威望
0
积分
6587
贡献
0
注册时间
2021-4-14
最后登录
2024-4-26
在线时间
667 小时
QQ
发表于 2023-12-18 21:08:25 | 显示全部楼层 |阅读模式
  1. <?php
  2. set_time_limit(0);

  3. {
  4. $zip = new ZipArchive();
  5. $filename = "./".date("Y-m-d")."_xiaoyuer.zip";
  6. if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
  7. exit("无法创建 <$filename>\n");
  8. }
  9. $files = listdir();
  10. foreach($files as $path)
  11. {
  12. $zip->addFile($path,str_replace("./","",str_replace("\","/",$path)));
  13. }
  14. echo "压缩完成,共压缩了: " . $zip->numFiles . "个文件\n";
  15. $zip->close();
  16. }
  17. Function listdir($start_dir='.') {
  18. $files = array();
  19. if (is_dir($start_dir)) {
  20. $fh = opendir($start_dir);
  21. while (($file = readdir($fh)) !== false) {
  22. if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue;
  23. $filepath = $start_dir . '/' . $file;
  24. if ( is_dir($filepath) )
  25. $files = array_merge($files, listdir($filepath));
  26. else
  27. array_push($files, $filepath);
  28. }
  29. closedir($fh);
  30. } else {
  31. $files = false;
  32. }
  33. return $files;
  34. }
  35. ?>
  36. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
  37. <html>
  38. <head>
  39. <title>小鱼儿PHP打包工具</title>
  40. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  41. </head>
  42. <body>
  43. <form name="form1" method="post" action="">
  44. <hr size="1">
  45. <h3><a href="http://www.shejifang.org">支持一下主页</a></h3>
  46. <P> <input type="submit" name="button" value="点击这里继续打包!" /></P>
  47. <P>说明:点开始打包,之后,就是耐心等待打包完成了,根据网站文件多少,需要的时间可能会很长。打包完成之后,压缩包会存放在要打包的站点目录下,以<span style='color:red;'>打包时间+xiaoyuer.zip</span>这样命名,请登陆ftp后下载。</P>
  48. </form>
  49. </body>
  50. </html>
复制代码





上一篇:IEEE30节点系统潮流计算
下一篇:利用OpenCV库函数实现PCA(主成成分分析)算法,该算法是...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|php中文网 | cnphp.com ( 赣ICP备2021002321号-2 )51LA统计

GMT+8, 2024-4-27 13:39 , Processed in 0.204756 second(s), 38 queries , Gzip On.

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

申明:本站所有资源皆搜集自网络,相关版权归版权持有人所有,如有侵权,请电邮(fiorkn@foxmail.com)告之,本站会尽快删除。

快速回复 返回顶部 返回列表