Exemplo n.º 1
0
 /**
  * 执行过滤规则
  */
 public function exeRule($content)
 {
     $filteredHtml = [];
     $filteredHref = [];
     //匹配链接
     foreach ($this->hrefRule[$this->ruleIndex] as $k => $v) {
         preg_match_all($v, $content, $filteredData);
         $filteredHref = $filteredHref + $filteredData[1];
     }
     //对获取的链接进行处理
     Component::CorrectHref()->checkHref($filteredHref);
     //匹配内容
     foreach ($this->htmlRule[$this->ruleIndex] as $k => $v) {
         preg_match_all($v, $content, $filteredData);
         $filteredHtml[$k] = $filteredData[1];
     }
     return ["filteredHref" => $filteredHref, "filteredHtml" => $filteredHtml];
 }
Exemplo n.º 2
0
 /**
  * 执行过滤规则
  */
 public function exeRule($content)
 {
     $htmldom = Component::HtmlDom();
     $htmldom->load($content);
     //匹配链接
     if (!empty($this->hrefRule[$this->ruleIndex])) {
         $filteredHref = call_user_func_array($this->hrefRule[$this->ruleIndex], [$htmldom]);
         if (!empty($filteredHref)) {
             //对获取的链接进行处理
             Component::CorrectHref()->checkHref($filteredHref);
         }
     } else {
         $filteredHref = "";
     }
     //匹配内容
     if (!empty($this->htmlRule[$this->ruleIndex])) {
         $filteredHtml = call_user_func_array($this->htmlRule[$this->ruleIndex], [$htmldom]);
     } else {
         $filteredHtml = "";
     }
     unset($htmldom);
     return ["filteredHref" => $filteredHref, "filteredHtml" => $filteredHtml];
 }