Example #1
0
function _highlight($string, $words, $result, $pre)
{
    global $cfg_replace_num;
    $string = str_replace('\\"', '"', $string);
    if ($cfg_replace_num > 0) {
        foreach ($words as $key => $word) {
            if ($GLOBALS['replaced'][$word] == 1) {
                continue;
            }
            $string = preg_replace("#" . preg_quote($word) . "#", $result[$key], $string, $cfg_replace_num);
            if (strpos($string, $word) !== FALSE) {
                $GLOBALS['replaced'][$word] = 1;
            }
        }
    } else {
        $string = str_replace($words, $result, $string);
    }
    $string = pr_str_replace($string);
    return $pre . $string;
}
Example #2
0
 /**
  *  下载其中一个网址,并保存
  *
  * @access    public
  * @param     int  $aid  文档ID
  * @param     string  $dourl  操作地址
  * @param     string  $litpic  缩略图
  * @param     bool  $issave  是否保存
  * @return    string
  */
 function DownUrl($aid, $dourl, $litpic = '', $issave = TRUE)
 {
     $this->tmpLinks = array();
     $this->tmpUnitValue = '';
     $this->breImage = '';
     $this->tmpHtml = $this->DownOnePage($dourl);
     //检测是否有分页字段,并预先处理
     if (!empty($this->artNotes['sppage'])) {
         $noteid = '';
         foreach ($this->artNotes as $k => $sarr) {
             if (isset($sarr['isunit']) && $sarr['isunit'] == 1) {
                 $noteid = $k;
                 break;
             }
         }
         $this->GetSpPage($dourl, $noteid, $this->tmpHtml);
         if (preg_match("/#p#/i", $this->tmpUnitValue)) {
             if ($this->artNotes["sptype"] != 'diyrule') {
                 $this->tmpUnitValue = '副标题#e#' . $this->tmpUnitValue;
             }
         }
     }
     //处理字段
     $body = $this->GetPageFields($dourl, $issave, $litpic);
     $body = pr_str_replace($body);
     //add by pagerank
     //保存资料到数据库
     if ($issave) {
         $query = " UPDATE `#@__co_htmls` SET dtime='" . time() . "',result='" . filter_utf8_char(addslashes($body)) . "',isdown='1' WHERE aid='{$aid}' ";
         if (!$this->dsql->ExecuteNoneQuery($query)) {
             echo $this->dsql->GetError();
         }
         return $body;
     }
     return filter_utf8_char(addslashes($body));
 }