diff --git a/application/controllers/information.php b/application/controllers/information.php index d75ea6fd..10105183 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -26,7 +26,7 @@ class Information extends CI_Controller $this->load->model('Feedback_model'); $this->load->library('Amplib'); //加载AMP处理类 $this->load->library('html_optimize_lib'); //加载HTML优化类 - + } public function index() @@ -410,8 +410,12 @@ class Information extends CI_Controller } else if (strcasecmp($site_code, "ch") == 0 && !empty($auto_update_cache)) { //读取模板生成PC和移动优先文件 $information_new = $this->Information_model->Detail($this->input->post('is_id')); - $this->make_www_cache('mobile', $information_new); - $this->make_www_cache('pc', $information_new); + $recommand_information = $this->recommand_information($information); + //$this->benchmark->mark('111'); + $this->make_www_cache('mobile', $information_new, $recommand_information); + //$this->benchmark->mark('222'); + $this->make_www_cache('pc', $information_new, $recommand_information); + //echo $this->benchmark->elapsed_time('111', '222'); } else if (strcasecmp($site_code, "ah") == 0 && !empty($auto_update_cache)) { //读取模板生成PC和移动优先文件 $information_new = $this->Information_model->Detail($this->input->post('is_id')); @@ -420,7 +424,7 @@ class Information extends CI_Controller } else if (strcasecmp($site_code, "gh") == 0 && !empty($auto_update_cache)) { $information_new = $this->Information_model->Detail($this->input->post('is_id')); $this->make_www_cache_gh($information_new); - }else if (strcasecmp($site_code, "chinatravel") == 0 && !empty($auto_update_cache)) { + } else if (strcasecmp($site_code, "chinatravel") == 0 && !empty($auto_update_cache)) { //chinatravel读取模板生成PC和移动优先文件 $information_new = $this->Information_model->Detail($this->input->post('is_id')); $this->make_www_cache_ct($information_new); @@ -513,7 +517,7 @@ class Information extends CI_Controller $this->make_www_cache_ah('mobile', $information); } else if ($this->config->item('site_code') == 'chinatravel') { $this->make_www_cache_ct($information); - // $this->make_www_cache_ct('mobile', $information); + // $this->make_www_cache_ct('mobile', $information); } echo json_encode(array('name' => 'yes', 'data' => '更新成功!')); @@ -565,7 +569,7 @@ class Information extends CI_Controller } //生成静态文件 $device='mobile' or 'pc' - function make_www_cache($device, $information) + function make_www_cache($device, $information, $recommand_information) { $data = array(); switch ($device) { @@ -591,7 +595,6 @@ class Information extends CI_Controller break; default: } - $breadcrumb_data = $this->Information_model->get_path_exclude_self($information->is_id, $information->is_path); $breadcrumb_structured_data_content = $this->load->view( @@ -603,7 +606,6 @@ class Information extends CI_Controller $breadcrumb_structured_data_content, $template); - //替换模板中的标签 $template = str_replace('', $information->ic_seo_title, $template); $template = str_replace('', $information->ic_seo_description, $template); @@ -630,6 +632,7 @@ class Information extends CI_Controller } } + //火车票搜索框添加 -- zp if ($information->is_parent_id == "278008234") { //本地测试的火车父类ID为:278035939 。网前为:278008234 @@ -637,7 +640,6 @@ class Information extends CI_Controller $template = str_replace('', $template_TrainSearch, $template); } - //非产品页面 $meta_product_code = get_meta($information->ic_id, 'meta_product_code'); if (empty($meta_product_code)) { @@ -672,30 +674,28 @@ class Information extends CI_Controller $information->ic_content = str_replace('', $breadcrumb_content, $information->ic_content); } - - //---day tours--- 20210922 zp //本地 278035929 //网前 278008224 if ($information->is_parent_id == "278008224") { - if (!empty($meta_product_code)){ + if (!empty($meta_product_code)) { //准备需要的数据 $dataTrippest = []; - $dataTrippest["ic_title"] = $information->ic_title; + $dataTrippest["ic_title"] = $information->ic_title; //附加选项 $t_Type = get_meta($information->ic_id, 'meta_trippest_type'); - if (isset($t_Type)){ + if (isset($t_Type)) { $dataTrippest["t_Type"] = $t_Type; - }else{ + } else { $dataTrippest["t_Type"] = "general"; } $t_package = get_meta($information->ic_id, 'meta_trippest_package'); - $dataTrippest["t_package"] = explode("|",$t_package); + $dataTrippest["t_package"] = explode("|", $t_package); $t_excludedate = get_meta($information->ic_id, 'meta_trippest_excludedate'); $dataTrippest["t_excludedate"] = $t_excludedate; - $t_includedate = get_meta($information->ic_id, 'meta_trippest_includedate'); + $t_includedate = get_meta($information->ic_id, 'meta_trippest_includedate'); $dataTrippest["t_includedate"] = $t_includedate; $t_excludemonth = get_meta($information->ic_id, 'meta_trippest_excludemonth'); $dataTrippest["t_excludemonth"] = $t_excludemonth; @@ -710,7 +710,7 @@ class Information extends CI_Controller // 132004 桂林目的地 // 132005 成都目的地 $PAG_SourceType = $dataTrippest['PagDetail']->PAG_SourceType; - switch ($PAG_SourceType){ + switch ($PAG_SourceType) { case '132001': $dataTrippest['PAG_SourceType'] = "beijing"; break; @@ -722,41 +722,40 @@ class Information extends CI_Controller break; case '132004': $dataTrippest['PAG_SourceType'] = "guilin"; - break; + break; case '132005': $dataTrippest['PAG_SourceType'] = "chengdu"; - break; + break; case '132006': - $dataTrippest['PAG_SourceType'] = "zhangjiajie"; - break; + $dataTrippest['PAG_SourceType'] = "zhangjiajie"; + break; case '132007': - $dataTrippest['PAG_SourceType'] = "huangshan"; - break; + $dataTrippest['PAG_SourceType'] = "huangshan"; + break; default: $dataTrippest['PAG_SourceType'] = ""; break; } - + //每周发团 $PAG_Scheme = $dataTrippest['PagDetail']->PAG_Scheme; $dataTrippest['PAG_Scheme'] = $PAG_Scheme; //接送 - if ($dataTrippest["t_Type"]=="transfer" || 1==1) - { + if ($dataTrippest["t_Type"] == "transfer" || 1 == 1) { $PagList = $this->trippest_model->GetTransfer($dataTrippest['PagDetail']->PAG_SN); $dataTrippest["PagList"] = $PagList; } - //价格 + //价格 // $price = $this->trippest_model->get_price("BJALC-1",2); - $price = $this->trippest_model->get_price($dataTrippest['PagDetail']->PAG_Code,2); + $price = $this->trippest_model->get_price($dataTrippest['PagDetail']->PAG_Code, 2); $showPrice = ""; - if (!empty($price)){ + if (!empty($price)) { $PKP_AdultNetPrice = $price->PKP_AdultNetPrice; $PKP_AdultSpecialPrice = $price->PKP_AdultSpecialPrice; - if ($PKP_AdultSpecialPrice>0){ + if ($PKP_AdultSpecialPrice > 0) { $showPrice = $PKP_AdultSpecialPrice; - }else{ + } else { $showPrice = $PKP_AdultNetPrice; } } @@ -774,9 +773,8 @@ class Information extends CI_Controller //---day tours end ---- - //信息推荐 - $template_recommand = $this->recommand_information($information); + $template_recommand = $recommand_information; //$this->recommand_information($information); 从外面传进来,pc和移动只需要查一次,减少数据库负担 $template = str_replace('', $this->load->view($template_path . '-next', array('recommands' => $template_recommand), TRUE), $template); // //广告,改叫tips,防止被插件屏蔽 if (!empty($template_recommand['Tips Right TOP'])) { @@ -796,7 +794,6 @@ class Information extends CI_Controller $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-tour', array('recommands' => $template_recommand), TRUE), $information->ic_content); } - //顶部全屏大图 if ($device == 'mobile') { //移动端读取移动大图 $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile'); @@ -806,7 +803,7 @@ class Information extends CI_Controller // 火车票首页搜索框 --zp $template_TrainSearch = ""; - if ($information->ic_url =="/china-trains/hometest.htm" || $information->ic_url=="/china-trains/"){ + if ($information->ic_url == "/china-trains/hometest.htm" || $information->ic_url == "/china-trains/") { $template_TrainSearch = $this->load->view($template_path . '-train-index', null, TRUE); } @@ -816,7 +813,7 @@ class Information extends CI_Controller if (!empty($meta_addon_picture_url)) { $template = str_replace('', '
', $template); } else { - $template = str_replace('', ' ', $template); + $template = str_replace('', ' ', $template); } } //顶部视频 @@ -825,15 +822,21 @@ class Information extends CI_Controller if (!empty($meta_news_video) && !empty($meta_video_picture)) { $template = str_replace('', '', $template); } - //主样式表,内联模式 - $main_css_string = compress_css(GET_HTTP('https://proxy-data.chinahighlights.com/css/mobile-first.css')); + + if (is_file('D:/wwwroot/origin-data.chinahighlights.com/css/mobile-first.css')) {//主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速 + $main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/mobile-first.css')); + } else { + $main_css_string = compress_css(GET_HTTP('https://proxy-data.chinahighlights.com/css/mobile-first.css')); + } $template = str_replace('', '', $template); //额外样式 $meta_addon_css = get_meta($information->ic_id, 'meta_addon_css'); if (!empty($meta_addon_css)) { - //引用方式 $template = str_replace('', '', $template); - //内联方式 - $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css)); + if ($meta_addon_css == 'https://proxy-data.chinahighlights.com/css/tour-detail-former.css' && is_file('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css')) { + $meta_addon_css_string = compress_css(file_get_contents('D:/wwwroot/origin-data.chinahighlights.com/css/tour-detail-former.css')); + } else { + $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css)); + } $template = str_replace('', '', $template); } //额外js @@ -854,18 +857,23 @@ class Information extends CI_Controller $template = str_replace('', '', $template); //} //社媒分享图片 - $full_ic_photo=''; + $full_ic_photo = ''; if (!empty($information->ic_photo)) { $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo; - }else{ - $full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile'); - } - if(!empty($full_ic_photo)){ + } else { + $full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile'); + } + if (!empty($full_ic_photo)) { $template = str_replace('', '', $template); } //设置图片尺寸 - $template = $this->html_optimize_lib->set_image_size($template); + if (is_dir('D:/wwwroot/origin-images.chinahighlights.com') && is_dir('D:/wwwroot/origin-www.chinahighlights.com')) { + $template = $this->html_optimize_lib->set_image_size_local($template, 'D:/wwwroot/origin-www.chinahighlights.com', 'D:/wwwroot/origin-images.chinahighlights.com'); + } else { + $template = $this->html_optimize_lib->set_image_size($template); + } // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm + $this->benchmark->mark('10'); $html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url; $html_path = str_replace("\\", "/", $html_path); if (substr($html_path, -1, 1) == '/') { @@ -877,7 +885,8 @@ class Information extends CI_Controller } - function make_www_cache_gh($information){ + function make_www_cache_gh($information) + { return false; $data = array(); $data['information'] = $information; @@ -1037,17 +1046,17 @@ class Information extends CI_Controller $template = str_replace('', '', $template); //} //社媒分享图片 - - $full_ic_photo=''; + + $full_ic_photo = ''; if (!empty($information->ic_photo)) { $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo; - }else{ - $full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile'); - } - if(!empty($full_ic_photo)){ + } else { + $full_ic_photo = get_meta($information->ic_id, 'meta_addon_picture_mobile'); + } + if (!empty($full_ic_photo)) { $template = str_replace('', '', $template); } - + //设置图片尺寸 $template = $this->html_optimize_lib->set_image_size($template); // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm @@ -1083,7 +1092,7 @@ class Information extends CI_Controller /* 详细内容 */ $ic_content = $information->ic_content; - // /**替换详细内容里面的价格 + // /**替换详细内容里面的价格 /* 直接使用fetch来动态获取价格,这样不用替换标签,直接录标签 // * // 一日游价格标签, "" 或者 逗号后面是人数 // * //精华线路标签"" @@ -1099,7 +1108,6 @@ class Information extends CI_Controller // return '';; // },$ic_content); - //图片加延迟 $ic_content = $this->html_optimize_lib->set_lazy_loader($ic_content, 'https://data.chinatravel.com/images/mobile-first/grey.gif'); @@ -1133,7 +1141,7 @@ class Information extends CI_Controller //主样式表,内联模式 //$apiweb="http://202.103.68.104"; //本地测试 - $apiweb = "https://data.chinatravel.com"; + $apiweb = "https://data.chinatravel.com"; $cssUrl = $apiweb . "/css/newcss3/base.css?v=" . time(); $main_css_string = compress_css(GET_HTTP($cssUrl)); $data["MAINCSS"] = ''; @@ -1151,11 +1159,11 @@ class Information extends CI_Controller //社媒分享图片 $data["OGIMAGE"] = ""; if (!empty($information->ic_photo)) { - if (strpos($information->ic_photo,"chinatravel.com")!=false){ + if (strpos($information->ic_photo, "chinatravel.com") != false) { $full_ic_photo = $information->ic_photo; - }else{ + } else { $full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo; - } + } $data["OGIMAGE"] = ''; } @@ -1189,7 +1197,7 @@ class Information extends CI_Controller if (!empty($meta_addon_js)) { $addonJs .= ''; } - //价格js + //价格js if ($meta_ct_page_price == "yes") { $addonJs .= ''; } @@ -1273,8 +1281,8 @@ class Information extends CI_Controller #endregion #region 移动端和PC端差别处理区域 - $arrDevice = array("mobile","pc"); - foreach($arrDevice as $device){ + $arrDevice = array("mobile", "pc"); + foreach ($arrDevice as $device) { //顶部全屏大图 $data["TOPBANNER"] = ""; $ImgText = ""; //图文字 @@ -1282,29 +1290,29 @@ class Information extends CI_Controller $meta_addon_picture_text = get_meta($information->ic_id, 'meta_addon_picture_text'); if ($device == 'mobile') { //移动端读取移动大图 $meta_addon_picture = get_meta($information->ic_id, 'meta_addon_picture_mobile'); - $bannerImg = '' . $meta_addon_picture_text . '
' . $meta_addon_picture_text . '