抱歉对此造成的困扰。我将整个代码都提供给你,没有省略任何部分:

class HtmlManager {
    var $dir;       // 目录用于存储 HTML 文件(不包含斜杠)
    var $rootdir;   // HTML 文件的根目录(不包含斜杠):html
    var $name;      // HTML 文件存放路径
    var $dirname;   // 指定的文件夹名称
    var $url;       // 获取 HTML 文件信息的来源网页地址
    var $time;      // HTML 文件信息添加时的时间
    var $dirtype;   // 目录存放方式:year, month, ...
    var $nametype;  // HTML 文件命名方式:name

    function HtmlManager($nametype = 'name', $dirtype = 'year', $rootdir = 'html') {
        $this->setVar($nametype, $dirtype, $rootdir);
    }

    function setVar($nametype = 'name', $dirtype = 'year', $rootdir = 'html') {
        $this->rootdir = $rootdir;
        $this->dirtype = $dirtype;
        $this->nametype = $nametype;
    }

    function createDir($dir = '') {
        $this->dir = $dir ? $dir : $this->dir;
        if (!is_dir($this->dir)) {
            $temp = explode('/', $this->dir);
            $cur_dir = '';
            for ($i = 0; $i < count($temp); $i++) {
                $cur_dir .= $temp[$i] . '/';
                if (!is_dir($cur_dir)) {
                    mkdir($cur_dir);
                    chmod($cur_dir, 0777);
                }
            }
        }
        return $this->dir;
    }

    function createHtml($url = '', $time = 0, $dirname = '', $htmlname = '') {
        $this->url = $url ? $url : $this->url;
        $this->dirname = $dirname ? $dirname : $this->dirname;
        $this->time = $time ? $time : $this->time;

        if (empty($htmlname))
            $this->getName();
        else
            $this->name = $dirname . '/' . $htmlname;

        $content = file($this->url) or die("Failed to open the url " . $this->url . " !");
        $content = join("", $content);
        $fp = @fopen($this->name, "w") or die("Failed to open the file " . $this->name . " !");
        if (@fwrite($fp, $content))
            return true;
        else
            return false;
        fclose($fp);
    }

    function deleteHtml($url = '', $time = 0, $dirname = '') {
        $this->url = $url ? $url : $this->url;
        $this->time = $time ? $time : $this->time;
        $this->getName();
        if (@unlink($this->name))
            return true;
        else
            return false;
    }

    function deleteDir($file) {
        if (file_exists($file)) {
            if (is_dir($file)) {
                $handle = opendir($file);
                while (false !== ($filename = readdir($handle))) {
                    if ($filename != "." && $filename != "..")
                        $this->deleteDir($file . "/" . $filename);
                }
                closedir($handle);
                rmdir($file);
                return true;
            } else {
                unlink($file);
            }
        }
    }

    function getDir() {
        $this->time = $time ? $time : $this->time;
        $this->dirname = $dirname ? $dirname : $this->dirname;
        switch ($this->dirtype) {
            case 'name':
                if (empty($this->dirname))
                    $this->dir = $this->rootdir;
                else
                    $this->dir = $this->rootdir . '/' . $this->dirname;
                break;
            case 'year':
                $this->dir = $this->rootdir . '/' . date("Y", $this->time);
                break;
            case 'month':
                $this->dir = $this->rootdir . '/' . date("Y-m", $this->time);
                break;
            case 'day':
                $this->dir = $this->rootdir . '/' . date("Y-m-d", $this->time);
                break;
        }
        $this->createDir();
        return $this->dir;
    }

    function getName() {
        $this->url = $url ? $url : $this->url;
        $this->dirname = $dirname ? $dirname : $this->dirname;
        $this->time = $time ? $time : $this->time;
        $this->getDir();
        switch ($this->nametype) {
            case 'name':
                $filename = $this->getUrlName() . '.htm';
                $this->name = $this->dir . '/' . $filename;
                break;
            case 'time':
                $this->name = $this->dir . '/' . $this->time . '.htm';
                break;
            case 'query':
                $this->name = $this->dir . '/' . $this->getUrlQuery() . '.htm';
                break;
            case 'namequery':
                $this->name = $this->dir . '/' . $this->getUrlName() . '-' . $this->getUrlQuery() . '.htm';
                break;
            case 'nametime':
                $this->name = $this->dir . '/' . $this->getUrlName() . '-' . $this->time . '.htm';
                break;
        }
        return $this->name;
    }

    function getUrlName($url = '') {
        $this->url = $url ? $url : $this->url;
        $filename = basename($this->url);
        $filename = explode(".", $filename);
        return $filename[0];
    }

    function getUrlQuery($url = '') {
        $this->url = $url ? $url : $this->url;
        $durl = parse_url($this->url);
        $durl = explode("&", $durl['query']);
        foreach ($durl as $surl) {
            $gurl = explode("=", $surl);
            $eurl[] = $gurl[1];
        }
        return join("_", $eurl);
    }

    function setName($url = '', $time = 0, $dirname = '') {
        $this->url = $url ? $url : $this->url;
        $this->dirname = $dirname ? $dirname : $this->dirname;
        $this->time = $time ? $time : $this->time;
        $this->getDir();
        switch ($this->nametype) {
            case 'name':
                $filename = $this->getUrlName() . '.htm';
                $this->name = $this->dir . '/' . $filename;
                break;
            case 'time':
                $this->name = $this->dir . '/' . $this->time . '.htm';
                break;
            case 'query':
                $this->name = $this->dir . '/' . $this->getUrlQuery() . '.htm';
                break;
            case 'namequery':
                $this->name = $this->dir . '/' . $this->getUrlName() . '-' . $this->getUrlQuery() . '.htm';
                break;
            case 'nametime':
                $this->name = $this->dir . '/' . $this->getUrlName() . '-' . $this->time . '.htm';
                break;
        }
        return $this->name;
    }
}

?>