From 49810b3b45585a8d58233306589eabdebd0d3602 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Thu, 2 Aug 2018 10:31:34 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E8=B7=9F=E8=B8=AA=E9=93=BE=E6=8E=A5=E7=9A=84=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/welcome.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php index 72d5a942..22c8ef69 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.php @@ -195,10 +195,18 @@ class Welcome extends CI_Controller { // )); } + public function count_redirect_nofllow() { + $data['all_information'] = + $this->Information_model->search_all_text('.htm&t=78002', 2000); + echo 'count: '.count($data['all_information']).'
'; + var_dump($data['all_information']); + } + public function count_http_of_href() { $data['all_information'] = $this->Information_model->search_all_text('http://www.chinahighlights.com/', 2000); echo 'count: '.count($data['all_information']).'
'; + var_dump($data['all_information']); } public function transform_href_to_https() { From 62be7ded0c07b613eb5fe64457a810e7aff9aa4b Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Thu, 2 Aug 2018 10:38:08 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ID=E5=92=8CURL=E3=80=81Ti?= =?UTF-8?q?tle=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/welcome.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php index 22c8ef69..73dc33b3 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.php @@ -196,10 +196,12 @@ class Welcome extends CI_Controller { } public function count_redirect_nofllow() { - $data['all_information'] = + $include_redirece_info = $this->Information_model->search_all_text('.htm&t=78002', 2000); - echo 'count: '.count($data['all_information']).'
'; - var_dump($data['all_information']); + echo 'count: '.count($include_redirece_info).'
'; + foreach ($include_redirece_info as $info) { + echo '('.$info->ic_id.','.$info->is_id.')'.$info->ic_url.' | '.$info->ic_title.'
'; + } } public function count_http_of_href() { From d61ca06a4a42c2cfe2c47fbe1a8d1647c354d056 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Thu, 2 Aug 2018 10:57:28 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B7=9F=E8=B8=AA?= =?UTF-8?q?=E9=93=BE=E6=8E=A5nofollow=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/welcome.php | 32 +++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) 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() { From c63b65ba519f52616805c97b874ee89d6980d228 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Thu, 2 Aug 2018 11:47:10 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E4=B8=BA=E5=8A=A0nofollow=E7=9A=84=E8=B7=9F=E8=B8=AA=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/welcome.php | 66 +++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php index 65db0a8a..e01cf36e 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.php @@ -197,9 +197,9 @@ class Welcome extends CI_Controller { 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; + $this->Information_model->search_all_text('&t=78002', 2000); + echo 'redirect count: '.count($include_redirece_info).'
'; + $redirect_nofollow_list = []; $htm_doc = new DOMDocument(); $htm_doc->encoding='UTF-8'; libxml_use_internal_errors(true); @@ -214,22 +214,64 @@ class Welcome extends CI_Controller { $a_rel = $anchor->getAttribute('rel'); $match_result = array(); - preg_match('/.*.htm&t=78002$/', $a_href, $match_result); + preg_match('/.*&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); + $redirect_nofollow_list[] = $info; } - // if ($result_count == 2) { - // $result = '//www.chinahighlights.com'.$match_result[1]; - // $anchor->setAttribute('href', $result); - // echo $result.'
'; - // } } } - echo 'nofollow_count: '.$nofollow_count.'
'; + echo 'nofollow_count: '.count($redirect_nofollow_list).'
'; + return $redirect_nofollow_list; + } + + public function transform_redirect_nofollow() { + $redirect_nofollow_list = $this->count_redirect_nofollow(); + $htm_doc = new DOMDocument(); + $htm_doc->encoding='UTF-8'; + libxml_use_internal_errors(true); + $htm_doc->strictErrorChecking = false; + + foreach ($redirect_nofollow_list as $info) { + $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_rel = $anchor->getAttribute('rel'); + $anchor->setAttribute('rel', 'nofollow'); + $this->Logs_model->backup($info->is_id, $info->ic_content); + $info->ic_content = $htm_doc->saveHTML(); + $this->InfoContents_model->Update( + $info->ic_id, + $info->ic_url, + $info->ic_url_title, + $info->ic_type, + $info->ic_title, + $info->ic_content, + $info->ic_summary, + $info->ic_seo_title, + $info->ic_seo_description, + $info->ic_seo_keywords, + $info->ic_show_bread_crumbs, + $info->ic_status, + $info->ic_template, + $info->ic_photo, + $info->ic_photo_width, + $info->ic_photo_height, + $info->ic_recommend_tours, + $info->ic_recommend_packages, + $info->ic_ht_area_id, + $info->ic_ht_area_type, + $info->ic_ht_product_id, + $info->ic_ht_product_type, + $info->ic_author); + } + } + + echo 'update_nofollow_count: '.count($redirect_nofollow_list).'
'; } public function count_http_of_href() { From 0602d1cde6963c82f6972ddd62b4b51016ce9cc4 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Thu, 2 Aug 2018 13:35:35 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/welcome.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php index e01cf36e..016fcabd 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.php @@ -199,7 +199,7 @@ class Welcome extends CI_Controller { $include_redirece_info = $this->Information_model->search_all_text('&t=78002', 2000); echo 'redirect count: '.count($include_redirece_info).'
'; - $redirect_nofollow_list = []; + $redirect_nofollow_list = array(); $htm_doc = new DOMDocument(); $htm_doc->encoding='UTF-8'; libxml_use_internal_errors(true); From 53bcb77aa81782d45d1f6fdc545c5b2f5e471ba4 Mon Sep 17 00:00:00 2001 From: lmrwork <59361885@qq.com> Date: Thu, 2 Aug 2018 14:29:17 +0800 Subject: [PATCH 6/6] infotahg --- application/controllers/information.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/application/controllers/information.php b/application/controllers/information.php index d4cd7dd1..3df77f35 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -22,7 +22,7 @@ class Information extends CI_Controller { $this->load->model('InfoSMS_model'); if (is_series_site()) { - $this->load->model('InfoTags_model'); + //$this->load->model('InfoTags_model'); } $this->load->library('Accesscheck'); @@ -271,10 +271,10 @@ class Information extends CI_Controller { $data['all_tags'] = array(); if (is_series_site()) { //信息标签 - $this->InfoTags_model->ic_id = null; - $data['all_tags'] = $this->InfoTags_model->list_tag(); - $this->InfoTags_model->ic_id = $data['information']->ic_id; - $data['my_tags'] = $this->InfoTags_model->list_tag(); + //$this->InfoTags_model->ic_id = null; + //$data['all_tags'] = $this->InfoTags_model->list_tag(); + //$this->InfoTags_model->ic_id = $data['information']->ic_id; + //$data['my_tags'] = $this->InfoTags_model->list_tag(); //差集 foreach ($data['all_tags'] as &$it) {