Esempio n. 1
0
 /**
  * 内容页
  */
 public function show()
 {
     $catid = intval($_GET['catid']);
     $id = intval($_GET['id']);
     if (!$catid || !$id) {
         showmessage(L('information_does_not_exist'), 'blank');
     }
     $_userid = $this->_userid;
     $_username = $this->_username;
     $_groupid = $this->_groupid;
     $page = isset($_GET['page']) ? max(intval($_GET['page']), 1) : 1;
     $CATEGORYS = S('common/category_content');
     if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) {
         showmessage(L('information_does_not_exist'), 'blank');
     }
     $this->category = $CAT = $CATEGORYS[$catid];
     $this->category_setting = $CAT['setting'] = string2array($this->category['setting']);
     $MODEL = S('common/model');
     $modelid = $CAT['modelid'];
     $tablename = $this->db->table_name = $this->db->get_prefix() . $MODEL[$modelid]['tablename'];
     $r = $this->db->getby_id($id);
     if (!$r || $r['status'] != 99) {
         showmessage(L('info_does_not_exists'), 'blank');
     }
     $this->db->table_name = $tablename . '_data';
     $r2 = $this->db->getby_id($id);
     $rs = $r2 ? array_merge($r, $r2) : $r;
     // 再次重新赋值,以数据库为准
     $catid = $CATEGORYS[$r['catid']]['catid'];
     $modelid = $CATEGORYS[$catid]['modelid'];
     require_once CACHE_MODEL_PATH . 'content_output.php';
     $content_output = new content_output($modelid, $catid, $CATEGORYS);
     $data = $content_output->get($rs);
     extract($data);
     // 检查文章会员组权限
     if ($groupids_view && is_array($groupids_view)) {
         $_groupid = cookie('_groupid');
         $_groupid = intval($_groupid);
         if (!$_groupid) {
             $forward = urlencode(Base_Request::get_url());
             showmessage(L('login_website'), U('member/passport/login', array('forward' => $forward)));
         }
         if (!in_array($_groupid, $groupids_view)) {
             showmessage(L('no_priv'));
         }
     } else {
         // 根据栏目访问权限判断权限
         $_priv_data = $this->_category_priv($catid);
         if ($_priv_data == '-1') {
             $forward = urlencode(Base_Request::get_url());
             showmessage(L('login_website'), U('member/passport/login', array('forward' => $forward)));
         } elseif ($_priv_data == '-2') {
             showmessage(L('no_priv'));
         }
     }
     if (app_exists('comment')) {
         $allow_comment = isset($allow_comment) ? $allow_comment : 1;
     } else {
         $allow_comment = 0;
     }
     // 阅读收费 类型
     $paytype = $rs['paytype'];
     $readpoint = $rs['readpoint'];
     $allow_visitor = 1;
     if ($readpoint || $this->category_setting['defaultchargepoint']) {
         if (!$readpoint) {
             $readpoint = $this->category_setting['defaultchargepoint'];
             $paytype = $this->category_setting['paytype'];
         }
         // 检查是否支付过
         $allow_visitor = self::_check_payment($catid . '_' . $id, $paytype);
         if (!$allow_visitor) {
             $http_referer = urlencode(Base_Request::get_url());
             $allow_visitor = String::authcode($catid . '_' . $id . '|' . $readpoint . '|' . $paytype) . '&http_referer=' . $http_referer;
         } else {
             $allow_visitor = 1;
         }
     }
     // 最顶级栏目ID
     $arrparentid = explode(',', $CAT['arrparentid']);
     $top_parentid = isset($arrparentid[1]) ? $arrparentid[1] : $catid;
     $template = $template ? $template : $CAT['setting']['show_template'];
     if (!$template) {
         $template = 'show';
     }
     // SEO
     $seo_keywords = '';
     if (!empty($keywords)) {
         $seo_keywords = implode(',', $keywords);
     }
     $SEO = seo($catid, $title, $description, $seo_keywords);
     define('STYLE', $CAT['setting']['template_list']);
     if (isset($rs['paginationtype'])) {
         $paginationtype = $rs['paginationtype'];
         $maxcharperpage = $rs['maxcharperpage'];
     }
     $pages = $titles = '';
     if ($rs['paginationtype'] == 1) {
         // 自动分页
         if ($maxcharperpage < 10) {
             $maxcharperpage = 500;
         }
         $contentpage = Loader::lib('content:contentpage');
         $content = $contentpage->get_data($content, $maxcharperpage);
     }
     if ($rs['paginationtype'] != 0) {
         // 手动分页
         $CONTENT_POS = strpos($content, '[page]');
         if ($CONTENT_POS !== false) {
             $this->url = Loader::lib('content:url');
             $contents = array_filter(explode('[page]', $content));
             $pagenumber = count($contents);
             if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) {
                 $pagenumber--;
             }
             for ($i = 1; $i <= $pagenumber; $i++) {
                 $pageurls[$i] = $this->url->show($id, $i, $catid, $rs['inputtime']);
             }
             $END_POS = strpos($content, '[/page]');
             if ($END_POS !== false) {
                 if ($CONTENT_POS > 7) {
                     $content = '[page]' . $title . '[/page]' . $content;
                 }
                 if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) {
                     foreach ($m[1] as $k => $v) {
                         $p = $k + 1;
                         $titles[$p]['title'] = strip_tags($v);
                         $titles[$p]['url'] = $pageurls[$p][0];
                     }
                 }
             }
             // 当不存在 [/page]时,则使用下面分页
             $pages = content_pages($pagenumber, $page, $pageurls);
             // 判断[page]出现的位置是否在第一位
             if ($CONTENT_POS < 7) {
                 $content = $contents[$page];
             } else {
                 if ($page == 1 && !empty($titles)) {
                     $content = $title . '[/page]' . $contents[$page - 1];
                 } else {
                     $content = $contents[$page - 1];
                 }
             }
             if ($titles) {
                 list($title, $content) = explode('[/page]', $content);
                 $content = trim($content);
                 if (strpos($content, '</p>') === 0) {
                     $content = '<p>' . $content;
                 }
                 if (stripos($content, '<p>') === 0) {
                     $content = $content . '</p>';
                 }
             }
         }
     }
     $this->db->table_name = $tablename;
     // 上一页
     $previous_page = $this->db->where(array('status' => 99, 'catid' => $catid, 'id' => array('lt', $id)))->order('id DESC')->find();
     // 下一页
     $next_page = $this->db->where(array('status' => 99, 'catid' => $catid, 'id' => array('gt', $id)))->find();
     if (empty($previous_page)) {
         $previous_page = array('title' => L('first_page'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('first_page') . '\');');
     }
     if (empty($next_page)) {
         $next_page = array('title' => L('last_page'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('last_page') . '\');');
     }
     include template('content', $template);
 }
Esempio n. 2
0
 public function show()
 {
     $catid = intval($_GET['catid']);
     $id = intval($_GET['id']);
     if (!$catid || !$id) {
         showmessage(L('information_does_not_exist'), 'blank');
     }
     $page = intval($_GET['page']);
     $page = max($page, 1);
     $siteids = getcache('category_content', 'commons');
     $siteid = $siteids[$catid];
     $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
     if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) {
         showmessage(L('information_does_not_exist'), 'blank');
     }
     $this->category = $CAT = $CATEGORYS[$catid];
     $this->category_setting = $CAT['setting'] = string2array($this->category['setting']);
     $siteid = $GLOBALS['siteid'] = $CAT['siteid'];
     $MODEL = getcache('model', 'commons');
     $modelid = $CAT['modelid'];
     $tablename = $this->db->table_name = $this->db->db_tablepre . $MODEL[$modelid]['tablename'];
     $r = $this->db->get_one(array('id' => $id));
     if (!$r || $r['status'] != 99) {
         showmessage(L('info_does_not_exists'), 'blank');
     }
     $this->db->table_name = $tablename . '_data';
     $r2 = $this->db->get_one(array('id' => $id));
     $rs = $r2 ? array_merge($r, $r2) : $r;
     //再次重新赋值,以数据库为准
     $catid = $CATEGORYS[$r['catid']]['catid'];
     $modelid = $CATEGORYS[$catid]['modelid'];
     require_once CACHE_MODEL_PATH . 'content_output.class.php';
     $content_output = new content_output($modelid, $catid, $CATEGORYS);
     $data = $content_output->get($rs);
     //print_r($data);
     extract($data);
     //检查文章会员组权限
     if ($groupids_view && is_array($groupids_view)) {
         $_groupid = param::get_cookie('_groupid');
         $_groupid = intval($_groupid);
         if (!$_groupid) {
             $forward = urlencode(get_url());
             showmessage(L('login_website'), APP_PATH . 'index.php?m=member&c=index&a=login&forward=' . $forward);
         }
         if (!in_array($_groupid, $groupids_view)) {
             showmessage(L('no_priv'));
         }
     } else {
         //根据栏目访问权限判断权限
         $_priv_data = $this->_category_priv($catid);
         if ($_priv_data == '-1') {
             $forward = urlencode(get_url());
             showmessage(L('login_website'), APP_PATH . 'index.php?m=member&c=index&a=login&forward=' . $forward);
         } elseif ($_priv_data == '-2') {
             showmessage(L('no_priv'));
         }
     }
     if (module_exists('comment')) {
         $allow_comment = isset($allow_comment) ? $allow_comment : 1;
     } else {
         $allow_comment = 0;
     }
     //阅读收费 类型
     $paytype = $rs['paytype'];
     $readpoint = $rs['readpoint'];
     $allow_visitor = 1;
     if ($readpoint || $this->category_setting['defaultchargepoint']) {
         if (!$readpoint) {
             $readpoint = $this->category_setting['defaultchargepoint'];
             $paytype = $this->category_setting['paytype'];
         }
         //检查是否支付过
         $allow_visitor = self::_check_payment($catid . '_' . $id, $paytype);
         if (!$allow_visitor) {
             $http_referer = urlencode(get_url());
             $allow_visitor = sys_auth($catid . '_' . $id . '|' . $readpoint . '|' . $paytype) . '&http_referer=' . $http_referer;
         } else {
             $allow_visitor = 1;
         }
     }
     //最顶级栏目ID
     $arrparentid = explode(',', $CAT['arrparentid']);
     $top_parentid = $arrparentid[1] ? $arrparentid[1] : $catid;
     $brother_cats = subcat($top_parentid);
     //顶级栏目子栏目集合,03月10日
     $template = $template ? $template : $CAT['setting']['show_template'];
     if (!$template) {
         $template = 'show';
     }
     //SEO
     $seo_keywords = '';
     if (!empty($keywords)) {
         $seo_keywords = implode(',', $keywords);
     }
     $_cateinfo = M("category")->get_one("catid=" . $catid);
     $sys_title = M("safe_system")->get_one("id=1");
     $SEO = array('site_title' => $sys_title['attr_value'], 'keyword' => empty($seo_keywords) ? $sys_title['attr_value'] : $seo_keywords, "description" => $sys_title['attr_value'], 'title' => $title . " - " . $_cateinfo['catname'] . " - ");
     define('STYLE', $CAT['setting']['template_list']);
     if (isset($rs['paginationtype'])) {
         $paginationtype = $rs['paginationtype'];
         $maxcharperpage = $rs['maxcharperpage'];
     }
     $pages = $titles = '';
     if ($rs['paginationtype'] == 1) {
         //自动分页
         if ($maxcharperpage < 10) {
             $maxcharperpage = 500;
         }
         $contentpage = pc_base::load_app_class('contentpage');
         $content = $contentpage->get_data($content, $maxcharperpage);
     }
     if ($rs['paginationtype'] != 0) {
         //手动分页
         $CONTENT_POS = strpos($content, '[page]');
         if ($CONTENT_POS !== false) {
             $this->url = pc_base::load_app_class('url', 'content');
             $contents = array_filter(explode('[page]', $content));
             $pagenumber = count($contents);
             if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) {
                 $pagenumber--;
             }
             for ($i = 1; $i <= $pagenumber; $i++) {
                 $pageurls[$i] = $this->url->show($id, $i, $catid, $rs['inputtime']);
             }
             $END_POS = strpos($content, '[/page]');
             if ($END_POS !== false) {
                 if ($CONTENT_POS > 7) {
                     $content = '[page]' . $title . '[/page]' . $content;
                 }
                 if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) {
                     foreach ($m[1] as $k => $v) {
                         $p = $k + 1;
                         $titles[$p]['title'] = strip_tags($v);
                         $titles[$p]['url'] = $pageurls[$p][0];
                     }
                 }
             }
             //当不存在 [/page]时,则使用下面分页
             $pages = content_pages($pagenumber, $page, $pageurls);
             //判断[page]出现的位置是否在第一位
             if ($CONTENT_POS < 7) {
                 $content = $contents[$page];
             } else {
                 if ($page == 1 && !empty($titles)) {
                     $content = $title . '[/page]' . $contents[$page - 1];
                 } else {
                     $content = $contents[$page - 1];
                 }
             }
             if ($titles) {
                 list($title, $content) = explode('[/page]', $content);
                 $content = trim($content);
                 if (strpos($content, '</p>') === 0) {
                     $content = '<p>' . $content;
                 }
                 if (stripos($content, '<p>') === 0) {
                     $content = $content . '</p>';
                 }
             }
         }
     }
     $this->db->table_name = $tablename;
     //上一页
     $previous_page = $this->db->get_one("`catid` = '{$catid}' AND `id`<'{$id}' AND `status`=99", '*', 'id DESC');
     //下一页
     $next_page = $this->db->get_one("`catid`= '{$catid}' AND `id`>'{$id}' AND `status`=99");
     if (empty($previous_page)) {
         $previous_page = array('title' => L('first_page'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('first_page') . '\');');
     }
     if (empty($next_page)) {
         $next_page = array('title' => L('last_page'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('last_page') . '\');');
     }
     include template('content', $template);
 }
Esempio n. 3
0
 public function show()
 {
     $WAP = $this->wap;
     $WAP_SETTING = string2array($WAP['setting']);
     $TYPE = $this->types;
     $GLOBALS['siteid'] = $siteid = max($this->siteid, 1);
     $typeid = $type_tmp = intval($_GET['typeid']);
     $catid = $_GET['catid'];
     $id = intval($_GET['id']);
     if (!$catid || !$id) {
         exit(L('parameter_error'));
     }
     $siteids = getcache('category_content', 'commons');
     $siteid = $siteids[$catid];
     $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
     $page = intval($_GET['page']);
     $page = max($page, 1);
     if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) {
         exit(L('information_does_not_exist', '', 'content'));
     }
     $this->category = $CAT = $CATEGORYS[$catid];
     $this->category_setting = $CAT['setting'] = string2array($this->category['setting']);
     $siteid = $GLOBALS['siteid'] = $CAT['siteid'];
     $MODEL = getcache('model', 'commons');
     $modelid = $CAT['modelid'];
     $tablename = $this->db->table_name = $this->db->db_tablepre . $MODEL[$modelid]['tablename'];
     $r = $this->db->get_one(array('id' => $id));
     if (!$r || $r['status'] != 99) {
         showmessage(L('info_does_not_exists'), 'blank');
     }
     $this->db->table_name = $tablename . '_data';
     $r2 = $this->db->get_one(array('id' => $id));
     $rs = $r2 ? array_merge($r, $r2) : $r;
     //再次重新赋值,以数据库为准
     $catid = $CATEGORYS[$r['catid']]['catid'];
     $modelid = $CATEGORYS[$catid]['modelid'];
     require_once CACHE_MODEL_PATH . 'content_output.class.php';
     $content_output = new content_output($modelid, $catid, $CATEGORYS);
     $data = $content_output->get($rs);
     extract($data);
     $typeid = $type_tmp;
     if (strpos($content, '[/page]') !== false) {
         $content = preg_replace("|\\[page\\](.*)\\[/page\\]|U", '', $content);
     } elseif (strpos($content, '[page]') !== false) {
         $content = str_replace('[page]', '', $content);
     }
     //根据设置字节数对文章加入分页标记
     if ($maxcharperpage < 10) {
         $maxcharperpage = $WAP_SETTING['c_num'];
     }
     $contentpage = pc_base::load_app_class('contentpage', 'content');
     $content = $contentpage->get_data($content, $maxcharperpage);
     $isshow = 1;
     if ($pictureurls) {
         $pictureurl = pic_pages($pictureurls);
         $isshow = 0;
         //进行图片分页处理
         $PIC_POS = strpos($pictureurl, '[page]');
         if ($PIC_POS !== false) {
             $this->url = pc_base::load_app_class('wap_url', 'wap');
             $pictureurls = array_filter(explode('[page]', $pictureurl));
             $pagenumber = count($pictureurls);
             if (strpos($pictureurl, '[/page]') !== false && $CONTENT_POS < 7) {
                 $pagenumber--;
             }
             for ($i = 1; $i <= $pagenumber; $i++) {
                 $pageurls[$i] = $this->url->show($id, $i, $catid, $typeid);
             }
             $END_POS = strpos($pictureurl, '[/page]');
             if ($END_POS !== false) {
                 if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $pictureurl, $m, PREG_PATTERN_ORDER)) {
                     foreach ($m[1] as $k => $v) {
                         $p = $k + 1;
                         $titles[$p]['title'] = strip_tags($v);
                         $titles[$p]['url'] = $pageurls[$p][0];
                     }
                 }
             }
             //当不存在 [/page]时,则使用下面分页
             $pages = content_pages($pagenumber, $page, $pageurls, 0);
             //判断[page]出现的位置是否在第一位
             if ($CONTENT_POS < 7) {
                 $pictureurl = $pictureurls[$page];
             } else {
                 if ($page == 1 && !empty($titles)) {
                     $pictureurl = $title . '[/page]' . $pictureurls[$page - 1];
                 } else {
                     $pictureurl = $pictureurls[$page - 1];
                 }
             }
         }
     }
     //进行自动分页处理
     $CONTENT_POS = strpos($content, '[page]');
     if ($CONTENT_POS !== false) {
         $this->url = pc_base::load_app_class('wap_url', 'wap');
         $contents = array_filter(explode('[page]', $content));
         $pagenumber = count($contents);
         if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) {
             $pagenumber--;
         }
         for ($i = 1; $i <= $pagenumber; $i++) {
             $pageurls[$i] = $this->url->show($id, $i, $catid, $typeid);
         }
         $END_POS = strpos($content, '[/page]');
         if ($END_POS !== false) {
             if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) {
                 foreach ($m[1] as $k => $v) {
                     $p = $k + 1;
                     $titles[$p]['title'] = strip_tags($v);
                     $titles[$p]['url'] = $pageurls[$p][0];
                 }
             }
         }
         //当不存在 [/page]时,则使用下面分页
         $pages = content_pages($pagenumber, $page, $pageurls);
         //判断[page]出现的位置是否在第一位
         if ($CONTENT_POS < 7) {
             $content = $contents[$page];
         } else {
             if ($page == 1 && !empty($titles)) {
                 $content = $title . '[/page]' . $contents[$page - 1];
             } else {
                 $content = $contents[$page - 1];
             }
         }
         if ($_GET['remains'] == 'true') {
             $content = $pages = '';
             for ($i = $page; $i <= $pagenumber; $i++) {
                 $content .= $contents[$i - 1];
             }
         }
     }
     $content = content_strip(wml_strip($content));
     $template = $WAP_SETTING['show_template'] ? $WAP_SETTING['show_template'] : 'show';
     include template('wap', $template);
 }
Esempio n. 4
0
 /**
  * 生成内容页
  * @param  $file 文件地址
  * @param  $data 数据
  * @param  $array_merge 是否合并
  * @param  $action 方法
  * @param  $upgrade 是否是升级数据
  */
 public function show($file, $data = '', $array_merge = 1, $action = 'add', $upgrade = 0)
 {
     if ($upgrade) {
         $file = '/' . ltrim($file, WEB_PATH);
     }
     $allow_visitor = 1;
     $id = $data['id'];
     if ($array_merge) {
         $data = new_stripslashes($data);
         $data = array_merge($data['system'], $data['model']);
     }
     //通过rs获取原始值
     $rs = $data;
     if (isset($data['paginationtype'])) {
         $paginationtype = $data['paginationtype'];
         $maxcharperpage = $data['maxcharperpage'];
     } else {
         $paginationtype = 0;
     }
     $catid = $data['catid'];
     $CATEGORYS = $this->categorys;
     $CAT = $CATEGORYS[$catid];
     $CAT['setting'] = string2array($CAT['setting']);
     define('STYLE', $CAT['setting']['template_list']);
     //最顶级栏目ID
     $arrparentid = explode(',', $CAT['arrparentid']);
     $top_parentid = $arrparentid[1] ? $arrparentid[1] : $catid;
     //$file = '/'.$file;
     //添加到发布点队列
     //当站点为非系统站点
     if ($this->siteid != 1) {
         $site_dir = $this->sitelist[$this->siteid]['dirname'];
         $file = $this->html_root . '/' . $site_dir . $file;
     }
     $this->queue->add_queue($action, $file, $this->siteid);
     $modelid = $CAT['modelid'];
     require_once CACHE_MODEL_PATH . 'content_output.class.php';
     $content_output = new content_output($modelid, $catid, $CATEGORYS);
     $output_data = $content_output->get($data);
     extract($output_data);
     if (module_exists('comment')) {
         $allow_comment = isset($allow_comment) ? $allow_comment : 1;
     } else {
         $allow_comment = 0;
     }
     $this->db = pc_base::load_model('content_model');
     $this->db->set_model($modelid);
     //上一页
     $previous_page = $this->db->get_one("`catid` = '{$catid}' AND `id`<'{$id}' AND `status`=99", '*', 'id DESC');
     //下一页
     $next_page = $this->db->get_one("`catid`= '{$catid}' AND `id`>'{$id}' AND `status`=99");
     if (empty($previous_page)) {
         $previous_page = array('title' => L('first_page', '', 'content'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('first_page', '', 'content') . '\');');
     }
     if (empty($next_page)) {
         $next_page = array('title' => L('last_page', '', 'content'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('last_page', '', 'content') . '\');');
     }
     $title = strip_tags($title);
     //SEO
     $seo_keywords = '';
     if (!empty($keywords)) {
         $seo_keywords = implode(',', $keywords);
     }
     $siteid = $this->siteid;
     $SEO = seo($siteid, $catid, $title, $description, $seo_keywords);
     $ishtml = 1;
     $template = $template ? $template : $CAT['setting']['show_template'];
     //分页处理
     $pages = $titles = '';
     if ($paginationtype == 1) {
         //自动分页
         if ($maxcharperpage < 10) {
             $maxcharperpage = 500;
         }
         $contentpage = pc_base::load_app_class('contentpage');
         $content = $contentpage->get_data($content, $maxcharperpage);
     }
     if ($paginationtype != 0) {
         //手动分页
         $CONTENT_POS = strpos($content, '[page]');
         if ($CONTENT_POS !== false) {
             $this->url = pc_base::load_app_class('url', 'content');
             $contents = array_filter(explode('[page]', $content));
             $pagenumber = count($contents);
             if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) {
                 $pagenumber--;
             }
             for ($i = 1; $i <= $pagenumber; $i++) {
                 $upgrade = $upgrade ? '/' . ltrim($file, WEB_PATH) : '';
                 $pageurls[$i] = $this->url->show($id, $i, $catid, $data['inputtime'], '', '', 'edit', $upgrade);
             }
             $END_POS = strpos($content, '[/page]');
             if ($END_POS !== false) {
                 if ($CONTENT_POS > 7) {
                     $content = '[page]' . $title . '[/page]' . $content;
                 }
                 if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) {
                     foreach ($m[1] as $k => $v) {
                         $p = $k + 1;
                         $titles[$p]['title'] = strip_tags($v);
                         $titles[$p]['url'] = $pageurls[$p][0];
                     }
                 }
             }
             //生成分页
             foreach ($pageurls as $page => $urls) {
                 $pages = content_pages($pagenumber, $page, $pageurls);
                 //判断[page]出现的位置是否在第一位
                 if ($CONTENT_POS < 7) {
                     $content = $contents[$page];
                 } else {
                     if ($page == 1 && !empty($titles)) {
                         $content = $title . '[/page]' . $contents[$page - 1];
                     } else {
                         $content = $contents[$page - 1];
                     }
                 }
                 if ($titles) {
                     list($title, $content) = explode('[/page]', $content);
                     $content = trim($content);
                     if (strpos($content, '</p>') === 0) {
                         $content = '<p>' . $content;
                     }
                     if (stripos($content, '<p>') === 0) {
                         $content = $content . '</p>';
                     }
                 }
                 $pagefile = $urls[1];
                 if ($this->siteid != 1) {
                     $pagefile = $this->html_root . '/' . $site_dir . $pagefile;
                 }
                 $this->queue->add_queue($action, $pagefile, $this->siteid);
                 $pagefile = PHPCMS_PATH . $pagefile;
                 ob_start();
                 include template('content', $template);
                 $this->createhtml($pagefile);
             }
             return true;
         }
     }
     //分页处理结束
     $file = PHPCMS_PATH . $file;
     ob_start();
     include template('content', $template);
     return $this->createhtml($file);
 }
Esempio n. 5
0
 public function public_preview()
 {
     $catid = intval($_GET['catid']);
     $id = intval($_GET['id']);
     if (!$catid || !$id) {
         showmessage(L('missing_part_parameters'), 'blank');
     }
     $page = intval($_GET['page']);
     $page = max($page, 1);
     $CATEGORYS = getcache('category_content_' . $this->get_siteid(), 'commons');
     if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) {
         showmessage(L('missing_part_parameters'), 'blank');
     }
     define('HTML', true);
     $CAT = $CATEGORYS[$catid];
     $siteid = $CAT['siteid'];
     $MODEL = getcache('model', 'commons');
     $modelid = $CAT['modelid'];
     $this->db->table_name = $this->db->db_tablepre . $MODEL[$modelid]['tablename'];
     $r = $this->db->get_one(array('id' => $id));
     if (!$r) {
         showmessage(L('information_does_not_exist'));
     }
     $this->db->table_name = $this->db->table_name . '_data';
     $r2 = $this->db->get_one(array('id' => $id));
     $rs = $r2 ? array_merge($r, $r2) : $r;
     //再次重新赋值,以数据库为准
     $catid = $CATEGORYS[$r['catid']]['catid'];
     $modelid = $CATEGORYS[$catid]['modelid'];
     require_once CACHE_MODEL_PATH . 'content_output.class.php';
     $content_output = new content_output($modelid, $catid, $CATEGORYS);
     $data = $content_output->get($rs);
     extract($data);
     $CAT['setting'] = string2array($CAT['setting']);
     $template = $template ? $template : $CAT['setting']['show_template'];
     $allow_visitor = 1;
     //SEO
     $SEO = seo($siteid, $catid, $title, $description);
     define('STYLE', $CAT['setting']['template_list']);
     if (isset($rs['paginationtype'])) {
         $paginationtype = $rs['paginationtype'];
         $maxcharperpage = $rs['maxcharperpage'];
     }
     $pages = $titles = '';
     if ($rs['paginationtype'] == 1) {
         //自动分页
         if ($maxcharperpage < 10) {
             $maxcharperpage = 500;
         }
         $contentpage = pc_base::load_app_class('contentpage');
         $content = $contentpage->get_data($content, $maxcharperpage);
     }
     if ($rs['paginationtype'] != 0) {
         //手动分页
         $CONTENT_POS = strpos($content, '[page]');
         if ($CONTENT_POS !== false) {
             $this->url = pc_base::load_app_class('url', 'content');
             $contents = array_filter(explode('[page]', $content));
             $pagenumber = count($contents);
             for ($i = 1; $i <= $pagenumber; $i++) {
                 $pageurls[$i] = $this->url->show($id, $i, $catid, $rs['inputtime']);
             }
             $END_POS = strpos($content, '[/page]');
             if ($END_POS !== false) {
                 if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) {
                     foreach ($m[1] as $k => $v) {
                         $p = $k + 1;
                         $titles[$p]['title'] = strip_tags($v);
                         $titles[$p]['url'] = $pageurls[$p][0];
                     }
                 }
             } else {
                 //当不存在 [/page]时,则使用下面分页
                 $pages = content_pages($pagenumber, $page, $pageurls);
             }
             //判断[page]出现的位置是否在第一位
             if ($CONTENT_POS < 7) {
                 $content = $contents[$page];
             } else {
                 $content = $contents[$page - 1];
             }
             if ($titles) {
                 list($title, $content) = explode('[/page]', $content);
                 $content = trim($content);
                 if (strpos($content, '</p>') === 0) {
                     $content = '<p>' . $content;
                 }
                 if (stripos($content, '<p>') === 0) {
                     $content = $content . '</p>';
                 }
             }
         }
     }
     include template('content', $template);
     $pc_hash = $_SESSION['pc_hash'];
     $steps = intval($_GET['steps']);
     echo "\n\t\t<link href=\"" . CSS_PATH . "dialog_simp.css\" rel=\"stylesheet\" type=\"text/css\" />\n\t\t<script language=\"javascript\" type=\"text/javascript\" src=\"" . JS_PATH . "dialog.js\"></script>\n\t\t<script type=\"text/javascript\">art.dialog({lock:false,title:'" . L('operations_manage') . "',mouse:true, id:'content_m', content:'<span id=cloading ><a href=\\'javascript:ajax_manage(1)\\'>" . L('passed_checked') . "</a> | <a href=\\'javascript:ajax_manage(2)\\'>" . L('reject') . "</a> | <a href=\\'javascript:ajax_manage(3)\\'>" . L('delete') . "</a></span>',left:'100%',top:'100%',width:200,height:50,drag:true, fixed:true});\n\t\tfunction ajax_manage(type) {\n\t\t\tif(type==1) {\n\t\t\t\t\$.get('?m=content&c=content&a=pass&ajax_preview=1&catid=" . $catid . "&steps=" . $steps . "&id=" . $id . "&pc_hash=" . $pc_hash . "');\n\t\t\t} else if(type==2) {\n\t\t\t\t\$.get('?m=content&c=content&a=pass&ajax_preview=1&reject=1&catid=" . $catid . "&steps=" . $steps . "&id=" . $id . "&pc_hash=" . $pc_hash . "');\n\t\t\t} else if(type==3) {\n\t\t\t\t\$.get('?m=content&c=content&a=delete&ajax_preview=1&dosubmit=1&catid=" . $catid . "&steps=" . $steps . "&id=" . $id . "&pc_hash=" . $pc_hash . "');\n\t\t\t}\n\t\t\t\$('#cloading').html('<font color=red>" . L('operation_success') . "<span id=\"secondid\">2</span>" . L('after_a_few_seconds_left') . "</font>');\n\t\t\tsetInterval('set_time()', 1000);\n\t\t\tsetInterval('window.close()', 2000);\n\t\t}\n\t\tfunction set_time() {\n\t\t\t\$('#secondid').html(1);\n\t\t}\n\t\t</script>";
 }
Esempio n. 6
0
 /**
  * 专题展示
  */
 public function show()
 {
     $id = intval($_GET['id']);
     if (!$id) {
         showmessage(L('content_not_exist'), 'blank');
     }
     $page = $_GET['page'];
     $c_db = pc_base::load_model('special_content_model');
     $c_data_db = pc_base::load_model('special_c_data_model');
     $rs = $c_db->get_one(array('id' => $id));
     if (!$rs) {
         showmessage(L('content_checking'), 'blank');
     }
     extract($rs);
     if ($isdata) {
         $arr_content = $c_data_db->get_one(array('id' => $id));
         if (is_array($arr_content)) {
             extract($arr_content);
         }
     }
     $siteid = get_siteid();
     if ($paginationtype) {
         //文章使用分页时
         if ($paginationtype == 1) {
             if (strpos($content, '[/page]') !== false) {
                 $content = preg_replace("|\\[page\\](.*)\\[/page\\]|U", '', $content);
             }
             if (strpos($content, '[page]') !== false) {
                 $content = str_replace('[page]', '', $content);
             }
             $contentpage = pc_base::load_app_class('contentpage', 'content');
             //调用自动分页类
             $content = $contentpage->get_data($content, $maxcharperpage);
             //自动分页,自动添加上[page]
         }
     } else {
         if (strpos($content, '[/page]') !== false) {
             $content = preg_replace("|\\[page\\](.*)\\[/page\\]|U", '', $content);
         }
         if (strpos($content, '[page]') !== false) {
             $content = str_replace('[page]', '', $content);
         }
     }
     $template = $show_template ? $show_template : 'show';
     //调用模板
     $CONTENT_POS = strpos($content, '[page]');
     if ($CONTENT_POS !== false) {
         $contents = array_filter(explode('[page]', $content));
         $pagenumber = count($contents);
         $END_POS = strpos($content, '[/page]');
         if ($END_POS !== false && $CONTENT_POS < 7) {
             $pagenumber--;
         }
         for ($i = 1; $i <= $pagenumber; $i++) {
             $pageurls[$i] = content_url($id, $i, $inputtime, 'php');
         }
         if ($END_POS !== false) {
             if ($CONTENT_POS > 7) {
                 $content = '[page]' . $title . '[/page]' . $content;
             }
             if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) {
                 foreach ($m[1] as $k => $v) {
                     $p = $k + 1;
                     $titles[$p]['title'] = strip_tags($v);
                     $titles[$p]['url'] = $pageurls[$p][1];
                 }
             }
         }
         //判断[page]出现的位置是否在第一位
         if ($CONTENT_POS < 7) {
             $content = $contents[$page];
         } else {
             if ($page == 1 && !empty($titles)) {
                 $content = $title . '[/page]' . $contents[$page - 1];
             } else {
                 $content = $contents[$page - 1];
             }
         }
         if ($titles) {
             list($title, $content) = explode('[/page]', $content);
             $content = trim($content);
             if (strpos($content, '</p>') === 0) {
                 $content = '<p>' . $content;
             }
             if (stripos($content, '<p>') === 0) {
                 $content = $content . '</p>';
             }
         }
         pc_base::load_app_func('util', 'content');
         $title_pages = content_pages($pagenumber, $page, $pageurls);
     }
     $_special = $this->db->get_one(array('id' => $specialid), '`title`, `url`, `show_template`, `isvideo`');
     if ($_special['isvideo']) {
         $video_store = pc_base::load_model('video_store_model');
         $v_r = $video_store->get_one(array('videoid' => $videoid), 'vid');
         $video['vid'] = $v_r['vid'];
     }
     pc_base::load_sys_class('format', '', 0);
     $inputtime = format::date($inputtime, 1);
     $SEO = seo($siteid, '', $title);
     $template = $show_template ? $show_template : ($_special['show_template'] ? $_special['show_template'] : 'show');
     $style = $style ? $style : 'default';
     include template('special', $template, $style);
 }
Esempio n. 7
0
 /**
  * 生成文章静态页
  * @param intval $contentid 文章ID
  * @return string	返回文章的url
  */
 public function _create_content($contentid = 0)
 {
     if (!$contentid) {
         return false;
     }
     pc_base::load_app_func('global', 'special');
     $r = $this->c_db->get_one(array('id' => $contentid));
     $_special = $s_info = $this->db->get_one(array('id' => $r['specialid']));
     if ($s_info['ishtml'] == 0) {
         return content_url($contentid, '1', 0, 'php');
     }
     unset($arr_content);
     $arr_content = $this->data_db->get_one(array('id' => $contentid));
     @extract($r);
     $title = strip_tags($title);
     if ($arr_content['paginationtype']) {
         //文章使用分页时
         if ($arr_content['paginationtype'] == 1) {
             if (strpos($arr_content['content'], '[/page]') !== false) {
                 $arr_content['content'] = preg_replace("|\\[page\\](.*)\\[/page\\]|U", '', $arr_content['content']);
             }
             if (strpos($arr_content['content'], '[page]') !== false) {
                 $arr_content['content'] = str_replace('[page]', '', $data['content']);
             }
             $contentpage = pc_base::load_app_class('contentpage', 'content');
             //调用自动分页类
             $arr_content['content'] = $contentpage->get_data($arr_content['content'], $arr_content['maxcharperpage']);
             //自动分页,自动添加上[page]
         }
     } else {
         if (strpos($arr_content['content'], '[/page]') !== false) {
             $arr_content['content'] = preg_replace("|\\[page\\](.*)\\[/page\\]|U", '', $arr_content['content']);
         }
         if (strpos($arr_content['content'], '[page]') !== false) {
             $arr_content['content'] = str_replace('[page]', '', $arr_content['content']);
         }
     }
     $template = $arr_content['show_template'] ? $arr_content['show_template'] : 'show';
     //调用模板
     //分站时,计算分站路径
     if ($s_info['siteid'] > 1) {
         $site_info = $this->site->get_by_id($s_info['siteid']);
     }
     $siteid = $s_info['siteid'];
     $CONTENT_POS = strpos($arr_content['content'], '[page]');
     if ($CONTENT_POS !== false) {
         $contents = array_filter(explode('[page]', $arr_content['content']));
         $pagenumber = count($contents);
         $END_POS = strpos($arr_content['content'], '[/page]');
         if ($END_POS !== false && $CONTENT_POS < 7) {
             $pagenumber--;
         }
         for ($i = 1; $i <= $pagenumber; $i++) {
             $pageurls[$i] = content_url($contentid, $i, $inputtime, 'html', $site_info);
         }
         if ($END_POS !== false) {
             if ($CONTENT_POS > 7) {
                 $arr_content['content'] = '[page]' . $title . '[/page]' . $arr_content['content'];
             }
             if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $arr_content['content'], $m, PREG_PATTERN_ORDER)) {
                 foreach ($m[1] as $k => $v) {
                     $p = $k + 1;
                     $titles[$p]['title'] = strip_tags($v);
                     $titles[$p]['url'] = $pageurls[$p][1];
                 }
             }
         }
         $currentpage = $filesize = 0;
         for ($i = 1; $i <= $pagenumber; $i++) {
             $currentpage++;
             //判断[page]出现的位置是否在第一位
             if ($CONTENT_POS < 7) {
                 $content = $contents[$currentpage];
             } else {
                 if ($currentpage == 1 && !empty($titles)) {
                     $content = $title . '[/page]' . $contents[$currentpage - 1];
                 } else {
                     $content = $contents[$currentpage - 1];
                 }
             }
             if ($titles) {
                 list($title, $content) = explode('[/page]', $content);
                 $content = trim($content);
                 if (strpos($content, '</p>') === 0) {
                     $content = '<p>' . $content;
                 }
                 if (stripos($content, '<p>') === 0) {
                     $content = $content . '</p>';
                 }
             }
             $file_url = content_url($contentid, $currentpage, $inputtime, 'html', $site_info);
             if ($currentpage == 1) {
                 $urls = $file_url;
             }
             pc_base::load_app_func('util', 'content');
             $title_pages = content_pages($pagenumber, $currentpage, $pageurls);
             $SEO = seo($s_info['siteid'], '', $title);
             $file = $file_url[1];
             //如果是分站的文件,将文件写入到信息队列中
             $this->queue->add_queue('add', $file, $siteid);
             $file = PHPCMS_PATH . $file;
             //生成文件的路径
             ob_start();
             include template('special', $template);
             $this->create_html($file);
         }
     } else {
         $page = 1;
         $title = strip_tags($title);
         $SEO = seo($s_info['siteid'], '', $title);
         $content = $arr_content['content'];
         $urls = content_url($contentid, $page, $inputtime, 'html', $site_info);
         $file = $urls[1];
         //如果是分站的文件,将文件写入到信息队列中
         $this->queue->add_queue('add', $file, $siteid);
         $file = PHPCMS_PATH . $file;
         ob_start();
         include template('special', $template);
         $this->create_html($file);
     }
     //$this->_index($specialid, 20, 5);  //更新专题首页
     //$this->_list($typeid, 20, 5); 		//更新所在的分类页
     return $urls;
 }
 public function create_list($catid, $p = 1, $count = 0)
 {
     $_GET['p'] = $p;
     if (APP_LANG) {
         $lang = C('URL_LANG') != LANG_NAME ? $lang = LANG_NAME . '/' : '';
         L(include LANG_PATH . LANG_NAME . '/common.php');
         $T = F('config_' . LANG_NAME, '', './Template/' . $this->sysConfig['DEFAULT_THEME'] . '/');
     } else {
         L(include LANG_PATH . $this->sysConfig['DEFAULT_LANG'] . '/common.php');
         $T = F('config_' . $this->sysConfig['DEFAULT_LANG'], '', './Template/' . $this->sysConfig['DEFAULT_THEME'] . '/');
     }
     $this->assign('T', $T);
     $search_module[0] = L('ALL');
     foreach ((array) $this->module as $r) {
         if ($r['issystem']) {
             $search_module[$r['id']] = L($r['name']);
         }
     }
     $this->assign('search_module', $search_module);
     $this->assign('form', new Form());
     $this->assign($this->Config);
     $this->assign('Categorys', $this->categorys);
     $this->assign('Module', $this->module);
     $this->assign('Type', $this->Type);
     $catid = intval($catid);
     if (empty($catid)) {
         $this->success(L('do_empty'));
     }
     $cat = $this->categorys[$catid];
     $this->assign('catid', $catid);
     if ($cat['type']) {
         return;
     }
     if (empty($cat['ishtml'])) {
         return;
     }
     unset($cat['id']);
     $this->assign($cat);
     $cat['id'] = $catid;
     $bcid = explode(",", $cat['arrparentid']);
     $bcid = $bcid[1];
     if ($bcid == '') {
         $bcid = intval($catid);
     }
     $this->assign('bcid', $bcid);
     $urlrule = geturl($cat, '', $this->Urlrule);
     $url = $p > 1 ? $urlrule[1] : $urlrule[0];
     $url = str_replace('{$p}', $p, $url);
     if (strstr($url, C('HTML_FILE_SUFFIX'))) {
         $filename = basename($url, C('HTML_FILE_SUFFIX'));
         $dir = dirname($url) . '/';
     } else {
         $filename = 'index';
         $dir = $url;
     }
     $dir = substr($dir, strlen(YP_PATH . '/'));
     if (empty($module)) {
         $module = $cat['module'];
     }
     $this->assign('module_name', $module);
     $this->assign('fields', F($cat['moduleid'] . '_Field'));
     $this->assign('form', new Form());
     if ($cat['moduleid'] == 1) {
         $cat['listtype'] = 2;
         $module = $cat['module'];
         $dao = M($module);
         $data = $dao->find($catid);
         $seo_title = $cat['title'] ? $cat['title'] : $data['title'];
         $this->assign('seo_title', $seo_title);
         $this->assign('seo_keywords', $data['keywords']);
         $this->assign('seo_description', $data['description']);
         $template = $cat['template_list'] ? $cat['template_list'] : 'index';
         //手动分页
         $CONTENT_POS = strpos($data['content'], '[page]');
         if ($CONTENT_POS !== false) {
             $contents = array_filter(explode('[page]', $data['content']));
             $pagenumber = count($contents);
             for ($i = 1; $i <= $pagenumber; $i++) {
                 $pageurls[$i] = str_replace('{$p}', $i, $urlrule);
             }
             //生成分页
             foreach ($pageurls as $p => $urls) {
                 $pages = content_pages($pagenumber, $p, $pageurls);
                 $this->assign('pages', $pages);
                 $data['content'] = $contents[$p - 1];
                 $this->assign($data);
                 if ($p > 1) {
                     $filename = basename($pageurls[$p]['1'], C('HTML_FILE_SUFFIX'));
                 }
                 $r = $this->buildHtml($filename, $dir, './Template/' . $this->sysConfig['DEFAULT_THEME'] . '/Page_' . $template . C('TMPL_TEMPLATE_SUFFIX'));
             }
         } else {
             $this->assign($data);
             $r = $this->buildHtml($filename, $dir, './Template/' . $this->sysConfig['DEFAULT_THEME'] . '/Page_' . $template . C('TMPL_TEMPLATE_SUFFIX'));
         }
     } else {
         $seo_title = $cat['title'] ? $cat['title'] : $cat['catname'];
         $this->assign('seo_title', $seo_title);
         $this->assign('seo_keywords', $cat['keywords']);
         $this->assign('seo_description', $cat['description']);
         if ($cat['listtype'] == 1) {
             $template_r = 'index';
         } else {
             $template_r = 'list';
         }
         $template = $cat['template_list'] ? $cat['template_list'] : $template_r;
         $r = $this->buildHtml($filename, $dir, './Template/' . $this->sysConfig['DEFAULT_THEME'] . '/' . $cat['module'] . '_' . $template . C('TMPL_TEMPLATE_SUFFIX'));
     }
     if ($r) {
         return true;
     }
 }
Esempio n. 9
0
 /**
  * 专题展示
  */
 public function show()
 {
     $id = intval($_GET['id']);
     if (!$id) {
         showmessage(L('content_not_exist'), 'blank');
     }
     $page = max(intval($_GET['page']), 1);
     $c_db = Loader::model('special_content_model');
     $c_data_db = Loader::model('special_c_data_model');
     $rs = $c_db->getby_id(intval($_GET['id']));
     if (!$rs) {
         showmessage(L('content_checking'), 'blank');
     }
     extract($rs);
     if ($isdata) {
         $arr_content = $c_data_db->getby_id(intval($_GET['id']));
         if (is_array($arr_content)) {
             extract($arr_content);
         }
     }
     if ($paginationtype) {
         // 文章使用分页时
         if ($paginationtype == 1) {
             if (strpos($content, '[/page]') !== false) {
                 $content = preg_replace("|\\[page\\](.*)\\[/page\\]|U", '', $content);
             }
             if (strpos($content, '[page]') !== false) {
                 $content = str_replace('[page]', '', $content);
             }
             $contentpage = Loader::lib('content:contentpage');
             // 调用自动分页类
             $content = $contentpage->get_data($content, $maxcharperpage);
             // 自动分页,自动添加上[page]
         }
     } else {
         if (strpos($content, '[/page]') !== false) {
             $content = preg_replace("|\\[page\\](.*)\\[/page\\]|U", '', $content);
         }
         if (strpos($content, '[page]') !== false) {
             $content = str_replace('[page]', '', $content);
         }
     }
     $template = $show_template ? $show_template : 'show';
     // 调用模板
     $CONTENT_POS = strpos($content, '[page]');
     if ($CONTENT_POS !== false) {
         $contents = array_filter(explode('[page]', $content));
         $pagenumber = count($contents);
         $END_POS = strpos($content, '[/page]');
         if ($END_POS !== false && $CONTENT_POS < 7) {
             $pagenumber--;
         }
         for ($i = 1; $i <= $pagenumber; $i++) {
             $pageurls[$i] = content_url($_GET['id'], $i, $inputtime, 'php');
         }
         if ($END_POS !== false) {
             if ($CONTENT_POS > 7) {
                 $content = '[page]' . $title . '[/page]' . $content;
             }
             if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) {
                 foreach ($m[1] as $k => $v) {
                     $p = $k + 1;
                     $titles[$p]['title'] = strip_tags($v);
                     $titles[$p]['url'] = $pageurls[$p][1];
                 }
             }
         }
         // 判断[page]出现的位置是否在第一位
         if ($CONTENT_POS < 7) {
             $content = $contents[$page];
         } else {
             if ($page == 1 && !empty($titles)) {
                 $content = $title . '[/page]' . $contents[$page - 1];
             } else {
                 $content = $contents[$page - 1];
             }
         }
         if ($titles) {
             list($title, $content) = explode('[/page]', $content);
             $content = trim($content);
             if (strpos($content, '</p>') === 0) {
                 $content = '<p>' . $content;
             }
             if (stripos($content, '<p>') === 0) {
                 $content = $content . '</p>';
             }
         }
         Loader::helper('content:util');
         $title_pages = content_pages($pagenumber, $page, $pageurls);
     }
     $_special = $this->db->where(array('id' => $specialid))->field('title, url')->find();
     $inputtime = Format::date($inputtime);
     $SEO = seo('', $title);
     $template = isset($show_template) && !empty($show_template) ? $show_template : 'show';
     $style = $style ? $style : 'default';
     include template('special', $template, $style);
 }
Esempio n. 10
0
 public function show($id = '', $module = '')
 {
     $this->Urlrule = F('Urlrule');
     $p = max(intval($_REQUEST[C('VAR_PAGE')]), 1);
     $id = $id ? $id : intval($_REQUEST['id']);
     $module = $module ? $module : MODULE_NAME;
     $this->assign('module_name', $module);
     $this->dao = M($module);
     $data = $this->dao->find($id);
     $catid = $data['catid'];
     $cat = $this->categorys[$data['catid']];
     if (empty($cat['ishtml'])) {
         $this->dao->where("id=" . $id)->setInc('hits');
     }
     //添加点击次数
     $bcid = explode(",", $cat['arrparentid']);
     $bcid = $bcid[1];
     if ($bcid == '') {
         $bcid = intval($catid);
     }
     if ($data['readgroup']) {
         if ($this->_groupid != 1 && !in_array($this->_groupid, explode(',', $data['readgroup']))) {
             $noread = 1;
         }
     } elseif ($cat['readgroup']) {
         if ($this->_groupid != 1 && !in_array($this->_groupid, explode(',', $cat['readgroup']))) {
             $noread = 1;
         }
     }
     if ($noread == 1) {
         $this->assign('jumpUrl', URL('User-Login/index'));
         $this->error(L('NO_READ'));
     }
     $chargepoint = $data['readpoint'] ? $data['readpoint'] : $cat['chargepoint'];
     if ($chargepoint && $data['userid'] != $this->_userid) {
         $user = M('User');
         $userdata = $user->find($this->_userid);
         if ($cat['paytype'] == 1 && $userdata['point'] >= $chargepoint) {
             $chargepointok = $user->where("id=" . $this->_userid)->setDec('point', $chargepoint);
         } elseif ($cat['paytype'] == 2 && $userdata['amount'] >= $chargepoint) {
             $chargepointok = $user->where("id=" . $this->_userid)->setDec('amount', $chargepoint);
         } else {
             $this->error(L('NO_READ'));
         }
     }
     $seo_title = $data['title'] . '|' . $cat['catname'];
     $this->assign('seo_title', $seo_title);
     $this->assign('seo_keywords', $data['keywords']);
     $this->assign('seo_description', $data['description']);
     $this->assign('fields', F($cat['moduleid'] . '_Field'));
     $fields = F($this->mod[$module] . '_Field');
     foreach ($data as $key => $c_d) {
         $setup = '';
         $fields[$key]['setup'] = $setup = string2array($fields[$key]['setup']);
         if ($setup['fieldtype'] == 'varchar' && $fields[$key]['type'] != 'text') {
             $data[$key . '_old_val'] = $data[$key];
             $data[$key] = fieldoption($fields[$key], $data[$key]);
         } elseif ($fields[$key]['type'] == 'images' || $fields[$key]['type'] == 'files') {
             if (!empty($data[$key])) {
                 $p_data = explode(':::', $data[$key]);
                 $data[$key] = array();
                 foreach ($p_data as $k => $res) {
                     $p_data_arr = explode('|', $res);
                     $data[$key][$k]['filepath'] = $p_data_arr[0];
                     $data[$key][$k]['filename'] = $p_data_arr[1];
                 }
                 unset($p_data);
                 unset($p_data_arr);
             }
         }
         unset($setup);
     }
     $this->assign('fields', $fields);
     //手动分页
     $CONTENT_POS = strpos($data['content'], '[page]');
     if ($CONTENT_POS !== false) {
         $urlrule = geturl($cat, $data, $this->Urlrule);
         $urlrule = str_replace('%7B%24page%7D', '{$page}', $urlrule);
         $contents = array_filter(explode('[page]', $data['content']));
         $pagenumber = count($contents);
         for ($i = 1; $i <= $pagenumber; $i++) {
             $pageurls[$i] = str_replace('{$page}', $i, $urlrule);
         }
         $pages = content_pages($pagenumber, $p, $pageurls);
         //判断[page]出现的位置是否在文章开始
         if ($CONTENT_POS < 7) {
             $data['content'] = $contents[$p];
         } else {
             $data['content'] = $contents[$p - 1];
         }
         $this->assign('pages', $pages);
     }
     if (!empty($data['template'])) {
         $template = $data['template'];
     } elseif (!empty($cat['template_show'])) {
         $template = $cat['template_show'];
     } else {
         $template = 'show';
     }
     $this->assign('catid', $catid);
     $this->assign($cat);
     $this->assign('bcid', $bcid);
     $this->assign($data);
     $this->display($module . ':' . $template);
 }
 public function create_list($catid, $p = 1, $count = 0)
 {
     C('DEFAULT_THEME_NAME', $this->sysConfig['DEFAULT_THEME']);
     C('HTML_FILE_SUFFIX', $this->sysConfig['HTML_FILE_SUFFIX']);
     C('TMPL_FILE_NAME', str_replace('Admin/Default', 'Home/' . $this->sysConfig['DEFAULT_THEME'], C('TMPL_FILE_NAME')));
     if (APP_LANG) {
         C('TMPL_CACHFILE_SUFFIX', '_' . LANG_NAME . '.php');
         $lang = C('URL_LANG') != LANG_NAME ? $lang = LANG_NAME . '/' : '';
         L(include LANG_PATH . LANG_NAME . '/common.php');
         $T = F('config_' . LANG_NAME, '', './Yourphp/Tpl/Home/' . $this->sysConfig['DEFAULT_THEME'] . '/');
     } else {
         L(include LANG_PATH . $this->sysConfig['DEFAULT_LANG'] . '/common.php');
         $T = F('config_' . $this->sysConfig['DEFAULT_LANG'], '', './Yourphp/Tpl/Home/' . $this->sysConfig['DEFAULT_THEME'] . '/');
     }
     $this->assign('T', $T);
     foreach ((array) $this->module as $r) {
         if ($r['issearch']) {
             $search_module[$r['name']] = L($r['name']);
         }
     }
     $this->assign('search_module', $search_module);
     $this->assign('form', new Form());
     $this->assign($this->Config);
     $this->assign('Categorys', $this->categorys);
     $this->assign('Module', $this->module);
     $this->assign('Type', $this->Type);
     $catid = intval($catid);
     if (empty($catid)) {
         $this->success(L('do_empty'));
     }
     $cat = $this->categorys[$catid];
     $this->assign('catid', $catid);
     if ($cat['type']) {
         return;
     }
     if (empty($cat['ishtml'])) {
         return;
     }
     unset($cat['id']);
     $this->assign($cat);
     $cat['id'] = $catid;
     $bcid = explode(",", $cat['arrparentid']);
     $bcid = $bcid[1];
     if ($bcid == '') {
         $bcid = intval($catid);
     }
     $this->assign('bcid', $bcid);
     $urlrule = geturl($cat, '', $this->Urlrule);
     $url = $p > 1 ? $urlrule[1] : $urlrule[0];
     $url = str_replace('{$page}', $p, $url);
     if (strstr($url, C('HTML_FILE_SUFFIX'))) {
         $filename = basename($url, C('HTML_FILE_SUFFIX'));
         $dir = dirname($url) . '/';
     } else {
         $filename = 'index';
         $dir = $url;
     }
     $dir = substr($dir, strlen(__ROOT__ . '/'));
     if (empty($module)) {
         $module = $cat['module'];
     }
     $this->assign('module_name', $module);
     $this->assign('fields', F($cat['moduleid'] . '_Field'));
     $this->assign('form', new Form());
     if ($cat['moduleid'] == 1) {
         $cat['listtype'] = 2;
         $module = $cat['module'];
         $dao = M($module);
         $data = $dao->find($catid);
         $seo_title = $cat['title'] ? $cat['title'] : $data['title'];
         $this->assign('seo_title', $seo_title);
         $this->assign('seo_keywords', $data['keywords']);
         $this->assign('seo_description', $data['description']);
         $template = $cat['template_list'] ? $cat['template_list'] : 'index';
         //手动分页
         $CONTENT_POS = strpos($data['content'], '[page]');
         if ($CONTENT_POS !== false) {
             $contents = array_filter(explode('[page]', $data['content']));
             $pagenumber = count($contents);
             for ($i = 1; $i <= $pagenumber; $i++) {
                 $pageurls[$i] = str_replace('{$page}', $i, $urlrule);
             }
             //生成分页
             foreach ($pageurls as $p => $urls) {
                 $pages = content_pages($pagenumber, $p, $pageurls);
                 $this->assign('pages', $pages);
                 $data['content'] = $contents[$p - 1];
                 $this->assign($data);
                 if ($p > 1) {
                     $filename = basename($pageurls[$p]['1'], C('HTML_FILE_SUFFIX'));
                 }
                 //$this->buildHtml($filename,$dir,'Home/'.$template);
                 $r = $this->buildHtml($filename, $dir, './Yourphp/Tpl/Home/' . $this->sysConfig['DEFAULT_THEME'] . '/Page_' . $template . C('TMPL_TEMPLATE_SUFFIX'));
             }
         } else {
             $this->assign($data);
             //$r=$this->buildHtml($filename,$dir,'Home/'.$template);
             $r = $this->buildHtml($filename, $dir, './Yourphp/Tpl/Home/' . $this->sysConfig['DEFAULT_THEME'] . '/Page_' . $template . C('TMPL_TEMPLATE_SUFFIX'));
         }
     } else {
         $seo_title = $cat['title'] ? $cat['title'] : $cat['catname'];
         $this->assign('seo_title', $seo_title);
         $this->assign('seo_keywords', $cat['keywords']);
         $this->assign('seo_description', $cat['description']);
         if ($cat['listtype'] == 1) {
             $template_r = 'index';
         } else {
             $where = " status=1 ";
             if ($cat['child']) {
                 $where .= " and catid in(" . $cat['arrchildid'] . ")";
             } else {
                 $where .= " and catid=" . $catid;
             }
             $module = $cat['module'];
             $dao = M($module);
             if (empty($count)) {
                 $count = $dao->where($where)->count();
             }
             if ($count) {
                 import("@.ORG.Page");
                 $listRows = !empty($cat['pagesize']) ? $cat['pagesize'] : C('PAGE_LISTROWS');
                 $page = new Page($count, $listRows, $p);
                 $page->urlrule = $urlrule;
                 $pages = $page->show();
                 $field = $this->module[$this->mod[$module]]['listfields'];
                 $field = $field ? $field : 'id,catid,userid,url,username,title,title_style,keywords,description,thumb,createtime,hits';
                 $list = $dao->field($field)->where($where)->order('id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
                 $this->assign('pages', $pages);
                 $this->assign('list', $list);
             }
             $template_r = 'list';
         }
         $template = $cat['template_list'] ? $cat['template_list'] : $template_r;
         $r = $this->buildHtml($filename, $dir, './Yourphp/Tpl/Home/' . $this->sysConfig['DEFAULT_THEME'] . '/' . $cat['module'] . '_' . $template . C('TMPL_TEMPLATE_SUFFIX'));
     }
     if ($r) {
         return true;
     }
 }