diff --git a/.gitignore b/.gitignore
index f4ff3920..47901456 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+.idea
+.phpintel
.svn/*
*/logs/log*
/web.config
@@ -7,5 +9,5 @@
/author/document/*
*/statement_files/*
*/paypal_activities/*
-test122.php
-/test122/*
+/author/document/*
+/application/libraries/composer
diff --git a/application/config/config.php b/application/config/config.php
index 100d3fd2..684dda6a 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -563,42 +563,6 @@ $config['InfoType_citizen'] = array(
'产品' => 'product'
);
-//可选模板
-$config['templates'] = array(
- '通用内容模板' => 'guide_info_detail',
- '城市-列表模板' => 'city_info_list',
- '城市-首页模板' => 'city_info_index',
- '城市-首页模板[简]' => 'city_info_s_index',
- '城市-景点列表模板' => 'city_info_attractions_list',
- '城市-景点列表模板[简]' => 'city_info_s_attractions_list',
- '城市-景点详细模板' => 'city_attractions',
- '城市-特色产品模板' => 'city_info_diytour',
- '城市-一线城市首页' => 'city_info_index_one',
- '省份-首页' => "area_info_index",
- '省份-列表模板' => 'area_info_list',
- '省份-通用内容模板' => 'area_info_detail',
- '文化模板 [列表式]' => "culture_info_detail_just_list",
- '文化模板 [单页式]' => 'culture_info_detail_one_page',
- '文化模板 [导航式]' => 'culture_info_detail_with_category',
- '信息专题模板' => 'guide_top_series',
- '火车专题模板' => 'train_top_series',
- '旅游攻略' => 'travel_story',
- '节庆-详细模板' => 'festival_detail',
- '节庆-列表模板' => 'festival_list',
- '大使馆-详细页' => 'embassy_info_detail',
- '城市-线路详细' => 'city_circuit',
- '专题模板(大)' => 'guide_big_series',
- '[国际站]响应式-空白模板' => 'r_tpl_empty',
- '[国际站]响应式-专题首页' => 'r_tpl_empty_navi0',
- '[国际站]响应式-专题列表页' => 'r_tpl_empty_navi1',
- '[国际站]响应式-专题列表页+' => 'r_tpl_empty_navi1p',
- '[国际站]响应式-专题详细页' => 'r_tpl_empty_navi2',
- '[-------已废弃-------]空白模板' => 'tpl_empty',
- '[-------已废弃-------]专题-温暖' => 'warm',
- '[-------已废弃-------]专题-庄重' => 'solemn',
- '[-------已废弃-------]专题-节庆' => 'festival',
- '[-------已废弃-------]专题-线路促销' => 'promotion_tour'
-);
//可选模板
$config['templates_i'] = array(
@@ -607,7 +571,9 @@ $config['templates_i'] = array(
'[城市]C首页模板' => 'city_info_index',
'[城市]C景点列表模板' => 'city_info_attractions_list',
'[城市]C景点详细模板' => 'city_attractions',
- '[专题]T0空白模板' => 'r_tpl_empty',
+ '[专题]T0空白' => 'r_tpl_empty',
+ '[专题]T0空白(HTML构建工具)' => 'r_empty_container',
+ '[专题]T0空白(H1+面包屑)' => 'r_empty2',
'----------二级目录----------' => '------2------',
'[专题]T2首页' => 'r_t2_index',
'[专题]T2详细' => 'r_t2_detail',
@@ -651,6 +617,7 @@ $config['area_type'] = array(
'大使馆' => 'y',
'公民游' => 'z',
'交换链接' => 'k',
+ '首页' => 'h',
'FAQ' => 'q'
);
@@ -693,24 +660,25 @@ $config['media_image_url_remote2'] = 'http://116.251.217.48:3581/upload';
//是否开启权限控制
$config['check_access'] = TRUE;
//权限管理超级管理
-$config['access_super_manage'] = array('ycc', 'lmr');
+$config['access_super_manage'] = array('ycc', 'lmr', 'lyj');
//编辑器预览样式路径
-$config['css_source_cht'] = '';
+$config['css_source_cht'] = '';
-$config['css_source_gm'] = '';
+$config['css_source_gm'] = '';
-$config['css_source_vc'] = '';
-$config['css_source_vac'] = '';
-$config['css_source_ru'] = '';
-$config['css_source_it'] = '';
-$config['css_source_jp'] = '';
+$config['css_source_vc'] = '';
+$config['css_source_vac'] = '';
+$config['css_source_ru'] = '';
+$config['css_source_it'] = '';
+$config['css_source_jp'] = '';
-$config['css_source_sht'] = '';
-$config['css_source_gl'] = '';
-$config['css_source_tbt'] = '';
-$config['css_source_mbj'] = '';
-$config['css_source_yz'] = '';
+$config['css_source_sht'] = '';
+$config['css_source_gl'] = '';
+$config['css_source_tbt'] = '';
+$config['css_source_mbj'] = '';
+$config['css_source_yz'] = '';
+$config['css_source_ah'] = '';
@@ -900,11 +868,45 @@ $config['InfoType_citizen'] = array(
'产品' => 'product'
);
+//ct站点用到了
+$config['InfoType_ct'] = array(
+ '不设置' => 'none',
+ '首页' => 'root',
+ '简介' => 'c_overview',
+ '关于' => 'c_about',
+ '食物' => 'c_food',
+ '食物详细' => 'c_food_detail',
+ '餐饮' => 'c_restaurant',
+ '餐饮详细' => 'c_restaurant_detail',
+ '历史' => 'c_history',
+ 'Facts信息' => 'c_facts',
+ '旅游' => 'c_travel',
+ '交通' => 'c_transport',
+ '交通详细' => 'c_transport_detail',
+ '地图' => 'c_map',
+ '地图详细' => 'c_map_detail',
+ '天气' => 'c_weather',
+ '天气详细' => 'c_weather_detail',
+ '购物' => 'c_shopping',
+ '夜生活' => 'c_nightlife',
+ '旅游建议' => 'c_tips',
+ '景点概述' => 'c_attraction',
+ '景点详细' => 'c_attraction_detail',
+ '推荐做的' => 'c_toptodo',
+ '城市article' => 'c_article',
+ '产品' => 'c_product',
+ '产品详细' => 'c_product_detail',
+ '游记' => 'story',
+ '一地线路详细' => 'c_single_circuit',
+ '一日游线路详细' => 'c_day_tour'
+);
+
//可选模板
$config['templates'] = array(
'通用内容模板' => 'guide_info_detail',
'城市-列表模板' => 'city_info_list',
'城市-首页模板' => 'city_info_index',
+ '城市-首页模板(GM)' => 'city_info_index_new',
'城市-首页模板[简]' => 'city_info_s_index',
'城市-景点列表模板' => 'city_info_attractions_list',
'城市-景点列表模板[简]' => 'city_info_s_attractions_list',
@@ -940,6 +942,47 @@ $config['templates'] = array(
'food列表' => 'food_list'
);
+//德语信息模板
+$config['templates_gm'] = array(
+ '通用内容模板' => 'guide_info_detail',
+ '城市-首页模板(GM)' => 'city_info_index',
+ '文化模板 [单页式]' => 'culture_info_detail_one_page',
+ '文化模板 [导航式]' => 'culture_info_detail_with_category',
+ '信息专题模板' => 'guide_top_series',
+ '列表式' => 'guide_info_list',
+ '空白模板'=>'none'
+);
+
+// CHT 信息模板
+$config['templates_cht'] = array(
+ '通用内容模板' => 'guide_info_detail',
+ '城市-列表模板' => 'city_info_list',
+ '城市-首页模板' => 'city_info_index',
+ '城市-首页模板[简]' => 'city_info_s_index',
+ '城市-景点列表模板' => 'city_info_attractions_list',
+ '城市-景点列表模板[简]' => 'city_info_s_attractions_list',
+ '城市-特色产品模板' => 'city_info_diytour',
+ '城市-一线城市首页' => 'city_info_index_one',
+ '省份-首页' => "area_info_index",
+ '省份-列表模板' => 'area_info_list',
+ '省份-通用内容模板' => 'area_info_detail',
+ '文化模板 [列表式]' => "culture_info_detail_just_list",
+ '文化模板 [单页式]' => 'culture_info_detail_one_page',
+ '文化模板 [导航式]' => 'culture_info_detail_with_category',
+ '信息专题模板' => 'guide_top_series',
+ '火车专题模板' => 'train_top_series',
+ '旅游攻略' => 'travel_story',
+ '节庆-详细模板' => 'festival_detail',
+ '节庆-列表模板' => 'festival_list',
+ '大使馆-详细页' => 'embassy_info_detail',
+ '城市-线路详细' => 'city_circuit',
+ '专题模板(大)' => 'guide_big_series',
+ '三峡游船' => 'yangtze',
+ '城市article列表' => 'city_article_list',
+ 'food列表' => 'food_list',
+ 'FAQ模板' => 'faq_detail'
+);
+
//产品管理板块模板
$config['templates_product'] = array(
'空白模板' => 'none',
@@ -947,6 +990,7 @@ $config['templates_product'] = array(
//产品管理板块模板(国际站使用)
$config['templates_product_i'] = array(
+ '空白模板(HTML构建工具)' => 'r_empty_container',
'空白模板(新)' => 'r_tpl_empty_2017',
'空白模板(旧)' => 'r_tpl_empty',
);
@@ -1031,9 +1075,6 @@ $config['media_image_url_org'] = 'http://photo.chtcdn.com:3581/upload';
$config['media_image_url_remote'] = 'http://photo.chtcdn.com/upload';
$config['media_image_url_remote2'] = 'http://116.251.217.48:3581/upload';
-//编辑器预览样式路径
-$config['css_source_cht'] = '';
-$config['css_source_ah'] = '';
/* End of file config.php */
/* Location: ./application/config/config.php */
diff --git a/application/controllers/CT_AMP_Loader.php b/application/controllers/CT_AMP_Loader.php
new file mode 100644
index 00000000..27ba257b
--- /dev/null
+++ b/application/controllers/CT_AMP_Loader.php
@@ -0,0 +1,59 @@
+load->model('information_model');
+ $this->load->model('InfoMetas_model');
+ //$this->load->library('Tags_analysis');
+ }
+
+ // http://localhost:8002/guide-use.php/amp_loader/test/?info_url=/yangtzecruise/
+ /**
+ * 加载已经发布的页面
+ */
+ public function load() {
+ $info_url = $this->input->get_post('info_url');
+ $webcode = $this->input->get_post('webcode');
+ if(!isset($webcode) ) {
+ $webcode="ct";
+ }
+ // $info_url="/yangtzecruise/";
+ // $webcode="cht";
+
+ $information_detail = $this->information_model->ct_get_by_url($info_url, $webcode);
+ $ic_id = $information_detail->ic_id;
+ $meta_amp_status = $this->InfoMetas_model->get($ic_id, 'AMP_STATUS');
+ if ($meta_amp_status) {
+ $meta_amp_html = $this->InfoMetas_model->get($ic_id, 'AMP');
+ //$include_price_html = $this->tags_analysis->replace_price_tag($meta_amp_html);
+ echo $meta_amp_html;
+ } else {
+ header('HTTP/1.1 404 Not Found');
+ header("status: 404 Not Found");
+ show_404();
+ exit;
+ }
+ }
+
+ // http://localhost:8002/guide-use.php/amp_loader/test/?info_url=/yangtzecruise/
+ /**
+ * 测试保存的页面
+ */
+ public function test() {
+ // $info_url = $this->input->get_post('info_url');
+ $info_url = "/yangtzecruise/";
+ $information_detail = $this->information_model->ct_get_by_url($info_url, "cht");
+ if (empty($information_detail)) {
+ echo $info_url.'没有信息类型';
+ }
+ $ic_id = $information_detail->ic_id;
+ $meta_amp_html = $this->InfoMetas_model->get($ic_id, 'AMP');
+ //$include_price_html = $this->tags_analysis->replace_price_tag($meta_amp_html);
+ echo $meta_amp_html;
+ }
+}
diff --git a/application/controllers/amp.php b/application/controllers/amp.php
index e24c449a..e7e5c374 100644
--- a/application/controllers/amp.php
+++ b/application/controllers/amp.php
@@ -11,52 +11,25 @@ class Amp extends CI_Controller {
//$this->output->enable_profiler(TRUE);
$this->load->model('Information_model');
$this->load->model('InfoMetas_model');
+ $this->load->library('Amplib');
}
public function index() {
$data = array();
$this->load->view('bootstrap3/header', $data);
- $this->load->view('amp_editor');
$this->load->view('bootstrap3/footer');
}
public function edit($ic_id) {
- $data = array();
- $data['information'] = $this->Information_model->detail_by_ic_id($ic_id);
- if ($data['information'] == FALSE) {
- show_404();
- }
- $this->load->view('bootstrap3/header', $data);
- $this->load->view('amp_editor');
- $this->load->view('bootstrap3/footer');
+ $this->amplib->edit($ic_id);
+ }
+
+ public function auto_create($ic_id) {
+ echo $this->amplib->auto_create($ic_id);
}
public function edit_save() {
- $data = array();
- $ic_id = $this->input->post('ic_id');
- $textarea_htmlcode = $this->input->post('textarea_htmlcode');
- $amp_status = $this->input->post('amp_status');
- $data['information'] = $this->Information_model->detail_by_ic_id($ic_id);
- if ($data['information'] == FALSE) {
- show_404();
- }
-
- $amp = $this->InfoMetas_model->get($ic_id, 'AMP');
- if ($amp === false) {
- $this->InfoMetas_model->add($ic_id, 'AMP', $textarea_htmlcode);
- } else {
- $this->InfoMetas_model->update($ic_id, 'AMP', $textarea_htmlcode);
- }
-
- $amp_status_value = $this->InfoMetas_model->get($ic_id, 'AMP_STATUS');
- if ($amp_status_value === false) {
- $this->InfoMetas_model->add($ic_id, 'AMP_STATUS', $amp_status);
- } else {
- $this->InfoMetas_model->update($ic_id, 'AMP_STATUS', $amp_status);
- }
-
- $data[] = array('name' => 'ok', 'value' => $this->lang->line('form_info_success'));
- echo json_encode($data);
+ echo $this->amplib->edit_save();
}
}
diff --git a/application/controllers/home.php b/application/controllers/home.php
new file mode 100644
index 00000000..c351dfc8
--- /dev/null
+++ b/application/controllers/home.php
@@ -0,0 +1,42 @@
+permission->is_admin();
+ //$this->output->enable_profiler(TRUE);
+ $this->load->model('Area_model');
+ $this->load->model('Information_model');
+ $this->load->model('InfoContents_model');
+ $this->load->model('InfoStructures_model');
+ }
+
+ //站点首页
+ public function index()
+ {
+ $home_id=1;
+ //查询结构根节点,当为空则建立
+ $rootStructure = $this->Information_model->GetRoot('h', $home_id);
+ if ($rootStructure == FALSE)
+ {
+ $this->InfoContents_model->Add('', 'HomePage', 'root', '', '', '', '', '', '', 0, 0, '', '', 0, 0, '', '', $home_id, 'h', 0,
+ '','');
+ $this->InfoStructures_model->Add(0, $this->InfoContents_model->insert_id);
+ $is_id = $this->InfoStructures_model->insert_id;
+ }
+ else
+ {
+ $is_id = $rootStructure->is_id;
+ }
+ redirect(site_url('information/edit/' . $is_id));
+ }
+
+
+}
+
diff --git a/application/controllers/info_amp.php b/application/controllers/info_amp.php
index 4e77ad13..99ac7662 100644
--- a/application/controllers/info_amp.php
+++ b/application/controllers/info_amp.php
@@ -12,60 +12,86 @@ class Info_amp extends CI_Controller
//$this->permission->is_admin();
$this->load->model('InfoMetas_model');
$this->load->model('InfoContents_model');
+ $this->load->model('Information_model');
$this->site_code = $this->config->item('site_code');
- //CORS TEST
- header('Access-Control-Allow-Origin:*');
+ //CORS
+ header('Access-Control-Allow-Origin:*');
+ header('Access-Control-Allow-Methods:GET,PUT,POST,DELETE,OPTIONS');
+ header('Access-Control-Allow-Headers:Content-Type,Authorization,Content-Length,X-Requested-With,Accept,x-csrf-token,origin');
}
public function save_amp()
{
- $icid = $this->input->post('icid');
- $json = $this->input->post('json');
- $html = $this->input->post('html');
- $css = $this->input->post('css');
- $schema = $this->input->post('schema');
- $script = $this->input->post('script');
- $status = $this->input->post('status');
+ $icid = $this->input->get_post('icid');
+ $json = $this->input->get_post('json');
+ $html = $this->input->get_post('html');
+ $pc_html = $this->input->get_post('pc_html');
+ $pc_css = $this->input->get_post('pc_css');
+ $css = $this->input->get_post('css');
+ $schema = $this->input->get_post('schema');
+ $script = $this->input->get_post('script');
+ $status = $this->input->get_post('status');
+
+ //如果源信息的内容为空,则插入内容。
+ $info = $this->InfoContents_model->get_ic_contents2($icid);
+ if ($info && empty($info->ic_content)) {
+ $this->InfoContents_model->force_update($icid, ''.$pc_html);
+ }
+
if ($icid && $json && $html) {
try {
//html
$meta = $this->InfoMetas_model->get($icid, 'AMP_BODY');
- if ($meta === false) {
+ if ($meta === FALSE) {
$this->InfoMetas_model->add($icid, 'AMP_BODY', $html);
} else {
$this->InfoMetas_model->update($icid, 'AMP_BODY', $html);
}
+ //pc_html
+ $meta = $this->InfoMetas_model->get($icid, 'AMP_BODY_PC');
+ if ($meta === FALSE) {
+ $this->InfoMetas_model->add($icid, 'AMP_BODY_PC', $pc_html);
+ } else {
+ $this->InfoMetas_model->update($icid, 'AMP_BODY_PC', $pc_html);
+ }
+ //pc_css
+ $meta = $this->InfoMetas_model->get($icid, 'AMP_CSS_PC');
+ if ($meta === FALSE) {
+ $this->InfoMetas_model->add($icid, 'AMP_CSS_PC', $pc_css);
+ } else {
+ $this->InfoMetas_model->update($icid, 'AMP_CSS_PC', $pc_css);
+ }
//json
$meta = $this->InfoMetas_model->get($icid, 'AMP_JSON');
- if ($meta === false) {
+ if ($meta === FALSE) {
$this->InfoMetas_model->add($icid, 'AMP_JSON', $json);
} else {
$this->InfoMetas_model->update($icid, 'AMP_JSON', $json);
}
//css
$meta = $this->InfoMetas_model->get($icid, 'AMP_CSS');
- if ($meta === false) {
+ if ($meta === FALSE) {
$this->InfoMetas_model->add($icid, 'AMP_CSS', $css);
} else {
$this->InfoMetas_model->update($icid, 'AMP_CSS', $css);
}
//script
$meta = $this->InfoMetas_model->get($icid, 'AMP_SCRIPT');
- if ($meta === false) {
+ if ($meta === FALSE) {
$this->InfoMetas_model->add($icid, 'AMP_SCRIPT', $script);
} else {
$this->InfoMetas_model->update($icid, 'AMP_SCRIPT', $script);
}
//schema
$meta = $this->InfoMetas_model->get($icid, 'AMP_SCHEMA');
- if ($meta === false) {
+ if ($meta === FALSE) {
$this->InfoMetas_model->add($icid, 'AMP_SCHEMA', $schema);
} else {
$this->InfoMetas_model->update($icid, 'AMP_SCHEMA', $schema);
}
//status
$meta = $this->InfoMetas_model->get($icid, 'AMP_STATUS');
- if ($meta === false) {
+ if ($meta === FALSE) {
$this->InfoMetas_model->add($icid, 'AMP_STATUS', $status);
} else {
$this->InfoMetas_model->update($icid, 'AMP_STATUS', $status);
@@ -89,7 +115,7 @@ class Info_amp extends CI_Controller
public function load_amp()
{
- $icid = $this->input->post('icid');
+ $icid = $this->input->get_post('icid');
if (!$icid) {
echo json_encode(array(
"succ" => false,
@@ -97,6 +123,42 @@ class Info_amp extends CI_Controller
));
return false;
}
+ //信息~返回信息
+ $ic = $this->InfoContents_model->get_ic_contents2($icid);
+ if (empty($ic)) {
+ echo json_encode(array(
+ "succ" => false,
+ "message" => "load_amp() -> 无信息"
+ ));
+ return false;
+ }
+ switch (strtolower($ic->ic_sitecode)) {
+ case 'vac':
+ $site = 'https://www.viaje-a-china.com';
+ break;
+ case 'vc':
+ $site = 'https://www.voyageschine.com';
+ break;
+ case 'jp':
+ $site = 'https://www.arachina.com';
+ break;
+ case 'ru':
+ $site = 'https://www.chinahighlights.ru';
+ break;
+ case 'it':
+ $site = 'https://www.viaggio-in-cina.it';
+ break;
+ case 'cht':
+ $site = 'https://www.chinahighlights.com';
+ break;
+ case 'gm':
+ $site = 'https://www.chinarundreisen.com/';
+ break;
+ default:
+ $site = '';
+ break;
+ }
+
$json = $this->InfoMetas_model->get($icid, 'AMP_JSON');
$status = $this->InfoMetas_model->get($icid, 'AMP_STATUS');
$schema = $this->InfoMetas_model->get($icid, 'AMP_SCHEMA');
@@ -104,6 +166,7 @@ class Info_amp extends CI_Controller
echo json_encode(array(
"succ" => true,
"icid" => $icid,
+ "icurl" => $site.$ic->ic_url,
"json" => $json,
"schema" => $schema,
"status" => $status
@@ -116,17 +179,142 @@ class Info_amp extends CI_Controller
}
}
+ public function list_amp()
+ {
+ $site = $this->input->get_post('site');
+ switch ($site) {
+ case 'https://www.viaje-a-china.com':
+ $site_code = 'vac';
+ break;
+ case 'https://www.voyageschine.com':
+ $site_code = 'vc';
+ break;
+ case 'https://www.arachina.com':
+ $site_code = 'jp';
+ break;
+ case 'https://www.chinahighlights.ru':
+ $site_code = 'ru';
+ break;
+ case 'https://www.viaggio-in-cina.it':
+ $site_code = 'it';
+ break;
+ case 'https://www.chinahighlights.com':
+ $site_code = 'cht';
+ break;
+ case 'https://www.chinarundreisen.com/':
+ $site_code = 'gm';
+ break;
+ default:
+ $site_code = false;
+ break;
+ }
+ if (!$site_code) {
+ echo json_encode(array(
+ "succ" => false,
+ "message" => "list_amp() -> 参数传递错误。"
+ ));
+ return false;
+ }
+ $rs = $this->InfoMetas_model->list_amp($site_code);
+ if (!empty($rs)) {
+ echo json_encode($rs);
+ } else {
+ echo json_encode(array(
+ "succ" => false,
+ "message" => "load_amp() -> 无数据返回。"
+ ));
+ }
+ }
+
+ public function list_info_children()
+ {
+ $site = $this->input->get_post('site');
+ switch ($site) {
+ case 'https://www.viaje-a-china.com':
+ $site_code = 'vac';
+ break;
+ case 'https://www.voyageschine.com':
+ $site_code = 'vc';
+ break;
+ case 'https://www.arachina.com':
+ $site_code = 'jp';
+ break;
+ case 'https://www.chinahighlights.ru':
+ $site_code = 'ru';
+ break;
+ case 'https://www.viaggio-in-cina.it':
+ $site_code = 'it';
+ break;
+ case 'https://www.chinahighlights.com':
+ $site_code = 'cht';
+ break;
+ case 'https://www.chinarundreisen.com/':
+ $site_code = 'gm';
+ break;
+ default:
+ $site_code = false;
+ break;
+ }
+ $is_path = $this->input->get_post('is_path'); // '25693,278002094,'
+ if (!$site_code || !$is_path) {
+ echo json_encode(array(
+ 'succ' => false,
+ 'message' => 'list_info_children() -> 参数传递错误。'
+ ));
+ return false;
+ }
+ $rs = $this->InfoMetas_model->list_info_by_path_with_meta($is_path, $site_code);
+ if (!empty($rs)) {
+ $newrs = array();
+ foreach ($rs as $info) {
+ $show_photo_meta = $this->InfoMetas_model->get($info->ic_id, 'meta_use_list_picture');
+ if ($show_photo_meta == 'no') {
+ $use_photo = '';
+ } else {
+ $use_photo = $this->config->item('site_image_url').$info->ic_photo;
+ }
+ if ($info->ic_type === 'c_attraction' || $info->ic_template === 'city_info_attractions_list' || $info->ic_template === 'r_tpl_empty_navi1p') {
+ $list_info = true;
+ } else {
+ $list_info = false;
+ }
+ if ($list_info || !empty($info->ic_content) && !empty($info->ic_url) && stripos($info->ic_url, '/test/')===false) {
+ array_push($newrs, array(
+ 'is_path' => $info->is_path,
+ 'ic_url' => $info->ic_url,
+ 'ic_id' => $info->ic_id,
+ 'title' => $info->ic_title,
+ 'photo' => $use_photo,
+ 'im_id' => $info->im_id
+ ));
+ }
+ }
+ echo json_encode($newrs);
+ } else {
+ echo json_encode(array(
+ "succ" => false,
+ "message" => "list_info_children() -> 无数据返回。"
+ ));
+ }
+ }
+
public function load_info()
{
- $icid = $this->input->post('icid');
+ $icid = $this->input->get_post('icid');
if ($icid) {
$ic = $this->InfoContents_model->get_ic_contents2($icid);
if ($ic) {
+ $show_photo_meta = $this->InfoMetas_model->get($icid, 'meta_use_list_picture');
+ if ($show_photo_meta == 'no') {
+ $use_photo = '';
+ } else {
+ $use_photo = $this->config->item('site_image_url').$ic->ic_photo;
+ }
echo json_encode(array(
"succ" => true,
- "info" => $ic->ic_content,
+ "info" => $ic->ic_content ? $ic->ic_content : "
".$ic->ic_seo_description."
",
"title" => $ic->ic_title,
- "photo" => $this->config->item('site_image_url').$ic->ic_photo,
+ "photo" => $use_photo,
"url" => $ic->ic_url,
"site" => $this->config->item('site_url')
));
@@ -144,5 +332,180 @@ class Info_amp extends CI_Controller
}
}
-}
+ public function handel_png_source() {
+ //ini_set('memory_limit', '50M');
+ $png_base64 = $this->input->post('png_base64');
+ //$png_base64 = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABlBMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDrEX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
+ $file = md5($png_base64).'.jpg';
+ $path = realpath('../cht-system/views/information/word_img').'/'.$file;
+ $png_base64 = str_replace('data:image/png;base64,', '', $png_base64);
+ $png_base64 = str_replace('data:image/jpg;base64,', '', $png_base64);
+ $png_base64 = base64_decode($png_base64);
+ $im = imagecreatefromstring($png_base64);
+ //保存图像
+ imagejpeg($im, $path);
+ //释放内存
+ imagedestroy($im);
+ $size = getimagesize($path);
+ if($png_base64 && $size) {
+ echo(json_encode(array(
+ 'status' => 'success',
+ 'path' => '/information-view/information/word_img/'.$file,
+ 'width' => $size[0],
+ 'height' => $size[1]
+ )));
+ } else {
+ echo(json_encode(array(
+ 'status' => 'error'
+ )));
+ }
+ }
+ public function handel_image_source() {
+ @ini_set('memory_limit', '256M');
+ $file = $_FILES['file'];
+ if (!$file) {
+ echo(json_encode(array(
+ 'status' => 'error',
+ 'msg' => "图片上传失败。"
+ )));
+ return;
+ }
+ $usr = $this->input->post('usr');
+ $icid = $this->input->post('icid');
+ //转移文件
+ $md5_file = md5($usr.$icid.$file['name']);
+ //ext
+ $ext = mb_strtolower(strrchr($file["name"],'.'));
+ if ($ext != '.jpg') {
+ echo(json_encode(array(
+ 'status' => 'error',
+ 'msg' => '只能接收(.jpg)图片。',
+ 'filename' => $file["name"]
+ )));
+ return;
+ }
+ $md5_name = $md5_file.$ext;
+ //临时docx文件
+ $image_path = realpath('../cht-system/views/information/word_img').'/'.basename($md5_name);
+ $html = 'to use mammoth';
+ if (move_uploaded_file($file['tmp_name'], $image_path)) {
+ //图片处理
+ $im = imagecreatefromjpeg($image_path);
+ imagejpeg($im, $image_path);
+ imagedestroy($im);
+ $size = getimagesize($image_path);
+ if($size) {
+ echo(json_encode(array(
+ 'status' => 'success',
+ 'path' => '/information-view/information/word_img/'.$md5_name,
+ 'width' => $size[0],
+ 'height' => $size[1]
+ )));
+ } else {
+ echo(json_encode(array(
+ 'status' => 'error'
+ )));
+ }
+ } else {
+ echo(json_encode(array(
+ 'status' => 'error',
+ 'msg' => "图片文件解析失败。"
+ )));
+ }
+ }
+
+ public function handel_word_source() {
+ @ini_set('memory_limit', '256M');
+ $file = $_FILES['file'];
+ if (!$file) {
+ echo(json_encode(array(
+ 'status' => 'error',
+ 'msg' => "文件上传失败。"
+ )));
+ return;
+ }
+ $usr = $this->input->post('usr');
+ $icid = $this->input->post('icid');
+ //转移文件
+ $md5_file = md5($usr.$icid.$file['name']);
+ //ext
+ $ext = mb_strtolower(strrchr($file["name"],'.'));
+ if ($ext != '.docx') {
+ echo(json_encode(array(
+ 'status' => 'error',
+ 'msg' => '只能接收word(.docx)文档。'
+ )));
+ return;
+ }
+ $md5_name = $md5_file.$ext;
+ //临时docx文件
+ $docx_path = realpath('../cht-system/views/information/word_source').'/'.basename($md5_name);
+ $html = 'to use mammoth';
+ if (move_uploaded_file($file['tmp_name'], $docx_path)) {
+ $docx_dir = realpath('../cht-system/views/information/word_source');
+ //图片及html目录
+ $img_dir = $docx_dir.'/'.$md5_file;
+ is_dir($img_dir) || mkdir($img_dir, 0777);
+ //临时html文件
+ $docx_parh = $img_dir.'/'.$md5_name;
+ $html_parh = str_ireplace('.docx', '.html', $docx_parh);
+ //运行docx转化插件
+ if ($_SERVER['SERVER_NAME'] == 'localhost' || $_SERVER['SERVER_NAME'] == '202.103.68.62') {
+ $yarnbin = 'C:\Users\cht77\AppData\Local\Yarn\bin\mammoth ';
+ $test_host = '//202.103.68.62:9096';
+ } else {
+ $yarnbin = 'C:\Users\lmr\AppData\Local\Yarn\bin\mammoth ';
+ $test_host = '';
+ }
+ $command = $yarnbin.$docx_path.' --output-dir='.$img_dir. ' 2>&1';
+ //$command = 'C:\Users\lmr\AppData\Local\Yarn\bin\mammoth -h 2>&1';
+ exec($command, $rs, $st);
+ //图片处理
+ $scan_img = scandir($img_dir);
+ $tmp = '';
+ foreach($scan_img as $f) {
+ $tmp_ext = mb_strtolower(strrchr($f, '.'));
+ if ($tmp_ext == '.jpeg') {
+ $tmp_img = $img_dir.'/'.$f;
+ $tmp_jpg = str_ireplace('.jpeg', '.jpg', $tmp_img);
+ $im = imagecreatefromjpeg($tmp_img);
+ imagejpeg($im, $tmp_jpg);
+ imagedestroy($im);
+ //删除临时图片
+ @unlink($tmp_img);
+ //$tmp .= $f . ' # ';
+ }
+ }
+ //html处理
+ if (file_exists($html_parh)) {
+ $html = file_get_contents($html_parh);
+ } else {
+ echo(json_encode(array(
+ 'status' => 'error',
+ 'html' => $command.' # '.$html_parh,
+ 'rs' => print_r($rs, true).' # '.$st
+ )));
+ return;
+ }
+ $html = preg_replace('/src="([\d]+).jpeg"/i', 'src="'.$test_host.'/information-view/information/word_source/'.$md5_file.'/$1.jpg"', $html);
+ //删除临时html
+ @unlink($html_parh);
+ //删除docx文档
+ @unlink($docx_path);
+ if ($html) {
+ echo(json_encode(array(
+ 'status' => 'success',
+ 'path' => $docx_path,
+ 'html' => $html
+ )));
+ }
+ } else {
+ echo(json_encode(array(
+ 'status' => 'error',
+ 'msg' => "word文件解析失败。"
+ )));
+ }
+ }
+
+}
diff --git a/application/controllers/information.php b/application/controllers/information.php
index 33912e01..d3d18193 100644
--- a/application/controllers/information.php
+++ b/application/controllers/information.php
@@ -1,737 +1,725 @@
-permission->is_admin();
- //$this->output->enable_profiler(TRUE);
- $this->load->model('Area_model');
- $this->load->model('Information_model');
- $this->load->model('InfoContents_model');
- $this->load->model('InfoStructures_model');
- $this->load->model('Landscape_model');
- $this->load->model('Operator_model');
- $this->load->model('Logs_model');
- $this->load->model('InfoMetas_model');
- $this->load->model('Infoauthors_model');
- $this->load->model('InfoKeywordsanalytics_model', 'analytics_model');
- $this->load->model('InfoSMS_model');
-
- if (is_series_site()) {
- $this->load->model('InfoTags_model');
- }
-
- $this->load->library('Accesscheck');
- $this->accesscheck->check_access();
- }
-
- public function index() {
- echo '信息首页';
- }
-
- public function add($is_parent_id) {
- //添加空内容.
- $this->InfoContents_model->Add('', 'New Information', '', '', '', '', '', '', '', 0, 0, '', '', 0, 0, '', '', 0, '', 0, '', '');
- $infocontent = $this->InfoContents_model->get_ic_contents($this->InfoContents_model->insert_id);
- if (!empty($infocontent) && $this->InfoStructures_model->Add($is_parent_id, $this->InfoContents_model->insert_id)) {
- $is_id = $this->InfoStructures_model->insert_id;
- $InfoStructures = $this->InfoStructures_model->Detail($is_id);
- $InfoStructures->is_id = $is_id;
- $data[] = array('name' => 'ok', 'value' => $InfoStructures);
- $this->Logs_model->add($this->InfoStructures_model->insert_id);
- } else {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('form_info_error'));
- }
- echo json_encode($data);
- return TRUE;
- }
-
- //移动结构顺序
- public function move() {
- //网站会提交一个同级节点id列表字符串,按照这个去排序
- $parent_id = $this->input->post('pid');
- $idsStr = $this->input->post('ids');
- $idsArray = explode(',', $idsStr);
- foreach ($idsArray as $key => $value) {
- if ($value) {
- //设置排序
- $this->InfoStructures_model->set_sort($value, $key);
- //设置path
- $this->InfoStructures_model->set_path($parent_id, $value);
- }
- }
- $data[] = array('name' => 'ok', 'value' => $this->lang->line('structures_success_move'));
- echo json_encode($data);
- $this->Logs_model->move($idsStr);
- return TRUE;
- }
-
- //把文章移动到任意板块文章下
- //is_id 信息结构ID,is_parent_id即将转移到的信息结构id
- public function move_by_is_id() {
- $data = array();
- $is_id = $this->input->post('is_id');
- $is_parent_id = $this->input->post('is_parent_id');
- if ($is_id == $is_parent_id || empty($is_id) || empty($is_parent_id)) {
- return false;
- }
- //即将移动到文章结构信息
- $Structure = $this->InfoStructures_model->Detail($is_id);
- //目标文章结构信息
- $Structure_parent = $this->InfoStructures_model->Detail($is_parent_id);
- //只能移动到本站点下
- if ($Structure->is_sitecode == $Structure_parent->is_sitecode) {
- //不能搬迁到自己的子节点下
- if (strpos(',' . $Structure_parent->is_path, ',' . $is_id . ',') == false) {
- $this->InfoStructures_model->set_path($is_parent_id, $is_id);
- }
- //信息的区域类型和id也要修改 todo
- }
- $data[] = array('name' => 'ok', 'value' => $this->lang->line('structures_success_move'));
- echo json_encode($data);
- $this->Logs_model->move($is_id);
- return TRUE;
- }
-
- public function delete($is_id) {
- //查询结构信息
- $Structure = $this->InfoStructures_model->Detail($is_id);
- if ($Structure == FALSE) {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('structures_error_notfound'));
- echo json_encode($data);
- return false;
- }
- if ($this->InfoStructures_model->HasChild($Structure->is_id)) {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('structures_error_haschild'));
- echo json_encode($data);
- return false;
- } else {
- $info_detail = $this->Information_model->Detail($is_id);
- $this->Logs_model->delete($is_id, $info_detail->ic_content);
- if (!empty($info_detail->ic_summary)) {
- $this->Logs_model->backup_summary($is_id, $info_detail->ic_summary);
- }
- $this->InfoStructures_model->Delete($Structure->is_id);
- $this->InfoContents_model->Delete($Structure->is_ic_id);
- //如果是已经发布的页面,删除静态文件
- if ($info_detail->ic_status == 1) {
- $this->update_cache($info_detail->ic_url, true);
- }
- //删除成功后返回一个上级链接给用户
- $drumpurl = site_url('information/edit/' . $Structure->is_parent_id);
- if ($Structure->is_parent_id == 0)
- $drumpurl = site_url('/');
- $data[] = array('name' => 'ok', 'value' => $drumpurl);
- echo json_encode($data);
- return true;
- }
- }
-
- public function edit($is_id) {
- header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
- header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
- set_time_limit(30);
- //$this->output->enable_profiler(true);
- //查询结构信息
- $Structure = $this->InfoStructures_model->Detail($is_id);
- if ($Structure == FALSE) {
- show_404();
- }
- //查询结构根节点
- $rootStructure = $this->InfoStructures_model->GetParent($Structure->is_path, 1);
- //没有根节点就从它本身开始查询
- if ($rootStructure == false) {
- $rootStructure_ID = $Structure->is_id;
- } else {
- $rootStructure_ID = $rootStructure->is_id;
- }
-
- //查询结构列表信息
- //$data['informationList'] = $this->Information_model->StructureList($rootStructure_ID);
- $data['informationList'] = $this->accesscheck->get_info_structure($rootStructure_ID);
- if (!$data['informationList']) {
- redirect(site_url('Login/refuse'));
- }
- $data['is_writeable'] = $this->accesscheck->get_edit_type($Structure->is_path);
-
- //增加一项,属于这个区域,但是结构数据层次不准确的也要列出来
- //todo:
- //信息内容
- $data['information'] = $this->Information_model->Detail($is_id);
-
- //检查该信息是否已收录
- $data['embody'] = 1;
- if (isset($data['information']->ic_id)) {
- $embody = $this->InfoMetas_model->get($data['information']->ic_id, 'meta_embody');
- if ($embody && $embody != '1') {
- $data['embody'] = 0;
- }
- //设置该信息所有未读消息为已读
- $this->InfoSMS_model->readed_for_info($data['information']->ic_id);
- }
-
- //主节点信息
- $data['rootInformation'] = $this->Information_model->Detail($rootStructure_ID);
- //获取未绑定的景点,只有城市有,无视其它区域类型
- $data['unlink_landscape_list'] = array();
-
- //可选的展示模板
- if (in_array($this->config->item('site_code'), array('vac', 'vc', 'jp', 'ru', 'it'))) {
- $this->config->set_item('templates', $this->config->item('templates_i'));
- }
-
- if (in_array($this->config->item('site_code'), array('ah'))) {
- $this->config->set_item('templates', $this->config->item('templates_ah'));
- }
- if (in_array($this->config->item('site_code'), array('pgr'))) {
- $this->config->set_item('templates', $this->config->item('templates_pgr'));
- }
- if (in_array($this->config->item('site_code'), array('ts'))) {
- $this->config->set_item('templates', $this->config->item('templates_ts'));
- }
-
- //信息区域类型
- switch ($data['rootInformation']->ic_ht_area_type) {
- case 'c': //城市
- $data['infoTypeList'] = $this->config->item('InfoType_city');
- $data['unlink_landscape_list'] = $this->Information_model->get_unlink_landscape_list($data['rootInformation']->ic_ht_area_id);
- break;
- case 'p'://省份
- $data['infoTypeList'] = $this->config->item('InfoType_province');
- break;
- case 'n'://国家
- $data['infoTypeList'] = $this->config->item('InfoType_country');
- break;
- case 't'://特殊区域
- $data['infoTypeList'] = $this->config->item('InfoType_special');
- break;
- case 'e'://大洲
- $data['infoTypeList'] = array();
- break;
- case 'z'://公民游
- $data['infoTypeList'] = $this->config->item('InfoType_citizen');
- break;
- case 'v'://视频
- $data['infoTypeList'] = $this->config->item('InfoType_video');
- break;
- case 'f'://节庆
- $data['infoTypeList'] = $this->config->item('InfoType_festival');
- break;
- case 'pd'://产品管理
- $data['infoTypeList'] = $this->config->item('InfoType_product');
- //LMR 2016-7-14
- if (in_array($this->config->item('site_code'), array('vac', 'vc', 'jp', 'ru', 'it'))) {
- $this->config->set_item('templates', $this->config->item('templates_product_i'));
- } else {
- $this->config->set_item('templates', $this->config->item('templates_product'));
- }
- break;
- default:
- $data['infoTypeList'] = array();
- break;
- }
-
-
-
- $data['templateList'] = $this->config->item('templates');
- //翰特产品类型
- $data['productTypeList'] = $this->config->item('ProductType_HT');
- //获取绑定的产品名称
- switch ($data['information']->ic_ht_product_type) {
- case 't':
- $data['product_title'] = $this->Landscape_model->get_landscape_title($data['information']->ic_ht_product_id);
- break;
- default:
- $data['product_title'] = '';
- break;
- }
- //获取最后更新者信息
- $data['last_edit_info'] = $this->Logs_model->get_last_edit($is_id);
-
- //编辑列表
- $sites = $this->config->item('site');
- $data['editor_list'] = $this->Operator_model->get_site_user($this->config->item('site_code'));
- //获取作者列表
- $data['author_list'] = $this->Infoauthors_model->get_site_user($this->config->item('site_code'));
-
- //获取备份信息记录
- $data['content_backup_list'] = $this->Logs_model->get_backup_list($is_id);
-
- //所属导航栏目
- $data['setting_website_nav'] = $this->InfoMetas_model->get_list(0, 'setting_website_nav_' . strtolower($this->config->item('site_code')));
-
- $data['my_tags'] = array();
- $data['all_tags'] = array();
- if (is_series_site()) {
- //信息标签
- $this->InfoTags_model->ic_id = null;
- $data['all_tags'] = $this->InfoTags_model->list_tag();
- $this->InfoTags_model->ic_id = $data['information']->ic_id;
- $data['my_tags'] = $this->InfoTags_model->list_tag();
- //差集
- foreach ($data['all_tags'] as &$it)
- {
- foreach ($data['my_tags'] as $it2)
- {
- if ($it->it_id == $it2->icit_it_id)
- {
- $it = null;
- break;
- }
- }
- }
- $data['all_tags'] = array_filter($data['all_tags']);
- }
-
- $this->load->view('bootstrap3/header', $data);
- $this->load->view('bootstrap3/information_edit');
- $this->load->view('bootstrap3/footer');
- }
-
- /**
- public function redirect($jumpUrl){
-
- header('HTTP/1.1 301 Moved Permanently');
-
- header($jumpUrl);// 301 跳转到设置的 url
-
- exit();
-
- } */
- public function test_proxy($url = false) {
- $curl = curl_init();
- //curl_setopt($curl,CURLOPT_URL, "http://graph.facebook.com/?id=http://www.chinahighlights.com");
- //curl_setopt($curl,CURLOPT_URL, 'http://graph.facebook.com/?id=http://www.mybeijingchina.com/beijing-attractions/beihai-park/');
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_HEADER, 0);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 1);
- curl_setopt($curl, CURLOPT_PROXY, "120.24.227.23:33333");
- $request = curl_exec($curl);
- curl_close($curl);
- return $request;
- //echo $request;
- }
-
- // 分享数 lzq
- public function statistical_sharing() {
-
- //$info_ic = $this->Information_model->get_ic_url_by_code('mbj');
- $info_ic = $this->Information_model->get_ic_url();
- $ic_id = $info_ic->ic_id;
- $ic_url = $info_ic->ic_url;
- $ic_sitecode = $info_ic->ic_sitecode;
- $site = $this->config->item('site');
-
- if (!empty($ic_url)) {
-
- $result = $this->Information_model->update_ic_date_by_code($ic_id);
- //var_dump($site['mbj']['site_url']);
- //$wz_url = 'http://graph.facebook.com/?id='.$site['mbj']['site_url'].$ic_url;
- $complete_url = 'http://graph.facebook.com/?id=' . $site[$ic_sitecode]['site_url'] . $ic_url;
- //echo $wz_url;
- $api_return = $this->test_proxy($complete_url);
- $api_return = json_decode($api_return);
- if (empty($api_return->shares)) {
- var_dump($api_return);
- $shares = 0;
- } else {
- var_dump($api_return);
- $shares = $api_return->shares;
- }
-
- //echo $asd->shares;
- $result2 = $this->Information_model->insert_url_to_csi($info_ic->ic_url, $ic_id, $info_ic->ic_sitecode, $shares);
- }
-
- //$sstt = $this->config->item('site');
- //foreach($infolist as $k=>$v){
- // $aabb[] = $v->ic_sitecode;
- //}
- //$url_count = $this->Information_model->get_count_by_code('mbj');
- //$surl = site_url('/information/fengxiangshu');
- //redirect($surl,'refresh',301);
-
- $this->load->view('bootstrap3/header');
- $this->load->view('bootstrap3/statistical_sharing');
- }
-
- public function edit_save() {
- header('Cache-Control: no-cache');
- $information = $this->Information_model->Detail($this->input->post('is_id'));
- if ($information === false) {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('structures_error_notfound'));
- echo json_encode($data);
- return false;
- }
-
- $this->form_validation->set_rules('ic_url_title', 'lang:ic_url_title', 'required');
- $this->form_validation->set_rules('ic_title', 'lang:ic_title', 'required');
- $this->form_validation->set_rules('ic_author', 'lang:ic_author', 'required');
- $this->form_validation->set_rules('ic_url', 'lang:ic_url', 'callback_ic_url_check');
- //这里比较特别,检测两次ic_url,ci会冲掉第一个ic_url的规则,所以需要在下面也加上callback_ic_url_check
- $this->form_validation->set_rules('ic_url', 'lang:ic_url_format', 'callback_ic_url_check|callback_ic_url_format');
-
- if ($this->input->post('ignore_seo_check') === false) {
- $this->form_validation->set_rules('ic_seo_title', 'lang:ic_seo_title', 'required');
- $this->form_validation->set_rules('ic_seo_description', 'lang:ic_seo_description', 'required|max_length[250]');
- }
- if ($this->form_validation->run() == FALSE) {
- $data = array();
- foreach ($this->form_validation->_error_array as $key => $value) {
- $data[] = array('name' => $key, 'value' => $value);
- }
- echo json_encode($data);
- } else {
- $this->InfoContents_model->Update($information->is_ic_id, $this->input->post('ic_url'), $this->input->post('ic_url_title'), $this->input->post('ic_type'), $this->input->post('ic_title'), $this->input->post('ic_content'), $this->input->post('ic_summary'), $this->input->post('ic_seo_title'), $this->input->post('ic_seo_description'), $this->input->post('ic_seo_keywords'), $this->input->post('ic_show_bread_crumbs'), $this->input->post('ic_status'), $this->input->post('ic_template'), $this->input->post('ic_photo'), $this->input->post('ic_photo_width'), $this->input->post('ic_photo_height'), $this->input->post('ic_recommend_tours'), $this->input->post('ic_recommend_packages'), $this->input->post('ic_ht_area_id'), $this->input->post('ic_ht_area_type'), $this->input->post('ic_ht_product_id'), $this->input->post('ic_ht_product_type'), $this->input->post('ic_author'));
-
- //收录查询,只在发布上线并且url不为空的时候检查
- $embody_url = $this->input->post('ic_url');
- $embody_url = trim($embody_url);
- if ($this->input->post('ic_status') == 1 && $embody_url != '') {
- $embody = $this->InfoMetas_model->get($information->is_ic_id, 'meta_embody');
- if (empty($embody)) {
- $times = date('Y-m-d H:i:s');
- $this->InfoMetas_model->add($information->is_ic_id, 'meta_embody', $times);
- }
- }
-
- //为新闻添加默认发布时间
- //if($information->ic_ht_area_type=='s' || $information->ic_type=='c_article')
- //{
- $meta_news_createdate = get_meta($information->ic_id, 'meta_news_createdate');
- if (empty($meta_news_createdate)) {
- add_meta($information->ic_id, 'meta_news_createdate', date('m/d/Y', time()));
- }
- //}
- // if (is_series_site()) {
- //如果URL有修改也删除静态文件
- if ($this->input->post('ic_url') != $information->ic_url) {
- $this->update_cache($information->ic_url, true);
- }
-
- //如果信息不发布则删除静态文件
- if ($this->input->post('ic_status') == '0') {
- $this->update_cache($this->input->post('ic_url'), true);
- }
-
-
- //德语站FAQ版块需要删除原来的文件才能更新静态
- $site_code = $this->config->item('site_code');
- $ic_url = $this->input->post('ic_url');
- $auto_update_cache = $this->input->get_post('auto_update_cache_checkbox');
- if ($site_code == 'gm' && substr($ic_url, 0, 5) == '/faq/') {
- $update_info_log = $this->update_cache($ic_url, true);
- } else if (strcasecmp($site_code, "cht") == 0 && !empty($auto_update_cache)) {
- $update_info_log = $this->update_cache($ic_url);
- } else if (strcasecmp($site_code, "cht") != 0) {//非cht站点
- $update_info_log = $this->update_cache($ic_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';
- }
-
- $data[] = array('name' => 'ok', 'value' => $this->lang->line('form_info_success'), 'update_info_log' => $update_info_log);
- $this->Logs_model->backup($information->is_id, $this->input->post('ic_content'));
- $this->Logs_model->backup_summary($information->is_id, $this->input->post('ic_summary'));
-
- //作者个人页面更新
- if ($this->config->item('site_code') == 'cht') {
- $author_pages = array(
- 'zzy' => 'http://www.chinahighlights.com/author/ruru-zhou/',
- 'Gavin' => 'http://www.chinahighlights.com/author/gavin-van-hinsbergh/',
- 'WBL' => 'http://www.chinahighlights.com/author/annie-wu/',
- 'PKL' => 'http://www.chinahighlights.com/author/kelly/',
- '210000017' => 'http://www.chinahighlights.com/author/lynne-buddin/',
- '202000027' => 'http://www.chinahighlights.com/author/margaux/',
- '202000019' => 'http://www.chinahighlights.com/author/anusuya-mitra/',
- '210000018' => 'http://www.chinahighlights.com/author/connie/',
- '210000016' => 'http://www.chinahighlights.com/author/ben/',
- '200000008' => 'http://www.chinahighlights.com/author/pete-marchetto/',
- '210000019' => 'http://www.chinahighlights.com/author/oscar/',
- '210000021' => 'http://www.chinahighlights.com/author/matthew/',
- '200000013' => 'http://www.chinahighlights.com/author/kit-onslow-smith/',
- '202000018' => 'http://www.chinahighlights.com/author/klaus-capra/',
- '202000017' => 'http://www.chinahighlights.com/author/christy-campbell/'
- );
- $key = $this->input->post('ic_author');
- if (isset($author_pages[$key])) {
- $this->update_cache($author_pages[$key]);
- }
- }
-
- echo json_encode($data);
- }
- }
-
- //URL不重复检查
- function ic_url_check() {
- if ($this->input->post('ignore_url_check')) {
- return true;
- }
-
- $url = $this->input->post('ic_url');
- if ($url === '') {
- return true;
- }
- $is_id = $this->input->post('is_id');
- return $this->Information_model->URLcheck($is_id, $url);
- }
-
- //URL格式检查,不能包含大小写、空格等特殊字符
- function ic_url_format($url) {
- if ($url != mb_strtolower($url) || strpos($url, ' ') !== false || strpos($url, '--') !== false || strpos($url, ')') !== false || strpos($url, '(') !== false || strpos($url, '//') !== false || strpos($url, '\\') !== false) {
- return false;
- }
- return true;
- }
-
- //更新静态文件
- //不用参数提交的原因是可能url带有特殊字符,CI会报错
- public function update_cache($static_html_url = false, $delete_only = false) {
- $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; //原始链接
- $delete_only = !empty($delete_only) ? $delete_only : $this->input->get_post('delete_only');
-
- switch ($this->config->item('site_code')) {
- case 'cht':
- $search_list = $this->Information_model->search_url($url);
- $amp_request = FALSE;
- foreach ($search_list as $key => $req_url) {
- $meta_amp_status = get_meta($req_url->ic_id, 'AMP_STATUS');
- if ($meta_amp_status) {
- $amp_request = TRUE;
- }
- }
- if ($amp_request) {
- $url = 'http://184.172.113.219:22224/amp' . $url;
- } else {
- $url = 'http://184.172.113.219:22224' . $url;
- }
- break;
- 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;
-
- case 'gm':
- GET_HTTP("http://148.251.35.42:3300/create-cache/?url=" . urlencode($url)); //请求nodejs静态化更新页面,删除缓存,因为部分页面没有进入信息平台
- if ($delete_only) {
- $url = "http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url);
- } else {
- //先删除再生成,部分页面没有在信息平台中
- GET_HTTP("http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url));
- $url = "http://144.76.185.44:8029" . $url;
- }
- 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)) {
- $url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
- } else {
- //先尝试删除静态文件。
- $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/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;
- }
- }
- 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
- //error_reporting(NULL);
- //ini_set('display_errors', 'Off');
-
- $content = GET_HTTP($url);
- if ($content === false) {
- $data[] = array('name' => 'no', 'value' => sprintf($this->lang->line('update_cache_failed'), $url));
- } else {
- //手动更新的话,接着更新CDN缓存
- $msg = $this->lang->line('update_cache_success');
-
- if ($this->input->post('updatecdn') == 1) {
- $notice = $this->update_cdn();
- if ($notice == 200) {
- $msg.=$this->lang->line('update_cdn_success');
- } else {
- $msg.=$this->lang->line('update_cdn_failed') . '
' . $notice;
- }
- }
- $data[] = array('name' => 'ok', 'value' => $msg, 'url' => $url);
- }
- //如果是外部调用就返回结果,内部就不返回了
- if ($this->input->post('cache_url')) {
- echo json_encode($data);
- }
- return $data;
- }
-
- //更新CDN缓存
- public function update_cdn($static_html_url = false) {
- $flag = false; //false:不更新,true:更新
- $update_site = array('jp', 'ru'); //需要更新CDN的站点
- //需要更新的url
- $url = $static_html_url;
- if (empty($url))
- $url = $this->input->post('cache_url');
-
- //如果传递进来的url是带有域名,则对域名进行判断
- $tempu = parse_url($url);
- if (isset($tempu['host'])) {
- $url = isset($tempu['path']) ? $tempu['path'] : '/';
- $pad = $tempu['host'];
- $flag = true;
- }
- //如果传递进来的url没有域名,则使用当前站点的信息进行判断
- else {
- $url = str_replace($this->config->item('site_url'), '', $url);
- $pad = str_replace('http://', '', $this->config->item('site_url'));
- if (in_array($this->config->item('site_code'), $update_site))
- $flag = TRUE;
- }
-
- //默认更新成功,如果不成功,则返回错误提示信息
- $notice = 200;
- if ($flag) {
- $result = GET_HTTP('https://openapi.us.cdnetworks.com/purge/rest/doPurge?user=ycc@chinahighlights.com&pass=cXi2UbsTrw9Urv@&pad=' . $pad . '&type=item&path=' . $url . '&output=json');
- $result = json_decode($result, true);
- if ($result['resultCode'] != 200)
- $notice = $result['notice'] . $result['details'];
- }
- return $notice;
- }
-
- //获取产品信息,提供给用户选择进行绑定
- function get_products() {
- $HT_productType = $this->input->post('product_type');
- $HT_productName = $this->input->post('product_name');
- //产品类型
- switch ($HT_productType) {
- case 't':
- $data['productList'] = $this->Landscape_model->search_list($HT_productName);
- break;
- default:
- $data['productList'] = array();
- break;
- }
- $data['product_type'] = $HT_productType;
- $product_list_page = $this->load->view('bootstrap/information_select_product', $data, true);
- $data = array();
- $data[] = array('name' => 'ok', 'value' => $product_list_page);
- echo json_encode($data);
- return true;
- }
-
- //显示备份的内容
- function backup_content($log_id) {
- $data['log_info'] = $this->Logs_model->read($log_id);
- $data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id);
- $this->load->view('bootstrap/header', $data);
- $this->load->view('bootstrap/information_backup_content');
- $this->load->view('bootstrap/footer');
- }
-
- //增加新景点到景点概述下
- //先找到当前城市的景点概述根节点,然后新增加
- //$lsi_sn 翰特景点id
- function add_landscape($area_id, $lsi_sn) {
- //获取景点概述节点
- $root_landscape = $this->Information_model->get_type_detail('c_attraction', 'c', $area_id);
-
- if ($root_landscape == FALSE) {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('root_landscape_notfound'));
- echo json_encode($data);
- return false;
- }
-
- //获取景点详细内容
- $Landscape = $this->Landscape_model->get_detail($lsi_sn);
- if ($root_landscape == FALSE) {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('landscape_notfound'));
- echo json_encode($data);
- return false;
- }
-
-
- //添加空内容
- $this->InfoContents_model->Add($Landscape->LSI2_Name, $Landscape->LSI2_Name, '', $Landscape->LSI2_Name, $Landscape->LSI2_ShortIntro, '', '', '', '', 0, 0, '', '', 0, 0, '', '', $area_id, 'c', $lsi_sn, 't', '');
- if ($this->InfoStructures_model->Add($root_landscape->is_id, $this->InfoContents_model->insert_id)) {
- $data[] = array('name' => 'ok', 'value' => site_url('information/edit/' . $this->InfoStructures_model->insert_id));
- } else {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('form_info_error'));
- }
- echo json_encode($data);
- $this->Logs_model->add($this->InfoStructures_model->insert_id);
- return true;
- }
-
- //保存自定义配置
- function save_meta() {
- $im_ic_id = $this->input->post('im_ic_id');
- $im_key = $this->input->post('im_key');
- $im_value = $this->input->post('im_value');
- if ($im_ic_id && $im_key && $im_value !== false) {
- $meta = $this->InfoMetas_model->get($im_ic_id, $im_key);
- if ($meta === false) {
- $this->InfoMetas_model->add($im_ic_id, $im_key, $im_value);
- } else {
- $this->InfoMetas_model->update($im_ic_id, $im_key, $im_value);
- }
- $data[] = array('name' => 'ok', 'value' => $this->lang->line('media_save_success'));
- } else {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('media_save_error'));
- }
- echo json_encode($data);
- return true;
- }
-
- //保存自定义配置
- function delete_meta() {
- $im_ic_id = $this->input->post('im_ic_id');
- $im_key = $this->input->post('im_key');
- if ($im_ic_id && $im_key) {
-
- $this->InfoMetas_model->delete($im_ic_id, $im_key);
- $data[] = array('name' => 'ok', 'value' => $this->lang->line('media_delete_success'));
- } else {
- $data[] = array('name' => 'no', 'value' => $this->lang->line('media_save_error'));
- }
- echo json_encode($data);
- return true;
- }
-
-}
+permission->is_admin();
+ //$this->output->enable_profiler(TRUE);
+ $this->load->model('Area_model');
+ $this->load->model('Information_model');
+ $this->load->model('InfoContents_model');
+ $this->load->model('InfoStructures_model');
+ $this->load->model('Landscape_model');
+ $this->load->model('Operator_model');
+ $this->load->model('Logs_model');
+ $this->load->model('InfoMetas_model');
+ $this->load->model('Infoauthors_model');
+ $this->load->model('InfoSMS_model');
+ $this->load->library('Amplib'); //加载AMP处理类
+ }
+
+ public function index() {
+ echo '信息首页';
+ }
+
+ public function add($is_parent_id) {
+ //添加空内容.
+ $this->InfoContents_model->Add('', 'New Information', '', '', '', '', '', '', '', 0, 0, '', '', 0, 0, '', '', 0, '', 0, '', '');
+ $infocontent = $this->InfoContents_model->get_ic_contents($this->InfoContents_model->insert_id);
+ if (!empty($infocontent) && $this->InfoStructures_model->Add($is_parent_id, $this->InfoContents_model->insert_id)) {
+ $is_id = $this->InfoStructures_model->insert_id;
+ $InfoStructures = $this->InfoStructures_model->Detail($is_id);
+ $InfoStructures->is_id = $is_id;
+ $data[] = array('name' => 'ok', 'value' => $InfoStructures);
+ $this->Logs_model->add($this->InfoStructures_model->insert_id);
+ } else {
+ $data[] = array('name' => 'no', 'value' => $this->lang->line('form_info_error'));
+ }
+ echo json_encode($data);
+ return TRUE;
+ }
+
+ //移动结构顺序
+ public function move() {
+ //网站会提交一个同级节点id列表字符串,按照这个去排序
+ $parent_id = $this->input->post('pid');
+ $idsStr = $this->input->post('ids');
+ $idsArray = explode(',', $idsStr);
+ foreach ($idsArray as $key => $value) {
+ if ($value) {
+ //设置排序
+ $this->InfoStructures_model->set_sort($value, $key);
+ //设置path
+ $this->InfoStructures_model->set_path($parent_id, $value);
+ }
+ }
+ $data[] = array('name' => 'ok', 'value' => $this->lang->line('structures_success_move'));
+ echo json_encode($data);
+ $this->Logs_model->move($idsStr);
+ return TRUE;
+ }
+
+ //把文章移动到任意板块文章下
+ //is_id 信息结构ID,is_parent_id即将转移到的信息结构id
+ public function move_by_is_id() {
+ $data = array();
+ $is_id = $this->input->post('is_id');
+ $is_parent_id = $this->input->post('is_parent_id');
+ if ($is_id == $is_parent_id || empty($is_id) || empty($is_parent_id)) {
+ return false;
+ }
+ //即将移动到文章结构信息
+ $Structure = $this->InfoStructures_model->Detail($is_id);
+ //目标文章结构信息
+ $Structure_parent = $this->InfoStructures_model->Detail($is_parent_id);
+ //只能移动到本站点下
+ if ($Structure->is_sitecode == $Structure_parent->is_sitecode) {
+ //不能搬迁到自己的子节点下
+ if (strpos(',' . $Structure_parent->is_path, ',' . $is_id . ',') == false) {
+ $this->InfoStructures_model->set_path($is_parent_id, $is_id);
+ }
+ //信息的区域类型和id也要修改 todo
+ }
+ $data[] = array('name' => 'ok', 'value' => $this->lang->line('structures_success_move'));
+ echo json_encode($data);
+ $this->Logs_model->move($is_id);
+ return TRUE;
+ }
+
+ public function delete($is_id) {
+ //查询结构信息
+ $Structure = $this->InfoStructures_model->Detail($is_id);
+ if ($Structure == FALSE) {
+ $data[] = array('name' => 'no', 'value' => $this->lang->line('structures_error_notfound'));
+ echo json_encode($data);
+ return false;
+ }
+ if ($this->InfoStructures_model->HasChild($Structure->is_id)) {
+ $data[] = array('name' => 'no', 'value' => $this->lang->line('structures_error_haschild'));
+ echo json_encode($data);
+ return false;
+ } else {
+ $info_detail = $this->Information_model->Detail($is_id);
+ $this->Logs_model->delete($is_id, $info_detail->ic_content);
+ if (!empty($info_detail->ic_summary)) {
+ $this->Logs_model->backup_summary($is_id, $info_detail->ic_summary);
+ }
+ $this->InfoStructures_model->Delete($Structure->is_id);
+ $this->InfoContents_model->Delete($Structure->is_ic_id);
+ //如果是已经发布的页面,删除静态文件
+ if ($info_detail->ic_status == 1) {
+ $this->update_cache($info_detail->ic_url, true);
+ }
+ //删除成功后返回一个上级链接给用户
+ $drumpurl = site_url('information/edit/' . $Structure->is_parent_id);
+ if ($Structure->is_parent_id == 0)
+ $drumpurl = site_url('/');
+ $data[] = array('name' => 'ok', 'value' => $drumpurl);
+ echo json_encode($data);
+ return true;
+ }
+ }
+
+ public function edit($is_id) {
+ set_time_limit(30);
+ //$this->output->enable_profiler(true);
+ //查询结构信息
+ $Structure = $this->InfoStructures_model->Detail($is_id);
+ if ($Structure == FALSE) {
+ show_404();
+ }
+ //查询结构根节点
+ $rootStructure = $this->InfoStructures_model->GetParent($Structure->is_path, 1);
+ //没有根节点就从它本身开始查询
+ if ($rootStructure == false) {
+ $rootStructure_ID = $Structure->is_id;
+ } else {
+ $rootStructure_ID = $rootStructure->is_id;
+ }
+
+ //查询结构列表信息
+ $data['informationList'] = $this->Information_model->StructureList($rootStructure_ID);
+
+ //增加一项,属于这个区域,但是结构数据层次不准确的也要列出来
+ //todo:
+ //信息内容
+ $data['information'] = $this->Information_model->Detail($is_id);
+
+ //检查该信息是否已收录
+ $data['embody'] = 1;
+ if (isset($data['information']->ic_id)) {
+ $embody = $this->InfoMetas_model->get($data['information']->ic_id, 'meta_embody');
+ if ($embody && $embody != '1') {
+ $data['embody'] = 0;
+ }
+ //设置该信息所有未读消息为已读
+ $this->InfoSMS_model->readed_for_info($data['information']->ic_id);
+ }
+
+ //主节点信息
+ $data['rootInformation'] = $this->Information_model->Detail($rootStructure_ID);
+ //获取未绑定的景点,只有城市有,无视其它区域类型
+ $data['unlink_landscape_list'] = array();
+
+ //可选的展示模板
+ if (in_array($this->config->item('site_code'), array('vac', 'vc', 'jp', 'ru', 'it'))) {
+ $this->config->set_item('templates', $this->config->item('templates_i'));
+ }
+
+ if (in_array($this->config->item('site_code'), array('ah'))) {
+ $this->config->set_item('templates', $this->config->item('templates_ah'));
+ }
+ if (in_array($this->config->item('site_code'), array('pgr'))) {
+ $this->config->set_item('templates', $this->config->item('templates_pgr'));
+ }
+ if (in_array($this->config->item('site_code'), array('ts'))) {
+ $this->config->set_item('templates', $this->config->item('templates_ts'));
+ }
+ if (in_array($this->config->item('site_code'), array('cht'))) {
+ $this->config->set_item('templates', $this->config->item('templates_cht'));
+ }
+ if (in_array($this->config->item('site_code'), array('gm'))) {
+ $this->config->set_item('templates', $this->config->item('templates_gm'));
+ }
+
+
+
+ if ($Structure->is_sitecode=='ct'){
+ $data['infoTypeList'] = $this->config->item('InfoType_ct');
+ }else {
+
+ switch ($data['rootInformation']->ic_ht_area_type) {
+ case 'c': //城市
+ $data['infoTypeList'] = $this->config->item('InfoType_city');
+ $data['unlink_landscape_list'] = $this->Information_model->get_unlink_landscape_list($data['rootInformation']->ic_ht_area_id);
+ break;
+ case 'p'://省份
+ $data['infoTypeList'] = $this->config->item('InfoType_province');
+ break;
+ case 'n'://国家
+ $data['infoTypeList'] = $this->config->item('InfoType_country');
+ break;
+ case 't'://特殊区域
+ $data['infoTypeList'] = $this->config->item('InfoType_special');
+ break;
+ case 'e'://大洲
+ $data['infoTypeList'] = array();
+ break;
+ case 'z'://公民游
+ $data['infoTypeList'] = $this->config->item('InfoType_citizen');
+ break;
+ case 'v'://视频
+ $data['infoTypeList'] = $this->config->item('InfoType_video');
+ break;
+ case 'f'://节庆
+ $data['infoTypeList'] = $this->config->item('InfoType_festival');
+ break;
+ case 'pd'://产品管理
+ $data['infoTypeList'] = $this->config->item('InfoType_product');
+ //LMR 2016-7-14
+ if (in_array($this->config->item('site_code'), array('vac', 'vc', 'jp', 'ru', 'it'))) {
+ $this->config->set_item('templates', $this->config->item('templates_product_i'));
+ } else {
+ $this->config->set_item('templates', $this->config->item('templates_product'));
+ }
+ break;
+ default:
+ $data['infoTypeList'] = array('不设置' => 'none');
+ break;
+ }
+ }
+
+
+
+ $data['templateList'] = $this->config->item('templates');
+ //翰特产品类型
+ $data['productTypeList'] = $this->config->item('ProductType_HT');
+ //获取绑定的产品名称
+ switch ($data['information']->ic_ht_product_type) {
+ case 't':
+ $data['product_title'] = $this->Landscape_model->get_landscape_title($data['information']->ic_ht_product_id);
+ break;
+ default:
+ $data['product_title'] = '';
+ break;
+ }
+ //获取最后更新者信息
+ $data['last_edit_info'] = $this->Logs_model->get_last_edit($is_id);
+
+ //编辑列表
+ $sites = $this->config->item('site');
+ $data['editor_list'] = $this->Operator_model->get_site_user($this->config->item('site_code'));
+ //获取作者列表
+ $data['author_list'] = $this->Infoauthors_model->get_site_user($this->config->item('site_code'));
+
+ //获取备份信息记录
+ $data['content_backup_list'] = $this->Logs_model->get_backup_list($is_id);
+
+ //所属导航栏目
+ $data['setting_website_nav'] = $this->InfoMetas_model->get_list(0, 'setting_website_nav_' . strtolower($this->config->item('site_code')));
+
+ $data['my_tags'] = array();
+ $data['all_tags'] = array();
+ if (is_series_site()) {
+ //信息标签
+ //$this->InfoTags_model->ic_id = null;
+ //$data['all_tags'] = $this->InfoTags_model->list_tag();
+ //$this->InfoTags_model->ic_id = $data['information']->ic_id;
+ //$data['my_tags'] = $this->InfoTags_model->list_tag();
+ //差集
+ foreach ($data['all_tags'] as &$it) {
+ foreach ($data['my_tags'] as $it2) {
+ if ($it->it_id == $it2->icit_it_id) {
+ $it = null;
+ break;
+ }
+ }
+ }
+ $data['all_tags'] = array_filter($data['all_tags']);
+ }
+
+ $this->load->view('bootstrap3/header', $data);
+ $this->load->view('bootstrap3/information_edit');
+ $this->load->view('bootstrap3/footer');
+ }
+
+ /**
+ public function redirect($jumpUrl){
+
+ header('HTTP/1.1 301 Moved Permanently');
+
+ header($jumpUrl);// 301 跳转到设置的 url
+
+ exit();
+
+ } */
+ public function test_proxy($url = false) {
+ $curl = curl_init();
+ //curl_setopt($curl,CURLOPT_URL, "http://graph.facebook.com/?id=http://www.chinahighlights.com");
+ //curl_setopt($curl,CURLOPT_URL, 'http://graph.facebook.com/?id=http://www.mybeijingchina.com/beijing-attractions/beihai-park/');
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_HEADER, 0);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 1);
+ curl_setopt($curl, CURLOPT_PROXY, "120.24.227.23:33333");
+ $request = curl_exec($curl);
+ curl_close($curl);
+ return $request;
+ //echo $request;
+ }
+
+ // 分享数 lzq
+ public function statistical_sharing() {
+
+ //$info_ic = $this->Information_model->get_ic_url_by_code('mbj');
+ $info_ic = $this->Information_model->get_ic_url();
+ $ic_id = $info_ic->ic_id;
+ $ic_url = $info_ic->ic_url;
+ $ic_sitecode = $info_ic->ic_sitecode;
+ $site = $this->config->item('site');
+
+ if (!empty($ic_url)) {
+
+ $result = $this->Information_model->update_ic_date_by_code($ic_id);
+ //var_dump($site['mbj']['site_url']);
+ //$wz_url = 'http://graph.facebook.com/?id='.$site['mbj']['site_url'].$ic_url;
+ $complete_url = 'http://graph.facebook.com/?id=' . $site[$ic_sitecode]['site_url'] . $ic_url;
+ //echo $wz_url;
+ $api_return = $this->test_proxy($complete_url);
+ $api_return = json_decode($api_return);
+ if (empty($api_return->shares)) {
+ var_dump($api_return);
+ $shares = 0;
+ } else {
+ var_dump($api_return);
+ $shares = $api_return->shares;
+ }
+
+ //echo $asd->shares;
+ $result2 = $this->Information_model->insert_url_to_csi($info_ic->ic_url, $ic_id, $info_ic->ic_sitecode, $shares);
+ }
+
+ //$sstt = $this->config->item('site');
+ //foreach($infolist as $k=>$v){
+ // $aabb[] = $v->ic_sitecode;
+ //}
+ //$url_count = $this->Information_model->get_count_by_code('mbj');
+ //$surl = site_url('/information/fengxiangshu');
+ //redirect($surl,'refresh',301);
+
+ $this->load->view('bootstrap3/header');
+ $this->load->view('bootstrap3/statistical_sharing');
+ }
+
+ public function edit_save() {
+ header('Cache-Control: no-cache');
+ $information = $this->Information_model->Detail($this->input->post('is_id'));
+ if ($information === false) {
+ $data[] = array('name' => 'no', 'value' => $this->lang->line('structures_error_notfound'));
+ echo json_encode($data);
+ return false;
+ }
+
+ $this->form_validation->set_rules('ic_url_title', 'lang:ic_url_title', 'required');
+ $this->form_validation->set_rules('ic_title', 'lang:ic_title', 'required');
+ $this->form_validation->set_rules('ic_author', 'lang:ic_author', 'required');
+ $this->form_validation->set_rules('ic_url', 'lang:ic_url', 'callback_ic_url_check');
+ //这里比较特别,检测两次ic_url,ci会冲掉第一个ic_url的规则,所以需要在下面也加上callback_ic_url_check
+ $this->form_validation->set_rules('ic_url', 'lang:ic_url_format', 'callback_ic_url_check|callback_ic_url_format');
+
+ if ($this->input->post('ignore_seo_check') === false) {
+ $this->form_validation->set_rules('ic_seo_title', 'lang:ic_seo_title', 'required');
+ $this->form_validation->set_rules('ic_seo_description', 'lang:ic_seo_description', 'required|max_length[250]');
+ }
+ if ($this->form_validation->run() == FALSE) {
+ $data = array();
+ foreach ($this->form_validation->_error_array as $key => $value) {
+ $data[] = array('name' => $key, 'value' => $value);
+ }
+ echo json_encode($data);
+ } else {
+ $this->InfoContents_model->Update($information->is_ic_id, $this->input->post('ic_url'), $this->input->post('ic_url_title'), $this->input->post('ic_type'), $this->input->post('ic_title'), $this->input->post('ic_content'), $this->input->post('ic_summary'), $this->input->post('ic_seo_title'), $this->input->post('ic_seo_description'), $this->input->post('ic_seo_keywords'), $this->input->post('ic_show_bread_crumbs'), $this->input->post('ic_status'), $this->input->post('ic_template'), $this->input->post('ic_photo'), $this->input->post('ic_photo_width'), $this->input->post('ic_photo_height'), $this->input->post('ic_recommend_tours'), $this->input->post('ic_recommend_packages'), $this->input->post('ic_ht_area_id'), $this->input->post('ic_ht_area_type'), $this->input->post('ic_ht_product_id'), $this->input->post('ic_ht_product_type'), $this->input->post('ic_author'));
+
+ //AMP更新和生成 beign
+ $auto_update_amp = $this->input->get_post('auto_update_amp');
+ if (!empty($auto_update_amp) && $auto_update_amp == 'true' && $this->input->post('ic_status') == 1) {
+ $amp_result=$this->amplib->auto_create($information->ic_id);
+ if (!empty($amp_result)) {
+ $amp_result = json_decode($amp_result);
+ if($amp_result->result=='ok'){
+ $amp_save_result= $this->amplib->edit_save($information->ic_id,$amp_result->data->amp,'1');
+ if(!empty($amp_save_result)){
+ $amp_save_result = json_decode($amp_save_result);
+ if($amp_save_result->name=='no'){
+ echo json_encode(array('name' => 'no', 'value' => 'AMP转换语法错误,请重新进入AMP编辑器检查'));
+ return;
+ }
+ }
+ }
+ }
+ }
+ //AMP更新和生成 end
+ //为新闻添加默认发布时间
+ $meta_news_createdate = get_meta($information->ic_id, 'meta_news_createdate');
+ if (empty($meta_news_createdate)) {
+ add_meta($information->ic_id, 'meta_news_createdate', date('m/d/Y', time()));
+ }
+
+ //如果URL有修改也删除静态文件
+ if ($this->input->post('ic_url') != $information->ic_url) {
+ $this->update_cache($information->ic_url, true);
+ }
+
+ //如果信息不发布则删除静态文件
+ if ($this->input->post('ic_status') == '0') {
+ $this->update_cache($this->input->post('ic_url'), true);
+ }
+
+ //德语站FAQ版块需要删除原来的文件才能更新静态
+ $site_code = $this->config->item('site_code');
+ $ic_url = $this->input->post('ic_url');
+ $auto_update_cache = $this->input->get_post('auto_update_cache_checkbox');
+
+ if (strcasecmp($site_code, "gm") == 0 && !empty($auto_update_cache)) {
+ $update_info_log = $this->update_cache($ic_url, true);
+ } else if (strcasecmp($site_code, "cht") == 0 && !empty($auto_update_cache)) {
+ $update_info_log = $this->update_cache($ic_url);
+ } else if (strcasecmp($site_code, "cht") != 0 && strcasecmp($site_code, "gm") != 0) {//非cht站点并且非GM
+ $update_info_log = $this->update_cache($ic_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';
+ }
+
+ $data[] = array('name' => 'ok', 'value' => $this->lang->line('form_info_success'), 'update_info_log' => $update_info_log);
+ $this->Logs_model->backup($information->is_id, $this->input->post('ic_content'));
+ $this->Logs_model->backup_summary($information->is_id, $this->input->post('ic_summary'));
+
+ //作者个人页面更新
+ if ($this->config->item('site_code') == 'cht') {
+ $author_pages = array(
+ 'zzy' => 'http://www.chinahighlights.com/author/ruru-zhou/',
+ 'Gavin' => 'http://www.chinahighlights.com/author/gavin-van-hinsbergh/',
+ 'WBL' => 'http://www.chinahighlights.com/author/annie-wu/',
+ 'PKL' => 'http://www.chinahighlights.com/author/kelly/',
+ '210000017' => 'http://www.chinahighlights.com/author/lynne-buddin/',
+ '202000027' => 'http://www.chinahighlights.com/author/margaux/',
+ '202000019' => 'http://www.chinahighlights.com/author/anusuya-mitra/',
+ '210000018' => 'http://www.chinahighlights.com/author/connie/',
+ '210000016' => 'http://www.chinahighlights.com/author/ben/',
+ '200000008' => 'http://www.chinahighlights.com/author/pete-marchetto/',
+ '210000019' => 'http://www.chinahighlights.com/author/oscar/',
+ '210000021' => 'http://www.chinahighlights.com/author/matthew/',
+ '200000013' => 'http://www.chinahighlights.com/author/kit-onslow-smith/',
+ '202000018' => 'http://www.chinahighlights.com/author/klaus-capra/',
+ '202000017' => 'http://www.chinahighlights.com/author/christy-campbell/'
+ );
+ $key = $this->input->post('ic_author');
+ if (isset($author_pages[$key])) {
+ $this->update_cache($author_pages[$key]);
+ }
+ }
+
+ echo json_encode($data);
+ }
+ }
+
+ //URL不重复检查
+ function ic_url_check() {
+ if ($this->input->post('ignore_url_check')) {
+ return true;
+ }
+
+ $url = $this->input->post('ic_url');
+ if ($url === '') {
+ return true;
+ }
+ $is_id = $this->input->post('is_id');
+ return $this->Information_model->URLcheck($is_id, $url);
+ }
+
+ //URL格式检查,不能包含大小写、空格等特殊字符
+ function ic_url_format($url) {
+ if ($url != mb_strtolower($url) || strpos($url, ' ') !== false || strpos($url, '--') !== false || strpos($url, ')') !== false || strpos($url, '(') !== false || strpos($url, '//') !== false || strpos($url, '\\') !== false) {
+ return false;
+ }
+ return true;
+ }
+
+ //更新静态文件
+ //不用参数提交的原因是可能url带有特殊字符,CI会报错
+ public function update_cache($static_html_url = false, $delete_only = false) {
+ $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; //原始链接
+ $delete_only = !empty($delete_only) ? $delete_only : $this->input->get_post('delete_only');
+
+ switch ($this->config->item('site_code')) {
+ case 'cht':
+ $search_list = $this->Information_model->search_url($url);
+ $amp_request = FALSE;
+ foreach ($search_list as $key => $req_url) {
+ $meta_amp_status = get_meta($req_url->ic_id, 'AMP_STATUS');
+ if ($meta_amp_status) {
+ $amp_request = TRUE;
+ }
+ }
+ if ($amp_request) {
+ $url = 'http://192.155.250.124:22224/ampreq' . $url;
+ } else {
+ $url = 'http://192.155.250.124:22224' . $url;
+ }
+ break;
+ 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;
+
+ case 'gm':
+ //GET_HTTP("http://148.251.35.42:3300/create-cache/?url=" . urlencode($url)); //请求nodejs静态化更新页面,删除缓存,因为部分页面没有进入信息平台
+ if ($delete_only) {
+ $url = "http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url);
+ } else {
+ //先删除再生成,部分页面没有在信息平台中
+ GET_HTTP("http://144.76.185.44:8029/gm.php/information/delete_cache_23Xd913mddkgssODII?static_html_url=" . urlencode($url));
+ $url = "http://144.76.185.44:8029" . $url;
+ }
+ 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)) {
+ $url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
+ } else {
+ //先尝试删除静态文件。
+ //$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/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;
+ }
+ //int return direct
+ $cache_url = $this->input->post('cache_url');
+ if ($url && !$cache_url) {
+ /*
+ ignore_user_abort(true);
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 1);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //禁止直接显示获取的内容
+ curl_setopt($ch, CURLOPT_HEADER, 0); //不需要HEAD
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
+ curl_setopt($ch, CURLOPT_NOBODY, 1);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+ curl_exec($ch);
+ curl_close($ch);
+ */
+ $data['async_update'] = $url;
+ $data[] = array('name' => 'ok', 'value' => '信息保存成功,请在8秒后检查更新页面。', 'url' => $url);
+ //如果是外部调用就返回结果,内部就不返回了
+ if ($cache_url) {
+ echo json_encode($data);
+ }
+ return $data;
+ }
+ }
+ 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;
+ }
+
+ $content = GET_HTTP($url);
+ if ($content === false) {
+ $data[] = array('name' => 'no', 'value' => sprintf($this->lang->line('update_cache_failed'), $url));
+ } else {
+ //手动更新的话,接着更新CDN缓存
+ $msg = $this->lang->line('update_cache_success');
+
+ if ($this->input->post('updatecdn') == 1) {
+ $notice = $this->update_cdn();
+ if ($notice == 200) {
+ $msg .= $this->lang->line('update_cdn_success');
+ } else {
+ $msg .= $this->lang->line('update_cdn_failed') . '
' . $notice;
+ }
+ }
+ $data[] = array('name' => 'ok', 'value' => $msg, 'url' => $url);
+ }
+ //如果是外部调用就返回结果,内部就不返回了
+ if ($this->input->post('cache_url')) {
+ echo json_encode($data);
+ }
+ return $data;
+ }
+
+ //更新CDN缓存
+ public function update_cdn($static_html_url = false) {
+ $flag = false; //false:不更新,true:更新
+ $update_site = array('jp', 'ru'); //需要更新CDN的站点
+ //需要更新的url
+ $url = $static_html_url;
+ if (empty($url))
+ $url = $this->input->post('cache_url');
+
+ //如果传递进来的url是带有域名,则对域名进行判断
+ $tempu = parse_url($url);
+ if (isset($tempu['host'])) {
+ $url = isset($tempu['path']) ? $tempu['path'] : '/';
+ $pad = $tempu['host'];
+ $flag = true;
+ }
+ //如果传递进来的url没有域名,则使用当前站点的信息进行判断
+ else {
+ $url = str_replace($this->config->item('site_url'), '', $url);
+ $pad = str_replace('http://', '', $this->config->item('site_url'));
+ if (in_array($this->config->item('site_code'), $update_site))
+ $flag = TRUE;
+ }
+
+ //默认更新成功,如果不成功,则返回错误提示信息
+ $notice = 200;
+ if ($flag) {
+ $result = GET_HTTP('https://openapi.us.cdnetworks.com/purge/rest/doPurge?user=ycc@chinahighlights.com&pass=cXi2UbsTrw9Urv@&pad=' . $pad . '&type=item&path=' . $url . '&output=json');
+ $result = json_decode($result, true);
+ if ($result['resultCode'] != 200)
+ $notice = $result['notice'] . $result['details'];
+ }
+ return $notice;
+ }
+
+ //获取产品信息,提供给用户选择进行绑定
+ function get_products() {
+ $HT_productType = $this->input->post('product_type');
+ $HT_productName = $this->input->post('product_name');
+ //产品类型
+ switch ($HT_productType) {
+ case 't':
+ $data['productList'] = $this->Landscape_model->search_list($HT_productName);
+ break;
+ default:
+ $data['productList'] = array();
+ break;
+ }
+ $data['product_type'] = $HT_productType;
+ $product_list_page = $this->load->view('bootstrap/information_select_product', $data, true);
+ $data = array();
+ $data[] = array('name' => 'ok', 'value' => $product_list_page);
+ echo json_encode($data);
+ return true;
+ }
+
+ //显示备份的内容
+ function backup_content($log_id) {
+ $data['log_info'] = $this->Logs_model->read($log_id);
+ $data['log_list'] = $this->Logs_model->get_all_backup_list($data['log_info']->log_res_id);
+ $this->load->view('bootstrap/header', $data);
+ $this->load->view('bootstrap/information_backup_content');
+ $this->load->view('bootstrap/footer');
+ }
+
+ //保存自定义配置
+ function save_meta() {
+ $im_ic_id = $this->input->post('im_ic_id');
+ $im_key = $this->input->post('im_key');
+ $im_value = $this->input->post('im_value');
+ if ($im_ic_id && $im_key && $im_value !== false) {
+ $meta = $this->InfoMetas_model->get($im_ic_id, $im_key);
+ if ($meta === false) {
+ $this->InfoMetas_model->add($im_ic_id, $im_key, $im_value);
+ } else {
+ $this->InfoMetas_model->update($im_ic_id, $im_key, $im_value);
+ }
+ $data[] = array('name' => 'ok', 'value' => $this->lang->line('media_save_success'));
+ } else {
+ $data[] = array('name' => 'no', 'value' => $this->lang->line('media_save_error'));
+ }
+ echo json_encode($data);
+ return true;
+ }
+
+ //保存自定义配置
+ function delete_meta() {
+ $im_ic_id = $this->input->post('im_ic_id');
+ $im_key = $this->input->post('im_key');
+ if ($im_ic_id && $im_key) {
+
+ $this->InfoMetas_model->delete($im_ic_id, $im_key);
+ $data[] = array('name' => 'ok', 'value' => $this->lang->line('media_delete_success'));
+ } else {
+ $data[] = array('name' => 'no', 'value' => $this->lang->line('media_save_error'));
+ }
+ echo json_encode($data);
+ return true;
+ }
+
+}
diff --git a/application/controllers/keyworlds.php b/application/controllers/keyworlds.php
index 472f0b9b..ae82e562 100644
--- a/application/controllers/keyworlds.php
+++ b/application/controllers/keyworlds.php
@@ -15,9 +15,6 @@ class Keyworlds extends CI_Controller {
}
public function index($kw_is_id = '') {
- $this->load->library('Accesscheck');
- $this->accesscheck->check_access();
-
$this->permission->is_admin();
//查询结构列表信息
$data['keyworldsList'] = $this->Keywords_model->get_structure_list();
diff --git a/application/controllers/login.php b/application/controllers/login.php
index 9f6c418f..4c0d5011 100644
--- a/application/controllers/login.php
+++ b/application/controllers/login.php
@@ -61,10 +61,6 @@ class Login extends CI_Controller {
$admin_info = $this->session->userdata('session_admin');
if ($this->accesscheck->check_access($site_code)) {
$this->session->set_userdata('session_site', $site_item);
- $this->session->unset_userdata('access_module');
- $this->session->unset_userdata('access_read_list');
- $this->session->unset_userdata('access_write_list');
- $this->session->unset_userdata('access_sitecode');
}
}
//跳转到指定页面。
diff --git a/application/controllers/look_order.php b/application/controllers/look_order.php
index 39aabc63..c85e926f 100644
--- a/application/controllers/look_order.php
+++ b/application/controllers/look_order.php
@@ -34,7 +34,9 @@ class Look_order extends CI_Controller {
//显示订单数量,如果大于阈值就显示错误
public function status() {
$data = array();
- $data['tour_count'] = $this->Orders_model->tour_count();
+ $tour_count = $this->Orders_model->tour_count();
+ $biz_count = $this->Orders_model->biz_count();
+ $data['tour_count'] = $tour_count + $biz_count;
if ($data['tour_count'] >= 550) {
$this->output->set_status_header(500);
}
diff --git a/application/controllers/payment.php b/application/controllers/payment.php
index 82a594ed..cdced964 100644
--- a/application/controllers/payment.php
+++ b/application/controllers/payment.php
@@ -16,8 +16,7 @@ class Payment extends CI_Controller
{
$data=array();
if ($this->input->post('price')) {
- $data['payurl']='
- load->library('Accesscheck');
- $this->accesscheck->check_access();
//查询不到省份信息则显示错误
$data['province'] = $this->Area_model->get_province($province_id);
if ($data['province'] == FALSE)
diff --git a/application/controllers/seo.php b/application/controllers/seo.php
index 74ac123b..ab0a152f 100644
--- a/application/controllers/seo.php
+++ b/application/controllers/seo.php
@@ -14,8 +14,6 @@ class Seo extends CI_Controller {
$this->load->model('InfoContents_model');
$this->load->model('InfoStructures_model');
$this->load->model('InfoSEOs_model');
- $this->load->library('Accesscheck');
- $this->accesscheck->check_access();
}
public function index() {
diff --git a/application/controllers/tools.php b/application/controllers/tools.php
index ac95ded2..12741419 100644
--- a/application/controllers/tools.php
+++ b/application/controllers/tools.php
@@ -11,6 +11,7 @@ class Tools extends CI_Controller
$this->load->model('Area_model');
$this->load->model('InfoStructures_model');
$this->load->model('Information_model');
+ $this->load->model('InfoMetas_model');
$this->site_code = $this->config->item('site_code');
}
@@ -52,6 +53,29 @@ class Tools extends CI_Controller
$this->load->view('tools/old', $data);
}
}
+
+ /**
+ *
+ * 公有函数:AMP转化表格。
+ *
+ * 必要参数:
+ * @param String $site_code
+ *
+ */
+ public function amp_check()
+ {
+ $data['amp'] = $this->input->get_post('amp');
+ if (!$data['amp']) $data['amp'] = 'yes';
+ //AMP转化列表
+ if ($data['amp'] == 'yes') {
+ $data['info'] = $this->InfoMetas_model->list_amp($this->site_code);
+ } else {
+ $data['info'] = $this->InfoMetas_model->list_no_amp($this->site_code);
+ }
+
+ //视图
+ $this->load->view('tools/amp_check', $data);
+ }
/**
* 导出CSV文件
diff --git a/application/controllers/welcome.php b/application/controllers/welcome.php
index 214252b1..75659070 100644
--- a/application/controllers/welcome.php
+++ b/application/controllers/welcome.php
@@ -26,7 +26,7 @@ class Welcome extends CI_Controller {
$data['last_city_list'] = $this->Area_model->get_last_edit_city();
if ($this->config->item('site_code') == 'pgr') {
- $data['countryList'] = $this->Area_model->get_country_list_for_site("'589','645'");
+ $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);
@@ -65,29 +65,24 @@ class Welcome extends CI_Controller {
$this->load->view('bootstrap/footer');
}
- //获取所有信息+产品url
- public function create_all_urls() {
+ //获取所有信息URL,用来批量静态化更新
+ public function create_all_urls($view=false) {
set_time_limit(0);
$this->output->enable_profiler(false);
- $this->Information_model->topNum = false;
- $data['all_information'] = $this->Information_model->GetList('ic_status,ic_url,ic_sitecode');
- //系列站产品连接
- $site_code = strtoupper($this->config->item('site_code'));
- if (!empty($site_code)) {
- $this->load->helper('file');
- $path = APPPATH . '/views/product_urls/updateCache' . $site_code . '.txt';
- if (file_exists($path)) {
- $data['product_urls'] = read_file($path);
- $domain = $this->config->item('site_url');
- $data['product_urls'] = str_replace("\n", '
', $data['product_urls']);
- $data['product_urls'] = str_replace($domain, $domain . '/index.php/welcome/update_cache/?static_html_url=', $data['product_urls']);
- }
+ $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');
}
- $this->load->view('none_urls', $data);
}
//获取某个信息节点和子节点url
- public function create_infomation_urls($is_parent_id) {
+ public function create_infomation_urls($is_parent_id, $view = false) {
$this->output->enable_profiler(FALSE);
$structure = $this->InfoStructures_model->Detail($is_parent_id);
if (empty($structure)) {
@@ -95,9 +90,15 @@ class Welcome extends CI_Controller {
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/cache_url', $data);
- $this->load->view('bootstrap/footer');
+ 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) {
@@ -118,37 +119,37 @@ class Welcome extends CI_Controller {
$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
- ));
+ '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
- ));
+ 'status' => 'success',
+ 'logId' => $last_backup->log_id,
+ 'datetime' => $last_backup->log_datetime,
+ 'username' => $last_backup->log_ht_username
+ ));
}
}
public function change_static_url($info_id) {
$information = $this->Information_model->Detail($info_id);
$htm_doc = new DOMDocument();
- $htm_doc->encoding='UTF-8';
+ $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'
- ));
+ 'status' => 'error',
+ 'infoId' => $info_id,
+ 'message' => 'info content is empty'
+ ));
return;
}
$htm_doc->loadHTML(
- mb_convert_encoding($information->ic_content, 'HTML-ENTITIES', 'UTF-8'));
+ mb_convert_encoding($information->ic_content, 'HTML-ENTITIES', 'UTF-8'));
$htm_doc->normalizeDocument();
$img_list = $htm_doc->getElementsByTagName('img');
foreach ($img_list as $img) {
@@ -157,87 +158,166 @@ class Welcome extends CI_Controller {
$img->setAttribute('src', $img_src);
}
- $information->ic_content = $htm_doc->saveHTML();
- $this->InfoContents_model->Update(
- $information->ic_id,
- $information->ic_url,
- $information->ic_url_title,
- $information->ic_type,
- $information->ic_title,
- $information->ic_content,
- $information->ic_summary,
- $information->ic_seo_title,
- $information->ic_seo_description,
- $information->ic_seo_keywords,
- $information->ic_show_bread_crumbs,
- $information->ic_status,
- $information->ic_template,
- $information->ic_photo,
- $information->ic_photo_width,
- $information->ic_photo_height,
- $information->ic_recommend_tours,
- $information->ic_recommend_packages,
- $information->ic_ht_area_id,
- $information->ic_ht_area_type,
- $information->ic_ht_product_id,
- $information->ic_ht_product_type,
- $information->ic_author);
-
- $this->echo_json(array(
- 'status' => 'ok',
- 'infoId' => $info_id,
- 'message' => 'success',
- 'date' => date('Y-m-d h:i:s')
- ));
+ $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 . '
';
+ }
+ }
+
+ // $information->ic_content = $htm_doc->saveHTML();
+ // $this->InfoContents_model->Update(
+ // $information->ic_id,
+ // $information->ic_url,
+ // $information->ic_url_title,
+ // $information->ic_type,
+ // $information->ic_title,
+ // $information->ic_content,
+ // $information->ic_summary,
+ // $information->ic_seo_title,
+ // $information->ic_seo_description,
+ // $information->ic_seo_keywords,
+ // $information->ic_show_bread_crumbs,
+ // $information->ic_status,
+ // $information->ic_template,
+ // $information->ic_photo,
+ // $information->ic_photo_width,
+ // $information->ic_photo_height,
+ // $information->ic_recommend_tours,
+ // $information->ic_recommend_packages,
+ // $information->ic_ht_area_id,
+ // $information->ic_ht_area_type,
+ // $information->ic_ht_product_id,
+ // $information->ic_ht_product_type,
+ // $information->ic_author);
+ // $this->echo_json(array(
+ // 'status' => 'ok',
+ // 'infoId' => $info_id,
+ // 'message' => 'success',
+ // 'date' => date('Y-m-d h:i:s')
+ // ));
+ }
+
+ 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;
+ }
+
+ 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) . '
';
+ }
+
+ 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->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
+ );
+ }
+ }
}
private function echo_json($obj) {
$this->output
- ->set_content_type('application/json')
- ->set_output(json_encode($obj));
+ ->set_content_type('application/json')
+ ->set_output(json_encode($obj));
}
-
- //批量替换二级域名,如图片或者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';
- }
- }
+ //批量替换二级域名,如图片或者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';
+ }
+ }
private function check_url($subject) {
$result = $subject;
@@ -261,7 +341,7 @@ class Welcome extends CI_Controller {
preg_match($pattern, $subject, $match_result);
$result_count = count($match_result);
if ($result_count == 2) {
- $result = $replace.$match_result[1];
+ $result = $replace . $match_result[1];
}
return $result;
}
@@ -282,7 +362,7 @@ class Welcome extends CI_Controller {
$parent_path = str_replace('-', ',', $parent_path);
$parent_path = trim($parent_path, ',');
if ($parent_path != '')
- $parent_path.=',';
+ $parent_path .= ',';
$this->load->model('Import_model');
$this->Import_model->set_path($is_id, $parent_path);
echo 'ok';
diff --git a/application/helpers/info_helper.php b/application/helpers/info_helper.php
index 99909ace..06cb3f44 100644
--- a/application/helpers/info_helper.php
+++ b/application/helpers/info_helper.php
@@ -312,6 +312,11 @@ function get_content_by_url($url) {
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$tmpInfo = curl_exec($curl); // 执行操作
+ $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+ if($httpCode>=400){//页面状态,如果大于400说明页面打不开
+ log_message('error', " curl {$httpCode} {$url} ");
+ return false;
+ }
$errno = curl_errno($curl);
if ($errno !== 0) {
return false;
diff --git a/application/libraries/Accesscheck.php b/application/libraries/Accesscheck.php
index bb0a3fc0..8f9faebf 100644
--- a/application/libraries/Accesscheck.php
+++ b/application/libraries/Accesscheck.php
@@ -18,16 +18,9 @@ class Accesscheck extends CI_Controller
return true;
}
- if ($this->session->userdata('access_module') === false){
- $this->init_accessdata();
- }
+ $this->session->set_userdata('access_sitecode', $this->Access_model->get_user_site_list($userdata['OPI_Code']));
//用户拥有权限de站点、模块&需要权限认证的模块
- $access_module = $this->session->userdata('access_module');
- $user_controller = $access_module['user_controller'];
- $user_action = $access_module['user_action'];
- $iaa_controller_list = $access_module['iaa_controller_list'];
- $iaa_action_list = $access_module['iaa_action_list'];
- $user_site_list = $this->session->userdata('access_sitecode');
+ $user_site_list = $this->session->userdata('access_sitecode');
//检测用户是否能访问当前站点,如果不能,则跳转到该用户有权限的站点
if($site_code=='')$site_code=$this->config->item('site_code');
@@ -35,86 +28,9 @@ class Accesscheck extends CI_Controller
header('Location: '.$_SERVER['HTTP_REFERER']);
exit();
}
-
- //判断当前操作是否需要认证
- $flag=true;
- if ($module!='') {
- $module_array=explode('/', trim($module));
- $this->router->class= $module_array[0];
- $this->router->method= $module_array[1];
- }
- //判断当前模块是否需要认证
- if (in_array($this->router->class, $iaa_controller_list)) {
- //如果需要认证,判断是否有权限操作当前模块
- if (in_array($this->router->class,$user_controller)) {
- //判断是否能编辑不同省份信息
- /*if($this->router->class=='province'){
- $province=str_replace('/province/', '', $this->uri->uri_string());
- $province=trim($province);
- if (!isset($user_action[$this->router->class]) || !in_array($province, $user_action[$this->router->class])) {
- $flag = false;//没有权限查看当前省份!
- }
- }
- //判断当前方法是否需要认证
- else*/
- if (isset($iaa_action_list[$this->router->class]) && in_array($this->router->method, $iaa_action_list[$this->router->class])) {
- //如果当前方法需要认证,则判断是否有权限
- if (!isset($user_action[$this->router->class]) || !in_array($this->router->method, $user_action[$this->router->class])) {
- $flag = false;//没有权限执行当前方法!
- }
- }
- }else {
- $flag = false;//没有权限执行当前控制器模块!
- }
- }
- if ($module =='' && !$flag) {
- redirect(site_url('Login/refuse'));
- exit();
- }
- return $flag;
+ return true;
}
- public function init_accessdata(){
- $userdata=$this->session->userdata('session_admin');
- //根据usercode获取用户角色、可读、可写列表
- $user_access=$this->Access_model->get_user_access($userdata['OPI_Code'],$this->config->item('site_code'));
- //根据角色字符串获取用户有权限的操作
- $user_node=$this->Access_model->get_node_list($user_access->iao_role.'0');
- //把用户拥有的所有角色id组装成一个数组集合
- $node_str='';
- foreach ($user_node as $node) {
- $node_str.=$node->ian_iaa_id;
- }
- $node_array=explode(',', substr($node_str, 0,-1));
-
- //用户拥有权限de站点、模块&需要权限认证的模块
- $user_controller = array();
- $user_action = array();
- $iaa_controller_list = array();
- $iaa_action_list = array();
-
- //所有需要认证的模块、方法
- $action_list=$this->Access_model->get_action_list();
- foreach ($action_list as $a) {
-
- //用户拥有的权限模块、方法
- if (in_array($a->iaa_id, $node_array) && $a->iaa_controller!='') {
- $user_controller[] = $a->iaa_controller;
- $user_action[$a->iaa_controller][] = $a->iaa_action;
- }
- //需要认证的控制器和方法
- if(!empty($a->iaa_controller))$iaa_controller_list[]=$a->iaa_controller;
- if(!empty($a->iaa_action))$iaa_action_list[$a->iaa_controller][]=$a->iaa_action;
- }
- $access_module['user_controller'] = $user_controller;
- $access_module['user_action'] = $user_action;
- $access_module['iaa_controller_list'] = $iaa_controller_list;
- $access_module['iaa_action_list'] = $iaa_action_list;
- $this->session->set_userdata('access_read_list', $user_access->iao_read);
- $this->session->set_userdata('access_write_list', $user_access->iao_write);
- $this->session->set_userdata('access_sitecode', $this->Access_model->get_user_site_list($userdata['OPI_Code']));
- $this->session->set_userdata('access_module', $access_module);
- }
//获取角色等级(角色树形结构的等级)
public function get_role_level($site_code='',$author=''){
diff --git a/application/libraries/Amplib.php b/application/libraries/Amplib.php
new file mode 100644
index 00000000..59239abf
--- /dev/null
+++ b/application/libraries/Amplib.php
@@ -0,0 +1,130 @@
+CI = & get_instance();
+ $this->CI->load->model('Information_model');
+ $this->CI->load->model('InfoMetas_model');
+ $this->CI->load->model('Logs_model');
+ }
+
+ 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();
+ }
+ $this->CI->load->view('bootstrap3/header', $data);
+ $this->CI->load->view('amp_editor');
+ $this->CI->load->view('bootstrap3/footer');
+ }
+
+ public function auto_create($ic_id) {
+ $data = array();
+ $data['information'] = $this->CI->Information_model->detail_by_ic_id($ic_id);
+ if ($data['information'] == FALSE) {
+ return json_encode(array('result' => 'no', 'data' => '找不到这个页面'));
+ }
+
+ //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://192.155.224.195:2222' . $data['information']->ic_url;
+ break;
+ case 'gm':
+ $websitehost = 'https://data.chinarundreisen.com';
+ $html_source_url = 'http://144.76.185.44:8029' . $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'){
+ return GET_HTTP(site_url('/apps/htmlcompressor/index_gm/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 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');
+ }
+ $data['information'] = $this->CI->Information_model->detail_by_ic_id($ic_id);
+
+ if ($data['information'] == FALSE) {
+ show_404();
+ }
+
+ //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://184.172.113.216: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);
+ }
+
+ $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(array('name' => 'ok', 'value' => $this->CI->lang->line('form_info_success')));
+ }
+
+}
diff --git a/application/libraries/MY_Composer.php b/application/libraries/MY_Composer.php
new file mode 100644
index 00000000..6cad19e7
--- /dev/null
+++ b/application/libraries/MY_Composer.php
@@ -0,0 +1,15 @@
+.
+//
+// ----------------------------------------------------------------------------
+//
+// Description : PHP class to read DOCX file into HTML format
+//
+// Author: Ricardo Pinto
+//
+// (c) Copyright:
+// Ricardo Pinto
+//============================================================+
+
+class WordPHP
+{
+ private $debug = false;
+ private $file;
+ private $rels_xml;
+ private $doc_xml;
+ private $doc_media = array();
+ private $last = 'none';
+ private $encoding = 'UTF-8';
+ private $tmpDir = 'tmp';
+ //图片目录和前缀
+ public $img_dir = '';
+ public $img_prex = '';
+
+ /**
+ * CONSTRUCTOR
+ *
+ * @param Boolean $debug Debug mode or not
+ * @return void
+ */
+ public function __construct($debug_=null, $encoding=null)
+ {
+ if($debug_ != null) {
+ $this->debug = $debug_;
+ }
+ if ($encoding != null) {
+ $this->encoding = $encoding;
+ }
+ $this->tmpDir = dirname(__FILE__);
+ }
+
+ /**
+ * Sets the tmp directory where images will be stored
+ *
+ * @param string $tmp The location
+ * @return void
+ */
+ private function setTmpDir($tmp)
+ {
+ $this->tmpDir = $tmp;
+ }
+
+ /**
+ * READS The Document and Relationships into separated XML files
+ *
+ * @param var $object The class variable to set as DOMDocument
+ * @param var $xml The xml file
+ * @param string $encoding The encoding to be used
+ * @return void
+ */
+ private function setXmlParts(&$object, $xml, $encoding)
+ {
+ $object = new DOMDocument();
+ $object->encoding = $encoding;
+ $object->preserveWhiteSpace = false;
+ $object->formatOutput = true;
+ $object->loadXML($xml);
+ $object->saveXML();
+ }
+
+ /**
+ * READS The Document and Relationships into separated XML files
+ *
+ * @param String $filename The filename
+ * @return void
+ */
+ private function readZipPart($filename)
+ {
+ $zip = new ZipArchive();
+ $_xml = 'word/document.xml';
+ $_xml_rels = 'word/_rels/document.xml.rels';
+
+ if (true === $zip->open($filename)) {
+ if (($index = $zip->locateName($_xml)) !== false) {
+ $xml = $zip->getFromIndex($index);
+ }
+ //Get the relationships
+ if (($index = $zip->locateName($_xml_rels)) !== false) {
+ $xml_rels = $zip->getFromIndex($index);
+ }
+ // load all images if they exist
+ for ($i=0; $i<$zip->numFiles;$i++) {
+ $zip_element = $zip->statIndex($i);
+ if(preg_match("([^\s]+(\.(?i)(jpg|jpeg|png|gif|bmp))$)",$zip_element['name'])) {
+ $this->doc_media[$zip_element['name']] = $zip_element['name'];
+ }
+ }
+ $zip->close();
+ } else die('non zip file');
+
+ $enc = mb_detect_encoding($xml);
+ $this->setXmlParts($this->doc_xml, $xml, $enc);
+ $this->setXmlParts($this->rels_xml, $xml_rels, $enc);
+
+ if($this->debug) {
+ echo "";
+ echo "";
+ }
+ }
+
+ /**
+ * CHECKS THE FONT FORMATTING OF A GIVEN ELEMENT
+ * Currently checks and formats: bold, italic, underline, background color and font family
+ *
+ * @param XML $xml The XML node
+ * @return String HTML formatted code
+ */
+ private function checkFormating(&$xml)
+ {
+ $node = trim($xml->readOuterXML());
+ $t = '';
+ // add
tags
+ if (mb_strstr($node,'';
+ // look for formatting tags
+ $f = "checkImageFormating($reader);
+ $img = $r !== null ? "" : null;
+ }
+ }
+
+ $f = rtrim($f, ',');
+ $f .= "'>";
+ $t .= ($img !== null ? $img : htmlentities($xml->expand()->textContent));
+
+ return $f.$t."";
+ }
+
+ /**
+ * CHECKS THE ELEMENT FOR UL ELEMENTS
+ * Currently under development
+ *
+ * @param XML $xml The XML node
+ * @return String HTML formatted code
+ */
+ private function getListFormating(&$xml)
+ {
+ $node = trim($xml->readOuterXML());
+
+ $reader = new XMLReader();
+ $reader->XML($node);
+ $ret="";
+ $close = "";
+ while ($reader->read()){
+ if($reader->name == "w:numPr" && $reader->nodeType == XMLReader::ELEMENT ) {
+
+ }
+ if($reader->name == "w:numId" && $reader->hasAttributes) {
+ switch($reader->getAttribute("w:val")) {
+ case 1:
+ $ret['open'] = "- ";
+ $ret['close'] = "
";
+ break;
+ case 2:
+ $ret['open'] = "";
+ break;
+ }
+
+ }
+ }
+ return $ret;
+ }
+
+ /**
+ * CHECKS IF THERE IS AN IMAGE PRESENT
+ * Currently under development
+ *
+ * @param XML $xml The XML node
+ * @return String The location of the image
+ */
+ private function checkImageFormating(&$xml)
+ {
+ $content = trim($xml->readInnerXml());
+
+ if (!empty($content)) {
+
+ $relId;
+ $notfound = true;
+ $reader = new XMLReader();
+ $reader->XML($content);
+
+ while ($reader->read() && $notfound) {
+ if ($reader->name == "a:blip") {
+ $relId = $reader->getAttribute("r:embed");
+ $notfound = false;
+ }
+ }
+
+ // image id found, get the image location
+ if (!$notfound && $relId) {
+ $reader = new XMLReader();
+ $reader->XML($this->rels_xml->saveXML());
+
+ while ($reader->read()) {
+ if ($reader->nodeType == XMLREADER::ELEMENT && $reader->name=='Relationship') {
+ if($reader->getAttribute("Id") == $relId) {
+ $link = "word/".$reader->getAttribute('Target');
+ break;
+ }
+ }
+ }
+
+ $zip = new ZipArchive();
+ $im = null;
+ if (true === $zip->open($this->file)) {
+ $im = $this->createImage($zip->getFromName($link), $relId, $link);
+ }
+ $zip->close();
+ return $im;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Creates an image in the filesystem
+ *
+ * @param objetc $image The image object
+ * @param string $relId The image relationship Id
+ * @param string $name The image name
+ * @return Array With HTML open and closing tag definition
+ */
+ private function createImage($image, $relId, $name)
+ {
+ $arr = explode('.', $name);
+ $l = count($arr);
+ $ext = mb_strtolower($arr[$l-1]);
+
+ $im = imagecreatefromstring($image);
+ if (empty($this->img_dir)) {
+ $fname = $this->tmpDir.'/tmp/'.$relId.'.'.$ext;
+ } else {
+ $ext = str_ireplace('jpeg', 'jpg', $ext);
+ $fname = $this->img_dir.'/'.$this->img_prex.'_'.mb_strtolower($relId).'.'.$ext;
+ }
+
+
+ switch ($ext) {
+ case 'png':
+ imagepng($im, $fname);
+ break;
+ case 'bmp':
+ imagebmp($im, $fname);
+ break;
+ case 'gif':
+ imagegif($im, $fname);
+ break;
+ case 'jpeg':
+ case 'jpg':
+ imagejpeg($im, $fname);
+ break;
+ default:
+ return null;
+ }
+
+ return $fname;
+ }
+
+ /**
+ * CHECKS IF ELEMENT IS AN HYPERLINK
+ *
+ * @param XML $xml The XML node
+ * @return Array With HTML open and closing tag definition
+ */
+ private function getHyperlink(&$xml)
+ {
+ $ret = array('open'=>'');
+ $link ='';
+ if($xml->hasAttributes) {
+ $attribute = "";
+ while($xml->moveToNextAttribute()) {
+ if($xml->name == "r:id")
+ $attribute = $xml->value;
+ }
+
+ if($attribute != "") {
+ $reader = new XMLReader();
+ $reader->XML($this->rels_xml->saveXML());
+
+ while ($reader->read()) {
+ if ($reader->nodeType == XMLREADER::ELEMENT && $reader->name=='Relationship') {
+ if($reader->getAttribute("Id") == $attribute) {
+ $link = $reader->getAttribute('Target');
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if($link != "") {
+ $ret['open'] = "";
+ $ret['close'] = "";
+ }
+
+ return $ret;
+ }
+
+
+ /**
+ * PROCESS TABLE CONTENT
+ *
+ * @param XML $xml The XML node
+ * @return THe HTML code of the table
+ */
+ private function checkTableFormating(&$xml)
+ {
+ $table = "";
+
+ while ($xml->read()) {
+ if ($xml->nodeType == XMLREADER::ELEMENT && $xml->name === 'w:tr') { //table row
+ $tc = $ts = "";
+
+
+ $tr = new XMLReader;
+ $tr->xml(trim($xml->readOuterXML()));
+
+ while ($tr->read()) {
+ if ($tr->nodeType == XMLREADER::ELEMENT && $tr->name === 'w:tcPr') { //table element properties
+ $ts = $this->processTableStyle(trim($tr->readOuterXML()));
+ }
+ if ($tr->nodeType == XMLREADER::ELEMENT && $tr->name === 'w:tc') { //table column
+ $tc .= $this->processTableRow(trim($tr->readOuterXML()));
+ }
+ }
+ $table .= ''.$tc.'
';
+ }
+ }
+
+ $table .= "
";
+ return $table;
+ }
+
+ /**
+ * PROCESS THE TABLE ROW STYLE
+ *
+ * @param string $content The XML node content
+ * @return THe HTML code of the table
+ */
+ private function processTableStyle($content)
+ {
+ /*border-collapse:collapse;
+ border-bottom:4px dashed #0000FF;
+ border-top:6px double #FF0000;
+ border-left:5px solid #00FF00;
+ border-right:5px solid #666666;*/
+
+ $tc = new XMLReader;
+ $tc->xml($content);
+ $style = "border-collapse:collapse;";
+
+ while ($tc->read()) {
+ if ($tc->name === "w:tcBorders") {
+ $tc2 = new SimpleXMLElement($tc->readOuterXML());
+
+ foreach ($tc2->children('w',true) as $ch) {
+ if (in_array($ch->getName(), array('left','top','botom','right'))) {
+ $line = $this->convertLine($ch['val']);
+ $style .= " border-".$ch->getName().":".$ch['sz']."px $line #".$ch['color'].";";
+ }
+ }
+
+ $tc->next();
+ }
+ }
+ return $style;
+ }
+
+ private function convertLine($in)
+ {
+ if (in_array($in, array('dotted')))
+ return "dashed";
+
+ if (in_array($in, array('dotDash','dotdotDash','dotted','dashDotStroked','dashed','dashSmallGap')))
+ return "dashed";
+
+ if (in_array($in, array('double','triple','threeDEmboss','threeDEngrave','thick')))
+ return "double";
+
+ if (in_array($in, array('nil','none')))
+ return "none";
+
+ return "solid";
+ }
+
+ /**
+ * PROCESS THE TABLE ROW
+ *
+ * @param string $content The XML node content
+ * @return THe HTML code of the table
+ */
+ private function processTableRow($content)
+ {
+ $tc = new XMLReader;
+ $tc->xml($content);
+ $ct = "";
+
+ while ($tc->read()) {
+ if ($tc->name === "w:r") {
+ $ct .= "".$this->checkFormating($tc)." | ";
+ $tc->next();
+ }
+ }
+ return $ct;
+ }
+
+ /**
+ * READS THE GIVEN DOCX FILE INTO HTML FORMAT
+ *
+ * @param String $filename The DOCX file name
+ * @return String With HTML code
+ */
+ public function readDocument($filename)
+ {
+ $this->file = $filename;
+ $this->readZipPart($filename);
+ $reader = new XMLReader();
+ $reader->XML($this->doc_xml->saveXML());
+
+ $text = ''; $list_format="";
+
+ $formatting['header'] = 0;
+ // loop through docx xml dom
+ while ($reader->read()) {
+ // look for new paragraphs
+ $paragraph = new XMLReader;
+ $p = $reader->readOuterXML();
+ //return $p;
+
+ if ($reader->nodeType == XMLREADER::ELEMENT && $reader->name === 'w:p') {
+ // set up new instance of XMLReader for parsing paragraph independantly
+ $paragraph->xml($p);
+
+ preg_match('/ 0) ? '' : '';
+
+ // loop through paragraph dom
+ while ($paragraph->read()) {
+ // look for elements
+ if ($paragraph->nodeType == XMLREADER::ELEMENT && $paragraph->name === 'w:r') {
+ if($list_format == "")
+ $text .= $this->checkFormating($paragraph);
+ else {
+ $text .= $list_format['open'];
+ $text .= $this->checkFormating($paragraph);
+ $text .= $list_format['close'];
+ }
+ $list_format ="";
+ $paragraph->next();
+ }
+ else if($paragraph->nodeType == XMLREADER::ELEMENT && $paragraph->name === 'w:pPr') { //lists
+ $list_format = $this->getListFormating($paragraph);
+ $paragraph->next();
+ }
+ else if($paragraph->nodeType == XMLREADER::ELEMENT && $paragraph->name === 'w:drawing') { //images
+ $text .= $this->checkImageFormating($paragraph);
+ $paragraph->next();
+ }
+ else if ($paragraph->nodeType == XMLREADER::ELEMENT && $paragraph->name === 'w:hyperlink') {
+ $hyperlink = $this->getHyperlink($paragraph);
+ $text .= $hyperlink['open'];
+ $text .= $this->checkFormating($paragraph);
+ $text .= $hyperlink['close'];
+ $paragraph->next();
+ }
+ }
+ $text .= ($formatting['header'] > 0) ? '
' : '';
+ }
+ else if ($reader->nodeType == XMLREADER::ELEMENT && $reader->name === 'w:tbl') { //tables
+ $paragraph->xml($p);
+ $text .= $this->checkTableFormating($paragraph);
+ $reader->next();
+ }
+ }
+ $reader->close();
+ if($this->debug) {
+ echo "";
+ echo mb_convert_encoding($text, $this->encoding);
+ echo "
";
+ }
+ return mb_convert_encoding($text, $this->encoding);
+ }
+}
\ No newline at end of file
diff --git a/application/models/infoContents_model.php b/application/models/infoContents_model.php
index aa37343e..676d76db 100644
--- a/application/models/infoContents_model.php
+++ b/application/models/infoContents_model.php
@@ -85,6 +85,14 @@ class InfoContents_model extends CI_Model
return $query;
}
+ //删除信息
+ function force_update($ic_id, $ic_content)
+ {
+ $sql = "UPDATE infoContents SET ic_content = N? WHERE ic_id = ?";
+ $query = $this->HT->query($sql, array($ic_content, $ic_id));
+ return $query;
+ }
+
//删除信息
function Delete($ic_id)
{
@@ -126,7 +134,7 @@ class InfoContents_model extends CI_Model
public function get_ic_contents2($ic_id)
{
- $sql="SELECT top 1 ic_id, ic_content, ic_title, ic_url, ic_photo from infoContents where ic_id=?";
+ $sql="SELECT top 1 ic_id, ic_content, ic_title, ic_url, ic_photo, ic_sitecode, ic_seo_description from infoContents where ic_id=?";
$query=$this->HT->query($sql,array($ic_id));
if ($query->result())
{
diff --git a/application/models/infoMetas_model.php b/application/models/infoMetas_model.php
index 1010b214..08264246 100644
--- a/application/models/infoMetas_model.php
+++ b/application/models/infoMetas_model.php
@@ -16,7 +16,7 @@ class InfoMetas_model extends CI_Model {
. " ( \n"
. " ?, ?, N? \n"
. " )";
- return $this->HT->query($sql, array($im_ic_id, $im_key, $im_value));
+ return $this->HT->query($sql, array($im_ic_id, $im_key, (string)$im_value));
}
function get_list($im_ic_id, $im_key) {
@@ -33,6 +33,102 @@ class InfoMetas_model extends CI_Model {
$query = $this->HT->query($sql, array($im_ic_id, $im_key));
return $query->result();
}
+
+ function get_list_by_key($im_key) {
+ $sql = "
+ SELECT im.im_id
+ ,im.im_ic_id
+ ,im.im_key
+ ,im.im_value
+ FROM infoMetas im
+ WHERE im.im_ic_id = ?
+ AND im.im_key = ?
+ ORDER BY im.im_id ASC
+ ";
+ $query = $this->HT->query($sql, array($im_ic_id, $im_key));
+ return $query->result();
+ }
+
+ //列表所有含AMPmeta的信息。
+ public function list_amp($site_code) {
+ $sql = "
+ SELECT im.im_id
+ ,im.im_ic_id
+ ,c.ic_url
+ ,c.ic_id
+ ,empty_tpl = case when c.ic_template in ('r_tpl_empty', 'r_empty_container', 'r_empty2', 'r_tpl_empty_2017', 'tpl_empty', 'tpl_empty_h1', 'tpl_empty_navi_h1') then 'yes' else 'no' end
+ FROM infoMetas im
+ INNER JOIN infoContents c
+ ON c.ic_id = im.im_ic_id
+ LEFT JOIN infoMetas im2
+ ON im2.im_ic_id = im.im_ic_id AND im2.im_key = 'AMP_STATUS'
+ LEFT JOIN infoMetas im3
+ ON im3.im_ic_id = im.im_ic_id AND im2.im_key = 'AMP_SCHEMA'
+ WHERE im.im_key = 'AMP_JSON'
+ AND c.ic_sitecode = ?
+ AND c.ic_status = 1
+ AND CONVERT(varchar, im2.im_value) = '1'
+ ";
+ $query = $this->HT->query($sql, array($site_code));
+ return $query->result();
+ }
+
+ //列表所有不含AMPmeta的信息。
+ public function list_no_amp($site_code) {
+ $sql = "
+ SELECT c0.ic_id, c0.ic_url
+ FROM infoContents c0
+ WHERE c0.ic_id not in (
+ SELECT c.ic_id
+ FROM infoMetas im
+ LEFT JOIN infoContents c
+ ON c.ic_id = im.im_ic_id
+ LEFT JOIN infoMetas im2
+ ON im2.im_ic_id = im.im_ic_id AND im2.im_key = 'AMP_STATUS'
+ LEFT JOIN infoMetas im3
+ ON im3.im_ic_id = im.im_ic_id AND im2.im_key = 'AMP_SCHEMA'
+ WHERE im.im_key = 'AMP_JSON'
+ AND c.ic_sitecode = ?
+ AND c.ic_status = 1
+ AND CONVERT(varchar, im2.im_value) = '1'
+ )
+ AND c0.ic_sitecode = ?
+ AND c0.ic_status = 1
+ AND c0.ic_url <> ''
+ AND datalength(c0.ic_content) > 0
+ AND CHARINDEX('search', c0.ic_url) = 0
+ AND CHARINDEX('faq', c0.ic_url) = 0
+ AND CHARINDEX('feedback', c0.ic_url) = 0
+ AND CHARINDEX('test', c0.ic_url) = 0
+ ";
+ $query = $this->HT->query($sql, array($site_code, $site_code));
+ return $query->result();
+ }
+
+ //按节点列表信息(含meta数据)
+ function list_info_by_path_with_meta($is_path, $site_code) {
+ $sql = "SELECT is1.is_id, \n"
+ . " is1.is_path, \n"
+ . " ic.ic_id, \n"
+ . " ic.ic_url, \n"
+ . " ic.ic_status, \n"
+ . " ic.ic_template, \n"
+ . " ic.ic_sitecode, \n"
+ . " ic.ic_content, \n"
+ . " ic.ic_photo, \n"
+ . " ic.ic_title, \n"
+ . " ic.ic_type, \n"
+ . " im.im_id \n"
+ . " FROM infoStructures is1 \n"
+ . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n"
+ . " AND ic.ic_sitecode = is1.is_sitecode \n"
+ . " LEFT JOIN infoMetas im ON im.im_ic_id = ic.ic_id AND im.im_key=?"
+ . " WHERE is1.is_path LIKE '$is_path%' AND is_sitecode = ? AND ic_status = 1"
+ . " ORDER BY is1.is_level, is1.is_sort, is1.is_path";
+ $query = $this->HT->query($sql, array('AMP_JSON', $site_code));
+ //print_r($this->HT->queries);
+ return $query->result();
+ }
function get($im_ic_id, $im_key) {
$sql = "SELECT im.im_value \n"
@@ -81,7 +177,7 @@ class InfoMetas_model extends CI_Model {
. "SET im_value = N? \n"
. "WHERE im_ic_id = ? \n"
. " AND im_key = ?";
- return $this->HT->query($sql, array($im_value, $im_ic_id, $im_key));
+ return $this->HT->query($sql, array((string)$im_value, $im_ic_id, $im_key));
}
function delete($im_ic_id, $im_key) {
diff --git a/application/models/information_model.php b/application/models/information_model.php
index c5b991a0..b1b78052 100644
--- a/application/models/information_model.php
+++ b/application/models/information_model.php
@@ -74,14 +74,14 @@ class Information_model extends CI_Model {
}
//根据根节点路径获取子节点列表
- function get_list_by_path($path, $level = false) {
+ function get_list_by_path($path, $level = false, $site_code = false) {
$this->init();
if ($level !== false) {
$this->level = " AND is1.is_level= '$level' ";
}
$this->path = " AND is1.is_path LIKE '$path%' ";
$this->orderBy = ' ORDER BY is1.is_level ASC, is1.is_sort ASC,is1.is_path ASC ';
- return $this->GetList();
+ return $this->GetList('', $site_code);
}
//根据路径获取某一级别节点详细页
@@ -129,7 +129,7 @@ class Information_model extends CI_Model {
return $this->GetList();
}
- function GetList($filed = "") {
+ function GetList($filed = "", $site_code = "") {
$this->topNum ? $sql = "SELECT TOP " . $this->topNum : $sql = "SELECT ";
if (empty($filed)) {
$sql .= " is1.is_id, \n"
@@ -164,10 +164,14 @@ class Information_model extends CI_Model {
. " ic.ic_ht_area_type, \n"
. " ic.ic_ht_product_id, \n"
. " ic.ic_ht_product_type, \n"
+ . " ic.SRMS_SIC_Code, \n"
+ . " ic.SRMS_SIIT_Code, \n"
. " ic.ic_author \n";
} else {
$sql.=" $filed ";
}
+ //添加查询AMP发布状态
+ $sql.=",isnull((select top 1 CONVERT(varchar, im_value) from infoMetas where im_ic_id=ic_id and im_key='AMP_STATUS'),0) as amp_status ";
$sql.="FROM infoStructures is1 \n"
. " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n"
. " AND ic.ic_sitecode = is1.is_sitecode \n"
@@ -187,7 +191,7 @@ class Information_model extends CI_Model {
$this->orderBy ? $sql.=$this->orderBy : false;
- $query = $this->HT->query($sql, array($this->config->item('site_code')));
+ $query = $this->HT->query($sql, array($site_code ? $site_code : $this->config->item('site_code')));
//print_r($this->HT->queries);
if ($this->topNum === 1) {
if ($query->num_rows() > 0) {
@@ -357,4 +361,54 @@ class Information_model extends CI_Model {
return $query->result();
}
+
+ //ct
+ function ct_get_by_url($ic_url,$webcode)
+ {
+ $this->ic_url_is_id=" AND ic.ic_url = N".$this->HT->escape($ic_url);
+ $sql = "SELECT is1.is_id, \n"
+ . " is1.is_parent_id, \n"
+ . " is1.is_path, \n"
+ . " is1.is_level, \n"
+ . " is1.is_sort, \n"
+ . " is1.is_sitecode, \n"
+ . " is1.is_datetime, \n"
+ . " is1.is_ic_id, \n"
+ . " ic.ic_id, \n"
+ . " ic.ic_url, \n"
+ . " ic.ic_url_title, \n"
+ . " ic.ic_type, \n"
+ . " ic.ic_title, \n"
+ . " ic.ic_content, \n"
+ . " ic.ic_summary, \n"
+ . " ic.ic_seo_title, \n"
+ . " ic.ic_seo_description, \n"
+ . " ic.ic_seo_keywords, \n"
+ . " ic.ic_show_bread_crumbs, \n"
+ . " ic.ic_status, \n"
+ . " ic.ic_template, \n"
+ . " ic.ic_photo, \n"
+ . " ic.ic_photo_width, \n"
+ . " ic.ic_photo_height, \n"
+ . " ic.ic_sitecode, \n"
+ . " ic.ic_recommend_tours, \n"
+ . " ic.ic_recommend_packages, \n"
+ . " ic.ic_datetime, \n"
+ . " ic.ic_ht_area_id, \n"
+ . " ic.ic_ht_area_type, \n"
+ . " ic.ic_ht_product_id, \n"
+ . " ic.ic_ht_product_type, \n"
+ . " ic.ic_author \n"
+ . " FROM infoStructures is1 \n"
+ . " INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id \n"
+ . " AND ic.ic_sitecode = is1.is_sitecode \n"
+ . " WHERE is1.is_sitecode = ? ";
+ $sql .= $this->ic_url_is_id;
+ $query = $this->HT->query($sql, $webcode);
+ // print_r($this->HT->queries);
+
+ return $query->row();
+ }
+
+
}
diff --git a/application/models/orders_model.php b/application/models/orders_model.php
index a374cc16..7d28d0a7 100644
--- a/application/models/orders_model.php
+++ b/application/models/orders_model.php
@@ -59,6 +59,24 @@ class Orders_model extends CI_Model {
}
}
+ //获取当天商务订单
+ function biz_count() {
+ $date_start = date('Y-m-d', time() - 86400);//减一天
+ $date_end = date('Y-m-d', time() + 86400);//加一天
+ $sql = "
+ SELECT COUNT(1) AS CLI_COUNT
+ FROM BIZ_ConfirmLineInfo bcli
+ WHERE bcli.COLI_ApplyDate BETWEEN '$date_start 00:00:00' AND '$date_end 23:59:59'
+ ";
+ $query = $this->HT->query($sql);
+ if ($query->num_rows() > 0) {
+ $row = $query->row();
+ return $row->CLI_COUNT;
+ } else {
+ return FALSE;
+ }
+ }
+
//获取当天商务订单
function get_biz_info($sitecode) {
$sql = "SELECT bcli.COLI_ID, n"
diff --git a/application/third_party/ctrip/controllers/ctrip_train.php b/application/third_party/ctrip/controllers/ctrip_train.php
new file mode 100644
index 00000000..1836268e
--- /dev/null
+++ b/application/third_party/ctrip/controllers/ctrip_train.php
@@ -0,0 +1,325 @@
+load->helper('ctrip');
+ $this->load->model("ctrip_model");
+ date_default_timezone_set('PRC');
+
+ }
+
+ public function index(){
+ exit('hello ctrip');
+ }
+
+ //查询车次余票
+ public function search(){
+ //接收参数
+ $date = $this->input->get_post('date');
+ $from = $this->input->get_post('from');
+ $to = $this->input->get_post('to');
+ $TrainNo = $this->input->get_post('TrainNo');
+
+ if(!$date || !$from || !$to){
+ header("HTTP/1.1 404 Not Found");
+ exit('{"httpstatus":404,"data":{"seven":false,"cache":false,"result":[],"map":{}}}');
+ }else{
+ $isCache = false;
+ $iseven = false;
+ $cachedata = false;
+ $now_time = time();
+ $differ = (strtotime($date) - $now_time) / 86400;
+ if($differ > 29){
+ $date = date('Y-m-d',strtotime('+7day'));
+ $iseven = true;
+ }
+
+ //转换三字码为中文
+ $FromName = $this->ctrip_model->ReplaceCodeToName($from);
+ $ToName = $this->ctrip_model->ReplaceCodeToName($to);
+
+
+ if(!$FromName || !$ToName){
+ header("HTTP/1.1 404 Not Found");
+ exit('{"httpstatus":404,"data":{"seven":false,"cache":false,"result":[],"map":{}}}');
+ }else{
+ $from = $FromName->station_name;
+ $to = $ToName->station_name;
+ }
+
+ //生成请求链接
+ $TimeStamp = time();
+ $Sign = md5($TimeStamp.DATAKEY);
+
+ $url = JSONRETURN.'SearchS2S/?From='.urlencode($from).'&To='.urlencode($to).'&DepartDate='.$date.'&User='.DATAUSER.'&TimeStamp='.$TimeStamp.'&Sign='.$Sign;
+
+ $api_start_time = microtime(true);
+
+ //获取数据
+ $ResponseJson = post_ctrip($url,'','GET');
+
+ $api_end_time = microtime(true);
+
+ $ResponseData = json_decode($ResponseJson);
+ $api_responsive_time = $api_end_time - $api_start_time;
+ //print_r($ResponseData);die();
+
+ if(empty($ResponseData->Trains)){
+ log_message('error','ctrip_trian|status:trains is empty |相应时间:'.$api_responsive_time);
+ }else{
+ log_message('error','ctrip_trian|status:'.$ResponseData->ResponseStatus->Ack.'|相应时间:'.$api_responsive_time);
+ }
+
+ //定义返回的json
+ $ReturnData = new stdClass();
+ $ReturnData->httpstatus = 200;
+ $ReturnData->data = new stdClass();
+ $ReturnData->data->seven = $iseven;
+ $ReturnData->data->cache = $isCache;
+ $ReturnData->data->result = array();
+ $ReturnData->data->map = new stdClass();
+ $obj = array();
+ $i = 0;
+ $PriceStr = '';
+ //数据解析
+ if(!empty($ResponseData->Trains)){
+ foreach ($ResponseData->Trains as $TrainInfo){
+ $obj[$TrainInfo->FromTelcode] = $TrainInfo->FromStationName;
+ $obj[$TrainInfo->ToTelcode] = $TrainInfo->ToStationName;
+ $SeaType = '';
+ $gjrwNum = $rwNum = $rzNum = $tdzNum = $wzNum = $yzNum = $edzNum = $ydzNum = $swzNum = $ywNum = $dwNum = null;
+ foreach($TrainInfo->Seats as $Seats){
+ if($Seats->SeatName == '高级软卧下'){
+ $gjrwXiaPrice = $Seats->Price * 10;
+ $SeaType .= '"6":"'.$gjrwXiaPrice.'","A6":"¥'.$Seats->Price.'",';
+ $gjrwNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '软卧下'){
+ $rwPrice = $Seats->Price * 10;
+ $SeaType .= '"4":"'.$rwPrice.'","A4":"¥'.$Seats->Price.'",';
+ $rwNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '一等双软下'){
+ $ydrwPrice = $Seats->Price * 10;
+ $SeaType .= '"I":"'.$ydrwPrice.'","AI":"¥'.$Seats->Price.'",';
+ $ydrwNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '软座'){
+ $rzPrice = $Seats->Price * 10;
+ $SeaType .= '"2":"'.$rzPrice.'","A2":"¥'.$Seats->Price.'",';
+ $rzNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '特等座'){
+ $SeaType .= '"P":"¥'.$Seats->Price.'",';
+ $tdzNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '无座'){
+ $SeaType .= '"WZ":"¥'.$Seats->Price.'",';
+ $wzNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '硬座'){
+ $yzPrice = $Seats->Price * 10;
+ $SeaType .= '"1":"'.$yzPrice.'","A1":"¥'.$Seats->Price.'",';
+ $yzNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '二等座'){
+ $SeaType .= '"O":"¥'.$Seats->Price.'",';
+ $edzNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '一等座'){
+ $SeaType .= '"M":"¥'.$Seats->Price.'",';
+ $ydzNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '商务座'){
+ $swzPrice = $Seats->Price * 10;
+ $SeaType .= '"9":"'.$swzPrice.'","A9":"¥'.$Seats->Price.'",';
+ $swzNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '硬卧下'){
+ $ywPrice = $Seats->Price * 10;
+ $SeaType .= '"3":"'.$ywPrice.'","A3":"¥'.$Seats->Price.'",';
+ $ywNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '二等双软下'){
+ $errwPrice = $Seats->Price * 10;
+ $SeaType .= '"J":"'.$errwPrice.'","AJ":"¥'.$Seats->Price.'",';
+ $errwNum = $Seats->TicketLeft;
+ }
+
+ if($Seats->SeatName == '动卧下'){
+ $SeaType .= '"F":"¥'.$Seats->Price.'",';
+ $dwNum = $Seats->TicketLeft;
+ }
+
+ $PriceStr = $SeaType.'"train_no":'.'"'.$TrainInfo->TrainNo.'"';
+ }
+
+
+ //对返回的数据进行容错处理
+ $gjrwNum = isset($gjrwNum) ? ticket_exchange($gjrwNum,$iseven) : '';
+ $rwNum = isset($rwNum) ? ticket_exchange($rwNum,$iseven) : '';
+ $rzNum = isset($rzNum) ? ticket_exchange($rzNum,$iseven) : '';
+ $tdzNum = isset($tdzNum) ? ticket_exchange($tdzNum,$iseven) : '';
+ $wzNum = isset($wzNum) ? ticket_exchange($wzNum,$iseven) : '';
+ $ywNum = isset($ywNum) ? ticket_exchange($ywNum,$iseven) : '';
+ $yzNum = isset($yzNum) ? ticket_exchange($yzNum,$iseven) : '';
+ $edzNum = isset($edzNum) ? ticket_exchange($edzNum,$iseven) : '';
+ $ydzNum = isset($ydzNum) ? ticket_exchange($ydzNum,$iseven) : '';
+ $swzNum = isset($swzNum) ? ticket_exchange($swzNum,$iseven) : '';
+ $dwNum = isset($dwNum) ? ticket_exchange($dwNum,$iseven) : '';
+ $ydrwNum = isset($ydrwNum) ? ticket_exchange($ydrwNum,$iseven) : '';
+ $errwNum = isset($errwNum) ? ticket_exchange($errwNum,$iseven) : '';
+
+ if($rwNum == '' && $ydrwNum != ''){
+ $rwNum = $ydrwNum;
+ }
+
+ if($ywNum == '' && $errwNum != ''){
+ $ywNum = $errwNum;
+ }
+
+ $runMin = $TrainInfo->DurationMinutes % 60;
+ $runHour = ($TrainInfo->DurationMinutes - $runMin) / 60;
+
+ $ReturnData->data->result[$i] = '|预定|'.$TrainInfo->Train12306No.'|'.$TrainInfo->TrainNo.'|'.$TrainInfo->FromStationName.'|'.$TrainInfo->ToStationName.'|'.$TrainInfo->FromTelcode.'|'.$TrainInfo->ToTelcode.'|'.$TrainInfo->StartTime.'|'.$TrainInfo->ArriveTime.'|'.$runHour.':'.$runMin.'|'.$TrainInfo->CanWebBuy.'||'.date('Ymd',strtotime($date)).'||||||||'.$gjrwNum.'||'.$rwNum.'|'.$rzNum.'|'.$tdzNum.'|'.$wzNum.'||'.$ywNum.'|'.$yzNum.'|'.$edzNum.'|'.$ydzNum.'|'.$swzNum.'|'.$dwNum.'||';
+
+ $data = '{"validateMessagesShowId":"_validatorMessage","status":true,"httpstatus":200,"data":{'.$PriceStr.'},"messages":[],"validateMessages":{}}';
+ $ReturnData->data->price[$i] = $data;
+ $i++;
+ }
+ }
+ //print_r($ResponseData);
+ $ReturnData->data->map = (object)$obj;
+ print_r(json_encode($ReturnData));
+ }
+ }
+
+ //查询经停站
+ public function getstopstation(){
+ //接收参数
+ $DepartDate = $this->input->get_post('DepartDate');
+ $TrainNo = $this->input->get_post('TrainNo');
+
+ if(!$DepartDate || !$TrainNo){
+ exit('传参错误!');
+ }else{
+ //生成请求链接
+ $TimeStamp = time();
+ $Sign = md5($TimeStamp.DATAKEY);
+
+ $url = JSONRETURN.'GetStopStations/?DepartDate='.$DepartDate.'&TrainNo='.$TrainNo.'&User='.DATAUSER.'&TimeStamp='.$TimeStamp.'&Sign='.$Sign;
+
+ $ResponseJson = post_ctrip($url,'','GET');
+ $ResponseData = json_decode($ResponseJson);
+
+ //构造12306格式
+ $ReturnData = array();
+ $ReturnData['validateMessagesShowId'] = '_validatorMessage';
+ $ReturnData['status'] = true;
+ $ReturnData['httpstatus'] = 200;
+ $ReturnData['data'] = array();
+ $i = 0;
+ $Last_num = count($ResponseData->StopStations);
+ foreach($ResponseData->StopStations as $items){
+ if($i == 0){
+ $ReturnData['data']['data'][$i]['start_station_name'] = $items->StationName;
+ $ReturnData['data']['data'][$i]['station_train_code'] = $TrainNo;
+ $ReturnData['data']['data'][$i]['end_station_name'] = $ResponseData->StopStations[$Last_num-1]->StationName;
+ }
+ $ReturnData['data']['data'][$i]['arrive_time'] = $items->ArrivalTime;
+ $ReturnData['data']['data'][$i]['station_name'] = $items->StationName;
+ $ReturnData['data']['data'][$i]['start_time'] = $items->StartTime;
+ $ReturnData['data']['data'][$i]['stopover_time'] = $items->StopMinutes;
+ $ReturnData['data']['data'][$i]['station_no'] = $items->StationNo;
+ $ReturnData['data']['data'][$i]['isEnabled'] = true;
+ $i++;
+ }
+ $ReturnData['messages'] = array();
+ $ReturnData['validateMessages'] = new stdClass();
+ print_r(json_encode($ReturnData));
+ }
+ }
+
+ //获取所有站点信息
+ public function getallstation(){
+ //生成请求参数
+ $TimeStamp = time();
+ $Sign = md5($TimeStamp.DATAKEY);
+
+ $url = JSONRETURN.'/GetAllStations/?&User='.DATAUSER.'&TimeStamp='.$TimeStamp.'&Sign='.$Sign;
+
+ $ResponseJson = post_ctrip($url,'','GET');
+
+ $ResponseData = json_decode($ResponseJson);
+
+ $data = array();
+ foreach ($ResponseData->Stations as $items){
+ $data['StationName'] = isset($items->StationName) ? checkNull($items->StationName) : '';
+ $data['PinYin'] = isset($items->PinYin) ? checkNull($items->PinYin) : '';
+ $data['Telecode'] = isset($items->Telecode) ? checkNull($items->Telecode) : '';
+ $data['Address'] = isset($items->Address) ? checkNull($items->Address) : '';
+ $data['Geography'] = isset($items->Geography) ? checkNull($items->Geography) : '';
+ $this->ctrip_model->AddOrUpdate($data);
+ }
+ }
+
+ //查询中转方案
+ public function gettraintrainsfer(){
+ $FromCode = $this->input->get_post('FromCode');
+ $ToCode = $this->input->get_post('ToCode');
+ $DepartDate = $this->input->get_post('DepartDate');
+
+ if(!$FromCode || !$ToCode || !$DepartDate){
+ exit('传参错误!');
+ }else{
+ $TimeStamp = time();
+ $Sign = md5($TimeStamp.DATAKEY);
+
+ $FromName = $this->ctrip_model->ReplaceCodeToName($FromCode);
+ $ToName = $this->ctrip_model->ReplaceCodeToName($ToCode);
+
+ $From = $FromName->station_name;
+ $To = $ToName->station_name;
+
+ $url = JSONRETURN.'GetTrainTransfer?User='.DATAUSER.'&TimeStamp='.$TimeStamp.'&Sign='.$Sign.'&From='.urlencode($From).'&To='.urlencode($To).'&DepartDate='.$DepartDate;
+
+
+ $ResponseJson = post_ctrip($url,'','GET');
+ //$ResponseData = json_decode($ResponseJson);
+ print_r($ResponseJson);
+ }
+ }
+}
\ No newline at end of file
diff --git a/application/third_party/ctrip/helpers/ctrip_helper.php b/application/third_party/ctrip/helpers/ctrip_helper.php
new file mode 100644
index 00000000..b84711e4
--- /dev/null
+++ b/application/third_party/ctrip/helpers/ctrip_helper.php
@@ -0,0 +1,81 @@
+= 99){
+ return '有';
+ }else{
+ return $num;
+ }
+ }
+ }
+ }
+
+ //发送请求函数
+ function post_ctrip($url, $data = '', $method = 'GET') {
+ $user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1";
+ if(isset($_SERVER['HTTP_USER_AGENT'])) {
+ $user_agent = $_SERVER['HTTP_USER_AGENT'];
+ }
+ $curl = curl_init(); // 启动一个CURL会话
+ curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // 从证书中检查SSL加密算法是否存在
+ curl_setopt($curl, CURLOPT_USERAGENT, $user_agent); // 模拟用户使用的浏览器
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
+ curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
+ if ($method == 'POST' && !empty($data)) {
+ curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
+ }
+ curl_setopt($curl, CURLOPT_TIMEOUT, 40); // 设置超时限制防止死循环
+ curl_setopt($curl, CURLOPT_TIMEOUT_MS, 40000); // 设置超时限制防止死循环
+ curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
+ $tmpInfo = curl_exec($curl); // 执行操作
+ $errno = curl_errno($curl);
+ if ($errno !== 0) {
+ log_message('error', 'ctripost'.$errno.curl_error($curl));
+ }
+ curl_close($curl); //关闭CURL会话
+ return $tmpInfo; //返回数据
+ }
+
+?>
\ No newline at end of file
diff --git a/application/third_party/ctrip/models/ctrip_model.php b/application/third_party/ctrip/models/ctrip_model.php
new file mode 100644
index 00000000..fac981e4
--- /dev/null
+++ b/application/third_party/ctrip/models/ctrip_model.php
@@ -0,0 +1,68 @@
+INFO = $this->load->database('INFO', TRUE);
+ }
+
+ //»
+ public function AddOrUpdate($data){
+ $sql = "IF NOT EXISTS(
+ SELECT 1
+ FROM train_stations
+ WHERE
+ station_telecode = '{$data['Telecode']}'
+ ) BEGIN
+ INSERT INTO train_stations
+ (
+ station_name,
+ station_telecode,
+ station_geography,
+ station_pinyin,
+ station_address
+ )
+ VALUES
+ (
+ '{$data['StationName']}','{$data['Telecode']}','{$data['Geography']}','{$data['PinYin']}','{$data['Address']}'
+ )
+ END
+ ELSE
+ BEGIN
+ UPDATE train_stations
+ SET station_name = '{$data['StationName']}',
+ station_geography = '{$data['Geography']}',
+ station_pinyin = '{$data['PinYin']}',
+ station_address = '{$data['Address']}'
+ WHERE
+ station_telecode = '{$data['Telecode']}'
+ END
+ ";
+ $query = $this->INFO->query($sql);
+ return $query;
+ }
+
+ //ȡĻϢ
+ //ȡ7ǰݾͲκݣҽɾ
+ public function get_train_cache($tpc_from_station,$tpc_to_station){
+ $sql = "SELECT
+ *
+ FROM
+ TrainPriceCache
+ WHERE
+ tpc_from_station = '$tpc_from_station'
+ AND
+ tpc_to_station = '$tpc_to_station'";
+ $query = $this->INFO->query($sql);
+ return $query->row();
+ }
+
+ //ȡվ
+ public function ReplaceCodeToName($code){
+ $sql = "SELECT station_name from train_stations where station_telecode = '{$code}'";
+ $query = $this->INFO->query($sql);
+ return $query->row();
+ }
+
+}
+?>
\ No newline at end of file
diff --git a/application/third_party/htmlcompressor/controllers/index.php b/application/third_party/htmlcompressor/controllers/index.php
index c0f4cb25..3b3cabda 100644
--- a/application/third_party/htmlcompressor/controllers/index.php
+++ b/application/third_party/htmlcompressor/controllers/index.php
@@ -1,146 +1,334 @@
-load->library('simple_html_dom_lib');
- }
-
- public function index() {
- $this->load->view('welcome');
- }
-
- public function optimize() {
- $htmlsource = $this->input->post('htmlsource');
- $websitehost = $this->input->post('websitehost');
- if (empty($htmlsource) || empty($websitehost)) {
- $this->output->set_status_header(500);
- echo 'error:htmlsource or websitehost is empty!';
- log_message('error', "htmlsource or websitehost is empty! " . $websitehost);
- return false;
- }
- //域名后面不能有/
- if (substr($websitehost, -1, 1) == '/') {
- $websitehost = substr($websitehost, 0, -1);
- }
-
- $html_object = str_get_html($htmlsource);
- if (!empty($html_object)) {
-
-//提取和下载所有CSS样式,包括链接文件和页面样式
- $link_css_array = array();
- $css_content = '';
- foreach ($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 = ''; //删除链接
- }
- }
- //print_r($link_css_array);
- foreach ($link_css_array as $item) {
- $get_http_temp = GET_HTTP($this->format_url($item, $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;
- }
- foreach ($html_object->find('style') as $style_css) {
- if ($style_css->type == "text/css") {
- $css_content .= $style_css->innertext;
- }
- }
- // echo $css_content;
- // echo $html_object;die();
- //
-//提取和下载所有JS脚本,包括链接文件和页面脚本
- $link_js_array = array();
- $js_inline_content = '';
- $js_jquery_content = '';
- foreach ($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;
-
- $html_object = str_replace('
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@AMP-GOOGLE-ANALYTICS@
+
+