增加跟踪链接nofollow规则

hotfix/远程访问多媒体中心
LiaoYijun 7 years ago
parent 62be7ded0c
commit d61ca06a4a

@ -195,13 +195,41 @@ class Welcome extends CI_Controller {
// )); // ));
} }
public function count_redirect_nofllow() { public function count_redirect_nofollow() {
$include_redirece_info = $include_redirece_info =
$this->Information_model->search_all_text('.htm&t=78002', 2000); $this->Information_model->search_all_text('.htm&t=78002', 2000);
echo 'count: '.count($include_redirece_info).'<br/>'; echo 'count: '.count($include_redirece_info).'<br/>';
$nofollow_count = 0;
$htm_doc = new DOMDocument();
$htm_doc->encoding='UTF-8';
libxml_use_internal_errors(true);
$htm_doc->strictErrorChecking = false;
foreach ($include_redirece_info as $info) { foreach ($include_redirece_info as $info) {
echo '('.$info->ic_id.','.$info->is_id.')'.$info->ic_url.' | '.$info->ic_title.'<br/>'; $htm_doc->loadHTML(
mb_convert_encoding($info->ic_content, 'HTML-ENTITIES', 'UTF-8'));
$htm_doc->normalizeDocument();
$anchor_list = $htm_doc->getElementsByTagName('a');
foreach ($anchor_list as $anchor) {
$a_href = $anchor->getAttribute('href');
$a_rel = $anchor->getAttribute('rel');
$match_result = array();
preg_match('/.*.htm&t=78002$/', $a_href, $match_result);
$result_count = count($match_result);
if ($result_count > 0 && $a_rel != 'nofollow') {
$nofollow_count = $nofollow_count + 1;
echo $info->ic_url.' | '.'('.$info->ic_id.','.$info->is_id.')'.'<br/>';
echo 'a.href: '.$a_href.'; rel: '.$a_rel.'<br>';
var_dump($match_result);
}
// if ($result_count == 2) {
// $result = '//www.chinahighlights.com'.$match_result[1];
// $anchor->setAttribute('href', $result);
// echo $result.'<br>';
// }
}
} }
echo 'nofollow_count: '.$nofollow_count.'<br/>';
} }
public function count_http_of_href() { public function count_http_of_href() {

Loading…
Cancel
Save