盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

PHP文件系统基本设置类

时间:2024/12/12作者:未知来源:盾怪网教程人气:

[摘要]]/", "", explode(DIRECTORY_SEPARATOR, ext)); array_pop(ext); ...
]/", "", explode(DIRECTORY_SEPARATOR, $ext));
                array_pop($ext);
                $path = explode(DIRECTORY_SEPARATOR, $path); // 建立目录层轴
                if ($path[count($path)-1]=="") array_pop($path);
                while (count($ext)) {
                    $i = array_shift($ext);
                    if ($i==".."&&count($path)>1) array_pop($path);
                    elseif (""!=str_replace(".", "", $i)) $path[] = $i;
                }
                $path = implode(DIRECTORY_SEPARATOR, $path);
            }
            unset($ext, $i);
            return $path;
        }

        /**
         * @]Method Name[= make_dir()
         * @]Purpose[=
         *     建立任意文件夹,相对或绝对路径皆可,深层建立亦可
         * @]Parameter[=
         *     string $path 要建立的最终目录路径
         * @]Return[= boolean 错误返回 FALSE,否则 TRUE
         * @]Author[= SNakeVil <51JS,BU,PHPx> (snakevil@qq.com)
         * @]See[=
         */
        function make_dir($path="") {
            $i = explode(DIRECTORY_SEPARATOR, $this->generate_path($path)); // 生成目录路径
            $path = array_shift($i);
            for ($j=0,$k=count($i);$j<$k;$j++) {
                $path .= DIRECTORY_SEPARATOR.$i[$j];
                if (!is_dir($path)) {
                    if ($this->exist_dir=="") $this->exist_dir = $path; // 记录最后存在的目录路径
                    if (!@mkdir($path)) return $this->error_occur(0x0003, substr($path, 0, strrpos($path, DIRECTORY_SEPARATOR)));
                }
            }
            if ($this->exist_dir=="") $this->exist_dir = $path;
            return TRUE;
        }

        /**
         * @]Method Name[= verify_file()
         * @]Purpose[=
         *     使用 MD5 算法比较两个文件是否相同
         * @]Parameter[=
         *     string $src 源文件路径
         *     string $dst 目标文件路径
         *     boolean $interal 对于超过 1MB 文件,设置 FALSE 省去 MD5 检验步骤,减轻服务器负担
         * @]Return[= boolean 错误返回 FALSE,否则 TRUE
         * @]Author[= SNakeVil <51JS,BU,PHPx> (snakevil@qq.com)
         * @]See[=
         */
        function verify_file($src="", $dst="", $interal=TRUE) {
            if (!is_file($src)

关键词:PHP文件系统基本设置类




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版