⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 html.php

📁 SSCMS网站管理系统 飞狐源码站 SSCMS可以将网站内容全部生成静态HTML文件,这样可以极大地节约主机资源
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php
include DIR_INCLUDES . 'cms_function.inc.php';
class CPage extends Page {
    var $CateID;
    var $ContentID;
    var $TableID;
    var $ContentTpl;
    var $RPSN;
    var $URL;
    var $SubDir;
    var $PublisDate;
    var $IndexID;
    var $Model;

    function CPage(&$app)
    {
        $this->Page($app);
        $this->userid = userid;
        $this->user_username = username;
        $this->app->includeClass("Files");
        $this->Files = new Files;
    } 

    function page_load()
    {
        if (empty($this->in['act'])) $this->onMake();
    } 

    function onMake()
    {
        include DIR_CACHE . 'cache_Cate.inc.php';
        include DIR_CACHE . 'cache_Category.inc.php';
        $ContentID = intval($this->in['ContentID']); //获取当前内容ID(内容表内)
        $CateID = intval($this->in['CateID']); //内容的分类ID
        $IndexID = intval($this->in['IndexID']); //文章的索引ID
        if (empty($IndexID)) {
            // 下面两行用来获取当前文章在系统文章库中的索引号码
            $sql = "SELECT * FROM " . $this->content_index . " WHERE ContentID=" . $ContentID . " AND CateID=" . $CateID;
        } else $sql = "SELECT * FROM " . $this->content_index . " WHERE IndexID=" . $IndexID;
        $query = $this->db->query($sql);
        $contentIndex = $this->db->fetch_array($query);
        $this->CateID = $contentIndex[CateID];
        $this->TableID = $Cate[$this->CateID][TableID];
        $contentIndex['SelfTemplate'] == ''?$this->ContentTpl = $Cate[$CateID]['ContentTpl']:$this->ContentTpl = $contentIndex['SelfTemplate'];
        $contentIndex['SelfPSN'] == ''?$this->RPSN = $Cate[$CateID]['ResourcePSN']:$this->RPSN = $contentIndex['SelfPSN'];
        $contentIndex['SelfPSNURL'] == ''?$this->URL = $Cate[$CateID]['ResourceURL']:$this->URL = $contentIndex['SelfPSNURL'];
        $contentIndex['SelfPublishFileName'] == ''?$this->fntype = $Cate[$CateID]['ContentFileName']:$this->fntype = $contentIndex['SelfPublishFileName'];
        $this->ContentID = $contentIndex[ContentID];
		$this->PublishDate = $contentIndex[PublishDate];
        $this->SubDir = $Cate[$this->CateID]['SubDir']; 
        // $this->PublisDate = $contentIndex['PublishDate'];
        $this->IndexID = $contentIndex['IndexID'];
        $this->Model = $Cate[$this->CateID][ContentModel];
        $msg = $this->MakeContent();
        $this->tpl->assign('msg', $msg);
        $this->tpl->display('admin/msg.html');
    } 

    function MakeContent()
    {
        include DIR_CACHE . 'cache_PSN.inc.php';
        include DIR_CACHE . 'cache_contentmodel.inc.php'; 
        // 获取当前分类的内容模板名称
        if ($this->ContentTpl == '')$this->ContentTpl = 'default/content.html'; 
        // 开始获取文章内容等字段
        $value = $this->objDataSet->getDataById($this->ContentID, "ContentID", $this-> {
                'content_' . $this->TableID} 
            ); 
        // 开始计算文件名的定义,并分离出主文件名和扩展文件名(分离是为了生成分页文件)
        $fntype = str_replace("{ContentID}", $this->ContentID, $this->fntype);
        $fntype = str_replace("{CateID}", $this->CateID, $fntype);
        $fntype = str_replace("{TimeStamp}", $this->PublishDate, $fntype);
        $fntype = str_replace("{IndexID}", $this->IndexID, $fntype);
		$this->tpl->assign('IndexID',$this->IndexID);
		$this->tpl->assign('PublishDate',$this->PublishDate);
        $apos = strpos($fntype, ".");
        if (!$apos) {
            $filename = $fntype;
            $ext = ".html";
        } else {
            $filename = substr($fntype, 0, $apos);
            $ext = substr($fntype, $apos);
        } 
        // 计算文件名的定义结束。
        // 下面用来获取当前文章的发布人,如果不需要显示的话,可以将
        $userid = userid;
        $users = $this->objDataSet->getDataById($value['CreationUserID'], $userid, $this->user); 
        // 以下开始计算当前分类内容页面保存的位置
        preg_match("/{PSN:(\d)}(.*)/is", $this->RPSN, $p);
        $RPSN = $PSN_cache[$p[1]]['PSN'];
        $RPSN = ltrim(rtrim(str_replace("Local::", "", $RPSN)));
        $RPSN .= $p[2];
        $RPSN .= "/";
        if ($this->SubDir) {
            $subdir = date($this->SubDir, $value[CreationDate]);
        } 
        if ($subdir)$RPSN .= $subdir . "/";
        $RPSN = str_replace("//", "/", $RPSN);
        preg_match("/{PSN-URL:(\d)}(.*)/is", $this->URL, $p);
        $RPSNURL = $PSN_cache[$p[1]]['URL'];
        $RPSNURL .= $p[2];
        $RPSNURL .= "/";
        if ($this->SubDir)$RPSNURL .= $subdir . "/";
        if (!is_dir($RPSN)) {
            $this->Files->mDir($RPSN);
        } 
        // echo $this->makenavbar($CateID);
        // 合并生成文件夹和主文件名
        $Pfilename = $RPSN . $filename;
        $url = $RPSNURL . $filename; 
        // $this->tpl->assign('CreationDate', $value['CreationDate']);
        $this->tpl->assign('PUBLISH_URL', HTTP_SERVER); 
        // $this->tpl->assign('Title',$value[Title]);
        $this->tpl->assign($value);
        $this->tpl->assign('Navigation', $this->MakeNavigation($this->CateID));
        foreach($content_model_info[$this->Model][Model] as $k => $val) {
            $FieldName = $val['FieldName'];
            $FieldText = $value[$val['FieldName']];
            if ($val['IsMainField'] == '1') {
                $Content = stripslashes($value[$val['FieldName']]);
            } elseif ($val['IsTitleField'] == '1') {
                $Title = $value[$val['FieldName']];
            } 
        } 
        $page = $this->page_chunk($Content, $Title);
        $this->tpl->assign('Editor', $users['user_username']);
        if (count($page) <= '1') {
            $this->tpl->assign('PageTitle', $Title);
            $this->tpl->assign('Content', $Content);
            $msg = "MakeHtml==><a href=" . $url . $ext . ">" . $Pfilename . $ext . "</a><br>";
            $string = $this->tpl->display($this->ContentTpl, 1);
            $this->Files->write($Pfilename . $ext, $string);
        } else {
            unset($pages);
            if (count($page) != '1') {
                for($i = 0;$i < count($page);$i++) {
                    if (!$i) {
                        $fn = $Pfilename . $ext;
                        $fnurl = $url . $ext;
                    } else {
                        $fn = $Pfilename . "_" . $i . $ext;
                        $fnurl = $url . "_" . $i . $ext;
                    } 
                    $j = $i + 1;
                    $pages[$j][URL] = $fnurl;
                    $pages[$j][Title] = $page[$i][Title];
                } 
            } 
            $msg = '';
            for($i = 0;$i < count($page);$i++) {
                if (!$i) {
                    $fn = $Pfilename . $ext;
                    $fnurl = $url . $ext;
                } else {
                    $fn = $Pfilename . "_" . $i . $ext;
                    $fnurl = $url . "_" . $i . $ext;
                } 
                $msg .= "MakeHtml==><a href=" . $fnurl . ">" . $fn . "</a><br>";
                $this->tpl->assign('PageNav', $pages);
                $this->tpl->assign('PageTitle', $page[$i][Title]);
                $this->tpl->assign('Content', $page[$i][Content]);
                $string = $this->tpl->display($this->ContentTpl, 1);
                $this->tpl->uassign('PageNav'); //删除模板变量PageNav;否则他将一直存在直到下一次被相同的变量所覆盖!
                $this->Files->write($fn, $string);
            } 
        }
        return $msg;
    } 

    function page_chunk($str, $first = '', $regexp = "#\[page:([^\]]+)\]#i") // $first???????
    {
        $match = array();
        preg_match_all($regexp, $str, $match);
        $page_title_list = $match[1];
        $page_content_list = preg_split($regexp, $str);
        array_unshift($page_title_list, $first);
        for($ii = 0; $ii < count($page_title_list); $ii++) {
            if (trim($page_content_list[$ii]) == '')continue;
            $pages['Title'] = $page_title_list[$ii];
            $pages['Content'] = $page_content_list[$ii];
            $page[] = $pages;
        } 
        Return $page;
    } 

    function onrefreshIndex()
    {
        include DIR_CACHE . 'cache_Cate.inc.php';
        $CateID = $this->in[CateID];
        echo "<script language='JavaScript'>top.TaskInfoFrame.addInfo('Updating index.html at " . $Cate[$CateID][Title] . " failed.', 'refreshIndex" . $CateID . "')</script><script language='JavaScript'>parent.endThread('refreshIndex" . $CateID . "');</script>";
    } 

    function onsiteRefresh()
    {
        $this->tpl->display('admin/siteRefresh.html');
    } 

    function CateRefresh()
    {
        include DIR_CACHE . 'cache_Cate.inc.php';
        $this->objDataSet->html = '1';
        $this->objDataSet->filename = 'index';
        $this->objDataSet->ext = 'html';
        $this->objDataSet->pagenum = $this->in[page];
        if ($this->CateID == '0')$this->CateID = '1';
        $this->CateID != ''?$where = ' where CateID=' . $this->CateID:'';
        $loop_data = $this->objDataSet->getList("select * from " . $this->content_index . $where . " order by IndexID", $this->content_num);
        if (is_array($loop_data->field)) {
            foreach($loop_data->field as $contentIndex) {
                $this->CateID = $contentIndex[CateID];
                $this->TableID = $Cate[$this->CateID][TableID];
                $contentIndex['SelfTemplate'] == ''?$this->ContentTpl = $Cate[$this->CateID]['ContentTpl']:$this->ContentTpl = $contentIndex['SelfTemplate'];
                $contentIndex['SelfPSN'] == ''?$this->RPSN = $Cate[$this->CateID]['ResourcePSN']:$this->RPSN = $contentIndex['SelfPSN'];
                $contentIndex['SelfPSNURL'] == ''?$this->URL = $Cate[$this->CateID]['ResourceURL']:$this->URL = $contentIndex['SelfPSNURL'];
                $contentIndex['SelfPublishFileName'] == ''?$this->fntype = $Cate[$this->CateID]['ContentFileName']:$this->fntype = $contentIndex['SelfPublishFileName'];
                $this->ContentID = $contentIndex[ContentID];
                $this->SubDir = $Cate[$this->CateID]['SubDir']; 
                $this->PublishDate = $contentIndex[PublishDate];
                $this->IndexID = $contentIndex['IndexID'];
                $this->Model = $Cate[$this->CateID][ContentModel];
                $msg .= $this->MakeContent();
            } 
            $this->tpl->assign('msg', $msg);
            $this->in[page]?$page = $this->in[page]:$page = '1';
            $page++;
            echo "<script language='JavaScript'>top.TaskInfoFrame.addInfo('Updating content  Cate" . $CateID . " (" . $loop_data->startnum . "," . $loop_data->endnum . ")', 'refreshcontent " . $CateID . "')</script>";
            if ($page <= $loop_data->totalpage) {
                return $page;
            } 
        } 
    } 
    function onrefreshSite()
    {
        include DIR_CACHE . 'cache_Cate.inc.php';
        $this->app->includeClass("Files");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -