From 6285a968dce0307754727b76dba8b75ee5e90bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=AF=9A=E8=AF=9A?= Date: Mon, 25 Sep 2017 11:35:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=9B=BF=E6=8D=A2=E5=BE=B7?= =?UTF-8?q?=E8=AF=AD=E5=9B=BE=E7=89=87=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/welcome.php | 42 ++++++++++++++++++++++++ application/models/information_model.php | 4 +-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php index bbea50bc..0a3c60df 100644 --- a/application/controllers/welcome.php +++ b/application/controllers/welcome.php @@ -192,6 +192,48 @@ class Welcome extends CI_Controller { ->set_content_type('application/json') ->set_output(json_encode($obj)); } + + + //批量替换二级域名,如图片或者data域名 + function replace_hostname($topnum){ + $data=array(); + $find_host='http://bilder.chinarundreisen.com/'; + $new_host='//bilder.chinarundreisen.com/'; + $data['all_information'] = $this->Information_model->search_all_text($find_host,$topnum); + if($data['all_information']){ + foreach($data['all_information'] as $item){ + echo $item->ic_url.'
'; + $item->ic_content=str_replace($find_host, $new_host,$item->ic_content); + $this->InfoContents_model->Update( + $item->ic_id, + $item->ic_url, + $item->ic_url_title, + $item->ic_type, + $item->ic_title, + $item->ic_content, + $item->ic_summary, + $item->ic_seo_title, + $item->ic_seo_description, + $item->ic_seo_keywords, + $item->ic_show_bread_crumbs, + $item->ic_status, + $item->ic_template, + $item->ic_photo, + $item->ic_photo_width, + $item->ic_photo_height, + $item->ic_recommend_tours, + $item->ic_recommend_packages, + $item->ic_ht_area_id, + $item->ic_ht_area_type, + $item->ic_ht_product_id, + $item->ic_ht_product_type, + $item->ic_author + ); + } + }else{ + echo 'all done'; + } + } private function check_url($subject) { $result = $subject; diff --git a/application/models/information_model.php b/application/models/information_model.php index f926ae0d..c5b991a0 100644 --- a/application/models/information_model.php +++ b/application/models/information_model.php @@ -57,9 +57,9 @@ class Information_model extends CI_Model { return $this->GetList(); } - function search_all_text($keyword) { + function search_all_text($keyword,$topnum=24) { $this->init(); - $this->topNum = 24; + $this->topNum = $topnum; $sql_keyword = '%' . $this->HT->escape_like_str($keyword) . '%'; $this->search = " AND ic_content like N'$sql_keyword' "; return $this->GetList();