diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php
index 73dc33b3..65db0a8a 100644
--- a/application/controllers/welcome.php
+++ b/application/controllers/welcome.php
@@ -195,13 +195,41 @@ class Welcome extends CI_Controller {
// ));
}
- public function count_redirect_nofllow() {
+ public function count_redirect_nofollow() {
$include_redirece_info =
$this->Information_model->search_all_text('.htm&t=78002', 2000);
echo 'count: '.count($include_redirece_info).'
';
+ $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) {
- echo '('.$info->ic_id.','.$info->is_id.')'.$info->ic_url.' | '.$info->ic_title.'
';
+ $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.')'.'
';
+ echo 'a.href: '.$a_href.'; rel: '.$a_rel.'
';
+ var_dump($match_result);
+ }
+ // if ($result_count == 2) {
+ // $result = '//www.chinahighlights.com'.$match_result[1];
+ // $anchor->setAttribute('href', $result);
+ // echo $result.'
';
+ // }
+ }
}
+ echo 'nofollow_count: '.$nofollow_count.'
';
}
public function count_http_of_href() {