index.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. pc_base::load_app_func('global', 'special');
  4. class index {
  5. private $db;
  6. function __construct() {
  7. $this->db = pc_base::load_model('special_model');
  8. }
  9. /**
  10. * 专题列表
  11. */
  12. public function special() {
  13. $siteid = $_GET['siteid'] ? intval($_GET['siteid']) : (get_siteid() ? get_siteid() : 1);
  14. $SEO = seo($siteid);
  15. include template('special', 'special_list');
  16. }
  17. /**
  18. * 专题首页
  19. */
  20. public function init() {
  21. $specialid = $_GET['id'] ? intval($_GET['id']) : ($_GET['specialid'] ? intval($_GET['specialid']) : 0);
  22. if (!$specialid) showmessage(L('illegal_action'));
  23. $info = $this->db->get_one(array('id'=>$specialid, 'disabled'=>0));
  24. if(!$info) showmessage(L('special_not_exist'), 'back');
  25. extract($info);
  26. $css = get_css(unserialize($css));
  27. if(!$ispage) {
  28. $type_db = pc_base::load_model('type_model');
  29. $types = $type_db->select(array('module'=>'special', 'parentid'=>$specialid), '*', '', '`listorder` ASC, `typeid` ASC', '', 'listorder');
  30. }
  31. if ($pics) {
  32. $pic_data = get_pic_content($pics);
  33. unset($pics);
  34. }
  35. if ($voteid) {
  36. $vote_info = explode('|', $voteid);
  37. $voteid = $vote_info[1];
  38. }
  39. $siteid = $_GET['siteid'] ? $_GET['siteid'] : get_siteid();
  40. $SEO = seo($siteid, '', $title, $description);
  41. $commentid = id_encode('special', $id, $siteid);
  42. $template = $info['index_template'] ? $info['index_template'] : 'index';
  43. define('STYLE',$info['style']);
  44. include template('special', $template);
  45. }
  46. /**
  47. * 专题分类
  48. */
  49. public function type() {
  50. $typeid = intval($_GET['typeid']);
  51. $specialid = intval($_GET['specialid']);
  52. if (!$specialid || !$typeid) showmessage(L('illegal_action'));
  53. $info = $this->db->get_one(array('id'=>$specialid, 'disabled'=>0));
  54. if(!$info) showmessage(L('special_not_exist'), 'back');
  55. $page = max(intval($_GET['page']), 1);
  56. extract($info);
  57. $css = get_css(unserialize($css));
  58. if(!$typeid) showmessage(L('illegal_action'));
  59. $type_db = pc_base::load_model('type_model');
  60. $info = $type_db->get_one(array('typeid'=>$typeid));
  61. $SEO = seo($siteid, '', $info['typename'], '');
  62. $template = $list_template ? $list_template : 'list';
  63. include template('special', $template);
  64. }
  65. /**
  66. * 专题展示
  67. */
  68. public function show() {
  69. $id = intval($_GET['id']);
  70. if(!$id) showmessage(L('content_not_exist'),'blank');
  71. $page = $_GET['page'];
  72. $c_db = pc_base::load_model('special_content_model');
  73. $c_data_db = pc_base::load_model('special_c_data_model');
  74. $rs = $c_db->get_one(array('id'=>$id));
  75. if(!$rs) showmessage(L('content_checking'),'blank');
  76. extract($rs);
  77. if ($isdata) {
  78. $arr_content = $c_data_db->get_one(array('id'=>$id));
  79. if (is_array($arr_content)) extract($arr_content);
  80. }
  81. $siteid = get_siteid();
  82. if ($paginationtype) { //文章使用分页时
  83. if($paginationtype==1) {
  84. if (strpos($content, '[/page]')!==false) {
  85. $content = preg_replace("|\[page\](.*)\[/page\]|U", '', $content);
  86. }
  87. if (strpos($content, '[page]')!==false) {
  88. $content = str_replace('[page]', '', $content);
  89. }
  90. $contentpage = pc_base::load_app_class('contentpage', 'content'); //调用自动分页类
  91. $content = $contentpage->get_data($content, $maxcharperpage); //自动分页,自动添加上[page]
  92. }
  93. } else {
  94. if (strpos($content, '[/page]')!==false) {
  95. $content = preg_replace("|\[page\](.*)\[/page\]|U", '', $content);
  96. }
  97. if (strpos($content, '[page]')!==false) {
  98. $content = str_replace('[page]', '', $content);
  99. }
  100. }
  101. $template = $show_template ? $show_template : 'show'; //调用模板
  102. $CONTENT_POS = strpos($content, '[page]');
  103. if ($CONTENT_POS !== false) {
  104. $contents = array_filter(explode('[page]', $content));
  105. $pagenumber = count($contents);
  106. $END_POS = strpos($content, '[/page]');
  107. if ($END_POS!==false && ($CONTENT_POS<7)) {
  108. $pagenumber--;
  109. }
  110. for ($i=1; $i<=$pagenumber; $i++) {
  111. $pageurls[$i] = content_url($id, $i, $inputtime, 'php');
  112. }
  113. if ($END_POS !== false) {
  114. if($CONTENT_POS>7) {
  115. $content = '[page]'.$title.'[/page]'.$content;
  116. }
  117. if (preg_match_all("|\[page\](.*)\[/page\]|U", $content, $m, PREG_PATTERN_ORDER)) {
  118. foreach ($m[1] as $k=>$v) {
  119. $p = $k+1;
  120. $titles[$p]['title'] = strip_tags($v);
  121. $titles[$p]['url'] = $pageurls[$p][1];
  122. }
  123. }
  124. }
  125. //判断[page]出现的位置是否在第一位
  126. if($CONTENT_POS<7) {
  127. $content = $contents[$page];
  128. } else {
  129. if ($page==1 && !empty($titles)) {
  130. $content = $title.'[/page]'.$contents[$page-1];
  131. } else {
  132. $content = $contents[$page-1];
  133. }
  134. }
  135. if($titles) {
  136. list($title, $content) = explode('[/page]', $content);
  137. $content = trim($content);
  138. if(strpos($content,'</p>')===0) {
  139. $content = '<p>'.$content;
  140. }
  141. if(stripos($content,'<p>')===0) {
  142. $content = $content.'</p>';
  143. }
  144. }
  145. pc_base::load_app_func('util', 'content');
  146. $title_pages = content_pages($pagenumber,$page, $pageurls);
  147. }
  148. $_special = $this->db->get_one(array('id'=>$specialid), '`title`, `url`, `show_template`, `isvideo`');
  149. if ($_special['isvideo']) {
  150. $video_store = pc_base::load_model('video_store_model');
  151. $v_r = $video_store->get_one(array('videoid'=>$videoid), 'vid');
  152. $video['vid'] = $v_r['vid'];
  153. }
  154. pc_base::load_sys_class('format', '', 0);
  155. $inputtime = format::date($inputtime,1);
  156. $SEO = seo($siteid, '', $title);
  157. $template = $show_template ? $show_template : ($_special['show_template'] ? $_special['show_template'] : 'show');
  158. $style = $style ? $style : 'default';
  159. include template('special', $template, $style);
  160. }
  161. public function comment_show() {
  162. $commentid = isset($_GET['commentid']) ? $_GET['commentid'] : 0;
  163. $url = isset($_GET['url']) ? $_GET['url'] : HTTP_REFERER;
  164. $id = isset($_GET['id']) ? intval($_GET['id']) : 0;
  165. $userid = param::get_cookie('_userid');
  166. include template('special', 'comment_show');
  167. }
  168. public function comment() {
  169. if (!$_GET['id']) return '0';
  170. $siteid = $_GET['siteid'] ? $_GET['siteid'] : get_siteid();
  171. $id = intval($_GET['id']);
  172. $commentid = id_encode('special', $id, $siteid);
  173. $username = param::get_cookie('_username');
  174. $userid = param::get_cookie('_userid');
  175. if (!$userid) {
  176. showmessage(L('login_website'), APP_PATH.'index.php?m=member&c=index');
  177. }
  178. $date = date('m-d H:i', SYS_TIME);
  179. if ($_POST['dosubmit']) {
  180. $r = $this->db->get_one(array('id'=>intval($_POST['id'])), '`title`, `url`');
  181. $comment = pc_base::load_app_class('comment', 'comment');
  182. if ($comment->add($commentid, $siteid, array('userid'=>$userid, 'username'=>$username, 'content'=>addslashes($_POST['content'])), '', $r['title'], $r['url'])) {
  183. exit($username.'|'.SYS_TIME.'|'.$_POST['content']);
  184. } else {
  185. exit(0);
  186. }
  187. } else {
  188. pc_base::load_sys_class('form');
  189. include template('special', 'comment');
  190. }
  191. }
  192. }
  193. ?>