From 390422d10492a102363c30e3b819a6022b62741a Mon Sep 17 00:00:00 2001 From: Ycc Date: Wed, 11 Feb 2026 14:40:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0thailand=E7=AB=99=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/config/config.php | 3 + application/controllers/information.php | 360 ++++++++++++++++++++++++ application/helpers/info_helper.php | 2 +- 3 files changed, 364 insertions(+), 1 deletion(-) diff --git a/application/config/config.php b/application/config/config.php index dfdb653d..94b6c5c4 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -396,6 +396,7 @@ $config['site'] = [ 'ah' => ['site_code' => 'ah', 'site_id' => 141, 'site_lgc' => '1', 'sitemap_name' => '', 'site_image_url' => 'https://images.asiahighlights.com', 'site_url' => 'https://www.asiahighlights.com', 'site_sitemap' => '', 'site_authors' => ['X', 'sfx'], 'site_user' => [',ycc,sfx,X,']], 'jh' => ['site_code' => 'jh', 'site_id' => 186, 'site_lgc' => '1', 'sitemap_name' => '', 'site_image_url' => 'https://images.japanhighlights.com', 'site_url' => 'https://www.japanhighlights.com', 'site_sitemap' => '', 'site_authors' => ['X', 'sfx'], 'site_user' => [',ycc,sfx,X,']], 'htravel' => ['site_code' => 'htravel', 'site_id' => 187, 'site_lgc' => '1', 'sitemap_name' => '', 'site_image_url' => 'https://images.highlightstravel.com', 'site_url' => 'https://www.highlightstravel.com', 'site_sitemap' => '', 'site_authors' => ['X', 'sfx'], 'site_user' => [',ycc,sfx,X,']], + 'thailand' => ['site_code' => 'thailand', 'site_id' => 188, 'site_lgc' => '1', 'sitemap_name' => '', 'site_image_url' => 'https://images.thailandhighlights.com', 'site_url' => 'https://www.thailandhighlights.com', 'site_sitemap' => '', 'site_authors' => ['X', 'sfx'], 'site_user' => [',ycc,sfx,X,']], 'gh' => ['site_code' => 'gh', 'site_id' => 163, 'site_lgc' => '1', 'sitemap_name' => '', 'site_image_url' => 'https://images.globalhighlights.com', 'site_url' => 'https://www.globalhighlights.com', 'site_sitemap' => '', 'site_authors' => ['X', 'sfx'], 'site_user' => [',ycc,sfx,X,']], 'gm' => ['site_code' => 'gm', 'site_id' => 22, 'site_lgc' => '4', 'site_url' => 'https://www.chinahighlightstravel.de', 'site_image_url' => '//images.chinahighlightstravel.de', 'site_authors' => ['DX', 'X', 'K', 'Lan', 'lmr', 'zyh', 'ZYHL', 'TDJ'], 'site_user' => ',ycc,lmr,B,zyh,DX,X,K,htc,zm,bhn,Lan,Tony,zyh,J,v,ZYHL,TDJ,LYY,shw,'], 'gh_gm' => ['site_code' => 'gh_gm', 'site_id' => 178, 'site_lgc' => '4', 'site_url' => 'https://www.globalhighlights.de', 'site_image_url' => '//www.globalhighlights.de', 'site_authors' => ['DX', 'X', 'K', 'Lan', 'lmr', 'zyh', 'ZYHL', 'TDJ'], 'site_user' => ',ycc,lmr,B,zyh,DX,X,K,htc,zm,bhn,Lan,Tony,zyh,J,v,ZYHL,TDJ,LYY,shw,'], @@ -551,6 +552,7 @@ $config['css_source_yz'] = 'https://www.yangtzeriver.org/css/css3/bootstrap/boot $config['css_source_ah'] = 'https://data.asiahighlights.com/css/mobile-first.css'; $config['css_source_jh'] = 'https://data.japanhighlights.com/css/mobile-first.css'; $config['css_source_htravel'] = 'https://data.highlightstravel.com/css/mobile-first.css'; +$config['css_source_thailand'] = 'https://data.thailandhighlights.comcss/mobile-first.css'; $config['css_source_gh'] = 'https://data.globalhighlights.com/css/gh-global.css'; $config['css_source_ct'] = 'https://data.chinatravel.com/css/min.php?f=/css/css3/bootstrap/bootstrap.css,/css/css3/style.css,/css/css3/destination-details.css'; $config['css_source_chinatravel'] = 'https://data.chinatravel.com/css/newcss3/base.css'; @@ -567,6 +569,7 @@ $config['cache']['ah']['cache_path'] = 'D:\wwwcache\asiahighlights.com'; $config['cache']['jh']['cache_path'] = 'D:\wwwcache\japanhighlights.com'; $config['cache']['gh']['cache_path'] = 'D:\wwwcache\globalhighlights.com'; $config['cache']['htravel']['cache_path'] = 'D:\wwwcache\highlightstravel.com'; +$config['cache']['thailand']['cache_path'] = 'D:\wwwcache\thailandhighlights.com'; $config['cache']['chinatravel']['cache_path'] = 'D:\wwwcache\mobile-first\chinatravel.com'; $config['cache']['shanghai']['cache_path'] = 'D:\wwwcache\mobile-first\shanghaihighlights.com'; $config['cache']['beijing']['cache_path'] = 'D:\wwwcache\mobile-first\mybeijingchina.com'; diff --git a/application/controllers/information.php b/application/controllers/information.php index 6741b7b2..5b745cfb 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -763,6 +763,11 @@ class Information extends CI_Controller { $information_new = $this->Information_model->Detail($this->input->post('is_id')); $this->make_www_cache_jh('mobile', $information_new, $recommand_information); $this->make_www_cache_jh('pc', $information_new, $recommand_information); + } else if (strcasecmp($site_code, "thailand") == 0 && ! empty($auto_update_cache)) { + $recommand_information = $this->recommand_information($information); + $information_new = $this->Information_model->Detail($this->input->post('is_id')); + $this->make_www_cache_thailand('mobile', $information_new, $recommand_information); + $this->make_www_cache_thailand('pc', $information_new, $recommand_information); } else if (strcasecmp($site_code, "chinatravel") == 0 && ! empty($auto_update_cache)) { //chinatravel读取模板生成PC和移动优先文件 $information_new = $this->Information_model->Detail($this->input->post('is_id')); @@ -873,6 +878,9 @@ class Information extends CI_Controller { } else if ($this->config->item('site_code') == 'jh') { $this->make_www_cache_jh('pc', $information, $recommand_information); $this->make_www_cache_jh('mobile', $information, $recommand_information); + }else if ($this->config->item('site_code') == 'thailand') { + $this->make_www_cache_thailand('pc', $information, $recommand_information); + $this->make_www_cache_thailand('mobile', $information, $recommand_information); } else if ($this->config->item('site_code') == 'chinatravel') { $this->make_www_cache_ct($information); // $this->make_www_cache_ct('mobile', $information); @@ -2654,6 +2662,358 @@ class Information extends CI_Controller { file_put_contents($html_path, $template, LOCK_EX); } + + public function make_www_cache_thailand($device, $information, $recommand_information) { + + $data = []; + $data['information'] = $information; + $recommand_template = ''; + $meta_show_advertise = get_meta($information->ic_id, 'meta_show_advertise'); + $data['meta_show_advertise'] = $meta_show_advertise; + switch ($device) { + case 'mobile': + //获取移动优先的模板,如果有的话 + $template_path = 'mobile_first/' . $this->config->item('site_code'); + if (is_file(APPPATH . 'views/' . $template_path . EXT)) { + $template = $this->load->view($template_path, '', true); + $html_path_ext = '-mobile.htm'; + } else { + return false; + } + $recommand_template = 'mobile_first/thailand-next-mobile'; + break; + case 'pc': + //获取PC的模板,如果有的话 + $template_path = 'mobile_first/' . $this->config->item('site_code'); + if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) { + $template = $this->load->view($template_path . '-pc', $data, true); + $html_path_ext = '-pc.htm'; + } else { + return false; + } + $recommand_template = 'mobile_first/thailand-next'; + break; + default: + } + + //替换模板中的标签 + $template = str_replace('', $information->ic_seo_title, $template); + $template = str_replace('', $information->ic_seo_description, $template); + $template = str_replace('', $information->ic_seo_keywords, $template); + $template = str_replace('', $this->config->item('site_url') . $information->ic_url, $template); + + //顶部视频 + $data['meta_news_video'] = get_meta($information->ic_id, 'meta_news_video'); + $data['meta_video_picture'] = get_meta($information->ic_id, 'meta_video_picture'); + if (empty($data['meta_news_video']) && empty($data['meta_video_picture'])) { + //没有顶部视频时候才读取全屏大图 + //顶部全屏大图 + if ($device == 'mobile') { //移动端读取移动大图 + $data['meta_addon_picture'] = get_meta($information->ic_id, 'meta_addon_picture_mobile'); + } else { + $data['meta_addon_picture'] = get_meta($information->ic_id, 'meta_addon_picture'); + } + $data['meta_addon_picture_url'] = get_meta($information->ic_id, 'meta_addon_picture_url'); + } + + // AH Home 下层节点名称和链接映射 + $group_map = [ + 278011836 => [ + 'ic_url' => '/about-us', + 'ic_url_title' => 'About Us', + ], + ]; + + $breadcrumb_data = $this->Information_model->get_breadcrumb_data($information->is_id, $information->is_path, $group_map); + $ads_by_google = ! empty(get_meta($information->ic_id, 'meta_google_ad_article')); + $data['meta_news_createdate'] = $this->get_publish_date_in_6_month($information); + $data['ads_by_google'] = $ads_by_google; + $data['author_name'] = ''; //获取作者信息 + $author = $this->Operator_model->get_author_nikename($information->ic_author); + $data['author_info'] = ['url' => '', 'avatar' => '', 'expertise' => '']; + + if (!empty($author)) { + $data['author_name'] = $author->OPI_FirstName; + $data['OPI_Code'] = $author->OPI_Code; + + $author_info = $this->get_author_info('thailandhighlights.com', $author->OPI_Code); + $data['author_info'] = $author_info; + } else { + $author_web = $this->Infoauthors_model->detail_by_id($information->ic_author); //原始作者,可能是在线作者等 + if (!empty($author_web)) { + $data['author_name'] = $author_web->a_name; + $author_info = ['url' => '', 'avatar' => '', 'expertise' => '']; + } + } + $data['breadcrumb_data'] = $breadcrumb_data; + $template_H1 = $this->load->view($template_path . '-h1', $data, true); + $template = str_replace('', $template_H1, $template); + // 结构化标签:Article + $article_structured_data_content = $this->load->view( + $template_path . '-structured-data-article', + ['information' => $information, 'author_name' => $data['author_name'], 'author_url' => $author_info['url']], + true + ); + $template = str_replace('', $article_structured_data_content, $template); + // 结构化标签:BreadcrumbList + $breadcrumb_structured_data_content = $this->load->view( + $template_path . '-structured-data-breadcrumb', + ['breadcrumb_data' => $breadcrumb_data, 'information' => $information], + true + ); + $template = str_replace( + '', + $breadcrumb_structured_data_content, + $template + ); + + //推荐信息或者产品 + $template_recommand = $recommand_information; + $template = str_replace('', $this->load->view($recommand_template, ['recommands' => $template_recommand], true), $template); + //广告,改叫tips,防止被插件屏蔽 + if (! empty($template_recommand['Tips Right']) && ($meta_show_advertise == 'yes' || empty($meta_show_advertise))) { + $template = str_replace('', "
" . $template_recommand['Tips Right']->it_content . "
", $template); + } + // 右侧列表广告 + $tips_right_a = []; + $tips_right_b = []; + $tips_right_c = []; + + for ($i = 1; $i <= 12; $i++) { + $key = 'List Tips Right A_' . $i; + if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) { + $tips_right_a[] = $recommand_information[$key]; + } + } + for ($i = 1; $i <= 12; $i++) { + $key = 'List Tips Right B_' . $i; + if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) { + $tips_right_b[] = $recommand_information[$key]; + } + } + for ($i = 1; $i <= 12; $i++) { + $key = 'List Tips Right C_' . $i; + if (array_key_exists($key, $recommand_information) && $recommand_information[$key]) { + $tips_right_c[] = $recommand_information[$key]; + } + } + + $tips_right_list_content = $this->load->view( + 'mobile_first/thailand-tips-right-list', + [ + 'tips_right_a' => $tips_right_a, + 'tips_right_b' => $tips_right_b, + 'tips_right_c' => $tips_right_c, + ], + true + ); + + if (($meta_show_advertise == 'yes' || empty($meta_show_advertise))) { + $template = str_replace('', $tips_right_list_content, $template); + } + + //文中的信息推荐 + if (strpos($information->ic_content, '') !== false) { + $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-article', ['recommands' => $template_recommand], true), $information->ic_content); + } + //文中的线路推荐 + if (strpos($information->ic_content, '') !== false) { + $information->ic_content = str_replace('', $this->load->view($template_path . '-recommends-tour', ['recommands' => $template_recommand], true), $information->ic_content); + } + + //替换内容中广告 + $temp_array = []; + preg_match_all('^^', $information->ic_content, $temp_array); + if (! empty($temp_array[1])) { + foreach ($temp_array[1] as $key => $item) { + $tips_detail = $this->recommends_and_tips_model->tips_detail($item); + if ($tips_detail) { + $information->ic_content = str_replace($temp_array[0][$key], $tips_detail->it_content, $information->ic_content); + } + } + } + + $meta_product_code = get_meta($information->ic_id, 'meta_product_code'); + // 非产品页面 + if (empty($meta_product_code)) { + + } else { + $template = str_replace('?product_code=', '?product_code=' . $meta_product_code, $template); + $inquiry_form_template = $this->load->view( + 'mobile_first/thailand-inquiry-form', + ['meta_product_code' => $meta_product_code, 'information' => $information], + true + ); + $information->ic_content = str_replace('', $inquiry_form_template, $information->ic_content); + + // GP 表单 + $gp_form_content = $this->load->view( + 'mobile_first/thailand-gp-form', + ['meta_product_code' => $meta_product_code, 'information' => $information], + true + ); + $information->ic_content = str_replace('', $gp_form_content, $information->ic_content); + + } + + $price_tag_list = $this->parse_price_tag($information->ic_content); + + foreach ($price_tag_list as $price_tag) { + $information->ic_content = str_replace( + $price_tag['placeholder'], + $price_tag['price_number'], + $information->ic_content + ); + } + + // 动态加载反馈标签,第一个城市不足八条,使用第二城市数据。 + // HTLM:
+ // 解析结果:; Siem Reap,Bangkok + $feedback_array = []; + preg_match_all('^^', $information->ic_content, $feedback_array); + if (! empty($feedback_array)) { + foreach ($feedback_array[0] as $index => $tag_name) { + $city_name_string = $feedback_array[1][$index]; + $city_name_list = explode(',', $city_name_string); + $feedback_list = $this->Feedback_model->get_feedback_by_city_list($city_name_list, FALSE); + // 防止触发 Google 网络垃圾政策只返回前三条,但市场要求显示五条 + $top3_feedback_list = array_slice($feedback_list, 0, 5); + $feedback_content = $this->load->view( + 'mobile_first/thailand-feedback-list', + ['feedback_list' => $top3_feedback_list], + true + ); + $information->ic_content = str_replace( + $tag_name, + $feedback_content, + $information->ic_content + ); + } + } + + // 动态加载反馈标签,每个城市三十条反馈。 + // HTLM:
+ // 解析结果:; Bangkok + $feedback30_array = []; + preg_match_all('^^', $information->ic_content, $feedback30_array); + if (! empty($feedback30_array)) { + foreach ($feedback30_array[0] as $index => $tag_name) { + $city_name = $feedback30_array[1][$index]; + $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 30, FALSE); + $feedback_30_content = $this->load->view( + 'mobile_first/thailand-feedback-30-list', + ['feedback_list' => $feedback_list], + true + ); + $information->ic_content = str_replace( + $tag_name, + $feedback_30_content, + $information->ic_content + ); + } + } + + // 集合页面反馈标签 + $feedback_city_array = []; + preg_match_all('^^', $information->ic_content, $feedback_city_array); + if (! empty($feedback_city_array)) { + foreach ($feedback_city_array[0] as $index => $tag_name) { + $city_name_string = $feedback_city_array[1][$index]; + $city_name_list = explode(',', $city_name_string); + $feedback_city_list = []; + foreach ($city_name_list as $index => $city_name) { + $feedback_list = $this->Feedback_model->get_feedback_by_city_name($city_name, 5, FALSE); + $data_name = str_replace(" ", "_", $city_name); + $feedback_city_list[$data_name] = $feedback_list; + } + + $feedback_city_content = $this->load->view( + 'mobile_first/thailand-feedback-city-list', + $feedback_city_list, + true + ); + $information->ic_content = str_replace( + $tag_name, + $feedback_city_content, + $information->ic_content + ); + } + } + + //主样式表,内联模式 + if (is_file('D:/wwwroot/origin-www.thailandhighlights.com/css/mobile-first.css')) { //主样式表,内联模式,优先读取本地,没有在从网络读取,为了加速 + $main_css_string = compress_css(file_get_contents('D:/wwwroot/origin-www.thailandhighlights.com/css/mobile-first.css')); + } else { + $main_css_string = compress_css(GET_HTTP('https://proxy-data.thailandhighlights.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)) { + //内联方式 + $meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css)); + $template = str_replace('', '', $template); + } + //额外js + $meta_addon_js = get_meta($information->ic_id, 'meta_addon_js'); + if (! empty($meta_addon_js)) { + $template = str_replace('', '', $template); + } + + $meta_note_ogtitle = get_meta($information->ic_id, 'meta_note_ogtitle'); + if (! empty($meta_note_ogtitle)) { + $template = str_replace('', '', $template); + } + + $meta_note = get_meta($information->ic_id, 'meta_note'); + if (! empty($meta_note)) { + $template = str_replace('', '', $template); + } + + $meta_index_set = get_meta($information->ic_id, 'meta_index_set'); + if (! empty($meta_index_set)) { + $template = str_replace('', '', $template); + } + //设置内容图片缓加载 + $lazy_content = $this->html_optimize_lib->set_lazy_loader($information->ic_content, 'https://data.thailandhighlights.com/grey.gif'); + $template = str_replace('', $lazy_content, $template); + + //Google广告代码 + //if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) { + $template = str_replace('', '', $template); + //} + //社媒分享图片 + + $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)) { + $template = str_replace('', '', $template); + } + + // 设置图片尺寸 + // 优化过图片目录:D:\wwwroot\origin-images.chinahighlights.com\optimize\ + $www_local_path = 'D:/wwwroot/origin-www.thailandhighlights.com'; + $image_local_path = 'D:/wwwroot/origin-images.thailandhighlights.com/optimize'; + if (is_dir($www_local_path) && is_dir($image_local_path)) { + $template = $this->html_optimize_lib->set_image_size_local($template, $www_local_path, $image_local_path); + } else { + $template = $this->html_optimize_lib->set_image_size($template); + } + // /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm + $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) == '/') { + $html_path = $html_path . 'index.htm'; + } + $html_path .= $html_path_ext; + create_folder_by_path(dirname($html_path)); + file_put_contents($html_path, $template, LOCK_EX); + } + public function make_www_cache_jh($device, $information, $recommand_information) { $data = []; diff --git a/application/helpers/info_helper.php b/application/helpers/info_helper.php index 3ce6fd2c..008b9183 100644 --- a/application/helpers/info_helper.php +++ b/application/helpers/info_helper.php @@ -103,7 +103,7 @@ function is_mobile_first() { $CI = &get_instance(); $sitecode = $CI->config->item('site_code'); - if ($sitecode == 'ch' || $sitecode == 'ah' || $sitecode == 'htravel' || $sitecode == 'chinatravel' || $sitecode == 'gh' || $sitecode == 'jh' || $sitecode == 'shanghai' || $sitecode=='beijing' || $sitecode == "trainspread" || $sitecode=="guilin" || $sitecode=="hly" || $sitecode=="hlyen") { + if ($sitecode == 'ch' || $sitecode == 'ah' || $sitecode == 'htravel' || $sitecode == 'chinatravel' || $sitecode == 'gh' || $sitecode == 'jh' || $sitecode == 'thailand' || $sitecode == 'shanghai' || $sitecode=='beijing' || $sitecode == "trainspread" || $sitecode=="guilin" || $sitecode=="hly" || $sitecode=="hlyen") { return true; } else { return false;