diff --git a/.gitignore b/.gitignore
index e4e0264d..6572b37a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
.idea
+.phpintel
.svn/*
*/logs/log*
/web.config
@@ -7,4 +8,5 @@
*/cache/*
*/statement_files/*
*/paypal_activities/*
-/author/document/*
\ No newline at end of file
+/author/document/*
+/application/libraries/composer
diff --git a/application/config/config.php b/application/config/config.php
index a6ad6f16..82fb443e 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -572,7 +572,8 @@ $config['templates_i'] = array(
'[城市]C景点列表模板' => 'city_info_attractions_list',
'[城市]C景点详细模板' => 'city_attractions',
'[专题]T0空白' => 'r_tpl_empty',
- '[专题]T0空白(带框架)' => 'r_empty2',
+ '[专题]T0空白(HTML构建工具)' => 'r_empty_container',
+ '[专题]T0空白(H1+面包屑)' => 'r_empty2',
'----------二级目录----------' => '------2------',
'[专题]T2首页' => 'r_t2_index',
'[专题]T2详细' => 'r_t2_detail',
@@ -662,21 +663,22 @@ $config['check_access'] = TRUE;
$config['access_super_manage'] = array('ycc', 'lmr');
//编辑器预览样式路径
-$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'] = '';
@@ -866,12 +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',
+ '城市-首页模板(GM)' => 'city_info_index_new',
'城市-首页模板[简]' => 'city_info_s_index',
'城市-景点列表模板' => 'city_info_attractions_list',
'城市-景点列表模板[简]' => 'city_info_s_attractions_list',
@@ -910,19 +945,11 @@ $config['templates'] = array(
//德语信息模板
$config['templates_gm'] = 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',
- '城市-特色产品模板' => 'city_info_diytour',
- '城市-一线城市首页' => 'city_info_index_one',
- '省份-首页' => "area_info_index",
- '文化模板 [列表式]' => "culture_info_detail_just_list",
+ '城市-首页模板(GM)' => 'city_info_index',
'文化模板 [单页式]' => 'culture_info_detail_one_page',
'文化模板 [导航式]' => 'culture_info_detail_with_category',
'信息专题模板' => 'guide_top_series',
+ '列表式' => 'guide_info_list',
'空白模板'=>'none'
);
@@ -963,6 +990,7 @@ $config['templates_product'] = array(
//产品管理板块模板(国际站使用)
$config['templates_product_i'] = array(
+ '空白模板(HTML构建工具)' => 'r_empty_container',
'空白模板(新)' => 'r_tpl_empty_2017',
'空白模板(旧)' => 'r_tpl_empty',
);
@@ -1047,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 55dd1aef..e7e5c374 100644
--- a/application/controllers/amp.php
+++ b/application/controllers/amp.php
@@ -21,15 +21,15 @@ class Amp extends CI_Controller {
}
public function edit($ic_id) {
- $this->amplib->edit($ic_id);
+ $this->amplib->edit($ic_id);
}
public function auto_create($ic_id) {
- echo $this->amplib->auto_create($ic_id);
+ echo $this->amplib->auto_create($ic_id);
}
public function edit_save() {
- echo $this->amplib->edit_save();
+ echo $this->amplib->edit_save();
}
}
diff --git a/application/controllers/info_amp.php b/application/controllers/info_amp.php
index 990f7f65..99ac7662 100644
--- a/application/controllers/info_amp.php
+++ b/application/controllers/info_amp.php
@@ -14,8 +14,10 @@ class Info_amp extends CI_Controller
$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()
@@ -23,50 +25,73 @@ class Info_amp extends CI_Controller
$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);
@@ -306,4 +331,181 @@ 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 4e3fd961..d3d18193 100644
--- a/application/controllers/information.php
+++ b/application/controllers/information.php
@@ -1,703 +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('InfoSMS_model');
- $this->load->library('Amplib'); //加载AMP处理类
- $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'));
- }
- 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'));
- }
-
-
- //信息区域类型
- 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'));
-
- //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;
- }
- }
- 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') . ' ';
+
+ // 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) ? '
' . $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;
- }
-
-}
+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/province.php b/application/controllers/province.php
index 9b982144..00051438 100644
--- a/application/controllers/province.php
+++ b/application/controllers/province.php
@@ -19,8 +19,6 @@ class Province extends CI_Controller
public function index($province_id=0)
{
- $this->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/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
index 5630d27b..59239abf 100644
--- a/application/libraries/Amplib.php
+++ b/application/libraries/Amplib.php
@@ -14,6 +14,7 @@ class Amplib {
$this->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) {
@@ -59,12 +60,16 @@ class Amplib {
$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);
- return GET_HTTP(site_url('/apps/htmlcompressor/index/optimize'), $post_data, 'POST');
+ //德语站点走另外一个控制器,其他站点还是走原来的流程
+ 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' => '不知道哪里错了,看代码'));
}
@@ -89,6 +94,9 @@ class Amplib {
//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
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,'
";
+ 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'=>'','close'=>'
');
+ $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 .= '
";
+ 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 .= "'.$tc.' ';
+ }
+ }
+
+ $table .= "".$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('/