Delete copy of file by function to show whether magic reference is turned on

Source: Internet
Author: User
Deleting a file by using a function to copy has shown whether to turn on magic references
  1. /**
  2. 2012-4-12 丨 still rice too
  3. * Custom addslashes function, support multi-dimension group, support automatically identify whether the server turns on magic reference
  4. */
  5. function Add_slashes ($var) {
  6. First determine if the server supports magic references
  7. if (GET_MAGIC_QUOTES_GPC () ==0) {
  8. if (Is_array ($var)) {
  9. Iterating through an array
  10. foreach ($var as $key = = $value) {
  11. $var [$key] = add_slashes ($value);
  12. }
  13. return $var;
  14. }
  15. }elseif (is_string ($var)) {
  16. Not an array is a string
  17. Return addslashes ($var);
  18. }else{
  19. has been opened
  20. return $var;
  21. }
  22. }
  23. copy function for file and folder copying function
  24. function Dir_copy ($SRC, $DST) {
  25. if (Is_dir ($SRC)) {
  26. if (!file_exists ($DST)) {
  27. @mkdir ($DST, 0777,true);
  28. }
  29. }
  30. $fp = Opendir ($SRC);
  31. while (!false== ($fn =readdir ($fp))) {
  32. if ($fn = = "." | | $fn = = "..") {
  33. Continue
  34. }
  35. $path = $src. Directory_separator. $fn;
  36. if (Is_dir ($path)) {
  37. Dis_copy ($path, ($DST. Directory_separator. $fn));
  38. }elseif (Is_file ($path)) {
  39. Copy ($path, ($DST. Directory_separator. $fn));
  40. }else{
  41. Copy ($path, ($DST. Directory_separator. $fn));
  42. }
  43. }
  44. Closedir ($FP);
  45. }
  46. Delete a function
  47. function Delete_dir ($SRC) {
  48. if (Is_dir ($SRC)) {
  49. $fp = Opendir ($SRC);
  50. while (!false== ($fn =readdir ($fp))) {
  51. if ($fn = = "." | | $fn = = "..") {
  52. Continue
  53. }
  54. $path = $src. Directory_separator. $fn;
  55. if (Is_dir ($path)) {
  56. Delete_dir ($path);
  57. }elseif (Is_file ($path)) {
  58. @unlink ($path);
  59. }else{
  60. @unlink ($path);
  61. }
  62. }
  63. }
  64. Closedir ($FP);
  65. @rmdir ($SRC);
  66. }
  67. MSG Output returned
  68. function msg ($msg) {
  69. echo $msg. "
    ";
  70. echo "Return to previous page";
  71. Die
  72. }
Copy Code
  • 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.