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,'XML($node); + $img = null; + + while ($reader->read()) { + if($reader->name == "w:b") { + $f .= "font-weight: bold,"; + } + if($reader->name == "w:i") { + $f .= "text-decoration: underline,"; + } + if($reader->name == "w:color") { + $f .="color: #".$reader->getAttribute("w:val").","; + } + if($reader->name == "w:rFont") { + $f .="font-family: #".$reader->getAttribute("w:ascii").","; + } + if($reader->name == "w:shd" && $reader->getAttribute("w:val") != "clear" && $reader->getAttribute("w:fill") != "000000") { + $f .="background-color: #".$reader->getAttribute("w:fill").","; + } + $temp_rx = $reader->readInnerXml(); + if($reader->name == 'w:drawing' && !empty($temp_rx)) { + $r = $this->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'] = "
  1. "; + $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('', $lastload_js . '', $html_object); - } - echo json_encode(array('result' => 'ok', 'data' => array('html_object' => $html_object, 'js_content' => $js_content))); - } - -//格式化url,保证请求的URL有域名,//更换为对应的域名路径 - function format_url($url, $host = '') { - if (substr($url, 0, 8) == 'https://' || substr($url, 0, 7) == 'http://') { - return urldecode($url); - } - - if (substr($url, 0, 2) == '//') { //https或http - return urldecode(str_replace('//', 'http://', $url)); - } - - return urldecode($host . $url); - } - -} +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'); + $template_name = $this->input->post('template_name'); + $create_amp = $this->input->post('create_amp'); + $debug = $this->input->post('debug'); + 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('', $lastload_js . '', $html_object); + } + + //只返回AMP代码 + if (!empty($create_amp)) { + $amp = $this->create_amp($html_object, $template_name, $websitehost,$debug); + echo json_encode(array('result' => 'ok', 'data' => array('amp' => $amp))); + return; + } + echo json_encode(array('result' => 'ok', 'data' => array('html_object' => $html_object, 'js_content' => $js_content))); + + } + +//格式化url,保证请求的URL有域名,//更换为对应的域名路径 + function format_url($url, $host = '') + { + if (substr($url, 0, 8) == 'https://' || substr($url, 0, 7) == 'http://') { + $url = str_replace('http://', 'https://', $url);//http要改为https + return urldecode($url); + } + + if (substr($url, 0, 2) == '//') { //https或http + return urldecode('https://'.substr($url, 2, strlen($url)-2)); //只替换开头的//,部分url不规范,有//在url中间 + } + + return urldecode($host . $url); + } + + + +//生成AMP版本 用移动端版本生成 + /* + 1.加载站点AMP模板,模板只有导航、头部、底部 + 2.删除全部js引用和内链代码 + 3.删除全部css引用,内联css放入", $this->html_object); + //删除多余空格和换行符 + $this->html_object = str_replace(array(" ", "\t", "\n", "\r"), " ", $this->html_object); + //循环n次,把双空格替换为一个空格 + for ($i = 0; $i <= 4; $i++) { + $this->html_object = str_replace(" ", " ", $this->html_object); + } + + //在最后加载原始css文件和js文件 + //把css移动到页面底部,延迟加载 + $lastload_js = ''; + + $js_content = $js_scr_content . $js_jquery_content; + //延迟加载js,需要把返回的js代码保存到一个文件中,然后替换占位符,以便加载js文件 + $lastload_js .= ''; + $lastload_js .= $js_inline_content; + + $this->html_object = str_replace('', $lastload_js . '', $this->html_object); + echo json_encode(array('result' => 'ok', 'data' => array('html_object' => $this->html_object, 'js_content' => $js_content))); + } + + //生成AMP版本 用移动端版本生成 + /* + 1.加载站点AMP模板,模板只有导航、头部、底部 + 2.删除全部js引用和内链代码 + 3.删除全部css引用,内联css放入 + + + + + + + + + +
+
+ + +
+ + + + +
+ + + +
+
+
+ + + +
+ + +
+ + + +
+
+@AMP-GOOGLE-ANALYTICS@ + + + diff --git a/application/third_party/htmlcompressor/views/amp-template/cht.php b/application/third_party/htmlcompressor/views/amp-template/cht.php new file mode 100644 index 00000000..fb951b4b --- /dev/null +++ b/application/third_party/htmlcompressor/views/amp-template/cht.php @@ -0,0 +1,136 @@ + + + + +<!--@TITLE@--> + + + + + + + + + + + + + + + + +
+
+ + China Highlights ® + CUSTOMIZE +
+
+ + + +
+
+
+ + + + +
+ + + + +
+ Start planning your tailor-made China tour … + Create My Trip +
+ + + + + + + +
+ + diff --git a/application/third_party/htmlcompressor/views/amp-template/ct.php b/application/third_party/htmlcompressor/views/amp-template/ct.php new file mode 100644 index 00000000..338379ef --- /dev/null +++ b/application/third_party/htmlcompressor/views/amp-template/ct.php @@ -0,0 +1,218 @@ + + + + +<!--@TITLE@--> + + + + + + + + + + + + + + +
+
China Travel ® CUSTOMIZE
+
+ + +
+
+
+ +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/application/third_party/htmlcompressor/views/amp-template/gm.php b/application/third_party/htmlcompressor/views/amp-template/gm.php new file mode 100644 index 00000000..63ca3a47 --- /dev/null +++ b/application/third_party/htmlcompressor/views/amp-template/gm.php @@ -0,0 +1,45 @@ + + + + + <!--@TITLE@--> + + + + + + + + + + + + + + + + + + + +
+@AMP-COMMON-HEADER@ + + + +@AMP-COMMON-FOOTER@ + +
+
+ + + \ No newline at end of file diff --git a/application/third_party/htmlcompressor/views/welcome.php b/application/third_party/htmlcompressor/views/welcome.php index e18468fd..2c57e7e0 100644 --- a/application/third_party/htmlcompressor/views/welcome.php +++ b/application/third_party/htmlcompressor/views/welcome.php @@ -14,7 +14,23 @@

页面样式精简



- + + +

+ + + +

+
diff --git a/application/third_party/order/controllers/confirm.php b/application/third_party/order/controllers/confirm.php index 4dda6cd4..e8c3e11b 100644 --- a/application/third_party/order/controllers/confirm.php +++ b/application/third_party/order/controllers/confirm.php @@ -30,14 +30,14 @@ class Confirm extends CI_Controller { } } } else { - $this->load->view($site_code.'/link_tips', $data); + $this->load->view($site_code.'/link_tips', $data); return false; } $visitor_link_arr = $this->Order_model->get_visitor_link($COLI_SN); foreach ($visitor_link_arr as $l) { if ($visitor_link == $l->visitor_link) { - $this->load->view($site_code.'/link_tips', $data); + $this->load->view($site_code.'/link_tips', $data); return false; } } @@ -57,10 +57,16 @@ class Confirm extends CI_Controller { $COLI_SN = $this->input->post('COLI_SN'); $visitor_link = $this->input->post('visitor_link'); $COLI_ID = $this->input->post('COLI_ID'); + //航班信息 + $MEI_ArrivalFlightNo = $this->input->post('MEI_ArrivalFlightNo'); + $MEI_ArrivalTime = $this->input->post('MEI_ArrivalTime'); + $MEI_DepartureFlightNo = $this->input->post('MEI_DepartureFlightNo'); + $MEI_DepartureTime = $this->input->post('MEI_DepartureTime'); //已经确认过 $had_save = $this->Order_model->get_visitor_link($COLI_SN, $visitor_link); + if (!empty($had_save)) { echo json_encode(array('status' => 'ok')); return; @@ -74,7 +80,7 @@ class Confirm extends CI_Controller { } elseif ($this->input->post('address_street')) { $MEI_Street = $this->input->post('address_street') . ',' . $this->input->post('address_city') . ',' . $this->input->post('address_state') . ',' . $this->input->post('address_country'); } else { - $MEI_Street = ''; + $MEI_Street = $this->input->post('street').','.$this->input->post('city').','.$this->input->post('country'); } $data['MEI_Street'] = $MEI_Street; if (isset($given_name[$key]) && $given_name[$key] != 'None') { @@ -85,34 +91,21 @@ class Confirm extends CI_Controller { $MEI_LastName = $name; - if ($this->input->post('arrive_flight')) { - $CUL_Memo = 'Arrival China Flight No : ' - . $this->input->post('arrive_flight') - . ' & Arrival time : ' - . $this->input->post('arrive_time') - . ' & Departure China Flight no : ' - . $this->input->post('departure_flight') - . ' & Departure time : ' - . $this->input->post('depart_time'); - } else { - $CUL_Memo = ''; - } - $CUL_Memo .= $this->input->post('insurance_information'); + $CUL_Memo = $this->input->post('insurance_information'); $MEI_Memo = $this->input->post('special_request') . ' ' . $CUL_Memo; - //$birthday[$key] = date('Y-m-d H:i:s', strtotime($birthday[$key])); $birthday_tmp = date('Y-m-d H:i:s', strtotime($birthday[$key])); - //$expiration_date[$key] = date('Y-m-d H:i:s', strtotime($expiration_date[$key])); $expiration_date_tmp = date('Y-m-d H:i:s', strtotime($expiration_date[$key])); - $MEI_SN = $this->Order_model->add_customer_info($gender[$key], $nationality[$key], $MEI_FirstName, $MEI_LastName, $passport[$key], $expiration_date_tmp, $birthday_tmp, $MEI_Memo, $MEI_Street, '', $contact_phone, 0, $COLI_SN, $visitor_link); + $MEI_SN = $this->Order_model->add_customer_info($gender[$key], $nationality[$key], $MEI_FirstName, $MEI_LastName, $passport[$key], $expiration_date_tmp, $birthday_tmp, $MEI_Memo, $MEI_Street, '', $contact_phone, 0, $COLI_SN, $visitor_link,$MEI_ArrivalFlightNo,$MEI_ArrivalTime,$MEI_DepartureFlightNo,$MEI_DepartureTime); } } if ($MEI_SN && $this->input->post('emergency_person_name') != '') { $add_emergency_res = $this->Order_model->add_customer_info( '', '', $this->input->post('emergency_person_name'), '', '', '', '', $this->input->post('emergency_relationship'), '', $this->input->post('emergency_email'), $this->input->post('emergency_telephone'), 1, $COLI_SN, $visitor_link + ,$MEI_ArrivalFlightNo,$MEI_ArrivalTime,$MEI_DepartureFlightNo,$MEI_DepartureTime ); } @@ -133,7 +126,7 @@ class Confirm extends CI_Controller { echo json_encode(array('status' => 'no')); } } - + //只有ch有review功能 function review() { $data = array(); diff --git a/application/third_party/order/models/order_model.php b/application/third_party/order/models/order_model.php index be036f56..9ba407c6 100644 --- a/application/third_party/order/models/order_model.php +++ b/application/third_party/order/models/order_model.php @@ -43,7 +43,7 @@ class Order_model extends CI_Model { } //添加客人信息 - public function add_customer_info($MEI_Gender,$MEI_Nationality,$MEI_FirstName,$MEI_LastName,$MEI_PassportNo,$MEI_PassportValidDate,$MEI_Birthday,$MEI_Memo,$MEI_Street,$MEI_MailList='',$MEI_Phone='',$CUL_IsEmergency=0,$CUL_COLI_SN='',$visitor_link='') + public function add_customer_info($MEI_Gender,$MEI_Nationality,$MEI_FirstName,$MEI_LastName,$MEI_PassportNo,$MEI_PassportValidDate,$MEI_Birthday,$MEI_Memo,$MEI_Street,$MEI_MailList='',$MEI_Phone='',$CUL_IsEmergency=0,$CUL_COLI_SN='',$visitor_link='',$MEI_ArrivalFlightNo,$MEI_ArrivalTime,$MEI_DepartureFlightNo,$MEI_DepartureTime) { $createdate=date('Y-m-d H:i:s'); $sql="INSERT INTO MEmberInfoTmpCheck @@ -69,9 +69,13 @@ class Order_model extends CI_Model { visitor_link, CreateDate, CUL_IsLinkMan, - copyState - ) VALUES (?,?,?,?,?,?,?,?,?,?,?,102001,0,0,1,1,?,?,?,?,0,0) "; - $this->HT->query($sql, array($MEI_Gender,$MEI_Nationality,$MEI_FirstName,$MEI_LastName,$MEI_PassportNo,$MEI_PassportValidDate,$MEI_Birthday,$MEI_Memo,$MEI_Street,$MEI_MailList,$MEI_Phone,$CUL_IsEmergency,$CUL_COLI_SN,$visitor_link,$createdate)); + copyState, + MEI_ArrivalFlightNo, + MEI_ArrivalTime, + MEI_DepartureFlightNo, + MEI_DepartureTime + ) VALUES (?,?,?,?,?,?,?,?,?,?,?,102001,0,0,1,1,?,?,?,?,0,0,?,?,?,?) "; + $this->HT->query($sql, array($MEI_Gender,$MEI_Nationality,$MEI_FirstName,$MEI_LastName,$MEI_PassportNo,$MEI_PassportValidDate,$MEI_Birthday,$MEI_Memo,$MEI_Street,$MEI_MailList,$MEI_Phone,$CUL_IsEmergency,$CUL_COLI_SN,$visitor_link,$createdate,$MEI_ArrivalFlightNo,$MEI_ArrivalTime,$MEI_DepartureFlightNo,$MEI_DepartureTime)); $insertid = $this->HT->last_id('MEmberInfoTmpCheck');//$this->HT->insert_id(); return $insertid; } diff --git a/application/third_party/order/views/confirm_order.php b/application/third_party/order/views/confirm_order.php index 1661dcd2..05a815f3 100644 --- a/application/third_party/order/views/confirm_order.php +++ b/application/third_party/order/views/confirm_order.php @@ -7,13 +7,13 @@ China Highlights! Please complete and submit the information. - + - + @@ -70,7 +70,10 @@
-

Passenger Information (we need passport info for all the group members)

+

Passenger Information (we need passport info for all the group members)
+ Please ensure the details you provide are correct, as stated in your passport. We use this information to book all your hotels and transportation. If the name you provide are incorrect, you would not be able to board your flight or trains in China, and therefore reissuing of tickets would be at your expense! +

+
diff --git a/application/views/bootstrap/header.php b/application/views/bootstrap/header.php index ac30a510..feb5f103 100644 --- a/application/views/bootstrap/header.php +++ b/application/views/bootstrap/header.php @@ -80,8 +80,12 @@
  • 广告管理
  • TA评论采集
  • 老旧信息查询
  • +
  • AMP转化检查
  • Html基础知识
  • -
  • AMP知识及构建SOP
  • +
  • AMP知识
  • +
  • AMP操作SOP
  • +
  • HTML构建工具V3
  • +
  • PS基础课件
  • 系统设置
  • diff --git a/application/views/bootstrap/information_edit.php b/application/views/bootstrap/information_edit.php index c6d0f27f..a5e1400e 100644 --- a/application/views/bootstrap/information_edit.php +++ b/application/views/bootstrap/information_edit.php @@ -350,32 +350,6 @@ return true; } - - //添加绑定景点 - function add_landscape(area_id, lsi_sn) { - var urlReQuery = ""; - $.ajax({ - type: "get", - url: urlReQuery + '/' + area_id + '/' + lsi_sn, - success: function(data, textStatus) { - var dataArray = $.parseJSON(data);//JSON.parse(data); - for (var key in dataArray) { - if (dataArray[key].name == 'ok') { - window.location.href = dataArray[key].value; - return true; - } else if (dataArray[key].name == 'no') { - $.modaldialog.error(dataArray[key].value); - return false; - } - } - }, - error: function() { - $.modaldialog.error('发生错误,请联系YCC'); - return false; - } - }); - } - //跳转到前台页面 function goto_page() { var site_url = 'config->item('site_url') ?>'; @@ -1000,7 +974,7 @@
    - +
    - - - \ No newline at end of file diff --git a/application/views/bootstrap/infoshare_week.php b/application/views/bootstrap/infoshare_week.php index 6bf7d4f0..c7e45873 100644 --- a/application/views/bootstrap/infoshare_week.php +++ b/application/views/bootstrap/infoshare_week.php @@ -3,7 +3,7 @@ URLS - + diff --git a/application/views/bootstrap/welcome.php b/application/views/bootstrap/welcome.php index 4b01fa01..d2bca395 100644 --- a/application/views/bootstrap/welcome.php +++ b/application/views/bootstrap/welcome.php @@ -10,6 +10,7 @@
  • +
  • 首页
  • 专题管理
  • 交换链接
  • 机场信息
  • @@ -40,6 +41,8 @@
  • CDN定时更新
  • 订单邮件管理
  • 信息分享平台
  • +
  • 全站静态化更新
  • +
  • 全站AMP更新
  • diff --git a/application/views/bootstrap3/footer.php b/application/views/bootstrap3/footer.php index 502ad690..796427df 100644 --- a/application/views/bootstrap3/footer.php +++ b/application/views/bootstrap3/footer.php @@ -15,7 +15,7 @@ + @@ -191,6 +230,7 @@ }); $(".ui-datepicker").css('width', '15.7em'); + }); function show_order_modal(pn_txn_id, pn_invoice,noticeTime,old_order) { if (pn_txn_id) { diff --git a/webht/third_party/pay/views/alipay_note_setting.php b/webht/third_party/pay/views/alipay_note_setting.php index 90332bba..e1bcc4bb 100644 --- a/webht/third_party/pay/views/alipay_note_setting.php +++ b/webht/third_party/pay/views/alipay_note_setting.php @@ -1,4 +1,4 @@ - +
    交易号
    diff --git a/webht/third_party/pay/views/gai_setting.php b/webht/third_party/pay/views/gai_setting.php new file mode 100644 index 00000000..06808d0c --- /dev/null +++ b/webht/third_party/pay/views/gai_setting.php @@ -0,0 +1,42 @@ + + +

    已录入订单

    + + + + + + + $value) { ?> + + + + + + +
    订单号申请金额/币种实收金额
    COLI_ID; ?>GAI_SQJE; ?> GAI_SQJECurrency; ?>GAI_SSJE; ?> CNY
    +

    撤回以上订单收款记录, 并转移到订单: (手动录入的不会撤回)

    + +
    + + +
    + +
    订单详细内容:
    +

    + $order_info->COLI_SN
    "; + echo "COLI_ID => $order_info->COLI_ID
    "; + echo "OPI_Email => $order_info->OPI_Email
    "; + echo "OPI_Name => $order_info->OPI_Name
    "; + echo!empty($order_info->COLI_GroupCode) ? "COLI_GroupCode => $order_info->COLI_GroupCode
    " : false; + echo!empty($order_info->COLI_OrderDetailText) ? "COLI_OrderDetailText => $order_info->COLI_OrderDetailText\n" : false; + } else { + echo '找不到目标订单内容'; + } + ?> +

    + + + diff --git a/webht/third_party/pay/views/iPayLinks_list.php b/webht/third_party/pay/views/iPayLinks_list.php index ce91c9c7..bd101cac 100644 --- a/webht/third_party/pay/views/iPayLinks_list.php +++ b/webht/third_party/pay/views/iPayLinks_list.php @@ -52,7 +52,7 @@
    -
    +
    @@ -75,9 +75,16 @@
    -
    +
    @@ -159,6 +166,8 @@ $class_css = ''; if ($item->IPL_sent == 'send') { $show_send = $item->IPL_sent; + } else if ($item->IPL_sent == 'closeRecord') { + $show_send = "已忽略"; } else if (strcmp(trim($item->IPL_stateCode), "2") && $item->IPL_stateCode != NULL) { $class_css = 'btn-danger'; $show_send = $paytext[intval(trim($item->IPL_stateCode))]; @@ -166,7 +175,7 @@ $class_css = 'btn-danger'; $show_send = $item->IPL_sent; } - ?> + ?> @@ -253,12 +262,12 @@ return date; } }); - function show_order_modal(pn_txn_id, pn_invoice,noticeTime,old_order) { + function show_order_modal(pn_txn_id, pn_invoice,noticeTime,old_order, pn_id) { if (pn_txn_id) { $.ajax({ type: "get", dataType: "json", - url: '/webht.php/apps/pay/ipaylinksservice/note_modal/' + pn_txn_id , + url: '/webht.php/apps/pay/ipaylinksservice/note_modal/' + pn_txn_id + '/' + pn_invoice + '/' + pn_id, success: function(data, textStatus) { $('#modal_set_orderid_body').html(data); $('#modal_set_orderid').modal('show'); diff --git a/webht/third_party/pay/views/iPayLinks_list2.php b/webht/third_party/pay/views/iPayLinks_list2.php new file mode 100644 index 00000000..0a981772 --- /dev/null +++ b/webht/third_party/pay/views/iPayLinks_list2.php @@ -0,0 +1,443 @@ + +* @date 2017-09-06 +*/ +?> + + + + + + iPayLinks Notes - China Highlights + + + + + + + + + + +
    +
    +
    + + + +
    + + $item) { + ?> +
      + +
    • +
    • + IPL_dealId) { ?> + + + + + IPL_orderId . ' / ' . $item->IPL_orderAmount . $item->IPL_currencyCode ; ?> +
    • + +
    • + IPL_payType == 'refund') { + echo "退款"; + } else { + echo $item->IPL_payerName . "
      " . $item->IPL_payerEmail; + } ?> +
    • + +
    • IPL_dealId; ?>
    • + +
    • IPL_acquiringTime; ?>
    • + + +
    + + +
    + + +
    +
    +
    +
    +
    + + + + + + + + + + + + + diff --git a/webht/third_party/pay/views/mail_advisor.php b/webht/third_party/pay/views/mail_advisor.php new file mode 100644 index 00000000..272340c6 --- /dev/null +++ b/webht/third_party/pay/views/mail_advisor.php @@ -0,0 +1 @@ +
    payment logo
    Transaction ID:  
    Hello Guilin China International Travel Service Co.,Ltd,
    You received a payment of
    Seller Protection-
    Buyer


    Description     Amount

    diff --git a/webht/third_party/pay/views/note_setting.php b/webht/third_party/pay/views/note_setting.php index 47280d28..973aef58 100644 --- a/webht/third_party/pay/views/note_setting.php +++ b/webht/third_party/pay/views/note_setting.php @@ -13,13 +13,12 @@
    IPL_acquiringTime; ?>
    -
    订单号
    - +
    @@ -28,7 +27,6 @@
    订单详细内容
    - $order_info->COLI_SN
    "; @@ -50,4 +48,5 @@
    + diff --git a/webht/third_party/pay/views/payment_gai_setting.php b/webht/third_party/pay/views/payment_gai_setting.php new file mode 100644 index 00000000..097a3f7b --- /dev/null +++ b/webht/third_party/pay/views/payment_gai_setting.php @@ -0,0 +1,59 @@ +
    + +

    已录入订单

    + + + + + + + $value) { ?> + + + + + + +
    订单号申请金额/币种实收金额
    GAI_COLI_ID; ?>GAI_SQJE; ?> GAI_SQJECurrency; ?>GAI_SSJE; ?> CNY
    +

    撤回以上订单收款记录, 并转移到订单: (手动录入的不会撤回)

    + +
    +
    交易号
    +
    OPN_transactionId ?> ( OPN_noticeType) . " " . $note->OPN_transactionResult; ?> )
    +
    +
    +
    付款金额
    +
    OPN_currency . ' ' . $note->OPN_orderAmount ?>
    +
    +
    +
    付款时间
    +
    OPN_completeTime; ?>
    +
    + +
    + + +
    + +
    订单详细内容:
    +

    + $order_info->COLI_SN
    "; + echo "COLI_ID => $order_info->COLI_ID
    "; + echo "OPI_Email => $order_info->OPI_Email
    "; + echo "OPI_Name => $order_info->OPI_Name
    "; + echo!empty($order_info->COLI_GroupCode) ? "COLI_GroupCode => $order_info->COLI_GroupCode
    " : false; + echo!empty($order_info->COLI_OrderDetailText) ? "COLI_OrderDetailText => $order_info->COLI_OrderDetailText\n" : false; + } else { + echo '找不到目标订单内容'; + } + ?> +

    + + +
    +
    +

    原始数据

    +

    +
    diff --git a/webht/third_party/pay/views/payment_list.php b/webht/third_party/pay/views/payment_list.php new file mode 100644 index 00000000..57310825 --- /dev/null +++ b/webht/third_party/pay/views/payment_list.php @@ -0,0 +1,303 @@ + + + + + + + + + + Payment List - China Highlights + + + + + + + + + + + + + +
    +
    +
    + + + +
    + + + + + + + + + + + + + + $item) { + ?> + + + + + + + + + + + +
    #主题付款人交易号收单时间通知时间状态[通知/记录]
    OPN_orderId . ' / ' . $item->OPN_orderAmount . $item->OPN_currency; ?> + OPN_payerEmail; + ?> + OPN_transactionId; ?>OPN_acquiringTime; ?>OPN_noticeTime; ?> + OPN_accountStatus !== 'recorded') { + $send_class = 'btn-danger'; + } + if ($item->OPN_noticeSendStatus !== 'send' ) { + $send_class = 'btn-danger'; + } + if ($item->OPN_noticeSendStatus === 'closed') { + $send_class = ''; + } + ?> + OPN_noticeType !== 'pay') { + echo '' . strtoupper($item->OPN_noticeType) . '
    '; + } ?> + + OPN_noticeSendStatus .' / ' . $item->OPN_accountStatus; ?> + +
    +
    + +
    +
    +
    + + + + + + diff --git a/webht/third_party/paypal/controllers/index.php b/webht/third_party/paypal/controllers/index.php index 7d1f3d8b..3c2bdb67 100644 --- a/webht/third_party/paypal/controllers/index.php +++ b/webht/third_party/paypal/controllers/index.php @@ -10,6 +10,7 @@ class Index extends CI_Controller { // $this->output->enable_profiler(TRUE); $this->load->model('Paypal_model'); $this->load->model('Note_model'); + bcscale(2); } public function index() { @@ -189,6 +190,21 @@ class Index extends CI_Controller { echo ('更新了' . ($result_count) . '条记录'); } + public function get_transactions_detail_by_paymentToken() + { + $token = $this->input->post("t"); + $base = $this->base(0); + // $post = "METHOD=GetTransactionDetails&VERSION=100.0&TRANSACTIONID=$token"; + // $post = "METHOD=GetExpressCheckoutDetails&VERSION=124.0&TOKEN=$token"; + + $token = str_replace(' ', 'T', $token) . 'Z'; + $post = "METHOD=TransactionSearch&VERSION=100.0&TRANSACTIONCLASS=ALL&STARTDATE=$token"; + + $detail = $this->call($base, $post); + var_dump($detail); + return; + } + //根据交易号获取交易详细信息 public function get_transactions_detail($redirect = 0) { //从数据库提取一条还没有更新交易详情的记录获取交易号 @@ -554,8 +570,10 @@ class Index extends CI_Controller { //存储paypal发送的消息 public function paypal_note() { $pn_txn_id = $this->input->post('txn_id'); + log_message('error','paypal-note: ' . $pn_txn_id); $pn_invoice = $this->input->post('invoice'); + empty($pn_invoice) ? $pn_invoice = $this->input->post('transaction_subject') : false; empty($pn_invoice) ? $pn_invoice = '' : false; $pn_custom = $this->input->post('custom'); @@ -585,10 +603,12 @@ class Index extends CI_Controller { //把PDT时间转成GMT时间 $pn_payment_date = gmdate('Y-m-d H:i:s', strtotime($pn_payment_date)); $this->Note_model->save_paypal_note($pn_txn_id, $pn_invoice, $pn_custom, $pn_mc_gross, $pn_item_name, $pn_item_number, $pn_mc_currency, $pn_payment_status, $pn_payer, $pn_payer_email, $pn_payment_date, $pn_memo); - echo 'ok'; + log_message('error','paypal-note-succeed ' . $pn_txn_id . ' # ' . $pn_invoice); + // echo 'ok'; } else { - echo 'no'; + // echo 'no'; } + return ; } //解析出订单号 @@ -627,12 +647,18 @@ class Index extends CI_Controller { $ordertype = 'N'; if (isset($note_invoice_string[1])) { $ordertype_temp = trim($note_invoice_string[1]); - if (substr($ordertype_temp, 0, 1) == 'T') { + if (substr($ordertype_temp, 0, 2) == 'TP') { + $ordertype = 'TP'; + } elseif (substr($ordertype_temp, 0, 1) == 'T') { $ordertype = 'T'; } elseif (substr($ordertype_temp, 0, 1) == 'B') { $ordertype = 'B'; } } + // 2018.05.28 for Trippest, tourMaster的订单号是01开头 + if (substr($note_invoice_string[0], 0, 2) == '01') { + $ordertype = 'TP'; + } //手机订单、机票订单都没有加标示,在这里帮加上,暂时的,今后还是要在网前设置好 if ($ordertype == 'N' && isset($note_invoice_string[0])) { @@ -688,8 +714,9 @@ class Index extends CI_Controller { */ //找到没有发送的记录 - public function send_note($pn_txn_id = false) { + public function send_note($pn_txn_id = false, $old_ssje=NULL) { $data = array(); + $handpick = empty($pn_txn_id) ? false : TRUE; //优先处理指定的交易号,用于修正交易号直接发送通知 if (!empty($pn_txn_id)) { @@ -710,7 +737,7 @@ class Index extends CI_Controller { foreach ($data['unsend_list'] as $item) { //已经发送的不处理,防止重复发送 - if ($item->pn_send == 'send') { + if ($item->pn_send == 'send' && empty($pn_txn_id)) { continue; } @@ -731,7 +758,13 @@ class Index extends CI_Controller { } //检测是否是APP订单,默认不处理 - if ((strpos($item->pn_memo, 'China Train Booking') !== false) || (strpos($item->pn_memo, 'ChinaTrainBooking') !== false)) { //APP自动出票的订单不需要处理 + // && $item->pn_payment_status !== 'Refunded' + if ( + ( (strpos($item->pn_memo, 'China Train Booking') !== false) + || (strpos($item->pn_memo, 'ChinaTrainBooking') !== false) + ) + && empty($pn_txn_id) + ) { //APP自动出票的订单不需要处理 $this->Note_model->update_send($item->pn_txn_id, 'send'); continue; } @@ -757,7 +790,14 @@ class Index extends CI_Controller { //根据订单号查找外联信息 $orderid_info = json_decode($orderid_info); - $advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype); + $handpick = empty($pn_txn_id) ? false : TRUE; + $advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype, $handpick); + + // for trippest tourMaster 2018.05.28 + if ($orderid_info->ordertype == 'TP') { + $this->trippest_note($orderid_info, $item); + continue; + } //查不到订单信息 if (empty($advisor_info)) { @@ -769,7 +809,7 @@ class Index extends CI_Controller { $this->Note_model->set_invoice($item->pn_txn_id, $orderid_info->orderid . '_' . $orderid_info->ordertype); //检测是否是APP订单,默认不处理 - if ($orderid_info->ordertype == 'A') { //APP自动出票的订单不需要处理 + if ($orderid_info->ordertype == 'A' ) { //APP自动出票的订单不需要处理 $this->Note_model->update_send($item->pn_txn_id, 'send'); continue; } @@ -777,19 +817,25 @@ class Index extends CI_Controller { //添加支付信息入库 //没有分配订单之前先添加付款记录,这个过程可能会执行多次,必须在添加记录前查找是否有数据 if (!empty($orderid_info)) { + $ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency)); + $ssje = $old_ssje===NULL ? $ssje : $old_ssje; //更新还没有填的客邮和交易号de收款记录(商务订单) if (isset($advisor_info->order_type) && $advisor_info->order_type == 0) { $ht_memo = '交易号(自动录入):' . $item->pn_txn_id; $GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0; //CHTAPP订单添加记录前判断是否有记录,以前的APP版本没有交易号,只能拿金额来判断 if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP') {//只判断前6位字符,CHTAPP-fr CHTAPP-jp等各语种都属于APP订单 - $ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency)); $this->Paypal_model->add_account_info_forAPP($GAI_COLI_SN, $advisor_info->COLI_ID, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, '', $item->pn_payer_email, $item->pn_txn_id, $ht_memo); if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11) { //只修改APP组的订单状态,并且订单进度是我的订单 $this->Paypal_model->update_biz_coli_state($GAI_COLI_SN, 8); //把订单状态改为已付款 + $this->Paypal_model->insert_biz_order_log($GAI_COLI_SN, 'BS8'); } } else { - $ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency)); + // 把订单状态设置为13-新订单已支付 + if (false == $this->Paypal_model->if_biz_gai_exists($item->pn_txn_id) ) { + $this->Paypal_model->update_biz_coli_state($GAI_COLI_SN, 13); + $this->Paypal_model->insert_biz_order_log($GAI_COLI_SN, 'BS13'); + } $this->Paypal_model->add_account_info($GAI_COLI_SN, $advisor_info->COLI_ID, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, '', $item->pn_payer_email, $item->pn_txn_id, $ht_memo); // 更新订单主表付款方式,防止没访问thankyou-train.asp $this->Paypal_model->update_paymanner($GAI_COLI_SN, '15010'); @@ -799,22 +845,25 @@ class Index extends CI_Controller { elseif (isset($advisor_info->order_type) && $advisor_info->order_type == 1) { $ht_memo = '交易号(自动录入):' . $item->pn_txn_id; $GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0; - $ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency)); - $this->Paypal_model->add_tour_account_info($GAI_COLI_SN, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, '', $item->pn_payer_email, $item->pn_txn_id, $ht_memo); + $gai_sn = $this->Paypal_model->add_tour_account_info($GAI_COLI_SN, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payer, $item->pn_payer_email, $item->pn_txn_id, $ht_memo); //添加汉特的订单提醒 $this->Paypal_model->update_coli_introduction($GAI_COLI_SN, '已支付 ' . mb_strtoupper($item->pn_mc_currency) . $item->pn_mc_gross); + // 添加HT任务 + $this->Paypal_model->exec_addToTask($gai_sn); } } $opi_email = !empty($advisor_info->OPI_Email) ? $advisor_info->OPI_Email : ''; //lussie@chinahighlights.net $opi_firstname = !empty($advisor_info->OPI_FirstName) ? $advisor_info->OPI_FirstName : !empty($advisor_info->OPI_Name) ? $advisor_info->OPI_Name : ''; //lussie + //没有外联信息表示订单未分配 if (empty($opi_email) || empty($opi_firstname)) { $this->Note_model->update_send($item->pn_txn_id, 'sendfail'); continue; } + //添加邮件发送记录 //给外联发送通知邮件 $fromName = !empty($item->pn_payer) ? $item->pn_payer : ''; @@ -825,7 +874,7 @@ class Index extends CI_Controller { $body = $this->load->view('mail_templete', $item, true); //$item->pn_memo; $M_RelatedInfo = $item->pn_sn; $M_AddTime = $item->pn_payment_date; - $M_State = 0; //设置已经发送,测试专用 + $M_State = 0; $this->Paypal_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'paypal note'); //添加邮件发送记录 end @@ -834,8 +883,175 @@ class Index extends CI_Controller { //echo 'done!'; } + public function send_refund($item, $handpick, $old_ssje=NULL) + { + // 找到原始收款交易的订单 + $parent_note = $this->note_modal->note($item->parent_txn_id); + if (empty($parent_note)) { + return false; + } + //订单号 + $orderid_info = $this->analysis_orderid($parent_note->pn_invoice); + + //找不到订单号,设置为发送失败标示 + if (empty($orderid_info)) { + $this->Note_model->update_send($item->pn_txn_id, 'sendfail'); + return false; + } + + // for trippest tourMaster 2018.05.28 + if ($orderid_info->ordertype == 'TP') { + $this->trippest_note($orderid_info, $item); + return false; + } + + //根据订单号查找外联信息 + $orderid_info = json_decode($orderid_info); + $advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype, $handpick); + + //查不到订单信息 + if (empty($advisor_info)) { + $this->Note_model->update_send($item->pn_txn_id, 'sendfail'); + return false; + } + + //更新正确的订单信息到记录中,以这个为主 + $this->Note_model->set_invoice($item->pn_txn_id, $orderid_info->orderid . '_' . $orderid_info->ordertype); + + //添加支付信息入库 + //没有分配订单之前先添加付款记录,这个过程可能会执行多次,必须在添加记录前查找是否有数据 + if (!empty($orderid_info)) { + $ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency)); + $ssje = $old_ssje===NULL ? $ssje : $old_ssje; + //更新还没有填的客邮和交易号de收款记录(商务订单) + if (isset($advisor_info->order_type) && $advisor_info->order_type == 0) { + $ht_memo = '退款交易号(自动录入):' . $item->pn_txn_id . "\n. "; + $ht_memo .= '原收款交易号(自动录入):' . $item->parent_txn_id; + $GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0; + //CHTAPP订单添加记录前判断是否有记录,以前的APP版本没有交易号,只能拿金额来判断 + if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP') {//只判断前6位字符,CHTAPP-fr CHTAPP-jp等各语种都属于APP订单 + $this->Paypal_model->add_account_info_forAPP($GAI_COLI_SN, $advisor_info->COLI_ID, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, '', $item->pn_payer_email, $item->pn_txn_id, $ht_memo); + $this->Paypal_model->insert_biz_order_log($GAI_COLI_SN, 'Refunded'); + } else { + if (false == $this->Paypal_model->if_biz_gai_exists($item->pn_txn_id) ) { + $this->Paypal_model->insert_biz_order_log($GAI_COLI_SN, 'Refunded'); + } + $this->Paypal_model->add_account_info($GAI_COLI_SN, $advisor_info->COLI_ID, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, '', $item->pn_payer_email, $item->pn_txn_id, $ht_memo); + } + } + //更新还没有填的客邮和交易号de收款记录(传统订单) + elseif (isset($advisor_info->order_type) && $advisor_info->order_type == 1) { + $ht_memo = '退款交易号(自动录入):' . $item->pn_txn_id . "\n. "; + $ht_memo .= '原收款交易号(自动录入):' . $item->parent_txn_id; + $GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0; + $gai_sn = $this->Paypal_model->add_tour_account_info($GAI_COLI_SN, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payer, $item->pn_payer_email, $item->pn_txn_id, $ht_memo); + //添加汉特的订单提醒 + $this->Paypal_model->update_coli_introduction($GAI_COLI_SN, '已退款 ' . mb_strtoupper($item->pn_mc_currency) . $item->pn_mc_gross); + } + } + + + $opi_email = !empty($advisor_info->OPI_Email) ? $advisor_info->OPI_Email : ''; //lussie@chinahighlights.net + $opi_firstname = !empty($advisor_info->OPI_FirstName) ? $advisor_info->OPI_FirstName : !empty($advisor_info->OPI_Name) ? $advisor_info->OPI_Name : ''; //lussie + + //没有外联信息表示订单未分配 + if (empty($opi_email) || empty($opi_firstname)) { + $this->Note_model->update_send($item->pn_txn_id, 'sendfail'); + return false; + } + + //添加邮件发送记录 + //给外联发送通知邮件 + $fromName = !empty($item->pn_payer) ? $item->pn_payer : ''; + $fromEmail = !empty($item->pn_payer_email) ? $item->pn_payer_email : ''; + $toName = !empty($opi_firstname) ? $opi_firstname : ''; + $toEmail = !empty($opi_email) ? $opi_email : ''; + $subject = $orderid_info->orderid . '_' . $orderid_info->ordertype . ' / ' . $item->pn_mc_gross . $item->pn_mc_currency . ' / ' . $fromName; + $body = $this->load->view('mail_templete', $item, true); //$item->pn_memo; + $M_RelatedInfo = $item->pn_sn; + $M_AddTime = $item->pn_payment_date; + $M_State = 0; + $this->Paypal_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'paypal note'); + // TODO 通知财务, 如果已做账 + //添加邮件发送记录 end + + + return $this->Note_model->update_send($item->pn_txn_id, 'send'); + } + + public function trippest_note($orderid_info, $paypal_msg) + { + $send_type = ''; + $tp_orderid = ''; + $real_orderid = $orderid_info->orderid; + if (substr($orderid_info->orderid, 0, 2) == '01') { + $tp_orderid = "#" . substr($orderid_info->orderid, 10); + $real_orderid = ''; + } + // 获取HT订单号 + $ht_tp_order = $this->Paypal_model->get_trippest_order($tp_orderid, $real_orderid); + if (empty($ht_tp_order)) { + /** + * 此处不直接退出是为了:在(邮件订单不能自动录入/未收到新订单邮件)时也能通知外联已收款,防止漏单 + * 本方法内-以下的非空判断同理: !empty($ht_tp_order) + * * 未找到订单先邮件通知: pn_send='', 继续排队等待录入. 直到匹配订单变更为send + */ + // return $this->Note_model->update_send($paypal_msg->pn_txn_id, 'sendfail'); + } else { + $tp_orderid = $ht_tp_order->COLI_PriceMemo; + $real_orderid = $ht_tp_order->COLI_ID; + //更新正确的订单信息到记录中,以这个为主 + $this->Note_model->set_invoice($paypal_msg->pn_txn_id, $ht_tp_order->COLI_ID . '_TP'); + } + $ssje = $this->Paypal_model->get_ssje($paypal_msg->pn_mc_gross, '15002', mb_strtoupper($paypal_msg->pn_mc_currency)); + $ht_memo = '交易号(自动录入):' . $paypal_msg->pn_txn_id; + if (false == $this->Paypal_model->if_biz_gai_exists($paypal_msg->pn_txn_id) ) { + if ( ! empty($ht_tp_order)) { + $this->Paypal_model->update_biz_coli_state($ht_tp_order->COLI_SN, 13); + $this->Paypal_model->insert_biz_order_log($ht_tp_order->COLI_SN, 'BS13'); + $this->Paypal_model->update_paymanner($ht_tp_order->COLI_SN, '15010'); + } + if (trim($paypal_msg->pn_send)!='' && trim($paypal_msg->pn_send)!='send') { + $opi_firstname = "David"; + $opi_email = "david@trippest.com"; + $fromName = !empty($paypal_msg->pn_payer) ? $paypal_msg->pn_payer : ''; + $fromEmail = !empty($paypal_msg->pn_payer_email) ? $paypal_msg->pn_payer_email : ''; + $toName = !empty($opi_firstname) ? $opi_firstname : ''; + $toEmail = !empty($opi_email) ? $opi_email : ''; + $subject = $real_orderid . $tp_orderid . '_' . $orderid_info->ordertype . ' / ' . $paypal_msg->pn_mc_gross . $paypal_msg->pn_mc_currency . ' / ' . $fromName; + $body = $this->load->view('mail_templete', $paypal_msg, true); //$paypal_msg->pn_memo; + $M_RelatedInfo = $paypal_msg->pn_sn; + $M_AddTime = $paypal_msg->pn_payment_date; + $M_State = 0; + $this->Paypal_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'paypal note'); + empty($ht_tp_order) ? $send_type = "" : false ; // 未录订单先通知收款, 置为空继续排队 + } + } + if ( ! empty($ht_tp_order)) { + $this->Paypal_model->add_account_info( + $ht_tp_order->COLI_SN, + $ht_tp_order->COLI_ID, + $paypal_msg->pn_mc_gross, + $paypal_msg->pn_payment_date, + mb_strtoupper($paypal_msg->pn_mc_currency), + $ssje, + $paypal_msg->pn_payment_date, + $paypal_msg->pn_payment_date, + $paypal_msg->pn_payment_date, + '', + $paypal_msg->pn_payer_email, + $paypal_msg->pn_txn_id, + $ht_memo + ); + $send_type = "send"; + } + + $this->Note_model->update_send($paypal_msg->pn_txn_id, $send_type); + } + //所有记录列表 public function note_list() { + $this->permission->is_admin(true); $data = array(); //有关键词则不限制日期 $data['search_key'] = $this->input->post('search_key'); @@ -848,6 +1064,11 @@ class Index extends CI_Controller { $data['notelist'] = $this->Note_model->search_date($data['date']); } + /** + * 导出记录用的记录节点 + */ + $data['record_flags'] = $this->Note_model->list_export_record(); + $this->load->view('n-header', $data); $this->load->view('note_list'); $this->load->view('n-footer'); @@ -855,6 +1076,7 @@ class Index extends CI_Controller { //所有记录列表 public function note_faillist() { + $this->permission->is_admin(true); $data = array(); //有关键词则不限制日期 $data['search_key'] = $this->input->post('search_key'); @@ -868,6 +1090,7 @@ class Index extends CI_Controller { //获取note详情,修改各项数据 public function note_modal($pn_txn_id, $pn_invoice = false) { + $this->permission->is_admin(true); $data = array(); $data['pn_invoice'] = $pn_invoice; if (!empty($pn_txn_id)) { @@ -891,25 +1114,26 @@ class Index extends CI_Controller { //修改订单名 public function note_modal_save() { - $data = array(); - - $pn_txn_id = $this->input->post('pn_txn_id'); - $pn_invoice = $this->input->post('pn_invoice'); - - if (!empty($pn_txn_id) && !empty($pn_invoice)) { - $orderid_info = $this->analysis_orderid($pn_invoice); - if (!empty($orderid_info)) { - $orderid_info = json_decode($orderid_info); - $advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype); - if (!empty($advisor_info)) { - $this->Note_model->set_invoice($pn_txn_id, $pn_invoice); - $this->send_note($pn_txn_id); - echo json_encode('修改成功!'); - return true; - } - } - } - echo json_encode('没找到数据!'); + $this->gai_modal_save(); + // $data = array(); + + // $pn_txn_id = $this->input->post('pn_txn_id'); + // $pn_invoice = $this->input->post('pn_invoice'); + + // if (!empty($pn_txn_id) && !empty($pn_invoice)) { + // $orderid_info = $this->analysis_orderid($pn_invoice); + // if (!empty($orderid_info)) { + // $orderid_info = json_decode($orderid_info); + // $advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype); + // if (!empty($advisor_info)) { + // $this->Note_model->set_invoice($pn_txn_id, $pn_invoice); + // $this->send_note($pn_txn_id); + // echo json_encode('修改成功!'); + // return true; + // } + // } + // } + // echo json_encode('没找到数据!'); } //关闭note通知,用于手动处理通知后 @@ -929,11 +1153,103 @@ class Index extends CI_Controller { $from_date = $this->input->post("from_date"); $to_date = $this->input->post("to_date"); $currency = $this->input->post("currency"); - $export_list = $this->Note_model->date_range($from_date, $to_date, $currency); + $amount = $this->input->post("set_amount"); + $last_record = $this->input->post("date_history"); + if (empty($amount)) { + $export_list = $this->Note_model->date_range($from_date, $to_date, $currency); + } else { + $allmost_day = intval(ceil($amount/10000)); + if ( ! in_array($currency, array('CNY','USD'))) { + $allmost_day = 30; + } + $last_sn = null; + $last_notice_sn = null; + $last_notice_record = array(); + if ( ! empty($last_record)) { + $selection_text = explode("@", $last_record); + $last_sn = $selection_text[0]; + $last_notice_record = $this->Note_model->list_export_record($last_sn); + if ( ! empty($last_notice_record[0])) { + $last_notice_sn = $last_notice_record[0]->TEL_transactionNoticeId; + // 查询导出记录时包含上次导出的最后一条. + // 因此目标金额设为本次的目标+上次已导出的部分 + // 得到结果集之后会把本次的第一条的金额重新计算,即减去上次已导出金额.下述 + $amount = bcadd($amount, $last_notice_record[0]->TEL_exportAmount); + $from_date = strstr($last_notice_record[0]->TEL_transactionDate, " ", TRUE); + $currency = $last_notice_record[0]->TEL_transactionCurrency; + } + } + $all_list = $this->target_amount_recursive($currency, $amount, 0, $from_date, $allmost_day, array(), $last_notice_sn); + $export_list = $all_list['list']; + // 修改导出的第一条记录, 金额改为剩余金额 + if ( ! empty($last_notice_record[0]) && $last_notice_record[0]->TEL_transactionNoticeId==$export_list[0]->pn_sn) { + $export_list[0]->pn_mc_gross = bcsub($last_notice_record[0]->TEL_transactionAmount, $last_notice_record[0]->TEL_exportAmount); + } + } if ($export_list == false) { echo "Not found any records for export."; return false; } + // 记录这次导出的最后一条 + if (isset($all_list['last_flag']) && ! empty($all_list['last_flag'])) { + $balance_diff = bcsub($all_list['now_amount'], $amount); + $last_record_export = bcsub($all_list['last_flag']->pn_mc_gross, $balance_diff); + $insert_db = array( + "TEL_transactionType" => 15002 + ,"TEL_transactionNoticeId" => $all_list['last_flag']->pn_sn + ,"TEL_transactionId" => $all_list['last_flag']->pn_txn_id + ,"TEL_transactionDate" => $all_list['last_flag']->pn_datetime + ,"TEL_transactionAmount" => $all_list['last_flag']->pn_mc_gross + ,"TEL_transactionCurrency" => $all_list['last_flag']->pn_mc_currency + ,"TEL_orderId" => $all_list['last_flag']->pn_invoice + ,"TEL_exportAmount" => $last_record_export + ,"TEL_exportDate" => date('Y-m-d H:i:s') + ); + $this->Note_model->export_record($insert_db); + // 修改导出的最后一条 + array_pop($export_list); + $all_list['last_flag']->pn_mc_gross = $last_record_export; + array_push($export_list, $all_list['last_flag']); + } + + $this->save_excel($export_list); + } + + /*! + * 递归查询收款记录, 直到总金额>=目标总金额 + * @date 2019-02-27 + */ + public function target_amount_recursive($currency, $target_amount, $now_amount, $from_date,$days=10,$list=array(), $last_sn=null, $last_flag=null) + { + $to_date = date('Y-m-d', strtotime("+$days days", strtotime($from_date))); + $former_list = $this->Note_model->date_range($from_date, $to_date, $currency, $last_sn); + $list_index = 0; + $last_sn = $last_sn===null ? 0 : $last_sn; + $last_flag = $last_flag===null ? null : $last_flag; + while ($now_amount < $target_amount && isset($former_list[$list_index])) { + $list[] = $former_list[$list_index]; + $now_amount = bcadd($now_amount, $former_list[$list_index]->pn_mc_gross); + $last_sn = $former_list[$list_index]->pn_sn; + $last_flag = $former_list[$list_index]; + $list_index++; + } + $ret = array( + "last_flag" => $last_flag, + "list" => $list, + "now_amount" => $now_amount + ); + if (empty($former_list)) { + return $ret; + } + if ($now_amount < $target_amount) { + return $this->target_amount_recursive($currency, $target_amount, $now_amount, $to_date, 10, $list, $last_sn, $last_flag); + } else { + return $ret; + } + } + + public function save_excel($export_list) + { $this->load->library('PHPExcel'); $objPHPExcel = new PHPExcel(); $objPHPExcel->setActiveSheetIndex(0); @@ -944,17 +1260,22 @@ class Index extends CI_Controller { $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20); $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(30); $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20); + $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(20); + $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(20); // 对齐 $objPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); $objPHPExcel->getActiveSheet()->getStyle('C')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); + $objPHPExcel->getActiveSheet()->getStyle('D')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); // 表标题行 $objPHPExcel->getActiveSheet() ->SetCellValue('A1', '#') ->SetCellValue('B1', '团号') ->SetCellValue('C1', '金额') - ->SetCellValue('D1', '付款人') - ->SetCellValue('E1', '交易号') - ->SetCellValue('F1', '收单时间'); + ->SetCellValue('D1', '币种') + ->SetCellValue('E1', '付款人') + ->SetCellValue('F1', '付款人邮箱') + ->SetCellValue('G1', '交易号') + ->SetCellValue('H1', '收单时间'); $currency_sum = array(); bcscale(2); $rowCount = 2; @@ -966,11 +1287,14 @@ class Index extends CI_Controller { $orderid = $row->pn_invoice ? $row->pn_invoice : $row->pn_item_number; $objPHPExcel->getActiveSheet() ->SetCellValue('A'.$rowCount, ($rowCount-1)) + // ->SetCellValue('A'.$rowCount, $row->pn_sn) ->setCellValueExplicit('B'.$rowCount, $orderid,PHPExcel_Cell_DataType::TYPE_STRING) - ->setCellValueExplicit('C'.$rowCount, trim($row->pn_mc_currency) . number_format($row->pn_mc_gross, 2, ".", ""),PHPExcel_Cell_DataType::TYPE_STRING) - ->SetCellValue('D'.$rowCount, $payer) - ->setCellValueExplicit('E'.$rowCount, $row->pn_txn_id,PHPExcel_Cell_DataType::TYPE_STRING) - ->SetCellValue('F'.$rowCount, $row->pn_datetime); + ->setCellValue('C'.$rowCount, number_format($row->pn_mc_gross, 2, ".", "")) + ->setCellValueExplicit('D'.$rowCount, trim($row->pn_mc_currency) ,PHPExcel_Cell_DataType::TYPE_STRING) + ->SetCellValue('E'.$rowCount, $row->pn_payer) + ->SetCellValue('F'.$rowCount, $row->pn_payer_email) + ->setCellValueExplicit('G'.$rowCount, $row->pn_txn_id,PHPExcel_Cell_DataType::TYPE_STRING) + ->SetCellValue('H'.$rowCount, $row->pn_datetime); $payer = $orderid = ""; $rowCount++; } @@ -992,4 +1316,99 @@ class Index extends CI_Controller { $objWriter->save('php://output'); } + /** 查看收款记录的是否已录入到订单 */ + public function gai_modal($pn_txn_id=null, $pn_id = null, $neworder=null) + { + $this->permission->is_admin(true); + $data = array(); + $data['note'] = $this->Note_model->note($pn_txn_id, $pn_id); + $orderid_info = $this->analysis_orderid($data['note']->pn_invoice); + if (!empty($orderid_info)) { + $orderid_info = json_decode($orderid_info); + if ($orderid_info->ordertype === 'TP') { + $orderid_info->ordertype = 'B'; + } + if ($orderid_info->ordertype === 'T') { + $data['gai_info'] = $this->Paypal_model->get_money_t($pn_txn_id); + } elseif ($orderid_info->ordertype === 'B') { + $data['gai_info'] = $this->Paypal_model->get_money_b($pn_txn_id); + } + } + $data['old_order'] = $data['note']->pn_invoice; + $data['new_order'] = $neworder; + $data['order_info'] = null; + if ($neworder !== null) { + $neworder_id = $this->analysis_orderid($neworder); + $neworder_id = json_decode($neworder_id); + if ($neworder_id->ordertype === 'TP') { + $neworder_id->ordertype = 'B'; + } + if ( ! empty($neworder_id)) { + $data['order_info'] = $this->Paypal_model->get_order($neworder_id->orderid, true, $neworder_id->ordertype); + } + } + echo json_encode($this->load->view('gai_setting', $data, true)); + } + public function gai_modal_save() + { + $data = array(); + $old_ssje = NULL; + $pn_txn_id = $this->input->post('pn_txn_id'); + $pn_id = $this->input->post('pn_id'); + $neworder = $this->input->post('pn_invoice'); + + $data['note'] = $this->Note_model->note($pn_txn_id, $pn_id); + $orderid_info = $this->analysis_orderid($data['note']->pn_invoice); + if (!empty($orderid_info)) { + $orderid_info = json_decode($orderid_info); + if ($orderid_info->ordertype === 'TP') { + $orderid_info->ordertype = 'B'; + } + if ($orderid_info->ordertype === 'T') { + $data['gai_info'] = $this->Paypal_model->get_money_t($pn_txn_id); + if ( ! empty($data['gai_info'])) { + $old_ssje = $data['gai_info'][0]->GAI_SSJE; + $this->Paypal_model->delete_money_t($pn_txn_id); + } + } elseif ($orderid_info->ordertype === 'B') { + $data['gai_info'] = $this->Paypal_model->get_money_b($pn_txn_id); + if ( ! empty($data['gai_info'])) { + $old_ssje = $data['gai_info'][0]->GAI_SSJE; + $this->Paypal_model->delete_money_b($pn_txn_id); + } + } + } + + if (!empty($pn_txn_id) && !empty($neworder)) { + $orderid_info = $this->analysis_orderid($neworder); + if (!empty($orderid_info)) { + $orderid_info = json_decode($orderid_info); + if ($orderid_info->ordertype === 'TP') { + $orderid_info->ordertype = 'B'; + } + $advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype, TRUE); + if (!empty($advisor_info)) { + $this->Note_model->set_invoice($pn_txn_id, $neworder); + $this->send_note($pn_txn_id, $old_ssje); + echo json_encode('修改成功!'); + return true; + } + } + } + echo json_encode('没找到数据!'); + return; + } + public function closeGai($pn_txn_id) + { + $data = array(); + $data['note'] = $this->Note_model->note($pn_txn_id); + if (!empty($data['note'])) { + $this->Note_model->update_send($pn_txn_id, 'closeRecord'); + echo json_encode('该收款记录已经忽略!'); + return true; + } + echo json_encode('没找到数据!'); + return; + } + } diff --git a/webht/third_party/paypal/controllers/payment.php b/webht/third_party/paypal/controllers/payment.php index 9b5eb06a..cd08e942 100644 --- a/webht/third_party/paypal/controllers/payment.php +++ b/webht/third_party/paypal/controllers/payment.php @@ -5,7 +5,7 @@ if (!defined('BASEPATH')) class Payment extends CI_Controller { - public function __construct() + public function __construct() { parent::__construct(); $this->permission->is_admin(false); @@ -16,7 +16,7 @@ class Payment extends CI_Controller $data=array(); if ($this->input->post('price')) { //文字链接 - $paylink='https://www.chinahighlightstravel.com/payment/payment-center.asp?'. + $paylink='https://www.chinahighlights.com/securepayment/?'. 'Site_Language='.$this->input->post('lan').'&'. 'Site_CurrencyType='.$this->input->post('currency').'&'. 'Site_ACD=100-200-300&'. @@ -36,4 +36,4 @@ class Payment extends CI_Controller $this->load->view('n-footer'); } -} \ No newline at end of file +} diff --git a/webht/third_party/paypal/models/note_model.php b/webht/third_party/paypal/models/note_model.php index d5f6c022..0cd9ecd4 100644 --- a/webht/third_party/paypal/models/note_model.php +++ b/webht/third_party/paypal/models/note_model.php @@ -31,30 +31,31 @@ class Note_model extends CI_Model { public function unsend($topnum = 2) { $this->init(); $this->topnum = $topnum; - $this->pn_send = " AND (pn_send='unsend' OR pn_send='' OR pn_send IS NULL) "; + $this->pn_send = " AND (pn_send='unsend' OR pn_send IS NULL) "; return $this->get_list(); } public function failnote($topnum = 2) { $this->init(); $this->topnum = $topnum; - $this->pn_send = " AND pn_send='sendfail' "; + $this->pn_send = " AND (pn_send='sendfail' OR pn_send='') "; //$this->orderby = ' ORDER BY pn.pn_sn ASC '; return $this->get_list(); } public function search_date($date) { $this->init(); - $search_sql = " AND pn.pn_datetime BETWEEN '$date 00:00:00' AND '$date 23:59:59' "; + $search_sql = " AND (pn.pn_datetime BETWEEN '$date 00:00:00' AND '$date 23:59:59' OR pn_send not in ('send','closeRecord')) "; $this->search = $search_sql; $this->orderby=" ORDER BY CASE pn.pn_send WHEN 'sendfail' THEN 1 ELSE 2 END ,pn.pn_sn DESC "; return $this->get_list(); } - public function note($pn_txn_id){ + public function note($pn_txn_id, $pn_sn=NULL){ $this->init(); $this->topnum=1; $this->pn_txn_id=" AND pn.pn_txn_id=".$this->HT->escape($pn_txn_id); + $this->pn_txn_id .= ($pn_sn===NULL) ? "" : " AND pn.pn_sn=".$this->HT->escape($pn_sn); return $this->get_list(); } @@ -88,7 +89,7 @@ class Note_model extends CI_Model { ?,N?,N?,?,N?,N?,?,?,N?,N?,?, N?, GETDATE(),'unsend' ) "; - $query = $this->HT->query($sql, array($pn_txn_id, $pn_invoice, $pn_custom, $pn_mc_gross, $pn_item_name, $pn_item_number, $pn_mc_currency, $pn_payment_status, $pn_payer, $pn_payer_email, $pn_payment_date, $pn_memo)); + $query = $this->HT->query($sql, array($pn_txn_id, $pn_invoice, $pn_custom, $pn_mc_gross, mb_substr($pn_item_name, 0, 250) , $pn_item_number, $pn_mc_currency, $pn_payment_status, $pn_payer, $pn_payer_email, $pn_payment_date, $pn_memo)); $insertid = $this->HT->last_id('paypal_note'); return $query; } @@ -118,6 +119,7 @@ class Note_model extends CI_Model { $this->search ? $sql.=$this->search : false; $this->pn_txn_id ? $sql.=$this->pn_txn_id : false; $this->orderby ? $sql.=$this->orderby : false; +// log_message('error',$sql); $query = $this->HT->query($sql); //print_r($this->HT->queries); if ($this->topnum === 1) { @@ -151,7 +153,7 @@ class Note_model extends CI_Model { return $this->HT->query($sql, array($pn_invoice, $pn_txn_id)); } - public function date_range($from, $to, $currency=NULL) + public function date_range($from, $to, $currency=NULL, $pn_sn=NULL) { $this->init(); $search_sql = " AND pn_payment_status in ('Completed','Refunded') "; @@ -159,9 +161,34 @@ class Note_model extends CI_Model { if ( ! empty($currency)) { $search_sql .= " AND pn_mc_currency = '$currency' "; } + if ( ! empty($pn_sn)) { + $search_sql .= " AND pn_sn >= $pn_sn "; + } $this->search = $search_sql; - $this->orderby = ""; + $this->orderby = " order by pn.pn_sn asc"; return $this->get_list(); } + + /** + * export note + */ + public function export_record($db) + { + $this->info = $this->load->database('INFO', TRUE); + $this->info->insert('Transaction_Export_Log', $db); + } + + public function list_export_record($sn=0) + { + $this->info = $this->load->database('INFO', TRUE); + $search_sql = $sn===0 ? "" : " and TEL_SN=$sn "; + $sql = "SELECT TOP 10 * + FROM [InfoManager].[dbo].[Transaction_Export_Log] + WHERE 1=1 + $search_sql + order by TEL_SN desc"; + return $this->info->query($sql)->result(); + } + } diff --git a/webht/third_party/paypal/models/paypal_model.php b/webht/third_party/paypal/models/paypal_model.php index af3f95b5..df8808e5 100644 --- a/webht/third_party/paypal/models/paypal_model.php +++ b/webht/third_party/paypal/models/paypal_model.php @@ -14,12 +14,12 @@ class Paypal_model extends CI_Model { } //根据订单号获取外联邮箱 - public function get_order($COLI_ID, $orderinfo = false, $ordertype = 'N') { + public function get_order($COLI_ID, $orderinfo = false, $ordertype = 'N', $handpick=false) { $result = ''; $fieldsql = $orderinfo == false ? '' : " ,* "; //先查商务订单B,APP订单A、再查传统订单T if ($ordertype == 'B' || $ordertype == 'A') { - $sql = "SELECT TOP 1 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from BIZ_ConfirmLineInfo + $sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_PayManner,COLI_State $fieldsql from BIZ_ConfirmLineInfo LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN where COLI_ID =?"; $query = $this->HT->query($sql, array($COLI_ID)); @@ -27,17 +27,21 @@ class Paypal_model extends CI_Model { } //后查传统订单的原因是因为传统订单的订单号去掉外联名字首字母后可能会和商务订单的重合。 if (empty($result) && ($ordertype == 'T')) { - $sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from ConfirmLineInfo + $sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from ConfirmLineInfo LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN - where COLI_ID like '%$COLI_ID'"; + where COLI_ID like '%$COLI_ID' + order by CHARINDEX('$COLI_ID', COLI_ID) "; $query = $this->HT->query($sql); $result = $query->result(); + if ($handpick === TRUE) { + $result = array($result[0]); + } } //查传统订单add_code,网前实时支付会先生成一个临时订单号存在add_code里,如订单45103248 if (empty($result) && ($ordertype == 'M')) { - $sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo + $sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN where COLI_AddCode =? "; $query = $this->HT->query($sql, array($COLI_ID)); @@ -45,7 +49,7 @@ class Paypal_model extends CI_Model { } if (empty($result) && ($ordertype == 'M')) { - $sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo cli + $sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo cli LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN where EXISTS ( @@ -61,7 +65,7 @@ class Paypal_model extends CI_Model { //订单号查询不到尝试使用团号查询 if (empty($result) && $ordertype == 'B') { - $sql = "SELECT TOP 1 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from BIZ_ConfirmLineInfo + $sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_State $fieldsql from BIZ_ConfirmLineInfo LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN where COLI_GroupCode like '%-$COLI_ID%'"; $query = $this->HT->query($sql); @@ -69,10 +73,14 @@ class Paypal_model extends CI_Model { } //团号查询不到尝试使用客人邮箱查询(预订多次的老客户得按日期新旧排序,取最新的数据) - if (!empty($result)) { + if (!empty($result) && is_array($result) ) { //print_r($result[0]); //die(); - $result = $result[0]; + if (count($result) > 1) { + $result = array(); + } else { + $result = $result[0]; + } } return $result; @@ -118,14 +126,33 @@ class Paypal_model extends CI_Model { //修改订单状态 public function update_biz_coli_state($coli_sn, $coli_state) { $sql = " - UPDATE BIZ_ConfirmLineInfo - SET COLI_State = ? - WHERE COLI_SN = ? + IF EXISTS + ( SELECT OPI_DEI_SN + FROM OperatorInfo + INNER JOIN BIZ_ConfirmLineInfo ON OPI_SN=COLI_OPI_ID + WHERE COLI_SN=? AND OPI_DEI_SN=10 + ) + UPDATE BIZ_ConfirmLineInfo + SET COLI_State=? + WHERE COLI_SN=? + ELSE + UPDATE BIZ_ConfirmLineInfo + SET COLI_State=? WHERE COLI_SN=? + AND COLI_State IN (0,1,11,12,13,14,40,50,60,101,102,999) "; - $query = $this->HT->query($sql, array($coli_state, $coli_sn)); + $query = $this->HT->query($sql, array($coli_sn, $coli_state, $coli_sn, $coli_state, $coli_sn)); return $query; } + public function if_biz_gai_exists($GAI_AccreditNo) + { + $sql = " SELECT TOP 1 1 FROM BIZ_GroupAccountInfo + WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') + AND DeleteFlag=0"; + $result = $this->HT->query($sql, array($GAI_AccreditNo)); + return ($result->num_rows() > 0); + } + //添加收款记录(商务订单),APP会自动增加记录,所以添加前根据金额来判断是否有重复记录 public function add_account_info_forAPP($GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo) { //先判断是否有这条数据 @@ -133,7 +160,7 @@ class Paypal_model extends CI_Model { IF NOT EXISTS( SELECT TOP 1 1 FROM BIZ_GroupAccountInfo - WHERE GAI_COLI_SN = ? AND GAI_SQJE=? + WHERE GAI_COLI_SN = ? AND GAI_SQJE=? AND DeleteFlag=0 AND GAI_Type='15010' ) INSERT INTO BIZ_GroupAccountInfo ( GAI_COLI_SN @@ -166,7 +193,7 @@ class Paypal_model extends CI_Model { IF NOT EXISTS( SELECT TOP 1 1 FROM BIZ_GroupAccountInfo - WHERE GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%' + WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') AND DeleteFlag=0 ) INSERT INTO BIZ_GroupAccountInfo ( GAI_COLI_SN @@ -185,7 +212,7 @@ class Paypal_model extends CI_Model { ,GAI_Memo ,GAI_State ,DeleteFlag - ) VALUES (?,?,15010,?,?,?,?,?,?,?,?,?,?,?,0,0)"; + ) VALUES (?,?,15002,?,?,?,?,?,?,?,?,?,?,?,0,0)"; $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo)); $insertid = $this->HT->last_id('BIZ_GroupAccountInfo'); return $query; @@ -199,7 +226,7 @@ class Paypal_model extends CI_Model { IF NOT EXISTS( SELECT TOP 1 1 FROM GroupAccountInfo - WHERE GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%' + WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') and DeleteFlag=0 ) INSERT INTO GroupAccountInfo ( GAI_COLI_SN @@ -220,7 +247,7 @@ class Paypal_model extends CI_Model { ) VALUES (?,15002,?,?,?,?,?,?,?,?,?,?,?,0,0)"; $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo)); $insertid = $this->HT->last_id('GroupAccountInfo'); - return $query; + return $insertid; } //更新线路提醒 @@ -254,10 +281,6 @@ class Paypal_model extends CI_Model { return $query; } - public function note_list() { - - } - public function save_paypal_msg($pm_transaction_id, $pm_orderid, $pm_item_name, $pm_money, $pm_currency, $pm_payer, $pm_payer_email, $pm_payer_status, $pm_memo, $pm_payment_date, $pm_pay_type) { $sql = "INSERT INTO paypal_msg ( pm_transaction_id @@ -521,4 +544,71 @@ class Paypal_model extends CI_Model { $query = $this->HT->query($sql, array($paymanner, $COLI_SN)); return $query; } + //根据交易号获取收款记录(传统订单) + public function get_money_t($pn_invoice) { + $sql = "SELECT GroupAccountInfo.* + from GroupAccountInfo + where DeleteFlag=0 and GAI_AccreditNo=? + "; + $query = $this->HT->query($sql, array($pn_invoice)); + $result = $query->result(); + return $result; + } + //根据交易号获取收款记录(商务订单) + public function get_money_b($pn_invoice) { + $sql = "SELECT BIZ_GroupAccountInfo.* + from BIZ_GroupAccountInfo + where DeleteFlag=0 and GAI_AccreditNo=? + "; + $query = $this->HT->query($sql, array($pn_invoice)); + $result = $query->result(); + return $result; + } + /** 删除收款记录 */ + public function delete_money_t($deadId) + { + $sql = "UPDATE GroupAccountInfo SET DeleteFlag=1 WHERE GAI_AccreditNo=?"; + $query = $this->HT->query($sql, array($deadId)); + return $query; + } + public function delete_money_b($deadId) + { + $sql = "UPDATE BIZ_GroupAccountInfo SET DeleteFlag=1 WHERE GAI_AccreditNo=?"; + $query = $this->HT->query($sql, array($deadId)); + return $query; + } + + /** JJH: 添加订单收款记录之后执行 */ + public function exec_addToTask($GAI_SN) + { + $sql = " if not exists ( + select top 1 1 from Sysautotask + where SAT_Type=1 and SAT_SourceSN=$GAI_SN + ) exec SP_AddToSystask 1," . $GAI_SN; + $query = $this->HT->query($sql); + return $query; + } + + /** 写入商务订单操作记录 */ + public function insert_biz_order_log($coli_sn, $log_info) + { + $db_column = array( + "BOL_COLI_SN" => $coli_sn + ,"BOL_OPI_SN" => 0 + ,"BOL_OPType" => $log_info + ,"BOL_OPTime" => date('Y-m-d H:i:s') + ,"BOL_Creator" => 0 + ,"BOL_CreateTime" => date('Y-m-d H:i:s') + ); + return $this->HT->insert("BIZ_OrderOperationLog", $db_column); + } + + public function get_trippest_order($tp_order='', $real_orderid='') + { + $sql = "SELECT top 1 * from BIZ_ConfirmLineInfo + WHERE 1=1 "; + $tp_order ? $sql.=" and COLI_PriceMemo=$tp_order " : ""; + $real_orderid ? $sql.=" and COLI_ID=$real_orderid " : ""; + return $this->HT->query($sql)->row(); + } } diff --git a/webht/third_party/paypal/views/gai_setting.php b/webht/third_party/paypal/views/gai_setting.php new file mode 100644 index 00000000..e11d0137 --- /dev/null +++ b/webht/third_party/paypal/views/gai_setting.php @@ -0,0 +1,41 @@ +
    + +

    已录入订单

    + + + + + + + + + +
    申请金额/币种实收金额
    GAI_SQJE; ?> GAI_SQJECurrency; ?>GAI_SSJE; ?> CNY
    +

    撤回以上订单收款记录, 并转移到订单:

    + +

    未自动录入到订单

    + +
    + + +
    + +
    订单详细内容:
    +

    + $order_info->COLI_SN
    "; + echo "COLI_ID => $order_info->COLI_ID
    "; + echo "OPI_Email => $order_info->OPI_Email
    "; + echo "OPI_Name => $order_info->OPI_Name
    "; + echo!empty($order_info->COLI_GroupCode) ? "COLI_GroupCode => $order_info->COLI_GroupCode
    " : false; + echo!empty($order_info->COLI_OrderDetailText) ? "COLI_OrderDetailText => $order_info->COLI_OrderDetailText\n" : false; + } else { + echo '找不到目标订单内容'; + } + ?> +

    + + +
    diff --git a/webht/third_party/paypal/views/note_list.php b/webht/third_party/paypal/views/note_list.php index 0d8a07ce..70dcc979 100644 --- a/webht/third_party/paypal/views/note_list.php +++ b/webht/third_party/paypal/views/note_list.php @@ -1,6 +1,7 @@ -
    -
    -
    - - -
    -
    - - -
    -
    - - + + + + +
    @@ -123,8 +184,8 @@
  • 客人邮箱
  • 交易号
  • 收款(北京)时间
  • -
  • 通知时间
  • -
  • 通知状态
  • +
  • 通知时间
  • +
  • 通知状态
  • pn_txn_id; ?>
  • pn_payment_date) + 3600 * 8); ?>
  • -
  • pn_datetime; ?>
  • -
  • +
  • pn_datetime; ?>
  • +
  • pn_send == 'send') { $show_send = $item->pn_send; + } elseif ($item->pn_send == 'closeRecord') { + $show_send = $show_record = '已忽略'; } else if ($item->pn_payment_status == 'Completed') { $class_css = 'btn-danger'; $show_send = $item->pn_send; @@ -157,6 +221,12 @@ $show_send = $item->pn_payment_status; } ?> +
    + + +
  • @@ -186,8 +256,57 @@
    + + + + + + + diff --git a/webht/third_party/workflow/controllers/index.php b/webht/third_party/workflow/controllers/index.php index c37ca49a..0f209053 100644 --- a/webht/third_party/workflow/controllers/index.php +++ b/webht/third_party/workflow/controllers/index.php @@ -15,7 +15,11 @@ class Index extends CI_Controller $this->permission->is_admin(false); $this->load->model('workflow_model'); } - + + public function test(){ + $this->workflow_model->delete_test(); + } + //首页 public function index() { @@ -24,6 +28,7 @@ class Index extends CI_Controller } $data=array(); $typelist=$this->workflow_model->get_type_list('all'); + //print_r($typelist); $data['typelist']=array(); foreach ($typelist as $t) { $data['typelist'][$t->wt_parentid][]=$t; @@ -62,7 +67,12 @@ class Index extends CI_Controller //添加一个具体事务到数据库 public function do_add_work() - { + { + + $this->load->model('operator_model'); + $current_user=$this->input->post('wf_user'); + $tmp = $this->operator_model->get_user_by_name($current_user); + //判断是不是补填的值班记录 if ($this->input->post('mail_title')=='值班记录') { //本月和上个月的值班表(有可能本月初和上月尾是连着的假期) @@ -73,27 +83,32 @@ class Index extends CI_Controller $data['flow_data'][]=$this->workflow_model->get_work_flow_data($v->wf_sn); } //节假日列表 - $needdate_list=array(); + $needdate_list=$myrota=array(); foreach ($data['flow_data'] as $f) { foreach ($f as $d) { $wfd_key_arr=explode('_', $d->wfd_key); + //值班日期是周末的日期集合 if ($wfd_key_arr[0]=='weekend' && $d->wfd_value==1) { $wfd_key_arr[1]=strlen($wfd_key_arr[1])==7?substr($wfd_key_arr[1], 0,-1).'0'.substr($wfd_key_arr[1],-1):$wfd_key_arr[1]; $needdate_list[]=$wfd_key_arr[1]; } + //当前用户的值班日期集合 + $name_string=str_replace('惠毅', '惠毅;惠 毅', $d->wfd_value); + if (!empty($d->wfd_value) && stripos($name_string, $tmp['OPI_Name'])!==false && isset($wfd_key_arr[2]) && is_numeric($wfd_key_arr[2])) { + $need_date=strlen($wfd_key_arr[2])==7?substr($wfd_key_arr[2], 0,-1).'0'.substr($wfd_key_arr[2],-1):$wfd_key_arr[2]; + $myrota[]=date('Ymd',strtotime($need_date)); + } } } + $needdate_list=array_intersect($needdate_list,$myrota); $zhiban_date=date('Ymd',strtotime($this->input->post('wf_time'))); - if (!in_array($zhiban_date, $needdate_list)) { - echo json_encode(array('status'=>'no','msg'=>'请把左上角的日期改为你值班当天的日期')); - return true; + if (empty($needdate_list) or !in_array($zhiban_date, $needdate_list)) { + //echo json_encode(array('status'=>'no','msg'=>'值班日期与值班表不符,更换了值班的同学请更改值班表')); + //return true; } } //保存任务 - $this->load->model('operator_model'); - $current_user=$this->input->post('wf_user'); - $tmp = $this->operator_model->get_user_by_name($current_user); $wf_user=$tmp['OPI_SN']; $wf_time=strtotime($this->input->post('wf_time')); $group_admin=explode('@', $this->input->post('wf_wt_sn')); @@ -108,10 +123,13 @@ class Index extends CI_Controller if ($wfd_key=='emailcontent') { $wfd_value=htmlspecialchars($wfd_value); } - $col_val.="('".trim($wfd_key)."','".$wfd_value."',".$wfd_wf_sn."),"; + // $col_val.="('".trim($wfd_key)."','".$wfd_value."',".$wfd_wf_sn."),"; + $col_val.="('".trim($wfd_key)."','".chop($wfd_value)."',".$wfd_wf_sn."),";//csk 2016-9-22 去掉末尾的换行和空格 $mail_data[$wfd_key]=$wfd_value; $mail_data['flow_data'][$wfd_key]=$wfd_value; + $mail_data['flow_data'][$wfd_key]=chop($wfd_value);//csk 2016-9-22 去掉末尾的换行和空格 } + $apply_user=$this->input->post('apply_user'); if (empty($apply_user)) { $col_val.="('apply_user','".$current_user."',".$wfd_wf_sn."),"; @@ -123,7 +141,6 @@ class Index extends CI_Controller //添加审核人 $typeinfo=$this->workflow_model->get_type_list(0,$wf_wt_sn); $verify_tolist_array=$this->get_verify_admin_list($wfd_wf_sn,$group_admin[1],$typeinfo[0]->wt_linear); - //抄送邮件给指定人员 if ($wfd_wf_sn && $wfd_sn) { $data['userdata']=$this->session->userdata('admin_chtcdn'); @@ -177,6 +194,7 @@ class Index extends CI_Controller } $data['userdata']=$this->session->userdata('admin_chtcdn'); + //print_r($data['userdata']); //事务申请人信息 $userdata=$this->session->userdata('admin_chtcdn'); $flow=$this->workflow_model->get_work_list($userdata['OPI_SN'],$wv_status,$wf_sn); @@ -189,6 +207,7 @@ class Index extends CI_Controller $data[$d->wfd_key]=$d->wfd_value; $data['flow_data'][$d->wfd_key]=$d->wfd_value; } + //print_r($data); $form=$data['flow']->wt_form; $data['wf_sn']=$wf_sn; @@ -201,12 +220,16 @@ class Index extends CI_Controller //当前用户是否审核人员 0否 1是 $verify_user=$this->workflow_model->get_verify($wf_sn,0,false,50); $data['is_verify_user']=0; - foreach ($verify_user as $vu) { + // var_dump($data['userdata']);die; + if(!empty($data['userdata']['whu_uid'])){//csk2016-11-29 + foreach ($verify_user as $vu) { if ($data['userdata']['whu_uid']==$vu->wv_admin) { $data['is_verify_user']=1; break; } + } } + //用于做导航激活状态 $data['nav_type']=$nav_type; if ($nav_type=='userlist') { @@ -222,6 +245,7 @@ class Index extends CI_Controller } $data['wv_status']=$wv_status; $data['form']=$this->load->view("form/$form",$data,true); + //print_r($data); $this->load->view('n-header', $data); $this->load->view('w-nav'); $this->load->view('w-left'); @@ -313,7 +337,7 @@ class Index extends CI_Controller $namestrings=str_replace(';', ';', $namestrings); $namestrings=str_replace('(', '(', $namestrings); $namestrings=str_replace(')', ');', $namestrings); - $namestrings=str_replace('惠毅', '惠 毅', $namestrings); + //$namestrings=str_replace('惠毅', '惠 毅', $namestrings); $namestrings=str_replace("\n", ";", $namestrings); $namestrings=str_replace("\r", ";", $namestrings); $namestrings_arr=explode(';', $namestrings); @@ -336,9 +360,6 @@ class Index extends CI_Controller } if (isset($atd_sn_arr[0]->ATT_SN) && isset($epy_sn_arr[0]->EPY_ID)) { $jabtime=7; - if ($workdata[0]->OPI_Name=='周玲霞') { - $jabtime=3.5; - } //如果有自定义的考勤时间则使用自定义的数据 $kaoqin_time=$this->input->post('kaoqin_time')?$this->input->post('kaoqin_time'):''; $kaoqin_time=trim($kaoqin_time); @@ -467,6 +488,7 @@ class Index extends CI_Controller return $verify_tolist_array; } + // public function other_verify($wf_sn,$wv_status=0) { //获取当前值班名单 @@ -542,9 +564,9 @@ class Index extends CI_Controller array_multisort($datetemp3, SORT_ASC, $js_uname_list); $data['en_uname_list']=$en_uname_list; - $data['sw_uname_list']=$sw_uname_list; - $data['jd_uname_list']=$jd_uname_list; - $data['js_uname_list']=$js_uname_list; + $data['sw_uname_list']=array();//$sw_uname_list; + $data['jd_uname_list']=array();//$jd_uname_list; + $data['js_uname_list']=array();//$js_uname_list; $data['wf_sn']=$wf_sn; $data['nav_type']='rata_list'; @@ -624,6 +646,7 @@ class Index extends CI_Controller //分页 $page_flag=true; $list=$this->workflow_model->get_work_list($userdata['whu_uid'],$wv_status,false,$page_flag,false); + //print_r($list); $pages['total']=count($list);//数据总条数 $pages['pageSize']= 30;//每页展示数量 $pages['url'] = site_url("apps/workflow/index/unverify/$wv_status/");//页码链接 @@ -638,18 +661,34 @@ class Index extends CI_Controller } $datalist=$this->workflow_model->get_work_list_by_sn($task_id_str); $worklist=array(); + $wf_sn_str='0'; foreach ($datalist as $wlist) { $worklist[$wlist->wf_sn]=$wlist; + $wf_sn_str.=','.$wlist->wf_sn; } + $data['list']=$worklist; - + $flow_data=$this->workflow_model->get_work_flow_data($wf_sn_str); + + $f_datas=array(); + foreach ($flow_data as $k => $f) { + $f_datas[$f->wfd_wf_sn][$f->wfd_key]=$f->wfd_value; + } + $data['f_datas']=$f_datas; + $data['nav_type']='verify'; $data['left_nav']=$wv_status==0?'unverify':'verify'; $data['wv_status']=$wv_status; + //print_r($data); if ($wv_status==1) { $data['nav_type']='verifyed'; } - + // var_dump($data["list"]); + // foreach ($data["list"] as $key => $v) { + // echo $v->wf_status; + // echo $v->isverify; + // echo "
    "; + // } $this->load->view('n-header', $data); $this->load->view('w-nav'); $this->load->view('w-left'); @@ -847,10 +886,11 @@ class Index extends CI_Controller $data['rolelist']=$this->workflow_model->get_department_list(2); //用户列表 $data['userlist']=$this->workflow_model->get_user_list(); + if ($whu_uid!==false) { $data['userinfo']=$this->workflow_model->get_user_list($whu_uid); - $data['userinfo']=$data['userinfo'][0]; - $data['userrole']=array_filter(explode(',', $data['userinfo']->role)); + $data['userinfo']=$data['userinfo'][0]; + $data['userrole']=array_filter(explode(',', $data['userinfo']->role)); } $this->load->view('n-header', $data); $this->load->view('w-nav'); @@ -863,6 +903,7 @@ class Index extends CI_Controller //员工资料更新 public function user_edit() { + $type=$this->input->post('type'); $whu_role=$this->input->post('userrole'); $whu_uname=$this->input->post('whu_uname'); $whu_email=$this->input->post('whu_email'); @@ -870,11 +911,19 @@ class Index extends CI_Controller $department=$this->input->post('department'); $role=!empty($whu_role)?implode(',',$this->input->post('userrole')):NULL; $whu_uid=$this->input->post('whu_uid'); - $result=$this->workflow_model->update_webuser($whu_uname,$whu_email,$whu_ip,$department,$role,$whu_uid); + if($type == 'add'){ + $result = $result=$this->workflow_model->add_webuser($whu_uname,$whu_email,$whu_ip,$department,$role,$whu_uid); + }else if($type == 'delete'){ + $result=$this->workflow_model->delete_webuser($whu_uname,$whu_uid); + + }else if($type == 'update'){ + $result=$this->workflow_model->update_webuser($whu_uname,$whu_email,$whu_ip,$department,$role,$whu_uid); + } + if ($result) { - echo json_encode(array('status'=>'ok','msg'=>'保存成功!')); + echo json_encode(array('status'=>'ok','msg'=>'操作成功!')); }else{ - echo json_encode(array('status'=>'no','msg'=>'保存失败!')); + echo json_encode(array('status'=>'no','msg'=>'操作失败!')); } } @@ -1001,8 +1050,8 @@ class Index extends CI_Controller //发送邮件 $mail_tpl='rota.php'; - $subject='电子商务部'.date('n',$wf_time).'月值班安排'; - $html='各位同事,
    以下是电子商务部'.date('Y',$wf_time).'年'.date('n',$wf_time).'月值班安排,请大家做好提醒,按相关值班规定值班。
    为方便统计加班小时数,请记得到值班记录系统填写值班记录,自行调班的同事请记得到值班记录系统里面更改。
    谢谢!'; + $subject='海纳国旅'.date('n',$wf_time).'月值班安排'; + $html='各位同事,
    以下是海纳国旅'.date('Y',$wf_time).'年'.date('n',$wf_time).'月值班安排,请大家做好提醒,按相关值班规定值班。
    为方便统计加班小时数,请记得到值班记录系统填写值班记录,自行调班的同事请记得到值班记录系统里面更改。
    谢谢!'; $mailbody=$html.'

    '.$this->load->view("mail_tpl/$mail_tpl",$mail_data,true); //发送人信息 @@ -1032,13 +1081,16 @@ class Index extends CI_Controller if ($this->workflow_model->delete_wfd($wf_sn)) { $col_val=''; foreach ($this->input->post() as $wfd_key => $wfd_value) { - $col_val.="('".trim($wfd_key)."','".$wfd_value."',".$wf_sn."),"; + // $col_val.="('".trim($wfd_key)."','".$wfd_value."',".$wf_sn."),"; + + $col_val.="('".trim($wfd_key)."','".chop($wfd_value)."',".$wf_sn."),";//csk 2016-9-22 去掉末尾的换行和空格 } $apply_user=$this->input->post('apply_user'); if (empty($apply_user)) { $col_val.="('apply_user','".$current_user."',".$wf_sn."),"; } $col_val=substr($col_val, 0, -1); + $wfd_sn=$this->workflow_model->add_work_data($col_val); } @@ -1053,6 +1105,7 @@ class Index extends CI_Controller if ($this->session->userdata('verify_referer')) { $verify_referer_url=$this->session->userdata('verify_referer'); } + echo json_encode(array('status'=>'ok_go','msg'=>'更新成功!','url'=>$verify_referer_url)); } @@ -1413,5 +1466,6 @@ class Index extends CI_Controller } $this->load->view('index/print_text', $data); } - + + } diff --git a/webht/third_party/workflow/models/workflow_model.php b/webht/third_party/workflow/models/workflow_model.php index 3da7b4b6..da3c6732 100644 --- a/webht/third_party/workflow/models/workflow_model.php +++ b/webht/third_party/workflow/models/workflow_model.php @@ -100,7 +100,7 @@ class Workflow_model extends CI_Model { } public function get_work_list($wv_admin,$wv_status,$wf_sn=false,$page_flag=false,$wv_actived=-1) - { + {// $map=" AND wt_form!='rota.php' AND (wv_admin=258 or wv_admin='$wv_admin')"; if (!$wv_actived) { $map.=" AND wv_actived!=-1 "; @@ -117,7 +117,7 @@ class Workflow_model extends CI_Model { left join work_type on wf_wt_sn=wt_sn left join OperatorInfo on wf_user=OPI_SN WHERE wv_status=? $map - ORDER BY wf_time desc"; + ORDER BY wf_time desc"; $query = $this->HT->query($sql, array($wv_status)); $result=$query->result(); return $result; @@ -411,6 +411,34 @@ class Workflow_model extends CI_Model { $query = $this->HT->query($sql,array($whu_uname,$whu_email,$whu_ip,$department,$role,$whu_uid)); return $query; } + + public function add_webuser($whu_uname,$whu_email,$whu_ip,$department,$role) + { + $status = 1; + $sql="INSERT INTO webht_user + (whu_uname, + whu_email, + whu_ip, + whu_status, + department, + role) + VALUES + (?,?,?,?,?,?)"; + $query = $this->HT->query($sql,array($whu_uname,$whu_email,$whu_ip,$status,$department,$role)); + return $query; + } + + public function delete_webuser($whu_uname,$whu_uid) + { + $sql="DELETE FROM + webht_user + WHERE + whu_uname=? + and + whu_uid=?"; + $query = $this->HT->query($sql,array($whu_uname,$whu_uid)); + return $query; + } public function delete_wt($wt_sn,$wt_isdelete=1) { @@ -437,5 +465,10 @@ class Workflow_model extends CI_Model { $query=$this->HT->query($sql, array($wv_wf_sn)); return $query; } + + public function delete_test(){ + $sql = "delete from work_flow_data where wfd_key like '%201905%'"; + $query=$this->HT->query($sql); + } } \ No newline at end of file diff --git a/webht/third_party/workflow/views/form/rota.php b/webht/third_party/workflow/views/form/rota.php index 91ae4018..8d36ad27 100644 --- a/webht/third_party/workflow/views/form/rota.php +++ b/webht/third_party/workflow/views/form/rota.php @@ -5,7 +5,7 @@
    CH销售 CT 商务 - 德语 国际 技术 计调 + APP + 目的地 + 亚洲事业部 值班时间 12点-13点 9:30-12:00,13:00-17:00 - 10:00-16:00 + 10:00-16:00 到办公室 VPN 技术远程值班 无团电话值班 + VPN(8:30-23:00) + VPN(8:30-23:00) + VPN(8:30-23:00) - > + > @@ -89,9 +96,6 @@ - - - @@ -104,6 +108,15 @@ + + + + + + + + + diff --git a/webht/third_party/workflow/views/index/rata_list.php b/webht/third_party/workflow/views/index/rata_list.php index f897cfee..37e506a3 100644 --- a/webht/third_party/workflow/views/index/rata_list.php +++ b/webht/third_party/workflow/views/index/rata_list.php @@ -5,7 +5,8 @@ 提交时间 状态 操作 - 其他 + 其他 + session->userdata('admin_chtcdn'); ?> $v) { ?> @@ -23,7 +24,11 @@ 删除 - 不用发邮件记录考勤的员工 + + + 中午值班审核 + + diff --git a/webht/third_party/workflow/views/index/unverify.php b/webht/third_party/workflow/views/index/unverify.php index e37e0edc..98e05a90 100644 --- a/webht/third_party/workflow/views/index/unverify.php +++ b/webht/third_party/workflow/views/index/unverify.php @@ -6,9 +6,14 @@ 状态 操作 - $v) { ?> + $v) { ?> - + + + + + + wt_name.'('.$v->OPI_Name.')'; ?> wf_time); ?> wf_status==0? ($v->isverify!=1?'还没处理':'处理中'):'已审核';echo $status; ?> @@ -20,6 +25,15 @@ + + + + session->userdata('admin_chtcdn'); if (isset($left_nav) && $left_nav=='unverify' && ($userdata['OPI_Name']=='侯敏' || $userdata['OPI_Name']=='王婷' )) { ?> + 批量审核 + 审核不通过 + + + @@ -29,4 +43,52 @@ -
    \ No newline at end of file +
    + + \ No newline at end of file diff --git a/webht/third_party/workflow/views/index/user_manage.php b/webht/third_party/workflow/views/index/user_manage.php index e34bf2e7..4fde522d 100644 --- a/webht/third_party/workflow/views/index/user_manage.php +++ b/webht/third_party/workflow/views/index/user_manage.php @@ -20,7 +20,14 @@
    员工资料编辑 - + +
    +
    +
    @@ -63,16 +70,117 @@
    - - - + + +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + + + +
    +
    +
    + +
    +
    + + + + +
    +
    +
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + + + +
    +
    +
    + +
    +
    + + + + +
    +
    +
    +
    +
    + +
    diff --git a/webht/third_party/workflow/views/index/verify.php b/webht/third_party/workflow/views/index/verify.php index 17024a14..cb3a6ee5 100644 --- a/webht/third_party/workflow/views/index/verify.php +++ b/webht/third_party/workflow/views/index/verify.php @@ -31,9 +31,11 @@
    - + - + diff --git a/webht/third_party/workflow/views/mail_tpl/rota.php b/webht/third_party/workflow/views/mail_tpl/rota.php index 9d92193a..83bbc015 100644 --- a/webht/third_party/workflow/views/mail_tpl/rota.php +++ b/webht/third_party/workflow/views/mail_tpl/rota.php @@ -23,6 +23,7 @@ table th,table td{padding: 5px;font-size: 12px;text-align: center;vertical-align 国际 技术 计调 + APP 值班时间 @@ -33,6 +34,7 @@ table th,table td{padding: 5px;font-size: 12px;text-align: center;vertical-align VPN 技术远程值班 无团电话值班 + VPN(8:30-23:00) @@ -63,6 +66,7 @@ table th,table td{padding: 5px;font-size: 12px;text-align: center;vertical-align

    +

    \ No newline at end of file diff --git a/webht/third_party/workflow/views/w-left.php b/webht/third_party/workflow/views/w-left.php index f54dc2be..e4a3ce23 100644 --- a/webht/third_party/workflow/views/w-left.php +++ b/webht/third_party/workflow/views/w-left.php @@ -8,7 +8,10 @@
  • - session->userdata('admin_chtcdn'); if ($userdata['whu_isadmin']==1) { ?> + session->userdata('admin_chtcdn'); + if ( !empty($userdata['whu_isadmin']) && $userdata['whu_isadmin']==1) { + ?>
  • diff --git a/webht/views/demandform/index.php b/webht/views/demandform/index.php new file mode 100644 index 00000000..2dfb008b --- /dev/null +++ b/webht/views/demandform/index.php @@ -0,0 +1,160 @@ + + + + + + + + We Complete You + + + + + + + + +
    + +
    +
    +
    + + + +
      +
    • ", $form->F_comment); + $form_com = str_replace("\n", "
      ", $form_com); + echo $form_com; + ?> +
    • +
    + + $p) { ?> +

    +
    $q) { ?> +

    + . FD_question ?> + FD_required==1){ ?> + + +

    + + + + + + FD_AnswerType)) > 0) { // 选择题 + $answer_type = intval(trim($q->FD_AnswerType))==1 ? "radio" : "checkbox"; + ?> + answer as $ka => $an) { ?> + + + + + + + +
    + + + + +
    +
    + + + + + + diff --git a/webht/views/demandform/index1.php b/webht/views/demandform/index1.php new file mode 100644 index 00000000..07c122f9 --- /dev/null +++ b/webht/views/demandform/index1.php @@ -0,0 +1,315 @@ + + + + + Easy Planning from now! + + + + + + + + + + + + + + +
    +
    +
    + +
    +

    Easy Planning from now! The only thing you need to do is telling us your preference. Leave the rest to Us!

    +
    + + + +
    + $p) { ?> +

    +

    $q) { ?> +

    FD_question ?>

    + + + + + FD_AnswerType)) === 1) { ?> +
      + answer as $ka => $an) { ?> +
    1. + +
    2. + +
    + + + +

    + +
    + +
    +
    + + + +
    + + + + diff --git a/webht/views/demandform/reply.php b/webht/views/demandform/reply.php new file mode 100644 index 00000000..f47388c5 --- /dev/null +++ b/webht/views/demandform/reply.php @@ -0,0 +1,122 @@ + + + + + + + + customer reply + + + + +
    + +

    未收到回复

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $qn) { ?> + + + + + + + +
    等级关键问题辅助信息
    + + + $qa) { + if (intval($qa[0]->FD_ismain) == 1) { + echo $qa[0]->FD_question; + foreach ($qa as $ka => $answer) { ?> +

    CRD_result) . "." . $answer->CRD_content; ?>

    + +
    + $qa) { + if (intval($qa[0]->FD_ismain) != 1) { ?> + FD_question; ?> + $answer) { ?> +

    CRD_result) . "." . $answer->CRD_content; ?>

    + +
    + + + $qa) { + if (intval($qa[0]->FD_ismain) == 1) { + echo $qa[0]->FD_question; + foreach ($qa as $ka => $answer) { ?> +

    CRD_result) . "." . $answer->CRD_content; ?>

    + +
    + $qa) { + if (intval($qa[0]->FD_ismain) != 1) { ?> + FD_question; ?> + $answer) { ?> +

    CRD_result) . "." . $answer->CRD_content; ?>

    + +
    + + + $qa) { + if (intval($qa[0]->FD_ismain) == 1) { ?> + FD_question; + foreach ($qa as $ka => $answer) { ?> +

    CRD_result) . "." . $answer->CRD_content; ?>

    + + +
    + $qa) { ?> + FD_ismain) != 1) { ?> + FD_question; ?> + $answer) { ?> +

    CRD_content; ?>

    + + +
    + 其他信息 +
    + FD_question; ?> + + $na) { ?> +

    CRD_content; ?>

    + +
    + + +
    + + +