|
|
|
@ -139,35 +139,6 @@ class Information extends CI_Controller
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//移动优先的编辑
|
|
|
|
|
public function edit_mobile($is_id)
|
|
|
|
|
{
|
|
|
|
|
//查询结构信息
|
|
|
|
|
$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['information'] = $this->Information_model->Detail($is_id);
|
|
|
|
|
|
|
|
|
|
$this->load->view('bootstrap3/header', $data);
|
|
|
|
|
$this->load->view('mobile_first/editor');
|
|
|
|
|
$this->load->view('bootstrap3/footer');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function edit($is_id)
|
|
|
|
|
{
|
|
|
|
@ -329,14 +300,10 @@ class Information extends CI_Controller
|
|
|
|
|
|
|
|
|
|
//获取移动优先的模板,如果有的话
|
|
|
|
|
//增加判断站点,每个站点需要读取的模板不一样。 20210311 zp
|
|
|
|
|
if ($this->config->item('site_code')=="ch"){
|
|
|
|
|
if (is_mobile_first()) {
|
|
|
|
|
$mobile_first_template_path = 'mobile_first/' . $this->config->item('site_code');
|
|
|
|
|
if (is_file(APPPATH . 'views/' . $mobile_first_template_path . EXT)) {
|
|
|
|
|
$mobile_template_H1 = $this->call_mobile_template_H1($mobile_first_template_path, $data['information']->is_path, $data['information']->ic_author, $data['information']->ic_title, $data['information']->ic_photo);//H1模板替换
|
|
|
|
|
$data['mobile_first_template'] = $this->load->view($mobile_first_template_path, '', TRUE);
|
|
|
|
|
if (empty(get_meta($data['information']->ic_id, 'meta_product_code'))) {
|
|
|
|
|
$data['mobile_first_template'] = str_replace('<!--@HEAD_1@-->', $mobile_template_H1, $data['mobile_first_template']);
|
|
|
|
|
}
|
|
|
|
|
//主样式表,内联模式
|
|
|
|
|
$main_css_string = compress_css(GET_HTTP('https://proxy-data.chinahighlights.com/css/mobile-first.css'));
|
|
|
|
|
$data['mobile_first_template'] = str_replace('<!--@MAIN-CSS@-->', '<style type="text/css">' . $main_css_string . '</style>', $data['mobile_first_template']);
|
|
|
|
@ -363,75 +330,6 @@ class Information extends CI_Controller
|
|
|
|
|
$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()
|
|
|
|
|
{
|
|
|
|
@ -510,6 +408,12 @@ class Information extends CI_Controller
|
|
|
|
|
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
|
|
|
|
|
$this->make_www_cache('mobile', $information_new);
|
|
|
|
|
$this->make_www_cache('pc', $information_new);
|
|
|
|
|
|
|
|
|
|
} else if (strcasecmp($site_code, "ah") == 0 && !empty($auto_update_cache)) {
|
|
|
|
|
//读取模板生成PC和移动优先文件
|
|
|
|
|
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
|
|
|
|
|
$this->make_www_cache_ah('mobile', $information_new);
|
|
|
|
|
$this->make_www_cache_ah('pc', $information_new);
|
|
|
|
|
} else if (strcasecmp($site_code, "chinatravel") == 0 && !empty($auto_update_cache)) {
|
|
|
|
|
//chinatravel读取模板生成PC和移动优先文件
|
|
|
|
|
$information_new = $this->Information_model->Detail($this->input->post('is_id'));
|
|
|
|
@ -687,8 +591,16 @@ class Information extends CI_Controller
|
|
|
|
|
$template = str_replace('<!--@CANONICAL@-->', $this->config->item('site_url') . $information->ic_url, $template);
|
|
|
|
|
//非产品页面
|
|
|
|
|
if (empty(get_meta($information->ic_id, 'meta_product_code'))) {
|
|
|
|
|
$template_H1 = $this->call_mobile_template_H1($template_path, $information->is_path, $information->ic_author, $information->ic_title, $information->ic_photo);//H1模板替换
|
|
|
|
|
|
|
|
|
|
//H1模板替换
|
|
|
|
|
$data_H1 = array();
|
|
|
|
|
$data_H1['infocategory'] = $this->Information_model->get_detail_by_path($information->is_path, 1);//信息所属分类,获取信息顶级节点内容
|
|
|
|
|
$data_H1['author'] = $this->Operator_model->get_author_nikename($information->ic_author);//获取作者信息
|
|
|
|
|
$data_H1['ic_title'] = $information->ic_title;
|
|
|
|
|
$data_H1['ic_photo'] = $information->ic_photo;
|
|
|
|
|
$template_H1 = $this->load->view($template_path . '-h1', $data_H1, TRUE);
|
|
|
|
|
$template = str_replace('<!--@HEAD_1@-->', $template_H1, $template);
|
|
|
|
|
|
|
|
|
|
//信息推荐
|
|
|
|
|
$template_NEXT = $this->call_mobile_template_NEXT($template_path, $information->is_id);
|
|
|
|
|
$template = str_replace('<!--@ARTICLENEXT@-->', $template_NEXT, $template);
|
|
|
|
@ -760,13 +672,115 @@ class Information extends CI_Controller
|
|
|
|
|
file_put_contents($html_path, $template, LOCK_EX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function make_www_cache_ah($device, $information)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
|
$data['information']=$information;
|
|
|
|
|
switch ($device) {
|
|
|
|
|
case 'mobile':
|
|
|
|
|
//获取移动优先的模板,如果有的话
|
|
|
|
|
$template_path = 'mobile_first/' . $this->config->item('site_code');
|
|
|
|
|
if (is_file(APPPATH . 'views/' . $template_path . EXT)) {
|
|
|
|
|
$template = $this->load->view($template_path, '', TRUE);
|
|
|
|
|
$html_path_ext = '-mobile.htm';
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'pc':
|
|
|
|
|
//获取PC的模板,如果有的话
|
|
|
|
|
$template_path = 'mobile_first/' . $this->config->item('site_code');
|
|
|
|
|
if (is_file(APPPATH . 'views/' . $template_path . '-pc' . EXT)) {
|
|
|
|
|
$template = $this->load->view($template_path . '-pc', '', TRUE);
|
|
|
|
|
$html_path_ext = '-pc.htm';
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//替换模板中的标签
|
|
|
|
|
$template = str_replace('<!--@TITLE@-->', $information->ic_seo_title, $template);
|
|
|
|
|
$template = str_replace('<!--@DESCRIPTION@-->', $information->ic_seo_description, $template);
|
|
|
|
|
$template = str_replace('<!--@KEYWORDS@-->', $information->ic_seo_keywords, $template);
|
|
|
|
|
$template = str_replace('<!--@CANONICAL@-->', $this->config->item('site_url') . $information->ic_url, $template);
|
|
|
|
|
|
|
|
|
|
//顶部全屏大图
|
|
|
|
|
if ($device == 'mobile') {//移动端读取移动大图
|
|
|
|
|
$data['meta_addon_picture'] = get_meta($information->ic_id, 'meta_addon_picture_mobile');
|
|
|
|
|
} else {
|
|
|
|
|
$data['meta_addon_picture'] = get_meta($information->ic_id, 'meta_addon_picture');
|
|
|
|
|
}
|
|
|
|
|
$data['meta_addon_picture_url'] = get_meta($information->ic_id, 'meta_addon_picture_url');
|
|
|
|
|
$template_H1 = $this->load->view($template_path . '-h1', $data, TRUE);
|
|
|
|
|
$template = str_replace('<!--@HEAD_1@-->', $template_H1, $template);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//非产品页面
|
|
|
|
|
/*
|
|
|
|
|
if (empty(get_meta($information->ic_id, 'meta_product_code'))) {
|
|
|
|
|
//信息推荐 暂时不用,未来用广告系统替代
|
|
|
|
|
$template_NEXT = $this->call_mobile_template_NEXT($template_path, $information->is_id);
|
|
|
|
|
$template = str_replace('<!--@ARTICLENEXT@-->', $template_NEXT, $template);
|
|
|
|
|
$addthis_widget = $this->load->view($template_path . '-add-this', false, true);
|
|
|
|
|
$template = str_replace('<!--@ADDTHIS-WIDGET@-->', $addthis_widget, $template);
|
|
|
|
|
} else {
|
|
|
|
|
$template = str_replace('<!--@PRODUCT-JS@-->', '<script src="https://data.chinahighlights.com/js/flatpickr.js"></script>', $template);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//主样式表,内联模式
|
|
|
|
|
$main_css_string = compress_css(GET_HTTP('https://proxy-data.asiahighlights.com/css/mobile-first.css'));
|
|
|
|
|
$template = str_replace('<!--@MAIN-CSS@-->', '<style type="text/css">' . $main_css_string . '</style>', $template);
|
|
|
|
|
//额外样式
|
|
|
|
|
$meta_addon_css = get_meta($information->ic_id, 'meta_addon_css');
|
|
|
|
|
if (!empty($meta_addon_css)) {
|
|
|
|
|
//内联方式
|
|
|
|
|
$meta_addon_css_string = compress_css(GET_HTTP($meta_addon_css));
|
|
|
|
|
$template = str_replace('<!--@ADDON-CSS@-->', '<style type="text/css">' . $meta_addon_css_string . '</style>', $template);
|
|
|
|
|
}
|
|
|
|
|
//额外js
|
|
|
|
|
$meta_addon_js = get_meta($information->ic_id, 'meta_addon_js');
|
|
|
|
|
if (!empty($meta_addon_js)) {
|
|
|
|
|
$template = str_replace('<!--@ADDON-JS@-->', '<script src="' . $meta_addon_js . '"></script>', $template);
|
|
|
|
|
}
|
|
|
|
|
$template = str_replace('<!--@CUSTOM-CONENT@-->', $information->ic_content, $template);
|
|
|
|
|
//Google广告代码
|
|
|
|
|
//if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) {
|
|
|
|
|
$template = str_replace('<!--@Match-Content-GOOGLE@-->', '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-4231674166786366" data-ad-slot="1447610161" data-matched-content-rows-num="2,2" data-matched-content-columns-num="1,3" data-matched-content-ui-type="image_stacked,image_stacked"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $template);
|
|
|
|
|
//}
|
|
|
|
|
if (!empty(get_meta($information->ic_id, 'meta_google_ad_article'))) {
|
|
|
|
|
$in_article_google = $this->load->view($template_path . '-google-ad', false, true);
|
|
|
|
|
$template = str_replace('<!--@IN-ARTICLE-GOOGLE@-->', $in_article_google, $template);
|
|
|
|
|
}
|
|
|
|
|
//社媒分享图片
|
|
|
|
|
if (!empty($information->ic_photo)) {
|
|
|
|
|
$full_ic_photo = $this->config->item('site_image_url') . $information->ic_photo;
|
|
|
|
|
$template = str_replace('<!--@OG:IMAGE@-->', '<meta property="og:image" content="' . $full_ic_photo . '"><meta property="og:image:secure_url" content="' . $full_ic_photo . '"><meta property="og:image:width" content="800"><meta property="og:image:height" content="450">', $template);
|
|
|
|
|
}
|
|
|
|
|
//设置图片尺寸
|
|
|
|
|
$template = $this->html_optimize_lib->set_image_size($template);
|
|
|
|
|
// /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
|
|
|
|
|
$html_path = $this->config->item('cache')[$this->config->item('site_code')]['cache_path'] . $information->ic_url;
|
|
|
|
|
$html_path = str_replace("\\", "/", $html_path);
|
|
|
|
|
if (substr($html_path, -1, 1) == '/') {
|
|
|
|
|
$html_path = $html_path . 'index.htm';
|
|
|
|
|
}
|
|
|
|
|
$html_path .= $html_path_ext;
|
|
|
|
|
create_folder_by_path(dirname($html_path));
|
|
|
|
|
file_put_contents($html_path, $template, LOCK_EX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description: CT用的生成静态文件方法.有些内容的替换,CT这边不一样,需要单独处理 zp
|
|
|
|
|
* @param {type} $device='mobile' or 'pc'
|
|
|
|
|
* @return:
|
|
|
|
|
* @Date Changed:
|
|
|
|
|
*/
|
|
|
|
|
function make_www_cache_ct($device,$information){
|
|
|
|
|
function make_www_cache_ct($device, $information)
|
|
|
|
|
{
|
|
|
|
|
$data = array();
|
|
|
|
|
//先准备数据,CT采用直接赋值视图然后返回视图字符串的模式,不使用一次次替换视图模板内容的模式。
|
|
|
|
|
$data["TITLE"] = $information->ic_seo_title;
|
|
|
|
@ -796,9 +810,6 @@ class Information extends CI_Controller
|
|
|
|
|
$data["CUSTOMCONENT"] = $ic_content;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//非产品页面
|
|
|
|
|
$data["PRODUCTJS"] = "";
|
|
|
|
|
if (empty(get_meta($information->ic_id, 'meta_product_code'))) {
|
|
|
|
@ -924,7 +935,6 @@ class Information extends CI_Controller
|
|
|
|
|
$data["passParam"] = $passParam;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//两种模板
|
|
|
|
|
switch ($device) {
|
|
|
|
|
case 'mobile':
|
|
|
|
@ -962,9 +972,6 @@ class Information extends CI_Controller
|
|
|
|
|
file_put_contents($html_path, $template, LOCK_EX);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //Google广告代码
|
|
|
|
|
// if (!empty(get_meta($information->ic_id, 'meta_google_ad_content'))) {
|
|
|
|
|
// $template = str_replace('<!--@Match-Content-GOOGLE@-->', '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-4231674166786366" data-ad-slot="1447610161"></ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>', $template);
|
|
|
|
@ -981,15 +988,6 @@ class Information extends CI_Controller
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function call_mobile_template_H1($mobile_first_template_path, $is_path, $ic_author, $ic_title, $ic_photo)
|
|
|
|
|
{
|
|
|
|
|
$data['infocategory'] = $this->Information_model->get_detail_by_path($is_path, 1);//信息所属分类,获取信息顶级节点内容
|
|
|
|
|
$data['author'] = $this->Operator_model->get_author_nikename($ic_author);//获取作者信息
|
|
|
|
|
$data['ic_title'] = $ic_title;
|
|
|
|
|
$data['ic_photo'] = $ic_photo;
|
|
|
|
|
return $this->load->view($mobile_first_template_path . '-h1', $data, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//通过内容找到第一张图片
|
|
|
|
|
function set_photo_content($ic_photo, $ic_content)
|
|
|
|
|
{
|
|
|
|
|