国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

110 linhas
2.7KB

  1. <?php
  2. if (!defined('DEDEINC')) exit ('dedebiz');
  3. /**
  4. * 文件处理助手
  5. *
  6. * @version $id:file.helper.php 2010-07-05 11:43:09 tianya $
  7. * @package DedeBIZ.Helpers
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  10. * @link https://www.dedebiz.com
  11. */
  12. /**
  13. * 创建所有目录
  14. *
  15. * @param string $truepath 真实地址
  16. * @param string $mmode 模式
  17. * @return bool
  18. */
  19. if (!function_exists('MkdirAll')) {
  20. function MkdirAll($truepath, $mmode)
  21. {
  22. if (!file_exists($truepath)) {
  23. mkdir($truepath, $mmode);
  24. chmod($truepath, $mmode);
  25. return true;
  26. } else {
  27. return true;
  28. }
  29. }
  30. }
  31. /**
  32. * 修改所有模式
  33. *
  34. * @access public
  35. * @param string $truepath 文件路径
  36. * @param string $mmode 模式
  37. * @return string
  38. */
  39. if (!function_exists('ChmodAll')) {
  40. function ChmodAll($truepath, $mmode)
  41. {
  42. return chmod($truepath, '0'.$mmode);
  43. }
  44. }
  45. /**
  46. * 创建目录
  47. *
  48. * @param string $spath 创建的文件夹
  49. * @return bool
  50. */
  51. if (!function_exists('CreateDir')) {
  52. function CreateDir($spath)
  53. {
  54. if (!function_exists('SpCreateDir')) {
  55. require_once(DEDEINC.'/inc/inc_fun_funAdmin.php');
  56. }
  57. return SpCreateDir($spath);
  58. }
  59. }
  60. /**
  61. * 写文件
  62. *
  63. * @access public
  64. * @param string $file 文件名
  65. * @param string $content 文档
  66. * @param int $flag 标识
  67. * @return string
  68. */
  69. if (!function_exists('PutFile')) {
  70. function PutFile($file, $content, $flag = 0)
  71. {
  72. $pathinfo = pathinfo($file);
  73. if (!empty($pathinfo['dirname'])) {
  74. if (file_exists($pathinfo['dirname']) === FALSE) {
  75. if (@mkdir($pathinfo['dirname'], 0777, TRUE) === FALSE) {
  76. return FALSE;
  77. }
  78. }
  79. }
  80. if ($flag === FILE_APPEND) {
  81. return @file_put_contents($file, $content, FILE_APPEND);
  82. } else {
  83. return @file_put_contents($file, $content, LOCK_EX);
  84. }
  85. }
  86. }
  87. /**
  88. * 用递归方式删除目录
  89. *
  90. * @access public
  91. * @param string $file 目录文件
  92. * @return string
  93. */
  94. if (!function_exists('RmRecurse')) {
  95. function RmRecurse($file)
  96. {
  97. if (is_dir($file) && !is_link($file)) {
  98. foreach (glob($file.'/*') as $sf) {
  99. if (!RmRecurse($sf)) {
  100. return false;
  101. }
  102. }
  103. return @rmdir($file);
  104. } else {
  105. return @unlink($file);
  106. }
  107. }
  108. }
  109. ?>