From 7fe372f5567a9c6063fe35af221c03e4f047f06d Mon Sep 17 00:00:00 2001
From: LMR <59361885@qq.com>
Date: Thu, 21 Aug 2025 13:41:11 +0800
Subject: [PATCH] fix new gm domain
---
application/config/config.php | 6 +-
application/controllers/welcome.php | 735 +++++++++---------
application/libraries/Amplib.php | 257 +++---
.../htmlcompressor/controllers/index_ah.php | 725 ++++++++---------
.../htmlcompressor/controllers/index_gm.php | 725 ++++++++---------
.../htmlcompressor/views/amp-template/gm.php | 6 +-
.../order/views/gm/confirm_order.php | 84 +-
.../order/views/gm/confirm_order_back.php | 66 +-
.../third_party/order/views/gm/link_tips.php | 16 +-
application/views/bootstrap/footer.php | 8 +-
application/views/bootstrap3/footer.php | 2 +-
application/views/bootstrap3/header.php | 120 +--
.../views/bootstrap3/information_edit.php | 642 +++++++--------
application/views/mobile_first/gh.php | 2 +-
author/config/config.php | 109 ++-
splunk/order/search.php | 424 +++++-----
webht/config/config.php | 92 ++-
.../pay/language/de/ipl_common_lang.php | 4 +-
wysiwyg/ckfinder/config.php | 257 +++---
19 files changed, 2137 insertions(+), 2143 deletions(-)
diff --git a/application/config/config.php b/application/config/config.php
index 2e55c145..f793a0c3 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -397,7 +397,7 @@ $config['site'] = [
'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,']],
'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.chinarundreisen.com', 'site_image_url' => '//bilder.chinarundreisen.com', '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,'],
+ '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,'],
'vc' => ['site_code' => 'vc', 'site_id' => 30, 'site_lgc' => '5', 'site_url' => 'https://www.chinahighlights.fr', 'site_image_url' => '//images.chinahighlights.fr', 'site_authors' => ['JE', 'kq', 'lya', 'lyz', 'zyh'], 'site_user' => ',ycc,lmr, zyh,JE,htc,kq,lya,bhn,Tony,zyh,B,J,lyz,LYY,'],
'gh_vc' => ['site_code' => 'gh_vc', 'site_id' => 180, 'site_lgc' => '5', 'site_url' => 'https://www.globalhighlights.fr', 'site_image_url' => '//www.globalhighlights.fr', 'site_authors' => ['JE', 'kq', 'lya', 'lyz', 'zyh'], 'site_user' => ',ycc,lmr, zyh,JE,htc,kq,lya,bhn,Tony,zyh,B,J,lyz,LYY,'],
@@ -450,7 +450,7 @@ $config['cache']['gh_it']['cache_path'] = 'D:\wwwcache-intl\globalhighlights.it
//静态文件站点域名
$config['cache']['jp']['site_url'] = 'https://www.arachina.com';
-$config['cache']['gm']['site_url'] = 'https://www.chinarundreisen.com';
+$config['cache']['gm']['site_url'] = 'https://www.chinahighlightstravel.de';
$config['cache']['vc']['site_url'] = 'https://www.chinahighlights.fr';
$config['cache']['vac']['site_url'] = 'https://www.chinahighlights.es';
$config['cache']['ru']['site_url'] = 'https://www.chinahighlights.ru';
@@ -534,7 +534,7 @@ $config['access_super_manage'] = ['ycc', 'lmr', 'lyj', 'rz', 'zp'];
$config['css_source_cht'] = 'https://data.chinahighlights.com/css/min.php?f=/public/css/global.min.css,/css/festival-detail.css';
$config['css_source_ch'] = 'https://data.chinahighlights.com/css/mobile-first.css';
-$config['css_source_gm'] = 'https://data.chinarundreisen.com/public/pkg/css/baselAlRkXMnl750806T065919409Z.css';
+$config['css_source_gm'] = 'https://data.chinahighlightstravel.de/public/pkg/css/baselAlRkXMnl750806T065919409Z.css';
$config['css_source_vc'] = 'https://data.chinahighlights.fr/information-view/tools/min/?v=20150611&f=/bootstrap/css/bootstrap.min.css,/information/css/base.css,/information/css/r/Header.css,/information/css/r/PublicContent.css,/information/css/r/footergray.css,/information/js/i18n/jquery.ui.datepicker/smoothness/jquery.min.css,/information/css/tip-yellowsimple/tip-yellowsimple.css,/information/css/private-vc.css';
$config['css_source_vac'] = 'https://data.viaje-a-china.com/information-view/tools/min/?v=20150611&f=/bootstrap/css/bootstrap.min.css,/information/css/base.css,/information/css/r/Header.css,/information/css/r/PublicContent.css,/information/css/r/footergray.css,/information/js/i18n/jquery.ui.datepicker/smoothness/jquery.min.css,/information/css/tip-yellowsimple/tip-yellowsimple.css,/information/css/private-vac.css';
diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php
index 7a1471c4..2883a175 100644
--- a/application/controllers/welcome.php
+++ b/application/controllers/welcome.php
@@ -1,408 +1,405 @@
permission->is_admin();
- //$this->output->enable_profiler(TRUE);
- $this->load->model('Area_model');
- $this->load->model('InfoStructures_model');
- $this->load->model('Information_model');
- $this->load->model('InfoContents_model');
- $this->load->model('Coupon_model');
- $this->load->model('Logs_model');
+ function __construct() {
+ parent::__construct();
+ $this->permission->is_admin();
+ //$this->output->enable_profiler(TRUE);
+ $this->load->model('Area_model');
+ $this->load->model('InfoStructures_model');
+ $this->load->model('Information_model');
+ $this->load->model('InfoContents_model');
+ $this->load->model('Coupon_model');
+ $this->load->model('Logs_model');
+ }
+
+ public function index() {
+ $data = [];
+ $data['countryList'] = $this->Area_model->get_country_list();
+ $data['provinceList'] = $this->Area_model->get_province_list();
+ $data['city_list'] = $this->Area_model->get_municipalities_list();
+ $data['lastEditList'] = $this->Information_model->get_last_edit_list();
+ $data['last_city_list'] = $this->Area_model->get_last_edit_city();
+
+ $data['groupList'] = $this->Information_model->group_list();
+
+ if (is_mobile_first()) {
+
+ $this->load->view('bootstrap3/header', $data);
+ $this->load->view('bootstrap3/welcome');
+ $this->load->view('bootstrap3/footer');
+ return;
}
- public function index() {
- $data=array();
- $data['countryList'] = $this->Area_model->get_country_list();
- $data['provinceList'] = $this->Area_model->get_province_list();
- $data['city_list'] = $this->Area_model->get_municipalities_list();
- $data['lastEditList'] = $this->Information_model->get_last_edit_list();
- $data['last_city_list'] = $this->Area_model->get_last_edit_city();
-
- $data['groupList']=$this->Information_model->group_list();
-
- if(is_mobile_first() ){
-
- $this->load->view('bootstrap3/header', $data);
- $this->load->view('bootstrap3/welcome');
- $this->load->view('bootstrap3/footer');
- return;
- }
-
-
-
-
- if ($this->config->item('site_code') == 'pgr') {
- $data['countryList'] = $this->Area_model->get_country_list_for_site("'589','645','632','517','31','28','609','630','9','708','709'");
- }
-
- $this->load->view('bootstrap/header', $data);
- $this->load->view('bootstrap/welcome');
- $this->load->view('bootstrap/footer');
+ if ($this->config->item('site_code') == 'pgr') {
+ $data['countryList'] = $this->Area_model->get_country_list_for_site("'589','645','632','517','31','28','609','630','9','708','709'");
}
-
-
-
-
- public function search($isrecommend = false) {
- //先搜索url,如果找到唯一就跳走,多于一条的则列出来,一条没有的就去搜索信息
- $data['keywords'] = $this->input->post('keywords');
- $data['all_text_search'] = $this->input->post('all_text_search'); //全文搜索
- $search_url = str_replace($this->config->item('site_url'), "", $data['keywords']);
- $data['search_list'] = $this->Information_model->search_url($search_url);
- if (count($data['search_list']) === 0) {
- if (!empty($data['all_text_search']) && $data['all_text_search'] == 'true') {
- $data['search_list'] = $this->Information_model->search_all_text($data['keywords'],48);
- } else {
- $data['search_list'] = $this->Information_model->search($data['keywords']);
- }
- }
-
- if ($isrecommend) {
- $data['ic_id_list'] = $this->input->post('ic_id_list') == '' ? '0' : $this->input->post('ic_id_list');
- $this->load->view('bootstrap3/recommendlist', $data);
- return TRUE;
- } else if (count($data['search_list']) === 1) {
- redirect(site_url('information/edit/' . $data['search_list'][0]->is_id));
- }
- $data['countryList'] = $this->Area_model->get_country_list();
- $data['provinceList'] = $this->Area_model->get_province_list();
- $data['city_list'] = $this->Area_model->get_municipalities_list();
-
- $this->load->view('bootstrap/header', $data);
- $this->load->view('bootstrap/welcome');
- $this->load->view('bootstrap/footer');
+ $this->load->view('bootstrap/header', $data);
+ $this->load->view('bootstrap/welcome');
+ $this->load->view('bootstrap/footer');
+ }
+
+ public function search($isrecommend = false) {
+ //先搜索url,如果找到唯一就跳走,多于一条的则列出来,一条没有的就去搜索信息
+ $data['keywords'] = $this->input->post('keywords');
+ $data['all_text_search'] = $this->input->post('all_text_search'); //全文搜索
+ $search_url = str_replace($this->config->item('site_url'), "", $data['keywords']);
+ $data['search_list'] = $this->Information_model->search_url($search_url);
+ if (count($data['search_list']) === 0) {
+ if (! empty($data['all_text_search']) && $data['all_text_search'] == 'true') {
+ $data['search_list'] = $this->Information_model->search_all_text($data['keywords'], 48);
+ } else {
+ $data['search_list'] = $this->Information_model->search($data['keywords']);
+ }
}
- //获取所有信息URL,用来批量静态化更新
- public function create_all_urls($view=false) {
- set_time_limit(0);
- $this->output->enable_profiler(false);
- $data['all_information'] = $this->Information_model->GetList('ic_status,ic_id,ic_url,ic_sitecode,is_id');
- if ($view == 'amp') {
- $this->load->view('bootstrap3/header', $data);
- $this->load->view('bootstrap3/refresh_amp_urls');
- $this->load->view('bootstrap3/footer');
- } else {
- $this->load->view('bootstrap/header', $data);
- $this->load->view('bootstrap/cache_url', $data);
- $this->load->view('bootstrap/footer');
- }
+ if ($isrecommend) {
+ $data['ic_id_list'] = $this->input->post('ic_id_list') == '' ? '0' : $this->input->post('ic_id_list');
+ $this->load->view('bootstrap3/recommendlist', $data);
+ return TRUE;
+ } else if (count($data['search_list']) === 1) {
+ redirect(site_url('information/edit/' . $data['search_list'][0]->is_id));
}
- //获取某个信息节点和子节点url
- //$is_parent_id 结构id或者是url
- public function create_infomation_urls($is_parent_id, $view = false) {
- $ic_url=$this->input->get_post('ic_url');
- if(!empty($ic_url)){
- $structure = $this->Information_model->Detail($ic_url);
- }else{
- $structure = $this->InfoStructures_model->Detail($is_parent_id);
- }
-
- if (empty($structure)) {
- show_404();
- return false;
- }
- $data['all_information'] = $this->Information_model->get_list_by_path($structure->is_path,false,false,'is_id,ic_url,ic_id,ic_status');
- $this->load->view('bootstrap3/header', $data);
- switch ($view){
- case 'amp':
- $this->load->view('bootstrap3/refresh_amp_urls');
- break;
- case 'mobile-first':
- $this->load->view('bootstrap3/refresh_mobile_first_urls');
- break;
- default:
- $this->load->view('bootstrap/cache_url', $data);
-
- }
- $this->load->view('bootstrap/footer');
+ $data['countryList'] = $this->Area_model->get_country_list();
+ $data['provinceList'] = $this->Area_model->get_province_list();
+ $data['city_list'] = $this->Area_model->get_municipalities_list();
+
+ $this->load->view('bootstrap/header', $data);
+ $this->load->view('bootstrap/welcome');
+ $this->load->view('bootstrap/footer');
+ }
+
+ //获取所有信息URL,用来批量静态化更新
+ public function create_all_urls($view = false) {
+ set_time_limit(0);
+ $this->output->enable_profiler(false);
+ $data['all_information'] = $this->Information_model->GetList('ic_status,ic_id,ic_url,ic_sitecode,is_id');
+ if ($view == 'amp') {
+ $this->load->view('bootstrap3/header', $data);
+ $this->load->view('bootstrap3/refresh_amp_urls');
+ $this->load->view('bootstrap3/footer');
+ } else {
+ $this->load->view('bootstrap/header', $data);
+ $this->load->view('bootstrap/cache_url', $data);
+ $this->load->view('bootstrap/footer');
}
-
- //根据信息节点ID获取信息,用于搜索结果的批量更新静态页面
- public function create_infomation_urls_by_ids($view = false){
- $is_ids=$this->input->get('key');
- if (empty($is_ids)) {
- show_404();
- return false;
- }
- $data['all_information'] = $this->Information_model->get_detail_by_ids($is_ids);
- if ($view == 'amp') {
- $this->load->view('bootstrap3/header', $data);
- $this->load->view('bootstrap3/refresh_amp_urls');
- $this->load->view('bootstrap3/footer');
- } else {
- $this->load->view('bootstrap/header', $data);
- $this->load->view('bootstrap/cache_url', $data);
- $this->load->view('bootstrap/footer');
- }
- }
-
- public function get_infomation_urls($is_parent_id) {
- $this->output->enable_profiler(FALSE);
- $structure = $this->InfoStructures_model->Detail($is_parent_id);
- if (empty($structure)) {
- show_404();
- return false;
- }
- $data['all_information'] = $this->Information_model->get_list_by_path($structure->is_path);
-
- $this->load->view('bootstrap/header', $data);
- $this->load->view('bootstrap/static_url', $data);
- $this->load->view('bootstrap/footer');
+ }
+
+ //获取某个信息节点和子节点url
+ //$is_parent_id 结构id或者是url
+ public function create_infomation_urls($is_parent_id, $view = false) {
+ $ic_url = $this->input->get_post('ic_url');
+ if (! empty($ic_url)) {
+ $structure = $this->Information_model->Detail($ic_url);
+ } else {
+ $structure = $this->InfoStructures_model->Detail($is_parent_id);
}
- public function get_info_backup_id($info_id) {
- $last_backup = $this->Logs_model->get_last_backup($info_id);
- if (empty($last_backup)) {
- $this->echo_json(array(
- 'status' => 'error',
- 'logId' => 0,
- 'datetime' => 0,
- 'username' => 0
- ));
- } else {
- $this->echo_json(array(
- 'status' => 'success',
- 'logId' => $last_backup->log_id,
- 'datetime' => $last_backup->log_datetime,
- 'username' => $last_backup->log_ht_username
- ));
- }
+ if (empty($structure)) {
+ show_404();
+ return false;
}
-
- public function change_static_url($info_id) {
- $information = $this->Information_model->Detail($info_id);
- $htm_doc = new DOMDocument();
- $htm_doc->encoding = 'UTF-8';
- libxml_use_internal_errors(true);
- $htm_doc->strictErrorChecking = false;
- if (empty($information->ic_content)) {
- $this->echo_json(array(
- 'status' => 'error',
- 'infoId' => $info_id,
- 'message' => 'info content is empty'
- ));
- return;
- }
- $htm_doc->loadHTML(
- mb_convert_encoding($information->ic_content, 'HTML-ENTITIES', 'UTF-8'));
- $htm_doc->normalizeDocument();
- $img_list = $htm_doc->getElementsByTagName('img');
- foreach ($img_list as $img) {
- $img_src = $img->getAttribute('src');
- $img_src = $this->check_url($img_src);
- $img->setAttribute('src', $img_src);
- }
-
- $anchor_list = $htm_doc->getElementsByTagName('a');
- foreach ($anchor_list as $anchor) {
- $a_href = $anchor->getAttribute('href');
- echo 'a.href: ' . $a_href . '
';
-
- $match_result = array();
- preg_match('/^http:\/\/www.chinahighlights.com(.*)/', $a_href, $match_result);
- $result_count = count($match_result);
- if ($result_count == 2) {
- $result = '//www.chinahighlights.com' . $match_result[1];
- $anchor->setAttribute('href', $result);
- echo $result . '
';
- }
- }
+ $data['all_information'] = $this->Information_model->get_list_by_path($structure->is_path, false, false, 'is_id,ic_url,ic_id,ic_status');
+ $this->load->view('bootstrap3/header', $data);
+ switch ($view) {
+ case 'amp':
+ $this->load->view('bootstrap3/refresh_amp_urls');
+ break;
+ case 'mobile-first':
+ $this->load->view('bootstrap3/refresh_mobile_first_urls');
+ break;
+ default:
+ $this->load->view('bootstrap/cache_url', $data);
}
-
- public function count_redirect_nofollow() {
- $include_redirece_info = $this->Information_model->search_all_text('&t=78002', 2000);
- echo 'redirect count: ' . count($include_redirece_info) . '
';
- $redirect_nofollow_list = array();
- $htm_doc = new DOMDocument();
- $htm_doc->encoding = 'UTF-8';
- libxml_use_internal_errors(true);
- $htm_doc->strictErrorChecking = false;
- foreach ($include_redirece_info 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_href = $anchor->getAttribute('href');
- $a_rel = $anchor->getAttribute('rel');
-
- $match_result = array();
- preg_match('/.*&t=78002$/', $a_href, $match_result);
- $result_count = count($match_result);
- if ($result_count > 0 && $a_rel != 'nofollow') {
- echo $info->ic_url . ' | ' . '(' . $info->ic_id . ',' . $info->is_id . ')' . '
';
- echo 'a.href: ' . $a_href . '; rel: ' . $a_rel . '
';
- $redirect_nofollow_list[] = $info;
- }
- }
- }
- echo 'nofollow_count: ' . count($redirect_nofollow_list) . '
';
- return $redirect_nofollow_list;
+ $this->load->view('bootstrap/footer');
+ }
+
+ //根据信息节点ID获取信息,用于搜索结果的批量更新静态页面
+ public function create_infomation_urls_by_ids($view = false) {
+ $is_ids = $this->input->get('key');
+ if (empty($is_ids)) {
+ show_404();
+ return false;
}
-
- 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) . '
';
+ $data['all_information'] = $this->Information_model->get_detail_by_ids($is_ids);
+ if ($view == 'amp') {
+ $this->load->view('bootstrap3/header', $data);
+ $this->load->view('bootstrap3/refresh_amp_urls');
+ $this->load->view('bootstrap3/footer');
+ } else {
+ $this->load->view('bootstrap/header', $data);
+ $this->load->view('bootstrap/cache_url', $data);
+ $this->load->view('bootstrap/footer');
}
-
- 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 get_infomation_urls($is_parent_id) {
+ $this->output->enable_profiler(FALSE);
+ $structure = $this->InfoStructures_model->Detail($is_parent_id);
+ if (empty($structure)) {
+ show_404();
+ return false;
}
-
- public function transform_href_to_https() {
- $http_host = 'http://www.chinahighlights.com/';
- $https_host = 'https://www.chinahighlights.com/';
- $data['all_information'] = $this->Information_model->search_all_text($http_host, 200);
- echo 'count: ' . count($data['all_information']) . '
';
- if (empty($data['all_information'])) {
- echo 'nothing transform to https';
- } else {
- foreach ($data['all_information'] as $item) {
-
- if (empty($item->ic_url)) {
- echo '[' . $item->ic_title . '] [' . $item->ic_url . ']
';
- continue;
- } else {
- echo $item->ic_url . ' | ' . $item->ic_title . '
';
- }
-
- $this->Logs_model->backup($item->is_id, $item->ic_content);
- $item->ic_content = str_replace($http_host, $https_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
- );
- }
- }
+ $data['all_information'] = $this->Information_model->get_list_by_path($structure->is_path);
+
+ $this->load->view('bootstrap/header', $data);
+ $this->load->view('bootstrap/static_url', $data);
+ $this->load->view('bootstrap/footer');
+ }
+
+ public function get_info_backup_id($info_id) {
+ $last_backup = $this->Logs_model->get_last_backup($info_id);
+ if (empty($last_backup)) {
+ $this->echo_json([
+ 'status' => 'error',
+ 'logId' => 0,
+ 'datetime' => 0,
+ 'username' => 0,
+ ]);
+ } else {
+ $this->echo_json([
+ 'status' => 'success',
+ 'logId' => $last_backup->log_id,
+ 'datetime' => $last_backup->log_datetime,
+ 'username' => $last_backup->log_ht_username,
+ ]);
}
-
- private function echo_json($obj) {
- $this->output
- ->set_content_type('application/json')
- ->set_output(json_encode($obj));
+ }
+
+ public function change_static_url($info_id) {
+ $information = $this->Information_model->Detail($info_id);
+ $htm_doc = new DOMDocument();
+ $htm_doc->encoding = 'UTF-8';
+ libxml_use_internal_errors(true);
+ $htm_doc->strictErrorChecking = false;
+ if (empty($information->ic_content)) {
+ $this->echo_json([
+ 'status' => 'error',
+ 'infoId' => $info_id,
+ 'message' => 'info content is empty',
+ ]);
+ return;
}
-
- //批量替换二级域名,如图片或者data域名
- function replace_hostname($topnum) {
- $data = array();
- $find_host = 'http://data.chinarundreisen.com/'; //http://bilder.chinarundreisen.com/
- $new_host = '//data.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';
- }
+ $htm_doc->loadHTML(
+ mb_convert_encoding($information->ic_content, 'HTML-ENTITIES', 'UTF-8'));
+ $htm_doc->normalizeDocument();
+ $img_list = $htm_doc->getElementsByTagName('img');
+ foreach ($img_list as $img) {
+ $img_src = $img->getAttribute('src');
+ $img_src = $this->check_url($img_src);
+ $img->setAttribute('src', $img_src);
}
- private function check_url($subject) {
- $result = $subject;
- $check_rules = array(
- '/^\/image\/(.*)/' => '//data.chinahighlights.com/image/',
- '/^\/pic\/(.*)/' => '//data.chinahighlights.com/pic/',
- '/^\/allpicture\/(.*)/' => '//data.chinahighlights.com/allpicture/',
- '/^http:\/\/images.chinahighlights.com(.*)/' => '//images.chinahighlights.com',
- '/^http:\/\/data.chinahighlights.com(.*)/' => '//data.chinahighlights.com',
- '/^http:\/\/www.chinahighlights.com(.*)/' => '//www.chinahighlights.com');
-
- foreach ($check_rules as $pattern => $replace) {
- $result = $this->replace_url($pattern, $replace, $result);
- }
- return $result;
+ $anchor_list = $htm_doc->getElementsByTagName('a');
+ foreach ($anchor_list as $anchor) {
+ $a_href = $anchor->getAttribute('href');
+ echo 'a.href: ' . $a_href . '
';
+
+ $match_result = [];
+ preg_match('/^http:\/\/www.chinahighlights.com(.*)/', $a_href, $match_result);
+ $result_count = count($match_result);
+ if ($result_count == 2) {
+ $result = '//www.chinahighlights.com' . $match_result[1];
+ $anchor->setAttribute('href', $result);
+ echo $result . '
';
+ }
}
- private function replace_url($pattern, $replace, $subject) {
- $result = $subject;
- $match_result = array();
- preg_match($pattern, $subject, $match_result);
+ }
+
+ public function count_redirect_nofollow() {
+ $include_redirece_info = $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);
+ $htm_doc->strictErrorChecking = false;
+ foreach ($include_redirece_info 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_href = $anchor->getAttribute('href');
+ $a_rel = $anchor->getAttribute('rel');
+
+ $match_result = [];
+ preg_match('/.*&t=78002$/', $a_href, $match_result);
$result_count = count($match_result);
- if ($result_count == 2) {
- $result = $replace . $match_result[1];
+ if ($result_count > 0 && $a_rel != 'nofollow') {
+ echo $info->ic_url . ' | ' . '(' . $info->ic_id . ',' . $info->is_id . ')' . '
';
+ echo 'a.href: ' . $a_href . '; rel: ' . $a_rel . '
';
+ $redirect_nofollow_list[] = $info;
}
- return $result;
+ }
+ }
+ 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);
+ }
}
- //生肖促销订单查询
- public function coupon() {
- $data['countryList'] = $this->Area_model->get_country_list();
- $data['provinceList'] = $this->Area_model->get_province_list();
- $data['city_list'] = $this->Area_model->get_municipalities_list();
- $data['coupon'] = $this->Coupon_model->getlist();
+ echo 'update_nofollow_count: ' . count($redirect_nofollow_list) . '
';
+ }
+
+ 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() {
+ $http_host = 'http://www.chinahighlights.com/';
+ $https_host = 'https://www.chinahighlights.com/';
+ $data['all_information'] = $this->Information_model->search_all_text($http_host, 200);
+ echo 'count: ' . count($data['all_information']) . '
';
+ if (empty($data['all_information'])) {
+ echo 'nothing transform to https';
+ } else {
+ foreach ($data['all_information'] as $item) {
+
+ if (empty($item->ic_url)) {
+ echo '[' . $item->ic_title . '] [' . $item->ic_url . ']
';
+ continue;
+ } else {
+ echo $item->ic_url . ' | ' . $item->ic_title . '
';
+ }
- $this->load->view('bootstrap/header', $data);
- $this->load->view('bootstrap/welcome');
- $this->load->view('bootstrap/footer');
+ $this->Logs_model->backup($item->is_id, $item->ic_content);
+ $item->ic_content = str_replace($http_host, $https_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
+ );
+ }
}
-
- public function set_path($is_id, $parent_path = '') {
- $parent_path = str_replace('-', ',', $parent_path);
- $parent_path = trim($parent_path, ',');
- if ($parent_path != '')
- $parent_path .= ',';
- $this->load->model('Import_model');
- $this->Import_model->set_path($is_id, $parent_path);
- echo 'ok';
+ }
+
+ private function echo_json($obj) {
+ $this->output
+ ->set_content_type('application/json')
+ ->set_output(json_encode($obj));
+ }
+
+ //批量替换二级域名,如图片或者data域名
+ function replace_hostname($topnum) {
+ $data = [];
+ $find_host = 'http://data.chinahighlightstravel.de/'; //http://images.chinahighlightstravel.de/
+ $new_host = '//data.chinahighlightstravel.de/';
+ $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';
}
-
- public function search_by_icid() {
- $ic_id_list = $this->input->post('ic_id_list');
- $ic_id_list = rtrim(trim($ic_id_list), ',') . ',';
- $this->load->model('InfoContents_model');
- $data['search_list'] = $this->InfoContents_model->get_ic_contents_by_list($ic_id_list);
- $data['search_type'] = 'recommended';
- $this->load->view('bootstrap3/recommendlist', $data);
+ }
+
+ private function check_url($subject) {
+ $result = $subject;
+ $check_rules = [
+ '/^\/image\/(.*)/' => '//data.chinahighlights.com/image/',
+ '/^\/pic\/(.*)/' => '//data.chinahighlights.com/pic/',
+ '/^\/allpicture\/(.*)/' => '//data.chinahighlights.com/allpicture/',
+ '/^http:\/\/images.chinahighlights.com(.*)/' => '//images.chinahighlights.com',
+ '/^http:\/\/data.chinahighlights.com(.*)/' => '//data.chinahighlights.com',
+ '/^http:\/\/www.chinahighlights.com(.*)/' => '//www.chinahighlights.com'];
+
+ foreach ($check_rules as $pattern => $replace) {
+ $result = $this->replace_url($pattern, $replace, $result);
}
-
- /**
- * @description: 用于生成一个特殊的根结点is_level和is_sort都为0,CT移动优先项目用
- * @param {type}
- * @return:
- * @Date Changed:
- */
- public function AddRootNote(){
- $this->InfoContents_model->Add('', 'NewRootNote', 'root', 'NewRootNote', '', '', '', '', '', 0, 0, '', '', 0, 0, '', '', '', '', 0,
- '','');
- $this->InfoStructures_model->AddRootNote($this->InfoContents_model->insert_id);
- $is_id = $this->InfoStructures_model->insert_id;
- redirect(site_url('information/edit/' . $is_id));
+ return $result;
+ }
+
+ private function replace_url($pattern, $replace, $subject) {
+ $result = $subject;
+ $match_result = [];
+ preg_match($pattern, $subject, $match_result);
+ $result_count = count($match_result);
+ if ($result_count == 2) {
+ $result = $replace . $match_result[1];
}
+ return $result;
+ }
+
+ //生肖促销订单查询
+ public function coupon() {
+ $data['countryList'] = $this->Area_model->get_country_list();
+ $data['provinceList'] = $this->Area_model->get_province_list();
+ $data['city_list'] = $this->Area_model->get_municipalities_list();
+ $data['coupon'] = $this->Coupon_model->getlist();
+
+ $this->load->view('bootstrap/header', $data);
+ $this->load->view('bootstrap/welcome');
+ $this->load->view('bootstrap/footer');
+ }
+
+ public function set_path($is_id, $parent_path = '') {
+ $parent_path = str_replace('-', ',', $parent_path);
+ $parent_path = trim($parent_path, ',');
+ if ($parent_path != '') {
+ $parent_path .= ',';
+ }
+
+ $this->load->model('Import_model');
+ $this->Import_model->set_path($is_id, $parent_path);
+ echo 'ok';
+ }
+
+ public function search_by_icid() {
+ $ic_id_list = $this->input->post('ic_id_list');
+ $ic_id_list = rtrim(trim($ic_id_list), ',') . ',';
+ $this->load->model('InfoContents_model');
+ $data['search_list'] = $this->InfoContents_model->get_ic_contents_by_list($ic_id_list);
+ $data['search_type'] = 'recommended';
+ $this->load->view('bootstrap3/recommendlist', $data);
+ }
+
+ /**
+ * @description: 用于生成一个特殊的根结点is_level和is_sort都为0,CT移动优先项目用
+ * @param {type}
+ * @return:
+ * @Date Changed:
+ */
+ public function AddRootNote() {
+ $this->InfoContents_model->Add('', 'NewRootNote', 'root', 'NewRootNote', '', '', '', '', '', 0, 0, '', '', 0, 0, '', '', '', '', 0,
+ '', '');
+ $this->InfoStructures_model->AddRootNote($this->InfoContents_model->insert_id);
+ $is_id = $this->InfoStructures_model->insert_id;
+ redirect(site_url('information/edit/' . $is_id));
+ }
}
diff --git a/application/libraries/Amplib.php b/application/libraries/Amplib.php
index 026435ab..73866d9a 100644
--- a/application/libraries/Amplib.php
+++ b/application/libraries/Amplib.php
@@ -1,152 +1,149 @@
CI = &get_instance();
- $this->CI->load->model('Information_model');
- $this->CI->load->model('InfoMetas_model');
- $this->CI->load->model('Logs_model');
- }
+ var $CI;
- public function edit($ic_id)
- {
- $data = array();
- $data['information'] = $this->CI->Information_model->detail_by_ic_id($ic_id);
- if ($data['information'] == FALSE) {
- show_404();
- }
- //查询上一次保存记录
- $amp_log = $this->CI->Logs_model->get_last_edit_amp($ic_id);
- if (!empty($amp_log)) {
- $data['last_edit_amp_id'] = $amp_log->log_id;
- } else {
- $data['last_edit_amp_id'] = '';
- }
+ public function __construct() {
+ $this->CI = &get_instance();
+ $this->CI->load->model('Information_model');
+ $this->CI->load->model('InfoMetas_model');
+ $this->CI->load->model('Logs_model');
+ }
- $this->CI->load->view('bootstrap3/header', $data);
- $this->CI->load->view('amp_editor');
- $this->CI->load->view('bootstrap3/footer');
+ public function edit($ic_id) {
+ $data = [];
+ $data['information'] = $this->CI->Information_model->detail_by_ic_id($ic_id);
+ if ($data['information'] == FALSE) {
+ show_404();
+ }
+ //查询上一次保存记录
+ $amp_log = $this->CI->Logs_model->get_last_edit_amp($ic_id);
+ if (! empty($amp_log)) {
+ $data['last_edit_amp_id'] = $amp_log->log_id;
+ } else {
+ $data['last_edit_amp_id'] = '';
}
- public function auto_create($ic_id)
- {
- $data = array();
- if (strtolower($this->CI->config->item('site_code')) == 'cht') {
- $this->CI->Information_model->ic_type = "AND ic.ic_type != 'none'";
- }
- $data['information'] = $this->CI->Information_model->detail_by_ic_id($ic_id);
- if ($data['information'] == FALSE) {
- return json_encode(array('result' => 'no', 'data' => '找不到这个页面'));
- }
+ $this->CI->load->view('bootstrap3/header', $data);
+ $this->CI->load->view('amp_editor');
+ $this->CI->load->view('bootstrap3/footer');
+ }
- //144.76.185.44:8029
- //根据站点不同,配置不同参数
- $site_code = strtolower($this->CI->config->item('site_code'));
- switch ($site_code) {
- case 'ah':
- //websitehost是表示资源下载的域名,在网页代码中有/css/xxx.css之类的路径,程序需要添加域名组成完整URL去下载文件,一般是data域名或者www域名
- $websitehost = 'https://data.asiahighlights.com';
- $html_source_url = 'https://www.asiahighlights.com/index.php/information/detail/?no_cache=true&static_html_url=' . $data['information']->ic_url;
- break;
- case 'cht':
- $websitehost = 'https://data.chinahighlights.com';
- $html_source_url = 'http://169.54.172.35:3588' . $data['information']->ic_url;
- break;
- case 'gm':
- $websitehost = 'https://data.chinarundreisen.com';
- $html_source_url = 'https://www.chinarundreisen.com/' . $data['information']->ic_url;
- break;
- case 'ct':
- $websitehost = 'https://data.chinatravel.com';
- $html_source_url = 'http://158.85.210.78:2222' . $data['information']->ic_url;
- break;
- default:
- $websitehost = $this->CI->config->item('site_url');
- $html_source_url = $this->CI->config->item('site_url') . $data['information']->ic_url;
- }
- //获取网页当前源码,然后发送到信息平台
- $html_source = GET_HTTP($html_source_url);
- if (!empty($html_source)) {
- $post_data = array('websitehost' => $websitehost, 'template_name' => $site_code, 'create_amp' => 'true', 'htmlsource' => $html_source);
- //德语站点走另外一个控制器,其他站点还是走原来的流程
- if ($site_code == 'gm') {
- if ($data['information']->ic_url == '/massgeschneiderte-china-reisen/') {
- return json_encode(array());
- } else {
- return GET_HTTP(site_url('/apps/htmlcompressor/index_gm/choose_way'), $post_data, 'POST');
- }
- } elseif ($site_code == 'ah') {
- return GET_HTTP(site_url('/apps/htmlcompressor/index_ah/choose_way'), $post_data, 'POST');
- } else {
- return GET_HTTP(site_url('/apps/htmlcompressor/index/optimize'), $post_data, 'POST');
- }
- }
- return json_encode(array('result' => 'no', 'data' => '不知道哪里错了,看代码'));
+ public function auto_create($ic_id) {
+ $data = [];
+ if (strtolower($this->CI->config->item('site_code')) == 'cht') {
+ $this->CI->Information_model->ic_type = "AND ic.ic_type != 'none'";
+ }
+ $data['information'] = $this->CI->Information_model->detail_by_ic_id($ic_id);
+ if ($data['information'] == FALSE) {
+ return json_encode(['result' => 'no', 'data' => '找不到这个页面']);
}
- public function edit_save($ic_id = false, $textarea_htmlcode = false, $amp_status = false)
- {
- $data = array();
- if ($ic_id === false) {
- $ic_id = $this->CI->input->post('ic_id');
- }
- if ($textarea_htmlcode === false) {
- $textarea_htmlcode = $this->CI->input->post('textarea_htmlcode');
- }
- if ($amp_status === false) {
- $amp_status = $this->CI->input->post('amp_status');
+ //144.76.185.44:8029
+ //根据站点不同,配置不同参数
+ $site_code = strtolower($this->CI->config->item('site_code'));
+ switch ($site_code) {
+ case 'ah':
+ //websitehost是表示资源下载的域名,在网页代码中有/css/xxx.css之类的路径,程序需要添加域名组成完整URL去下载文件,一般是data域名或者www域名
+ $websitehost = 'https://data.asiahighlights.com';
+ $html_source_url = 'https://www.asiahighlights.com/index.php/information/detail/?no_cache=true&static_html_url=' . $data['information']->ic_url;
+ break;
+ case 'cht':
+ $websitehost = 'https://data.chinahighlights.com';
+ $html_source_url = 'http://169.54.172.35:3588' . $data['information']->ic_url;
+ break;
+ case 'gm':
+ $websitehost = 'https://data.chinahighlightstravel.de';
+ $html_source_url = 'https://www.chinarundreisen.com/' . $data['information']->ic_url;
+ break;
+ case 'ct':
+ $websitehost = 'https://data.chinatravel.com';
+ $html_source_url = 'http://158.85.210.78:2222' . $data['information']->ic_url;
+ break;
+ default:
+ $websitehost = $this->CI->config->item('site_url');
+ $html_source_url = $this->CI->config->item('site_url') . $data['information']->ic_url;
+ }
+ //获取网页当前源码,然后发送到信息平台
+ $html_source = GET_HTTP($html_source_url);
+ if (! empty($html_source)) {
+ $post_data = ['websitehost' => $websitehost, 'template_name' => $site_code, 'create_amp' => 'true', 'htmlsource' => $html_source];
+ //德语站点走另外一个控制器,其他站点还是走原来的流程
+ if ($site_code == 'gm') {
+ if ($data['information']->ic_url == '/massgeschneiderte-china-reisen/') {
+ return json_encode([]);
+ } else {
+ return GET_HTTP(site_url('/apps/htmlcompressor/index_gm/choose_way'), $post_data, 'POST');
}
- $data['information'] = $this->CI->Information_model->detail_by_ic_id($ic_id);
+ } elseif ($site_code == 'ah') {
+ return GET_HTTP(site_url('/apps/htmlcompressor/index_ah/choose_way'), $post_data, 'POST');
+ } else {
+ return GET_HTTP(site_url('/apps/htmlcompressor/index/optimize'), $post_data, 'POST');
+ }
+ }
+ return json_encode(['result' => 'no', 'data' => '不知道哪里错了,看代码']);
+ }
- if ($data['information'] == FALSE) {
- show_404();
- }
+ public function edit_save($ic_id = false, $textarea_htmlcode = false, $amp_status = false) {
+ $data = [];
+ if ($ic_id === false) {
+ $ic_id = $this->CI->input->post('ic_id');
+ }
+ if ($textarea_htmlcode === false) {
+ $textarea_htmlcode = $this->CI->input->post('textarea_htmlcode');
+ }
+ if ($amp_status === false) {
+ $amp_status = $this->CI->input->post('amp_status');
+ }
+ $data['information'] = $this->CI->Information_model->detail_by_ic_id($ic_id);
- //CH的页面没有canonical内容,在这里帮补上
- $textarea_htmlcode = str_replace('', $this->CI->config->item('site_url') . $data['information']->ic_url, $textarea_htmlcode);
-
- //备份修改的代码
- $this->CI->Logs_model->write('backup_amp', $ic_id, $textarea_htmlcode);
-
- //AMP格式验证
- if ($amp_status !== '0') {//只有发布的时候才需要验证
- //把AMP网页内容到purifycss处理,内置了AMP-Validator
- $purifycss_server = 'http://169.54.167.189:33033/';
- if ($this->CI->config->item('site_code' == 'gm')) {//德语站点使用自己的css处理服务器
- $purifycss_server = 'http://158.177.67.52:33033/';
- }
- $validator_result = GET_HTTP($purifycss_server, 'amp_source=' . urlencode($textarea_htmlcode), 'POST');
- $validator_result = json_decode($validator_result);
- if ($validator_result->status == 'FAIL') {
- return json_encode(array('name' => 'no', 'value' => $validator_result->errors));
- }
- }
- $amp = $this->CI->InfoMetas_model->get($ic_id, 'AMP');
- if ($amp === false) {
- $this->CI->InfoMetas_model->add($ic_id, 'AMP', $textarea_htmlcode);
- } else {
- $this->CI->InfoMetas_model->update($ic_id, 'AMP', $textarea_htmlcode);
- }
+ if ($data['information'] == FALSE) {
+ show_404();
+ }
- $amp_status_value = $this->CI->InfoMetas_model->get($ic_id, 'AMP_STATUS');
- if ($amp_status_value === false) {
- $this->CI->InfoMetas_model->add($ic_id, 'AMP_STATUS', $amp_status);
- } else {
- $this->CI->InfoMetas_model->update($ic_id, 'AMP_STATUS', $amp_status);
- }
+ //CH的页面没有canonical内容,在这里帮补上
+ $textarea_htmlcode = str_replace('', $this->CI->config->item('site_url') . $data['information']->ic_url, $textarea_htmlcode);
+
+ //备份修改的代码
+ $this->CI->Logs_model->write('backup_amp', $ic_id, $textarea_htmlcode);
+
+ //AMP格式验证
+ if ($amp_status !== '0') { //只有发布的时候才需要验证
+ //把AMP网页内容到purifycss处理,内置了AMP-Validator
+ $purifycss_server = 'http://169.54.167.189:33033/';
+ if ($this->CI->config->item('site_code' == 'gm')) { //德语站点使用自己的css处理服务器
+ $purifycss_server = 'http://158.177.67.52:33033/';
+ }
+ $validator_result = GET_HTTP($purifycss_server, 'amp_source=' . urlencode($textarea_htmlcode), 'POST');
+ $validator_result = json_decode($validator_result);
+ if ($validator_result->status == 'FAIL') {
+ return json_encode(['name' => 'no', 'value' => $validator_result->errors]);
+ }
+ }
+ $amp = $this->CI->InfoMetas_model->get($ic_id, 'AMP');
+ if ($amp === false) {
+ $this->CI->InfoMetas_model->add($ic_id, 'AMP', $textarea_htmlcode);
+ } else {
+ $this->CI->InfoMetas_model->update($ic_id, 'AMP', $textarea_htmlcode);
+ }
- return json_encode(array('name' => 'ok', 'value' => $this->CI->lang->line('form_info_success')));
+ $amp_status_value = $this->CI->InfoMetas_model->get($ic_id, 'AMP_STATUS');
+ if ($amp_status_value === false) {
+ $this->CI->InfoMetas_model->add($ic_id, 'AMP_STATUS', $amp_status);
+ } else {
+ $this->CI->InfoMetas_model->update($ic_id, 'AMP_STATUS', $amp_status);
}
+ return json_encode(['name' => 'ok', 'value' => $this->CI->lang->line('form_info_success')]);
+ }
+
}
diff --git a/application/third_party/htmlcompressor/controllers/index_ah.php b/application/third_party/htmlcompressor/controllers/index_ah.php
index f816bdbe..12b6fac1 100644
--- a/application/third_party/htmlcompressor/controllers/index_ah.php
+++ b/application/third_party/htmlcompressor/controllers/index_ah.php
@@ -1,167 +1,168 @@
load->library('simple_html_dom_lib');
- }
-
- public function index(){
- $this->load->view('welcome');
- }
-
- //选择处理方式
- public function choose_way(){
- $this->htmlsource = $this->input->post('htmlsource');
- $this->websitehost = $this->input->post('websitehost');
- $this->template_name = $this->input->post('template_name');
- $this->create_amp = $this->input->post('create_amp');
- $this->debug = $this->input->post('debug');
-
- /*$this->htmlsource = file_get_contents('aa.htm');
- $this->websitehost = 'https://data.chinarundreisen.com';
+if (! defined('BASEPATH')) {
+ exit('No direct script access allowed');
+}
+
+class Index_ah extends CI_Controller {
+
+ public function __construct() {
+ parent::__construct();
+ $this->load->library('simple_html_dom_lib');
+ }
+
+ public function index() {
+ $this->load->view('welcome');
+ }
+
+ //选择处理方式
+ public function choose_way() {
+ $this->htmlsource = $this->input->post('htmlsource');
+ $this->websitehost = $this->input->post('websitehost');
+ $this->template_name = $this->input->post('template_name');
+ $this->create_amp = $this->input->post('create_amp');
+ $this->debug = $this->input->post('debug');
+
+ /*$this->htmlsource = file_get_contents('aa.htm');
+ $this->websitehost = 'https://data.chinahighlightstravel.de';
$this->create_amp = 'true';
$this->template_name = 'gm';*/
-
- if (empty($this->htmlsource) || empty($this->websitehost)) {
- $this->output->set_status_header(500);
- echo 'error:htmlsource or websitehost is empty!';
- log_message('error', "htmlsource or websitehost is empty! " . $this->websitehost);
- return false;
+
+ if (empty($this->htmlsource) || empty($this->websitehost)) {
+ $this->output->set_status_header(500);
+ echo 'error:htmlsource or websitehost is empty!';
+ log_message('error', "htmlsource or websitehost is empty! " . $this->websitehost);
+ return false;
+ }
+
+ //域名后面不能有/
+ if (substr($this->websitehost, -1, 1) == '/') {
+ $this->websitehost = substr($this->websitehost, 0, -1);
+ }
+
+ //进行页面解析
+ $this->html_object = str_get_html($this->htmlsource);
+
+ //PC或AMP的构造方式
+ if (! empty($this->create_amp)) {
+ echo $this->create_amp();
+ return;
+ } else {
+ echo $this->optimize();
+ return;
+ }
+
+ }
+
+ //html优化处理
+ function optimize() {
+ //提取css样式地址
+ $link_css_array = [];
+ $css_content = '';
+ foreach ($this->html_object->find('link') as $link_css) {
+ //将所有的样式链接存储为一个数组
+ if ($link_css->rel == 'stylesheet' && ! empty($link_css->href)) {
+ $link_css_array[] = $link_css->href;
+ $link_css->outertext = ''; //删除链接
+ }
+ }
+
+ //循环下载所有的css样式,拼接成字符串
+ foreach ($link_css_array as $item) {
+ $get_http_temp = GET_HTTP($this->format_url($item, $this->websitehost));
+ if ($get_http_temp == false) {
+ $this->output->set_status_header(404);
+ echo 'CSS文件下载错误';
+ log_message('error', "optimize CSS文件下载错误! " . $item);
+ return FALSE;
+ }
+ $css_content .= $get_http_temp;
+ }
+
+ //找出所有style写的内置样式
+ foreach ($this->html_object->find('style') as $style_css) {
+ if ($style_css->type == "text/css") {
+ $css_content .= $style_css->innertext;
+ }
+ }
+
+ //提取和下载所有JS脚本,包括链接文件和页面脚本
+ $link_js_array = [];
+ $js_inline_content = '';
+ $js_jquery_content = '';
+ foreach ($this->html_object->find('script') as $link_script) {
+ if (! empty($link_script->src)) {
+ if (empty($link_script->defer) && empty($link_script->async)) { //没有defer标记的才处理,否则让js延后加载
+ $link_js_array[] = $link_script->src;
+ $link_script->outertext = ''; //删除链接,移动到页底
+ }
+ } else {
+ //网页内的js不需要提取
+ //$js_content.= $link_script->innertext;//js的内容
+ // $js_content.= $link_script;//js的内容,包含';
-
- $js_content = $js_scr_content . $js_jquery_content;
- //延迟加载js,需要把返回的js代码保存到一个文件中,然后替换占位符,以便加载js文件
- $lastload_js .= '';
- $lastload_js .= $js_inline_content;
-
- $this->html_object = str_replace('
+ Mitreisende hinzufügen
![]()
![]()