From d11a12503288bdfe87cef16e717354306b5c216b Mon Sep 17 00:00:00 2001 From: LMR <59361885@qq.com> Date: Thu, 9 May 2019 13:58:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E9=99=85=E7=AB=99=E7=A7=BB=E9=99=A4FA?= =?UTF-8?q?Q=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/information.php | 135 ++++++++++++++---------- 1 file changed, 77 insertions(+), 58 deletions(-) diff --git a/application/controllers/information.php b/application/controllers/information.php index d3d18193..cac198b1 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -3,9 +3,11 @@ if (!defined('BASEPATH')) exit('No direct script access allowed'); -class Information extends CI_Controller { +class Information extends CI_Controller +{ - function __construct() { + function __construct() + { parent::__construct(); $this->permission->is_admin(); //$this->output->enable_profiler(TRUE); @@ -22,11 +24,13 @@ class Information extends CI_Controller { $this->load->library('Amplib'); //加载AMP处理类 } - public function index() { + public function index() + { echo '信息首页'; } - public function add($is_parent_id) { + 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); @@ -44,7 +48,8 @@ class Information extends CI_Controller { } //移动结构顺序 - public function move() { + public function move() + { //网站会提交一个同级节点id列表字符串,按照这个去排序 $parent_id = $this->input->post('pid'); $idsStr = $this->input->post('ids'); @@ -65,7 +70,8 @@ class Information extends CI_Controller { //把文章移动到任意板块文章下 //is_id 信息结构ID,is_parent_id即将转移到的信息结构id - public function move_by_is_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'); @@ -90,7 +96,8 @@ class Information extends CI_Controller { return TRUE; } - public function delete($is_id) { + public function delete($is_id) + { //查询结构信息 $Structure = $this->InfoStructures_model->Detail($is_id); if ($Structure == FALSE) { @@ -124,7 +131,8 @@ class Information extends CI_Controller { } } - public function edit($is_id) { + public function edit($is_id) + { set_time_limit(30); //$this->output->enable_profiler(true); //查询结构信息 @@ -188,37 +196,37 @@ class Information extends CI_Controller { - if ($Structure->is_sitecode=='ct'){ + if ($Structure->is_sitecode == 'ct') { $data['infoTypeList'] = $this->config->item('InfoType_ct'); - }else { - + } 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'://省份 + case 'p': //省份 $data['infoTypeList'] = $this->config->item('InfoType_province'); break; - case 'n'://国家 + case 'n': //国家 $data['infoTypeList'] = $this->config->item('InfoType_country'); break; - case 't'://特殊区域 + case 't': //特殊区域 $data['infoTypeList'] = $this->config->item('InfoType_special'); break; - case 'e'://大洲 + case 'e': //大洲 $data['infoTypeList'] = array(); break; - case 'z'://公民游 + case 'z': //公民游 $data['infoTypeList'] = $this->config->item('InfoType_citizen'); break; - case 'v'://视频 + case 'v': //视频 $data['infoTypeList'] = $this->config->item('InfoType_video'); break; - case 'f'://节庆 + case 'f': //节庆 $data['infoTypeList'] = $this->config->item('InfoType_festival'); break; - case 'pd'://产品管理 + 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'))) { @@ -297,7 +305,8 @@ class Information extends CI_Controller { exit(); } */ - public function test_proxy($url = false) { + 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/'); @@ -313,7 +322,8 @@ class Information extends CI_Controller { } // 分享数 lzq - public function statistical_sharing() { + public function statistical_sharing() + { //$info_ic = $this->Information_model->get_ic_url_by_code('mbj'); $info_ic = $this->Information_model->get_ic_url(); @@ -355,7 +365,8 @@ class Information extends CI_Controller { $this->load->view('bootstrap3/statistical_sharing'); } - public function edit_save() { + public function edit_save() + { header('Cache-Control: no-cache'); $information = $this->Information_model->Detail($this->input->post('is_id')); if ($information === false) { @@ -387,18 +398,18 @@ class Information extends CI_Controller { //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); + $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; - } - } + 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; + } + } } } } @@ -428,7 +439,7 @@ class Information extends CI_Controller { $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 + } else if (strcasecmp($site_code, "cht") != 0 && strcasecmp($site_code, "gm") != 0) { //非cht站点并且非GM $update_info_log = $this->update_cache($ic_url); } @@ -470,7 +481,8 @@ class Information extends CI_Controller { } //URL不重复检查 - function ic_url_check() { + function ic_url_check() + { if ($this->input->post('ignore_url_check')) { return true; } @@ -484,7 +496,8 @@ class Information extends CI_Controller { } //URL格式检查,不能包含大小写、空格等特殊字符 - function ic_url_format($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; } @@ -493,7 +506,8 @@ class Information extends CI_Controller { //更新静态文件 //不用参数提交的原因是可能url带有特殊字符,CI会报错 - public function update_cache($static_html_url = false, $delete_only = false) { + 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; //原始链接 @@ -518,7 +532,7 @@ class Information extends CI_Controller { 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延迟加载 + } 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; @@ -534,16 +548,16 @@ class Information extends CI_Controller { } break; - case 'vac'://国际站 + case 'vac': //国际站 case 'vc': case 'it': case 'ru': case 'jp': - if ($delete_only) { + $information = $this->Information_model->Detail($url); + if ($delete_only || $information->ic_ht_area_type === 'q') { //只删除操作,在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/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了 @@ -558,9 +572,9 @@ class Information extends CI_Controller { 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) { + //int return direct + $cache_url = $this->input->post('cache_url'); + if ($url && !$cache_url) { /* ignore_user_abort(true); $ch = curl_init(); @@ -577,24 +591,25 @@ class Information extends CI_Controller { curl_close($ch); */ $data['async_update'] = $url; - $data[] = array('name' => 'ok', 'value' => '信息保存成功,请在8秒后检查更新页面。', 'url' => $url); - //如果是外部调用就返回结果,内部就不返回了 - if ($cache_url) { - echo json_encode($data); - } - return $data; - } + $data[] = array('name' => 'ok', 'value' => '信息保存成功,请在8秒后检查更新页面。', 'url' => $url); + //如果是外部调用就返回结果,内部就不返回了 + if ($cache_url) { + echo json_encode($data); + } + return $data; + } } break; - case 'ct'://子站点使用 + case 'ct': //子站点使用 case 'sht': case 'gl': case 'mbj': case 'yz': $url = $this->config->item('site_url') . $url . '@cache@refresh'; break; - default:return false; + default: + return false; break; } @@ -623,7 +638,8 @@ class Information extends CI_Controller { } //更新CDN缓存 - public function update_cdn($static_html_url = false) { + public function update_cdn($static_html_url = false) + { $flag = false; //false:不更新,true:更新 $update_site = array('jp', 'ru'); //需要更新CDN的站点 //需要更新的url @@ -658,7 +674,8 @@ class Information extends CI_Controller { } //获取产品信息,提供给用户选择进行绑定 - function get_products() { + function get_products() + { $HT_productType = $this->input->post('product_type'); $HT_productName = $this->input->post('product_name'); //产品类型 @@ -679,7 +696,8 @@ class Information extends CI_Controller { } //显示备份的内容 - function backup_content($log_id) { + 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); @@ -688,7 +706,8 @@ class Information extends CI_Controller { } //保存自定义配置 - function save_meta() { + 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'); @@ -708,7 +727,8 @@ class Information extends CI_Controller { } //保存自定义配置 - function delete_meta() { + 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) { @@ -721,5 +741,4 @@ class Information extends CI_Controller { echo json_encode($data); return true; } - }