国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > PhpCMS > 正文

【phpcms-v9】專題模塊前端控制器index.php文件分析

2024-09-10 07:15:47
字體:
來源:轉載
供稿:網友
  1. <?php    
  2. defined('IN_PHPCMS'or exit('No permission resources.');   
  3.    
  4. pc_base::load_app_func('global''special');//加載global.func.php文件   
  5. class index {   
  6.        
  7.     private $db;   
  8.        
  9.     function __construct() {   
  10.         $this->db = pc_base::load_model('special_model');//table_name:special   
  11.     }   
  12.        
  13.     /**  
  14.      * 專題列表   
  15.      */   
  16.     public function special() {   
  17.         //站點id   
  18.         $siteid = $_GET['siteid'] ? intval($_GET['siteid']) : (get_siteid() ? get_siteid() : 1);   
  19.         //seo信息   
  20.         $SEO = seo($siteid);   
  21.         //加載專題列表頁面   
  22.         include template('special''special_list');   
  23.     }   
  24.        
  25.     /**  
  26.      * 專題首頁  
  27.      */   
  28.     public function init() {   
  29.         //專題id   
  30.         $specialid = $_GET['id'] ? $_GET['id'] : ($_GET['specialid'] ? $_GET['specialid'] : 0);   
  31.         if (!$specialid) showmessage(L('illegal_action'));   
  32.         //相當于:select * from gt_special where id='$specialid' and disabled=0   
  33.         $info = $this->db->get_one(array('id'=>$specialid'disabled'=>0));   
  34.         if(!$info) showmessage(L('special_not_exist'), 'back');   
  35.            
  36.         //將當前專題id所對應的字段作為變量導入到當前的符號表   
  37.         extract($info);   
  38.            
  39.         $css = get_css(unserialize($css));   
  40.         if(!$ispage) {//字段變量:如果不分頁的話   
  41.             $type_db = pc_base::load_model('type_model');//類別表   
  42.             //查詢當前專題下所有的類別   
  43.             $types = $type_db->select(array('module'=>'special''parentid'=>$specialid), '*''''`listorder` ASC, `typeid` ASC''''listorder');   
  44.         }   
  45.         if ($pics) {//字段變量:專題導入的圖片報道信息,如:1|65|周克華被警方擊斃   
  46.             $pic_data = get_pic_content($pics);   
  47.             unset($pics);   
  48.         }   
  49.         if ($voteid) {//字段變量:投票信息,如:vote|1|你最愛吃的飯?   
  50.             $vote_info = explode('|'$voteid);   
  51.             $voteid = $vote_info[1];//投票id   
  52.         }   
  53.         $siteid =  $_GET['siteid'] ? $_GET['siteid'] : get_siteid();//站點id   
  54.         $SEO = seo($siteid''$title$description);//seo信息   
  55.         //評論表commentid字段的組成   
  56.         $commentid = id_encode('special'$id$siteid);//組成生成id號:urlencode($modules.'-'.$contentid.'-'.$siteid);   
  57.         $template = $info['index_template'] ? $info['index_template'] : 'index';//模板   
  58.         define('STYLE',$info['style']);   
  59.         include template('special'$template);   
  60.     }   
  61.        
  62.     /**  
  63.      * 專題分類  
  64.      */   
  65.     public function type() {   
  66.         $typeid = intval($_GET['typeid']);//分類id   
  67.         $specialid = intval($_GET['specialid']);//專題id   
  68.         if (!$specialid || !$typeid) showmessage(L('illegal_action'));   
  69.         //相當于:select * from gt_special where id='$special' and disabled=0  獲取當前專題信息   
  70.         $info = $this->db->get_one(array('id'=>$specialid'disabled'=>0));   
  71.         if(!$info) showmessage(L('special_not_exist'), 'back');   
  72.         $page = max(intval($_GET['page']), 1);   
  73.         //當前專題信息   
  74.         extract($info);   
  75.         $css = get_css(unserialize($css));   
  76.         if(!$typeid) showmessage(L('illegal_action'));   
  77.         $type_db = pc_base::load_model('type_model');//類別表   
  78.         //相當于:select * from gt_type where typeid='$typeid'   
  79.         $info = $type_db->get_one(array('typeid'=>$_GET['typeid']));   
  80.         $SEO = seo($siteid''$info['typename'], '');//類別名稱   
  81.         $template = $list_template ? $list_template : 'list';//類別對應的模板   
  82.         include template('special'$template);   
  83.     }   
  84.        
  85.     /**  
  86.      * 專題展示  
  87.      */   
  88.     public function show() {   
  89.         $id = intval($_GET['id']);//專題文章id   
  90.         if(!$id) showmessage(L('content_not_exist'),'blank');   
  91.            
  92.         $page = max(intval($_GET['page']), 1);   
  93.         $c_db = pc_base::load_model('special_content_model');//專題文章主表   
  94.         $c_data_db = pc_base::load_model('special_c_data_model');//專題文章附表   
  95.         $rs = $c_db->get_one(array('id'=>$_GET['id']));//獲取當前專題文章的主表內容   
  96.         if(!$rs) showmessage(L('content_checking'),'blank');   
  97.         //將當前專題文章主表中的字段轉化為變量   
  98.         extract($rs);   
  99.            
  100.         //是否用附表數據   
  101.         if ($isdata) {   
  102.             $arr_content = $c_data_db->get_one(array('id'=>$_GET['id']));//附表數據   
  103.             if (is_array($arr_content)) extract($arr_content);//將當前專題文章附表中的字段轉化為變量   
  104.         }   
  105.         $siteid = get_siteid();//站點id   
  106.         if ($paginationtype) {          //文章使用分頁時:0-不分頁  1-自動分頁    2-手動分頁   
  107.             if($paginationtype==1) {   
  108.                 if (strpos($content'[/page]')!==false) {   
  109.                     $content = preg_replace("|/[page/](.*)/[/page/]|U"''$content);   
  110.                 }   
  111.                 if (strpos($content'[page]')!==false) {   
  112.                     $content = str_replace('[page]'''$content);   
  113.                 }   
  114.                 $contentpage = pc_base::load_app_class('contentpage''content'); //調用自動分頁類   
  115.                 $content = $contentpage->get_data($content$maxcharperpage); //自動分頁,自動添加上[page]   
  116.             }    
  117.         } else {//文章不使用分頁的情況   
  118.             if (strpos($content'[/page]')!==false) {   
  119.                 $content = preg_replace("|/[page/](.*)/[/page/]|U"''$content);   
  120.             }   
  121.             if (strpos($content'[page]')!==false) {   
  122.                 $content = str_replace('[page]'''$content);   
  123.             }   
  124.         }   
  125.         $template = $show_template ? $show_template : 'show'//調用模板   
  126.         $CONTENT_POS = strpos($content'[page]');   
  127.         if ($CONTENT_POS !== false) {   
  128.             $contents = array_filter(explode('[page]'$content));   
  129.             $pagenumber = count($contents);   
  130.             $END_POS = strpos($content'[/page]');   
  131.             if ($END_POS!==false && ($CONTENT_POS<7)) {   
  132.                 $pagenumber--;   
  133.             }   
  134.             for ($i=1; $i<=$pagenumber$i++) {   
  135.                 $pageurls[$i] = content_url($_GET['id'], $i$inputtime'php');   
  136.             }   
  137.             if ($END_POS !== false) {   
  138.                 if($CONTENT_POS>7) {   
  139.                     $content = '[page]'.$title.'[/page]'.$content;   
  140.                 }   
  141.                 if (preg_match_all("|/[page/](.*)/[/page/]|U"$content$m, PREG_PATTERN_ORDER)) {   
  142.                     foreach ($m[1] as $k=>$v) {   
  143.                         $p = $k+1;   
  144.                         $titles[$p]['title'] = strip_tags($v);   
  145.                         $titles[$p]['url'] = $pageurls[$p][1];   
  146.                     }   
  147.                 }   
  148.             }   
  149.             //判斷[page]出現的位置是否在第一位    
  150.             if($CONTENT_POS<7) {   
  151.                 $content = $contents[$page];   
  152.             } else {   
  153.                 if ($page==1 && !emptyempty($titles)) {   
  154.                     $content = $title.'[/page]'.$contents[$page-1];   
  155.                 } else {   
  156.                     $content = $contents[$page-1];   
  157.                 }   
  158.             }   
  159.             if($titles) {   
  160.                 list($title$content) = explode('[/page]'$content);   
  161.                 $content = trim($content);   
  162.                 if(strpos($content,'</p>')===0) {   
  163.                     $content = '<p>'.$content;   
  164.                 }   
  165.                 if(stripos($content,'<p>')===0) {   
  166.                     $content = $content.'</p>';   
  167.                 }   
  168.             }   
  169.             pc_base::load_app_func('util''content');   
  170.             $title_pages = content_pages($pagenumber,$page$pageurls);//分頁代碼   
  171.         }   
  172.         //當前專題的標題和url   
  173.         $_special = $this->db->get_one(array('id'=>$specialid), '`title`, `url`');   
  174.         pc_base::load_sys_class('format''', 0);   
  175.         $inputtime = format::date($inputtime);//發布時間   
  176.         $SEO = seo($siteid''$title);   
  177.         $template = $show_template ? $show_template : 'show';   
  178.         $style = $style ? $style : 'default';   
  179.         include template('special'$template$style);   
  180.     }   
  181.        
  182.     public function comment_show() {   
  183.         $commentid = isset($_GET['commentid']) ? $_GET['commentid'] : 0;   
  184.         $url = isset($_GET['url']) ? $_GET['url'] : HTTP_REFERER;   
  185.         $id = isset($_GET['id']) ? intval($_GET['id']) : 0;   
  186.         $userid = param::get_cookie('_userid');   
  187.         include template('special''comment_show');   
  188.     }   
  189.        
  190.     public function comment() {   
  191.         if (!$_GET['id']) return '0';   
  192.         $siteid =  $_GET['siteid'] ? $_GET['siteid'] : get_siteid();   
  193.         $id = intval($_GET['id']);   
  194.         $commentid = id_encode('special'$id$siteid);   
  195.         $username = param::get_cookie('_username');   
  196.         $userid = param::get_cookie('_userid');   
  197.         if (!$userid) {   
  198.             showmessage(L('login_website'), APP_PATH.'index.php?m=member&c=index');   //開源軟件:Vevb.com 
  199.         }   
  200.         $date = date('m-d H:i', SYS_TIME);   
  201.         if ($_POST['dosubmit']) {   
  202.             $r = $this->db->get_one(array('id'=>$_POST['id']), '`title`, `url`');   
  203.             $comment = pc_base::load_app_class('comment''comment');   
  204.             if ($comment->add($commentid$siteidarray('userid'=>$userid'username'=>$username'content'=>$_POST['content']), ''$r['title'], $r['url'])) {   
  205.                 exit($username.'|'.SYS_TIME.'|'.$_POST['content']);   
  206.             } else {   
  207.                 exit(0);   
  208.             }   
  209.         } else {   
  210.             pc_base::load_sys_class('form');   
  211.             include template('special''comment');   
  212.         }   
  213.     }   
  214. }   
  215. ?>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 巴林右旗| 台安县| 泰来县| 万州区| 平武县| 高密市| 黑河市| 黑山县| 潜山县| 巴彦淖尔市| 临江市| 密云县| 腾冲县| 盐亭县| 平利县| 松原市| 衡东县| 屏南县| 乌鲁木齐县| 彰化市| 克东县| 历史| 库伦旗| 梁山县| 闵行区| 项城市| 垦利县| 金华市| 饶河县| 兰坪| 昂仁县| 正宁县| 鄄城县| 伊春市| 慈利县| 高雄市| 安平县| 柳河县| 昌吉市| 汉沽区| 中西区|