当前位置: 首页>>代码示例>>PHP>>正文


PHP bat_highlight函数代码示例

本文整理汇总了PHP中bat_highlight函数的典型用法代码示例。如果您正苦于以下问题:PHP bat_highlight函数的具体用法?PHP bat_highlight怎么用?PHP bat_highlight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bat_highlight函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showmessage

     $start_limit = ($page - 1) * $_G['tpp'];
     $index = C::t('common_searchindex')->fetch_by_searchid_srchmod($searchid, $srchmod);
     if (!$index) {
         showmessage('search_id_invalid');
     }
     $keyword = dhtmlspecialchars($index['keywords']);
     $keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
     $index['keywords'] = rawurlencode($index['keywords']);
     require_once libfile('function/discuzcode');
     $collectionlist = array();
     $maxcollection = $nowcollection = 0;
     $query = C::t('forum_collection')->fetch_all(explode(',', $index['ids']), $orderby, $ascdesc, $start_limit, $_G['tpp']);
     foreach ($query as $value) {
         $value['lastupdate'] = dgmdate($value['lastupdate']);
         $value['shortdesc'] = cutstr(strip_tags(discuzcode($value['desc'])), 50);
         $value['name'] = bat_highlight($value['name'], $keyword);
         $collectionlist[$value['ctid']] = $value;
     }
     $multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=collection&searchid={$searchid}&orderby={$orderby}&ascdesc={$ascdesc}&searchsubmit=yes");
     $url_forward = 'search.php?mod=collection&' . $_SERVER['QUERY_STRING'];
     include template('search/collection');
 } else {
     $searchstring = 'collection|title|' . addslashes($srchtxt);
     $searchindex = array('id' => 0, 'dateline' => '0');
     foreach (C::t('common_searchindex')->fetch_all_search($_G['setting']['search']['collection']['searchctrl'], $_G['clientip'], $_G['uid'], $_G['timestamp'], $searchstring, $srchmod) as $index) {
         if ($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
             $searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
             break;
         } elseif ($_G['adminid'] != '1' && $index['flood']) {
             showmessage('search_ctrl', 'search.php?mod=collection', array('searchctrl' => $_G['setting']['search']['collection']['searchctrl']));
         }
开发者ID:MCHacker,项目名称:discuz-docker,代码行数:31,代码来源:search_collection.php

示例2: max

     $page = max(1, intval($_G['gp_page']));
     $start_limit = ($page - 1) * $_G['tpp'];
     $index = DB::fetch_first("SELECT searchstring, keywords, num, ids FROM " . DB::table('common_searchindex') . " WHERE searchid='{$searchid}' AND srchmod='{$srchmod}'");
     if (!$index) {
         showmessage('search_id_invalid');
     }
     $keyword = htmlspecialchars($index['keywords']);
     $keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
     $index['keywords'] = rawurlencode($index['keywords']);
     $articlelist = array();
     $query = DB::query("SELECT at.*,ac.viewnum, ac.commentnum FROM " . DB::table('portal_article_title') . " at LEFT JOIN " . DB::table('portal_article_count') . " ac ON at.aid=ac.aid WHERE at.aid IN ({$index['ids']}) ORDER BY {$orderby} {$ascdesc} LIMIT {$start_limit}, {$_G['tpp']}");
     while ($article = DB::fetch($query)) {
         $article['dateline'] = dgmdate($article['dateline']);
         $article['pic'] = pic_get($article['pic'], 'portal', $article['thumb'], $article['remote']);
         $article['title'] = bat_highlight($article['title'], $keyword);
         $article['summary'] = bat_highlight($article['summary'], $keyword);
         $articlelist[] = $article;
     }
     $multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=portal&searchid={$searchid}&orderby={$orderby}&ascdesc={$ascdesc}&searchsubmit=yes");
     $url_forward = 'search.php?mod=portal&' . $_SERVER['QUERY_STRING'];
     include template('search/portal');
 } else {
     !($_G['group']['exempt'] & 2) && checklowerlimit('search');
     $searchstring = 'portal|title|' . addslashes($srchtxt);
     $searchindex = array('id' => 0, 'dateline' => '0');
     $query = DB::query("SELECT searchid, dateline,\r\n\t\t\t('" . $_G['setting']['search']['portal']['searchctrl'] . "'<>'0' AND " . (empty($_G['uid']) ? "useip='{$_G['clientip']}'" : "uid='{$_G['uid']}'") . " AND {$_G['timestamp']}-dateline<'" . $_G['setting']['search']['portal']['searchctrl'] . "') AS flood,\r\n\t\t\t(searchstring='{$searchstring}' AND expiration>'{$_G['timestamp']}') AS indexvalid\r\n\t\t\tFROM " . DB::table('common_searchindex') . "\r\n\t\t\tWHERE srchmod='{$srchmod}' AND ('" . $_G['setting']['search']['portal']['searchctrl'] . "'<>'0' AND " . (empty($_G['uid']) ? "useip='{$_G['clientip']}'" : "uid='{$_G['uid']}'") . " AND {$_G['timestamp']}-dateline<" . $_G['setting']['search']['portal']['searchctrl'] . ") OR (searchstring='{$searchstring}' AND expiration>'{$_G['timestamp']}')\r\n\t\t\tORDER BY flood");
     while ($index = DB::fetch($query)) {
         if ($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
             $searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
             break;
         } elseif ($_G['adminid'] != '1' && $index['flood']) {
开发者ID:v998,项目名称:discuzx-en,代码行数:31,代码来源:search_portal.php

示例3: array

             }
         }
     }
     $threadlist = $posttables = array();
     $query = DB::query("SELECT * FROM " . DB::table('forum_thread') . " WHERE tid IN ({$index['ids']}) AND displayorder>='0' ORDER BY {$orderby} {$ascdesc} LIMIT {$start_limit}, {$_G['tpp']}");
     while ($thread = DB::fetch($query)) {
         $thread['subject'] = bat_highlight($thread['subject'], $keyword);
         $thread['realtid'] = $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid'];
         $threadlist[$thread['tid']] = procthread($thread, 'dt');
         $posttables[$thread['posttableid']][] = $thread['tid'];
     }
     if ($threadlist) {
         foreach ($posttables as $tableid => $tids) {
             $query = DB::query("SELECT tid, message FROM " . DB::table(getposttable($tableid)) . " WHERE tid IN (" . dimplode($tids) . ") AND first='1'");
             while ($post = DB::fetch($query)) {
                 $threadlist[$post['tid']]['message'] = bat_highlight(messagecutstr($post['message'], 200), $keyword);
             }
         }
     }
     $multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=forum&searchid={$searchid}&orderby={$orderby}&ascdesc={$ascdesc}&searchsubmit=yes");
     $url_forward = 'search.php?mod=forum&' . $_SERVER['QUERY_STRING'];
     $fulltextchecked = $searchstring[1] == 'fulltext' ? 'checked="checked"' : '';
     include template('search/forum');
 } else {
     if ($_G['group']['allowsearch'] & 32 && $srchtype == 'fulltext') {
         periodscheck('searchbanperiods');
     } elseif ($srchtype != 'title') {
         $srchtype = 'title';
     }
     $forumsarray = array();
     if (!empty($srchfid)) {
开发者ID:pan289091315,项目名称:Discuz,代码行数:31,代码来源:search_forum.php

示例4: htmlspecialchars

     }
     $keyword = htmlspecialchars($index['keywords']);
     $keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
     $index['keywords'] = rawurlencode($index['keywords']);
     $bloglist = array();
     $pricount = 0;
     $query = DB::query("SELECT b.*,bf.pic, bf.message FROM " . DB::table('home_blog') . " b LEFT JOIN " . DB::table('home_blogfield') . " bf ON bf.blogid=b.blogid WHERE b.blogid IN({$index['ids']}) ORDER BY b.blogid DESC LIMIT {$start_limit}, {$_G['tpp']}");
     while ($value = DB::fetch($query)) {
         if (ckfriend($value['uid'], $value['friend'], $value['target_ids']) && ($value['status'] == 0 || $value['uid'] == $_G['uid'] || $_G['adminid'] == 1)) {
             if ($value['friend'] == 4) {
                 $value['message'] = $value['pic'] = '';
             } else {
                 $value['message'] = bat_highlight($value['message'], $keyword);
                 $value['message'] = getstr($value['message'], 255, 0, 0, 0, -1);
             }
             $value['subject'] = bat_highlight($value['subject'], $keyword);
             $value['dateline'] = dgmdate($value['dateline']);
             $value['pic'] = pic_cover_get($value['pic'], $value['picflag']);
             $bloglist[] = $value;
         } else {
             $pricount++;
         }
     }
     $multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=blog&searchid={$searchid}&orderby={$orderby}&ascdesc={$ascdesc}&searchsubmit=yes");
     $url_forward = 'search.php?mod=blog&' . $_SERVER['QUERY_STRING'];
     include template('search/blog');
 } else {
     $searchstring = 'blog|title|' . addslashes($srchtxt);
     $searchindex = array('id' => 0, 'dateline' => '0');
     $query = DB::query("SELECT searchid, dateline,\r\n\t\t\t('" . $_G['setting']['search']['blog']['searchctrl'] . "'<>'0' AND " . (empty($_G['uid']) ? "useip='{$_G['clientip']}'" : "uid='{$_G['uid']}'") . " AND {$_G['timestamp']}-dateline<'" . $_G['setting']['search']['blog']['searchctrl'] . "') AS flood,\r\n\t\t\t(searchstring='{$searchstring}' AND expiration>'{$_G['timestamp']}') AS indexvalid\r\n\t\t\tFROM " . DB::table('common_searchindex') . "\r\n\t\t\tWHERE srchmod='{$srchmod}' AND ('" . $_G['setting']['search']['blog']['searchctrl'] . "'<>'0' AND " . (empty($_G['uid']) ? "useip='{$_G['clientip']}'" : "uid='{$_G['uid']}'") . " AND {$_G['timestamp']}-dateline<" . $_G['setting']['search']['blog']['searchctrl'] . ") OR (searchstring='{$searchstring}' AND expiration>'{$_G['timestamp']}')\r\n\t\t\tORDER BY flood");
     while ($index = DB::fetch($query)) {
开发者ID:dalinhuang,项目名称:hlwbbsvincent,代码行数:31,代码来源:search_blog.php

示例5: while

                 while ($post = DB::fetch($query)) {
                     $threadlist[$post['tid']]['message'] = bat_highlight(messagecutstr($post['message'], 200), $keyword);
                 }
             }
         }
     }
     $groupnum = !empty($index['ids']['group']) ? count(explode(',', $index['ids']['group'])) - 1 : 0;
     if ($index['ids']['group'] && ($viewgroup || empty($searchstring[2]))) {
         if (empty($viewgroup)) {
             $index['ids']['group'] = implode(',', array_slice(explode(',', $index['ids']['group']), 0, 9));
         }
         $query = DB::query("SELECT f.*, ff.description, ff.membernum, ff.icon, ff.gviewperm, ff.jointype, ff.dateline FROM " . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff ON f.fid=ff.fid WHERE f.fid IN ({$index[ids][group]}) AND f.status='3' AND `type`='sub'" . ($viewgroup ? " LIMIT {$start_limit}, {$_G['tpp']}" : ''));
         while ($group = DB::fetch($query)) {
             $group['icon'] = get_groupimg($group['icon'], 'icon');
             $group['name'] = bat_highlight($group['name'], $keyword);
             $group['description'] = bat_highlight($group['description'], $keyword);
             $group['dateline'] = dgmdate($group['dateline'], 'u');
             $grouplist[] = $group;
         }
     }
     if (empty($viewgroup)) {
         $multipage = multi($index['num'], $_G['tpp'], $page, "search.php?mod=group&searchid={$searchid}&orderby={$orderby}&ascdesc={$ascdesc}&searchsubmit=yes" . ($viewgroup ? '&viewgroup=1' : ''));
     } else {
         $multipage = multi($groupnum, $_G['tpp'], $page, "search.php?mod=group&searchid={$searchid}&orderby={$orderby}&ascdesc={$ascdesc}&searchsubmit=yes" . ($viewgroup ? '&viewgroup=1' : ''));
     }
     $url_forward = 'search.php?mod=group&' . $_SERVER['QUERY_STRING'];
     include template('search/group');
 } else {
     $srchuname = isset($_G['gp_srchuname']) ? trim($_G['gp_srchuname']) : '';
     $searchstring = 'group|title|' . $srchfid . '|' . addslashes($srchtxt);
     $searchindex = array('id' => 0, 'dateline' => '0');
开发者ID:v998,项目名称:discuzx-en,代码行数:31,代码来源:search_group.php

示例6: strtotime

            if ($_G['adminid'] == 3 && !C::t('forum_moderator')->fetch_uid_by_fid_uid($modfid, $_G['uid'])) {
                $modfid = 0;
            }
        }
    }
    $todaytime = strtotime(dgmdate(TIMESTAMP, 'Ymd'));
    $threadlist = array();
    $tids = explode(',', $index['ids']);
    $threads = C::t('forum_thread')->fetch_all_by_tid($tids, $start_limit, $_G['tpp']);
    //tids是有序的,但是查出来的threads是无序的。
    foreach ($tids as $tid) {
        foreach ($threads as $thread) {
            if ($thread['tid'] != $tid) {
                continue;
            }
            $thread['subject'] = bat_highlight($thread['subject'], $keyword);
            $thread['realtid'] = $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid'];
            $thread['allreplies'] = $thread['replies'] + $thread['comments'];
            $threadlist[] = procthread($thread, 'dt');
            break;
        }
    }
    $multipage = multi($index['num'], $_G['tpp'], $page, "source/plugin/ngpt/search.php?" . "mod=seed&" . "searchid={$searchid}&" . "orderby={$orderby}&" . "ascdesc={$ascdesc}&" . "searchsubmit=yes&" . "kw=" . urlencode($keyword) . "&author={$author}&" . "oblue={$onlyblue}&" . "nodead={$nodead}");
    $url_forward = 'search.php?mod=forum&' . $_SERVER['QUERY_STRING'];
    $fulltextchecked = $searchstring[1] == 'fulltext' ? 'checked="checked"' : '';
    $_G['forum_threadlist'] = $threadlist;
    $_G['forum_threadcount'] = count($threadlist);
    include template('search/seed-main');
} else {
    $orderby = in_array($_GET['orderby'], array('dateline', 'replies', 'views')) ? $_GET['orderby'] : 'lastpost';
    $ascdesc = isset($_GET['ascdesc']) && $_GET['ascdesc'] == 'asc' ? 'asc' : 'desc';
开发者ID:KKRainbow,项目名称:ngpt_discuz,代码行数:31,代码来源:search.php

示例7: _searchData


//.........这里部分代码省略.........
         //搜索缓存表 查找字符串
         $srchuid = $srchuname = $srchfrom = $before = '';
         $searchstring = 'forum|' . $srchtype . '|' . base64_encode($srchtxt) . '|' . intval($srchuid) . '|' . $srchuname . '|' . addslashes($fids) . '|' . intval($srchfrom) . '|' . intval($before) . '|' . $srchfilter . '|' . $specials . '|' . $specialpluginstr . '|' . $se0;
         $searchindex = array('id' => 0, 'dateline' => '0');
         foreach (C::t('common_searchindex')->fetch_all_search($_G['setting']['search']['forum']['searchctrl'], $_G['clientip'], $_G['uid'], $_G['timestamp'], $searchstring, $srchmod) as $index) {
             if ($index['indexvalid'] && $index['dateline'] > $searchindex['dateline']) {
                 $searchindex = array('id' => $index['searchid'], 'dateline' => $index['dateline']);
                 break;
             } elseif ($_G['adminid'] != '1' && $index['flood']) {
                 //抱歉,您在 秒内只能进行一次搜索
                 return WebUtils::makeErrorInfo_oldVersion($res, 'search_ctrl', array('searchctrl' => $_G['setting']['search']['forum']['searchctrl']));
             }
         }
         if ($searchindex['id']) {
             $searchid = $searchindex['id'];
         } else {
             if ($_G['adminid'] != '1' && $_G['setting']['search']['forum']['maxspm']) {
                 if (C::t('common_searchindex')->count_by_dateline($_G['timestamp'], $srchmod) >= $_G['setting']['search']['forum']['maxspm']) {
                     //抱歉,站点设置每分钟系统最多响应搜索请求 {maxspm} 次,请稍候再试
                     return WebUtils::makeErrorInfo_oldVersion($res, 'search_toomany', array('maxspm' => $_G['setting']['search']['forum']['maxspm']));
                 }
             }
             $digestltd = $srchfilter == 'digest' ? "t.digest>'0' AND" : '';
             $topltd = $srchfilter == 'top' ? "AND t.displayorder>'0'" : "AND t.displayorder>='0'";
             $sqlsrch = $srchtype == 'fulltext' ? "FROM " . DB::table(getposttable($seltableid)) . " p, " . DB::table('forum_thread') . " t WHERE {$digestltd} t.fid IN ({$fids}) {$topltd} AND p.tid=t.tid AND p.invisible='0'" : "FROM " . DB::table('forum_thread') . " t WHERE {$digestltd} t.fid IN ({$fids}) {$topltd}";
             if ($srchtxt) {
                 $srcharr = $srchtype == 'fulltext' ? searchkey($keyword, "(p.message LIKE '%{text}%' OR p.subject LIKE '%{text}%')", true) : searchkey($keyword, "t.subject LIKE '%{text}%'", true);
                 $srchtxt = $srcharr[0];
                 $sqlsrch .= $srcharr[1];
             }
             $keywords = str_replace('%', '+', $srchtxt);
             $expiration = TIMESTAMP + $cachelife_text;
             $num = $ids = 0;
             $_G['setting']['search']['forum']['maxsearchresults'] = $_G['setting']['search']['forum']['maxsearchresults'] ? intval($_G['setting']['search']['forum']['maxsearchresults']) : 500;
             $query = DB::query("SELECT " . ($srchtype == 'fulltext' ? 'DISTINCT' : '') . " t.tid, t.closed, t.author, t.authorid {$sqlsrch} ORDER BY tid DESC LIMIT " . $_G['setting']['search']['forum']['maxsearchresults']);
             while ($thread = DB::fetch($query)) {
                 $ids .= ',' . $thread['tid'];
                 $num++;
             }
             DB::free_result($query);
             $idsArr = explode(',', $ids);
             $idCount = count($idsArr);
             if ($idCount == 1) {
                 return WebUtils::makeErrorInfo_oldVersion($res, 'search_no_results');
             }
             $searchid = C::t('common_searchindex')->insert(array('srchmod' => $srchmod, 'keywords' => $keywords, 'searchstring' => $searchstring, 'useip' => $_G['clientip'], 'uid' => $_G['uid'], 'dateline' => $_G['timestamp'], 'expiration' => $expiration, 'num' => $num, 'ids' => $ids), true);
             !($_G['group']['exempt'] & 2) && updatecreditbyaction('search');
         }
     }
     //这个分支要把数据取出来,并且返回正确的数据结构
     $start_limit = ($page - 1) * $pagesize;
     $index = C::t('common_searchindex')->fetch_by_searchid_srchmod($searchid, $srchmod);
     if (!$index) {
         //showmessage('search_id_invalid');//指定的搜索不存在或已过期
         return WebUtils::makeErrorInfo_oldVersion($res, 'search_id_invalid');
     }
     $keyword = dhtmlspecialchars($index['keywords']);
     $keyword = $keyword != '' ? str_replace('+', ' ', $keyword) : '';
     $index['keywords'] = rawurlencode($index['keywords']);
     $searchstring = explode('|', $index['searchstring']);
     $index['searchtype'] = $searchstring[0];
     $searchstring[2] = base64_decode($searchstring[2]);
     $srchuname = $searchstring[3];
     $modfid = 0;
     if ($keyword) {
         $modkeyword = str_replace(' ', ',', $keyword);
         $fids = explode(',', str_replace('\'', '', $searchstring[5]));
         if (count($fids) == 1 && in_array($_G['adminid'], array(1, 2, 3))) {
             $modfid = $fids[0];
             if ($_G['adminid'] == 3 && !C::t('forum_moderator')->fetch_uid_by_fid_uid($modfid, $_G['uid'])) {
                 $modfid = 0;
             }
         }
     }
     $threadlist = $posttables = array();
     foreach (C::t('forum_thread')->fetch_all_by_tid_fid_displayorder(explode(',', $index['ids']), null, 0, $orderby, $start_limit, $pagesize, '>=', $ascdesc, 0) as $thread) {
         $thread['subject'] = bat_highlight($thread['subject'], $keyword);
         $thread['realtid'] = $thread['isgroup'] == 1 ? $thread['closed'] : $thread['tid'];
         $tempLastPost = $thread['lastpost'];
         $tempDateLine = $thread['dateline'];
         $threadlist[$thread['tid']] = procthread($thread, 'dt');
         $threadlist[$thread['tid']]['lastpost'] = $tempLastPost;
         $threadlist[$thread['tid']]['dateline'] = $tempDateLine;
         $posttables[$thread['posttableid']][] = $thread['tid'];
     }
     if ($threadlist) {
         foreach ($posttables as $tableid => $tids) {
             foreach (C::t('forum_post')->fetch_all_by_tid($tableid, $tids, true, '', 0, 0, 1) as $post) {
                 $threadlist[$post['tid']]['message'] = bat_highlight(messagecutstr($post['message'], 200), $keyword);
             }
         }
     }
     $pageInfo = $row = $rows = array();
     $rows = $this->_fieldInfo($threadlist);
     $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pagesize, $index['num']);
     $res = array_merge($res, $pageInfo);
     $res['searchid'] = (int) $searchid;
     $res['list'] = $rows;
     return $res;
 }
开发者ID:frogoscar,项目名称:mobcent-discuz,代码行数:101,代码来源:SearchAction.php


注:本文中的bat_highlight函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。