common.php 1008 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. if (!defined('THINK_PATH')) exit();
  3. function xCopy($source, $destination, $child){
  4. //用法:
  5. // xCopy("feiy","feiy2",1):拷贝feiy下的文件到 feiy2,包括子目录
  6. // xCopy("feiy","feiy2",0):拷贝feiy下的文件到 feiy2,不包括子目录
  7. //参数说明:
  8. // $source:源目录名
  9. // $destination:目的目录名
  10. // $child:复制时,是不是包含的子目录
  11. if(!is_dir($source)){
  12. echo("Error:the $source is not a direction!");
  13. return 0;
  14. }
  15. if(!is_dir($destination)){
  16. mkdir($destination,0777);
  17. }
  18. $handle=dir($source);
  19. while($entry=$handle->read()) {
  20. if(($entry!=".")&&($entry!="..")){
  21. if(is_dir($source."/".$entry)){
  22. if($child)
  23. xCopy($source."/".$entry,$destination."/".$entry,$child);
  24. }
  25. else{
  26. copy($source."/".$entry,$destination."/".$entry);
  27. }
  28. }
  29. }
  30. return 1;
  31. }
  32. ?>