inc_search.php 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. CURSCRIPT != 'wap' && exit('FORBIDDEN');
  3. $keywords = isset($_GET['keywords']) ? addslashes($_GET['keywords']) : '';
  4. $keywords = checkhtml($keywords);
  5. if (preg_match('/from|script|iframe|alert/i', $keywords)) {
  6. $keywords = '';
  7. }
  8. if ($keywords != '' && strlen($keywords) < 2) {
  9. redirectmsg('您输入的关键字太短了!关键字不能少于2个字节!', 'index.php?mod=search');
  10. }
  11. $timestamp = time();
  12. define(CURSCRIPT, 'search');
  13. $perpage = $mayimobile['mobiletopicperpage'] ? $mayimobile['mobiletopicperpage'] : 10;
  14. $page = isset($_GET['page']) ? intval($_GET['page']) : '';
  15. $page = empty($page) ? 1 : $page;
  16. $where = ' WHERE a.info_level > 0 ';
  17. $cat_children = $catid ? get_children($catid) : '';
  18. $where .= $catid ? ' AND ' . $cat_children : '';
  19. $where .= $keywords ? ' AND (title LIKE \'%' . $keywords . '%\' OR content LIKE \'%' . $keywords . '%\') ' : '';
  20. $param = setparams(array('mod', 'keywords'));
  21. $rows_num = $db->getOne('SELECT COUNT(a.id) FROM `' . $db_mymps . 'information` AS a ' . $where);
  22. $totalpage = ceil($rows_num / $perpage);
  23. $num = intval($page - 1) * $perpage;
  24. $info_list = $db->getAll('SELECT a.* FROM `' . $db_mymps . 'information` AS a ' . $where . ' ORDER BY a.id DESC LIMIT ' . $num . ',' . $perpage);
  25. $pageview = pager();
  26. include mymps_tpl('search');
  27. ?>