From 0882c80699ee8634d2543fdb39aad9a6ed63c077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E8=AF=9A=E8=AF=9A?= Date: Fri, 18 Aug 2017 14:15:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BE=B7=E8=AF=AD=E9=9D=99?= =?UTF-8?q?=E6=80=81=E5=8C=96=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/information.php | 132 +++++++++++------------- 1 file changed, 61 insertions(+), 71 deletions(-) diff --git a/application/controllers/information.php b/application/controllers/information.php index a681d66d..b9f1da5d 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -398,8 +398,7 @@ class Information extends CI_Controller { $update_info_log = $this->update_cache($ic_url); } - if (empty($update_info_log) || count($update_info_log)==0 || !isset($update_info_log[0]['url'])) - { + if (empty($update_info_log) || count($update_info_log) == 0 || !isset($update_info_log[0]['url'])) { $update_info_log = 'not found update info log'; } @@ -433,24 +432,6 @@ class Information extends CI_Controller { } echo json_encode($data); - - //设置图片应用URL - /* $use_pictures=$this->input->post('use_pictures'); - if(!empty($use_pictures)) - { - foreach(explode(',',$use_pictures.'0:0:0') as $picture) - { - list($p_id,$p_path,$p_wh)=explode(':',$picture); - if (stripos($this->input->post('ic_content'),$p_path) !== FALSE || $p_path==$this->input->post('ic_photo') ) - { - if($p_id!=0) - { - $this->load->model('pictureUseStat_model'); - $this->pictureUseStat_model->set_useurl($p_id,$p_wh,$this->config->item('site_url').$this->input->post('ic_url')); - } - } - } - } */ } } @@ -479,63 +460,72 @@ class Information extends CI_Controller { //更新静态文件 //不用参数提交的原因是可能url带有特殊字符,CI会报错 public function update_cache($static_html_url = false, $delete_only = false) { - - $url = $static_html_url; - if (empty($url)) { - $url = $this->input->post('cache_url'); - } + $url = !empty($static_html_url) ? $static_html_url : $this->input->post('cache_url'); $url = str_replace($this->config->item('site_url'), '', $url); - //原始链接 - $original_url = $url; + $original_url = $url; //原始链接 + $delete_only = !empty($delete_only) ? $delete_only : $this->input->get_post('delete_only'); + + switch ($this->config->item('site_code')) { + case 'cht': + $url = 'http://192.155.224.195:8080/guide-use.php/travelguide/guide/?static_html_url=' . $url; + if (strpos($url, '/festivals/') !== false || strpos($url, '/faq/') !== false) {//ch的部分控制器不是travelguide,所以不能统一更新和生产缓存文件,只能跳过,统一控制器再回头取消这个限制 + $url = 'http://www.chinahighlights.com/'; + } + break; - if ($this->config->item('site_code') == 'cht') { - //$url = 'http://www.chinahighlights.com/api/community/updatecache.asp?gurl=http://www.chinahighlights.com' . $url . '&other=1&site=info'; - //$url = 'http://192.155.224.195:2222/guide-use.php/travelguide/guide/?static_html_url=' . $url; - $url = 'http://192.155.224.195:8080/guide-use.php/travelguide/guide/?static_html_url=' . $url; + case 'ah': + if ($delete_only === true) { + $url = 'https://www.asiahighlights.com/index.php/information/delete_cache_8X913mksJ/?static_html_url=' . $url; + } else {// static_html_optimize=comeon 启用静态化压缩和js、css延迟加载 + $url = 'https://www.asiahighlights.com/index.php/information/detail/?static_html_url=' . $url . '&static_html_optimize=comeon'; + } + break; - //ch的部分控制器不是travelguide,所以不能统一更新和生产缓存文件,只能跳过,统一控制器再回头取消这个限制 - if (strpos($url, '/festivals/') !== false) { - $url = 'http://www.chinahighlights.com/'; - } - if (strpos($url, '/faq/') !== false) { - $url = 'http://www.chinahighlights.com/'; - } - } elseif ($this->config->item('site_code') == 'gm') { - $url = "http://148.251.35.42:3300/create-cache/?url=$url"; - } else if (is_series_site()) { - if (FALSE === $delete_only) { - $delete_only = $this->input->get_post('delete_only'); - } - if ($delete_only) { - //只删除操作,在url修改和不发布信息的时候使用 - $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url; - } else { - $information = $this->Information_model->Detail($url); - $tmp = $url; - //判断是否是更新信息 - /* 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了 - */ - if (!empty($information->ic_content)) { - //先尝试删除静态文件。 - $try_del = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url; - file_get_contents($try_del); - $url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url; + case 'gm': + GET_HTTP("http://148.251.35.42:3300/create-cache/?url=" . urlencode($url)); //请求nodejs静态化更新页面,删除缓存,因为部分页面没有进入信息平台 + if ($delete_only) { + $url = $this->config->item('site_url') . "/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url); } else { - $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $url; + $url = $this->config->item('site_url') . "/gm.php/information/detail?static_html_optimize=comeon&static_html_url=" . urlencode($url); } - if (isset($information->ic_type) && $information->ic_type == 'product') { - $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $tmp; + break; + + case 'vac'://国际站 + case 'vc': + case 'it': + case 'ru': + case 'jp': + if ($delete_only) { + //只删除操作,在url修改和不发布信息的时候使用 + $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url; + } else { + $information = $this->Information_model->Detail($url); + $tmp = $url; + //判断是否是更新信息 + // 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了 + if (!empty($information->ic_content)) { + //先尝试删除静态文件。 + $try_del = $this->config->item('site_url') . '/index.php/welcome/update_cache/delete_only?static_html_url=' . $url; + file_get_contents($try_del); + $url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url; + } else { + $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $url; + } + if (isset($information->ic_type) && $information->ic_type == 'product') { + $url = $this->config->item('site_url') . '/index.php/welcome/update_cache/?static_html_url=' . $tmp; + } } - } - } else if ($this->config->item('site_code') == 'ah') { - if ($delete_only === true) { - $url = 'https://www.asiahighlights.com/index.php/information/delete_cache_8X913mksJ/?static_html_url=' . $url; - } else { - // static_html_optimize=comeon 启用静态化压缩和js、css延迟加载 - $url = 'https://www.asiahighlights.com/index.php/information/detail/?static_html_url=' . $url . '&static_html_optimize=comeon'; - } - } else { //子站点使用 - $url = $this->config->item('site_url') . $url . '@cache@refresh'; + break; + + case 'ct'://子站点使用 + case 'sht': + case 'gl': + case 'mbj': + case 'yz': + $url = $this->config->item('site_url') . $url . '@cache@refresh'; + break; + default:return false; + break; } //关闭错误提示,防止file_get_contents请求特殊字符的时候会报错或者404、500,特殊字符需要用urlencode编码第一个/后面的url