Merge branch 'master' of gitee.com:hainatravel/information-system

hotfix/远程访问多媒体中心
cyc 8 years ago
commit fc50d395a4

@ -11,6 +11,7 @@ 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() {
@ -20,101 +21,15 @@ class Amp extends CI_Controller {
}
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) {
$data = array();
$data['information'] = $this->Information_model->detail_by_ic_id($ic_id);
if ($data['information'] == FALSE) {
echo json_encode(array('result' => 'no', 'data' => '找不到这个页面'));
}
//144.76.185.44:8029
//根据站点不同,配置不同参数
$site_code = strtolower($this->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->config->item('site_url');
$html_source_url = $this->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);
echo GET_HTTP(site_url('/apps/htmlcompressor/index/optimize'), $post_data, 'POST');
return;
}
echo json_encode(array('result' => 'no', 'data' => '不知道哪里错了,看代码'));
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();
}
//CH的页面没有canonical内容在这里帮补上
$textarea_htmlcode = str_replace('<!--@CANONICAL@-->', $this->config->item('site_url') . $data['information']->ic_url, $textarea_htmlcode);
//AMP格式验证
//把AMP网页内容到purifycss处理内置了AMP-Validator
$purifycss_server = 'http://184.172.113.216:33033/';
if ($this->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') {
echo json_encode(array('name' => 'no', 'value' => $validator_result->errors));
return;
}
$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();
}
}

@ -18,13 +18,8 @@ class Information extends CI_Controller {
$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('Amplib'); //加载AMP处理类
$this->load->library('Accesscheck');
$this->accesscheck->check_access();
}
@ -196,10 +191,10 @@ class Information extends CI_Controller {
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'))) {
if (in_array($this->config->item('site_code'), array('gm'))) {
$this->config->set_item('templates', $this->config->item('templates_gm'));
}
//信息区域类型
switch ($data['rootInformation']->ic_ht_area_type) {
@ -280,12 +275,9 @@ class Information extends CI_Controller {
//$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)
{
foreach ($data['all_tags'] as &$it) {
foreach ($data['my_tags'] as $it2) {
if ($it->it_id == $it2->icit_it_id) {
$it = null;
break;
}
@ -396,26 +388,31 @@ class Information extends CI_Controller {
} 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);
//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
//为新闻添加默认发布时间
//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);
@ -426,11 +423,11 @@ class Information extends CI_Controller {
$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)) {
@ -535,8 +532,8 @@ class Information extends CI_Controller {
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));
//先删除再生成,部分页面没有在信息平台中
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;
@ -553,7 +550,7 @@ class Information extends CI_Controller {
$information = $this->Information_model->Detail($url);
$tmp = $url;
//判断是否是更新信息
// 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了
// 产品页面不能生成静态页面,比如/beijing/hotel/只是为了在导航显示一个链接,如果生成了静态页面,网前只会显示一个空白页面了
if (!empty($information->ic_content)) {
$url = $this->config->item('site_url') . '/index.php/information/detail/?static_html_url=' . $url;
} else {
@ -579,10 +576,6 @@ class Information extends CI_Controller {
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));
@ -593,9 +586,9 @@ class Information extends CI_Controller {
if ($this->input->post('updatecdn') == 1) {
$notice = $this->update_cdn();
if ($notice == 200) {
$msg.=$this->lang->line('update_cdn_success');
$msg .= $this->lang->line('update_cdn_success');
} else {
$msg.=$this->lang->line('update_cdn_failed') . '<br>' . $notice;
$msg .= $this->lang->line('update_cdn_failed') . '<br>' . $notice;
}
}
$data[] = array('name' => 'ok', 'value' => $msg, 'url' => $url);
@ -672,40 +665,6 @@ class Information extends CI_Controller {
$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');

@ -0,0 +1,122 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
/*
* AMP的相关方法
*/
class Amplib {
var $CI;
public function __construct() {
$this->CI = & get_instance();
$this->CI->load->model('Information_model');
$this->CI->load->model('InfoMetas_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);
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('<!--@CANONICAL@-->', $this->CI->config->item('site_url') . $data['information']->ic_url, $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')));
}
}

@ -169,7 +169,7 @@ class Information_model extends CI_Model {
$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' and CONVERT(varchar, im_value) = '1'),0) as amp_status ";
$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"

@ -1,317 +1,330 @@
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Index extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->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的内容包含<script>
//含有$表示调用了jquery的函数添加延迟加载defer
if (strpos($link_script, '$') !== FALSE) {
$js_jquery_content .= $link_script->innertext;
} else {
$js_inline_content .= $link_script; //js的内容包含<script>
}
$link_script->outertext = ''; //删除js移动到页底
}
}
$js_scr_content = '';
foreach ($link_js_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 'JS文件下载错误';
log_message('error', "optimize js文件下载错误! " . $item);
return FALSE;
}
$js_scr_content .= $get_http_temp;
}
//echo $js_content;
//把网页内容和css提交到purifycss处理
$purifycss_server = 'http://184.172.113.216:33033/';
if (strpos($websitehost, 'chinarundreisen.com') !== false) {//德语站点使用自己的css处理服务器
$purifycss_server = 'http://158.177.67.52:33033/';
}
$optimize_css = GET_HTTP($purifycss_server, 'html_source=' . urlencode($htmlsource) . '&html_css=' . urlencode($css_content), 'POST');
if (empty($optimize_css)) {
$this->output->set_status_header(500);
echo 'css精简错误';
return FALSE;
}
//把精简的css添加到head前面
$html_object = str_replace('</head>', '<style type="text/css">' . $optimize_css . "</style></head>", $html_object);
//删除多余空格和换行符
$html_object = str_replace(array(" ", "\t", "\n", "\r"), " ", $html_object);
//循环n次把双空格替换为一个空格
for ($i = 0; $i <= 4; $i++) {
$html_object = str_replace(" ", " ", $html_object);
}
//在最后加载原始css文件和js文件
//把css移动到页面底部延迟加载
$lastload_js = '<noscript id="deferred-styles">';
foreach ($link_css_array as $item) {
$lastload_js .= '<link rel="stylesheet" type="text/css" href="' . $item . '"/>';
}
$lastload_js .= '</noscript><script>var loadDeferredStyles=function(){var addStylesNode=document.getElementById("deferred-styles");var replacement=document.createElement("div");replacement.innerHTML=addStylesNode.textContent;document.body.appendChild(replacement);addStylesNode.parentElement.removeChild(addStylesNode)};var raf=requestAnimationFrame||mozRequestAnimationFrame||webkitRequestAnimationFrame||msRequestAnimationFrame;if(raf){raf(function(){window.setTimeout(loadDeferredStyles,0)})}else{window.addEventListener("load",loadDeferredStyles)};</script>';
$js_content = $js_scr_content . $js_jquery_content;
//延迟加载js需要把返回的js代码保存到一个文件中然后替换占位符以便加载js文件
$lastload_js .= '<script async src="##DEFERSCRIPTDEFER##"></script>';
$lastload_js .= $js_inline_content;
$html_object = str_replace('</body>', $lastload_js . '</body>', $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(str_replace('//', 'https://', $url));
}
return urldecode($host . $url);
}
//生成AMP版本 用移动端版本生成
/*
1.加载站点AMP模板模板只有导航、头部、底部
2.删除全部js引用和内链代码
3.删除全部css引用内联css放入<style amp-custom>
4.图片全部替换成amp-img设置宽高设置layout="responsive"
5.去掉所有元素中的style
6.去掉样式表中的!important
7.替换读取源文件title description keywords canonical
8.todo:增加application/ld+json
要求: 图片文件必须带有域名,否则的获取尺寸会出错,如 https://data.asiahighlights.com/pic/abc.jpg
*/
//$htmlsource 移动端版本的HTML对象 $cache_path AMP文件保存路径
function create_amp($htmlsource, $site_code, $websitehost,$debug=false)
{
$html_object = str_get_html($htmlsource);
//读取站点的AMP模板
$amp_template = $this->load->view('amp-template/' . $site_code, null, true);
//生成移动版本,删除多余元素
foreach ($html_object->find('.hidden-xs') as $hidden_item) {
$hidden_item->outertext = '';
}
foreach ($html_object->find('title') as $title) {
$amp_template = str_replace('<!--@TITLE@-->', $title->innertext, $amp_template);
}
foreach ($html_object->find('meta') as $meta) {
if ($meta->name == 'description') {
$amp_template = str_replace('<!--@DESCRIPTION@-->', $meta->content, $amp_template);
}
if ($meta->name == 'keywords') {
$amp_template = str_replace('<!--@KEYWORDS@-->', $meta->content, $amp_template);
}
}
foreach ($html_object->find('script') as $script) {
$script->outertext = '';
}
foreach ($html_object->find('noscript') as $noscript) {
$noscript->outertext = '';
}
foreach ($html_object->find('link') as $link) {
if ($link->rel == 'stylesheet' && !empty($link->href)) {
$link->outertext = '';
}
if ($link->rel == 'canonical' && !empty($link->href)) {
$amp_template = str_replace('<!--@CANONICAL@-->', $link->href, $amp_template);
}
}
$style_content = '';
foreach ($html_object->find('style') as $style) {
$style_content .= $style->innertext;
$style->outertext = '';
}
$style_content = str_replace('!important', '', $style_content);
$style_content = str_replace('@charset "utf-8";', '', $style_content);
$amp_template = str_replace('/*@CUSTOM-CSS@*/', $style_content, $amp_template);
//获取图片尺寸AMP要求必须填写width和height
//格式化图片URL
foreach ($html_object->find('img') as $image) {
if (!empty($image->src)) {
$img_src_host = parse_url($image->src, PHP_URL_HOST);
if (empty($img_src_host)) {
$img_src_host = $websitehost;
}
$image->src = $this->format_url($image->src, $img_src_host);
}
if (!empty($image->originalsrc)) {
$img_src_host = parse_url($image->src, PHP_URL_HOST);
if (empty($img_src_host)) {
$img_src_host = $websitehost;
}
$image->originalsrc = $this->format_url($image->originalsrc, $img_src_host);
}
}
//拼接请求的图片url如 https://data.asiahighlights.com/imagesize.php?photo=/pic/logo-ah.png,/pic/ah-slide-logo.png
$request_size = array();
foreach ($html_object->find('img') as $image) {
$img_src = $image->src;
if (!empty($image->originalsrc)) {
$img_src = $image->originalsrc;
}
if (strpos($img_src, 'facebook.com') !== false || strpos($img_src, 'dmca.com') !== false) {//facebook dmca会添加一个跟踪代码需要删除掉否则获取图片尺寸会报错
$image->outertext = '';
continue;
}
$img_src_urls = parse_url($img_src);
$request_size[$img_src_urls['host']][] = $img_src_urls['path'];
}
if($debug){
print_r($request_size);
}
//请求图片尺寸
$image_sizes = array();
foreach ($request_size as $host => $path) {
$parse_url = "https://{$host}/imagesize.php?photo=" . implode(',', $path);
$size_data = GET_HTTP($parse_url);
if (!empty($size_data)) {
$size_data = json_decode($size_data);
foreach ($size_data as $size_item) {
$size_item->photo = "https://{$host}" . $size_item->photo;
$image_sizes[$size_item->photo] = $size_item;
}
}
}
if($debug){
print_r($image_sizes);
}
//获取图片尺寸 end
foreach ($html_object->find('img') as $image) {
$img_src = $image->src;
if (!empty($image->originalsrc)) {
$img_src = $image->originalsrc;
}
if(empty($image_sizes[$img_src])){
//如果尺寸不存在则跳过
continue;
}
$img_size = $image_sizes[$img_src];
$img_alt = $image->alt;
$img_class = $image->class;
if (!empty($img_size)) {
$image->outertext = " <amp-img layout=\"responsive\" class=\"{$img_class}\" alt=\"{$img_alt}\" src=\"{$img_src}\" width=\"{$img_size->width}\" height=\"{$img_size->height}\"></amp-img>";
}
}
foreach ($html_object->find('#content_main') as $content_main) {
$amp_template = str_replace('<!--@CUSTOM-CONENT@-->', $content_main, $amp_template);
}
//替换掉写在组件上的样式
$amp_template = preg_replace('/style=.+?[\'|"]/i', '', $amp_template);
return $amp_template;
}
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Index extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->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的内容包含<script>
//含有$表示调用了jquery的函数添加延迟加载defer
if (strpos($link_script, '$') !== FALSE) {
$js_jquery_content .= $link_script->innertext;
} else {
$js_inline_content .= $link_script; //js的内容包含<script>
}
$link_script->outertext = ''; //删除js移动到页底
}
}
$js_scr_content = '';
foreach ($link_js_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 'JS文件下载错误';
log_message('error', "optimize js文件下载错误! " . $item);
return FALSE;
}
$js_scr_content .= $get_http_temp;
}
//echo $js_content;
//把网页内容和css提交到purifycss处理
$purifycss_server = 'http://184.172.113.216:33033/';
if (strpos($websitehost, 'chinarundreisen.com') !== false) {//德语站点使用自己的css处理服务器
$purifycss_server = 'http://158.177.67.52:33033/';
}
$optimize_css = GET_HTTP($purifycss_server, 'html_source=' . urlencode($htmlsource) . '&html_css=' . urlencode($css_content), 'POST');
if (empty($optimize_css)) {
$this->output->set_status_header(500);
echo 'css精简错误';
return FALSE;
}
//把精简的css添加到head前面
$html_object = str_replace('</head>', '<style type="text/css">' . $optimize_css . "</style></head>", $html_object);
//删除多余空格和换行符
$html_object = str_replace(array(" ", "\t", "\n", "\r"), " ", $html_object);
//循环n次把双空格替换为一个空格
for ($i = 0; $i <= 4; $i++) {
$html_object = str_replace(" ", " ", $html_object);
}
//在最后加载原始css文件和js文件
//把css移动到页面底部延迟加载
$lastload_js = '<noscript id="deferred-styles">';
foreach ($link_css_array as $item) {
$lastload_js .= '<link rel="stylesheet" type="text/css" href="' . $item . '"/>';
}
$lastload_js .= '</noscript><script>var loadDeferredStyles=function(){var addStylesNode=document.getElementById("deferred-styles");var replacement=document.createElement("div");replacement.innerHTML=addStylesNode.textContent;document.body.appendChild(replacement);addStylesNode.parentElement.removeChild(addStylesNode)};var raf=requestAnimationFrame||mozRequestAnimationFrame||webkitRequestAnimationFrame||msRequestAnimationFrame;if(raf){raf(function(){window.setTimeout(loadDeferredStyles,0)})}else{window.addEventListener("load",loadDeferredStyles)};</script>';
$js_content = $js_scr_content . $js_jquery_content;
//延迟加载js需要把返回的js代码保存到一个文件中然后替换占位符以便加载js文件
$lastload_js .= '<script async src="##DEFERSCRIPTDEFER##"></script>';
$lastload_js .= $js_inline_content;
$html_object = str_replace('</body>', $lastload_js . '</body>', $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(str_replace('//', 'https://', $url));
}
return urldecode($host . $url);
}
//生成AMP版本 用移动端版本生成
/*
1.加载站点AMP模板模板只有导航、头部、底部
2.删除全部js引用和内链代码
3.删除全部css引用内联css放入<style amp-custom>
4.图片全部替换成amp-img设置宽高设置layout="responsive"
5.去掉所有元素中的style
6.去掉样式表中的!important
7.替换读取源文件title description keywords canonical
8.todo:增加application/ld+json
要求: 图片文件必须带有域名,否则的获取尺寸会出错,如 https://data.asiahighlights.com/pic/abc.jpg
*/
//$htmlsource 移动端版本的HTML对象 $cache_path AMP文件保存路径
function create_amp($htmlsource, $site_code, $websitehost,$debug=false)
{
$html_object = str_get_html($htmlsource);
//读取站点的AMP模板
$amp_template = $this->load->view('amp-template/' . $site_code, null, true);
//生成移动版本,删除多余元素
foreach ($html_object->find('.hidden-xs') as $hidden_item) {
$hidden_item->outertext = '';
}
foreach ($html_object->find('title') as $title) {
$amp_template = str_replace('<!--@TITLE@-->', $title->innertext, $amp_template);
}
foreach ($html_object->find('meta') as $meta) {
if ($meta->name == 'description') {
$amp_template = str_replace('<!--@DESCRIPTION@-->', $meta->content, $amp_template);
}
if ($meta->name == 'keywords') {
$amp_template = str_replace('<!--@KEYWORDS@-->', $meta->content, $amp_template);
}
}
foreach ($html_object->find('script') as $script) {
$script->outertext = '';
}
foreach ($html_object->find('noscript') as $noscript) {
$noscript->outertext = '';
}
foreach ($html_object->find('link') as $link) {
if ($link->rel == 'stylesheet' && !empty($link->href)) {
$link->outertext = '';
}
if ($link->rel == 'canonical' && !empty($link->href)) {
$amp_template = str_replace('<!--@CANONICAL@-->', $link->href, $amp_template);
}
}
$style_content = '';
foreach ($html_object->find('style') as $style) {
$style_content .= $style->innertext;
$style->outertext = '';
}
$style_content = str_replace('!important', '', $style_content);
$style_content = str_replace('@charset "utf-8";', '', $style_content);
$amp_template = str_replace('/*@CUSTOM-CSS@*/', $style_content, $amp_template);
//获取图片尺寸AMP要求必须填写width和height
//格式化图片URL
foreach ($html_object->find('img') as $image) {
if (!empty($image->src)) {
$img_src_host = parse_url($image->src, PHP_URL_HOST);
if (empty($img_src_host)) {
$img_src_host = $websitehost;
}
$image->src = $this->format_url($image->src, $img_src_host);
}
if (!empty($image->originalsrc)) {
$img_src_host = parse_url($image->src, PHP_URL_HOST);
if (empty($img_src_host)) {
$img_src_host = $websitehost;
}
$image->originalsrc = $this->format_url($image->originalsrc, $img_src_host);
}
}
//拼接请求的图片url如 https://data.asiahighlights.com/imagesize.php?photo=/pic/logo-ah.png,/pic/ah-slide-logo.png
$request_size = array();
foreach ($html_object->find('img') as $image) {
$img_src = $image->src;
if (!empty($image->originalsrc)) {
$img_src = $image->originalsrc;
}
if (strpos($img_src, 'facebook.com') !== false || strpos($img_src, 'dmca.com') !== false) {//facebook dmca会添加一个跟踪代码需要删除掉否则获取图片尺寸会报错
$image->outertext = '';
continue;
}
$img_src_urls = parse_url($img_src);
$request_size[$img_src_urls['host']][] = $img_src_urls['path'];
}
if($debug){
print_r($request_size);
}
//请求图片尺寸
$image_sizes = array();
foreach ($request_size as $host => $path) {
$parse_url = "https://{$host}/imagesize.php?photo=" . implode(',', $path);
$size_data = GET_HTTP($parse_url);
if (!empty($size_data)) {
$size_data = json_decode($size_data);
foreach ($size_data as $size_item) {
$size_item->photo = "https://{$host}" . $size_item->photo;
$image_sizes[$size_item->photo] = $size_item;
}
}
}
if($debug){
print_r($image_sizes);
}
//获取图片尺寸 end
foreach ($html_object->find('img') as $image) {
$img_src = $image->src;
if (!empty($image->originalsrc)) {
$img_src = $image->originalsrc;
}
if(empty($image_sizes[$img_src])){
//如果尺寸不存在则跳过
continue;
}
$img_size = $image_sizes[$img_src];
$img_alt = $image->alt;
$img_class = $image->class;
if (!empty($img_size)) {
//添加webp图片支持
$img_src_webp='';
if(substr($img_src, -4) == '.jpg'){
$img_src_jpg=" <amp-img fallback layout=\"responsive\" class=\"{$img_class}\" alt=\"{$img_alt}\" src=\"{$img_src}\" width=\"{$img_size->width}\" height=\"{$img_size->height}\"></amp-img>";
$img_src_webp=substr($img_src, 0, strlen($img_src) - 4).'.webp';
$img_src_webp = " <amp-img layout=\"responsive\" class=\"{$img_class}\" alt=\"{$img_alt}\" src=\"{$img_src_webp}\" width=\"{$img_size->width}\" height=\"{$img_size->height}\">{$img_src_jpg}</amp-img>";
}
if(!empty($img_src_webp)){
$image->outertext =$img_src_webp;
}else{
$image->outertext = " <amp-img layout=\"responsive\" class=\"{$img_class}\" alt=\"{$img_alt}\" src=\"{$img_src}\" width=\"{$img_size->width}\" height=\"{$img_size->height}\"></amp-img>";
}
}
}
foreach ($html_object->find('#content_main') as $content_main) {
$amp_template = str_replace('<!--@CUSTOM-CONENT@-->', $content_main, $amp_template);
}
//替换掉写在组件上的样式
$amp_template = preg_replace('/style=.+?[\'|"]/i', '', $amp_template);
return $amp_template;
}
}

@ -34,6 +34,8 @@
<a href="http://tool.oschina.net/jscompress" target="_blank">CSS压缩</a>
|
<a href="http://tool.oschina.net/codeformat/css" target="_blank">CSS格式化</a>
|
<a href="<?php echo site_url('apps/htmlcompressor'); ?>" target="_blank">调试</a>
</div>
<div class="col-sm-3">
<button type="button" class="btn btn-info" onclick="auto_create_amp(this);">
@ -48,22 +50,36 @@
<option value="1" <?php echo get_meta($information->ic_id, 'AMP_STATUS') === '1' ? 'selected' : FALSE; ?> >
发布
</option>
<option value="2" <?php echo get_meta($information->ic_id, 'AMP_STATUS') === '2' ? 'selected' : FALSE; ?> >
发布-手动管理
</option>
</select>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-primary" onclick="submit_amp_editor();">保存</button>
<div class="btn-group">
<button type="button" class="btn btn-primary" onclick="submit_amp_editor();">保存</button>
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li role="separator" class="divider"></li>
<li><a href="javascript(0);" onclick="meta('delete', '<?php echo $information->ic_id; ?>', 'AMP', ''); meta('delete', '<?php echo $information->ic_id; ?>', 'AMP_STATUS', '');">删除</a></li>
</ul>
</div>
<?php if ($this->config->item('site_code') == 'cht') { ?>
<a href="http://192.155.224.195:8080/guide-use.php/amp_loader/test/?info_url=<?php echo $information->ic_url ?>"
<a href="http://192.155.224.195:8080/guide-use.php/amp_loader/test/?info_url=<?php echo $information->ic_url ?>" class="btn btn-primary"
target="_blank">看看</a>
<?php } ?>
</div>
<div class="col-sm-4">
<button type="button" class="btn btn-default"
onclick="meta('delete', '<?php echo $information->ic_id; ?>', 'AMP', ''); meta('delete', '<?php echo $information->ic_id; ?>', 'AMP_STATUS', '');">
删除
</button>
<button type="button" class="btn btn-primary" onclick="show_cache_refresh_modal('<?php echo $information->ic_url ?>');">更新静态页面</button>
</div>
</div>
</form>
@ -149,6 +165,8 @@
});
}
</script>

@ -350,32 +350,6 @@
return true;
}
//添加绑定景点
function add_landscape(area_id, lsi_sn) {
var urlReQuery = "<?php echo site_url('information/add_landscape/'); ?>";
$.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 = '<?php echo $this->config->item('site_url') ?>';
@ -1000,7 +974,7 @@
<div class="clearfix"></div>
<?php if (is_series_site()) { ?>
<label class="span12">系列站会自动更新静态页面</label>
<label class="span12">自动更新静态页面</label>
<?php } else { ?>
<label class="checkbox inline span12">
<input type="checkbox" name="auto_update_cache_checkbox" id="auto_update_cache_checkbox" onclick="get_update_cache_url();" value="<?php echo $information->ic_url; ?>" />静态更新
@ -1059,22 +1033,3 @@
</div>
<!-- Modal -->
<div id="myModal" class="modal hide fade" style="width:90%;left:25%;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div id="myModalLabel" style="line-height:30px;">
<h3 class="span5 pull-left">页面访问量明细表</h3>
<form style="margin-bottom:0px;" id="get-analytic-form" method="post" action="<?php echo site_url('keyworlds/get_analytics_by_date'); ?>">
<input class="span2 pull-left" style="margin-bottom:0;" size="16" id="startdate" name="startdate" type="text" value="开始时间">
<input class="span2 pull-left" style="margin-bottom:0;" size="16" id="enddate" name="enddate" type="text" placeholder="结束时间">
<input type="hidden" name="pagepath" value="<?php echo $information->ic_url; ?>">
<button type="button" class="btn" onClick="get_analytics_ajax('get-analytic-form', 'analytics-content', '0');">查询</button>
</form>
</div>
</div>
<div class="modal-body" id="analytics-content">
</div>
</div>

@ -15,7 +15,7 @@
<div class="modal-content" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 style="margin:0;">静态化更新-系列站专用</h3>
<h3 style="margin:0;">静态化更新</h3>
</div>
<div class="modal-body">
<label>需要更新的页面</label>

@ -448,20 +448,11 @@
change_seo_count('ic_seo_title');
change_seo_count('ic_seo_description');
//ajax获取获取google分析数据的日期设置
$("#startdate,#enddate").datepicker({
showButtonPanel: true
});
$("#total-analytics>a").trigger("click");
init_recommend_popover("#meta_recommend_info", ".meta_recommend_info_box");
init_recommend_popover("#meta_related_info", ".meta_related_info_box");
init_recommend_popover("#meta_bread_info", ".meta_bread_info_box");
//自动读取google网页性能评分
setTimeout(function () {
mobile_friendly(), 1000
});
});
var editor;
@ -563,9 +554,13 @@
<?php if (is_series_site()) { ?>
<label title="AMP页面编辑"><a href="<?php echo($amp_build_url); ?>" target="_blank">AMP构建工具</a></label> |
<?php } ?>
<?php if (get_meta($information->ic_id, 'AMP_STATUS') === '1') { ?>
<?php if ($information->amp_status === '1') { ?>
<label title="AMP页面编辑"><a href="<?php echo site_url('amp/edit/' . $information->ic_id); ?>" target="_blank"><i class="glyphicon glyphicon-flash"></i></a></label>
<?php } else { ?>
<?php } ?>
<?php if ($information->amp_status === '2') { ?>
<label title="AMP页面编辑"><a href="<?php echo site_url('amp/edit/' . $information->ic_id); ?>" target="_blank"><i class="glyphicon glyphicon-hand-up"></i></a></label>
<?php } ?>
<?php if ($information->amp_status === '0') { ?>
<label title="创建AMP页面"><a href="<?php echo site_url('amp/edit/' . $information->ic_id); ?>" target="_blank"><i class="glyphicon glyphicon-plus"></i></a></label>
<?php } ?>
</div>
@ -1259,22 +1254,19 @@
<input type="checkbox" name="ignore_url_check" id="ignore_url_check" />忽略URL重复
</label>
<div class="clearfix"></div>
<?php if (is_series_site() || ($this->config->item('site_code') == 'ah')) { ?>
<label class="col-xs-24">本站会自动更新静态页面</label>
<?php } else { ?>
<?php if ($this->config->item('site_code') == 'cht') { ?>
<label class="checkbox col-xs-24" style="font-weight: normal;margin-top:0;padding-left: 21px;">
<input type="checkbox" name="auto_update_cache_checkbox" id="auto_update_cache_checkbox" onclick="get_update_cache_url();" value="<?php echo $information->ic_url; ?>" />静态更新
</label>
<?php } ?>
<?php } ?>
<?php if (in_array($this->config->item('site_code'),array('cht','ah','gn'))) { ?>
<label class="checkbox col-xs-24" style="font-weight: normal;margin-top:0;padding-left: 21px;">
<input type="checkbox" name="auto_update_amp" id="auto_update_amp" <?php if($information->amp_status==='2'){echo 'disabled';} ?> value="true" />AMP更新 <?php if($information->amp_status==='2'){echo '<i class="glyphicon glyphicon-hand-up" title="手动管理,不会自动更新"></i>'; } ?>
</label>
<?php } ?>
<div class="clearfix"></div>
<p class="col-xs-24 nopadding">
<button type="button" id="btn-mobile-friendly" class="btn btn-sm" onclick="$('#btn-mobile-friendly').button('loading');
$('#mobile_friendly_status').html('');
mobile_friendly(true);">网页性能检测: </button>
<span id="mobile_friendly_status"></span>
<!-- <a href="javascript:void();" class="btn btn-sm" id="goto_validator_button" target="_blank" onclick="goto_validator();" >HTML规范验证</a> -->
</p>
<div class="btn-group col-xs-24 nopadding pull-right <?php
if ($is_writeable == 0) {

@ -57,7 +57,11 @@
function create_amp_data(index) {
if ($('#cache_url' + index).length > 0) {
if ($('#cache' + index).html() !== '\u0041\u004d\u0050\u66f4\u65b0\u6210\u529f\u0021') {
batch_update_amp(index);
if ($('#cache' + index).html() == '手动管理,不会自动更新') { //手动更新的项目跳过
create_amp_data(++index);
} else {
batch_update_amp(index);
}
}
}
}
@ -91,9 +95,12 @@
?>
<tr>
<td><a href="<?php echo site_url('amp/edit/'.$info->ic_id); ?>" target="_blank"><?php echo $i; ?></a></td>
<td><?php if($info->amp_status==='1'){echo '<i class="glyphicon glyphicon-flash"></i>'; } ?></td>
<td>
<?php if($info->amp_status==='1'){echo '<i class="glyphicon glyphicon-flash"></i>'; } ?>
<?php if($info->amp_status==='2'){echo '<i class="glyphicon glyphicon-hand-up" title="手动管理,不会自动更新"></i>'; } ?>
</td>
<td id="cache_url<?php echo $i; ?>" name="cache_url<?php echo $i; ?>" class="cache_url"><a href="<?php echo site_url('information/edit/'.$info->is_id) ?>" target="_blank"><?php echo $info->ic_url; ?></a></td>
<td id="cache<?php echo $i; ?>" name="cache<?php echo $i; ?>"><i class="icon-refresh"></i></td>
<td id="cache<?php echo $i; ?>" name="cache<?php echo $i; ?>"><?php if($info->amp_status==='2'){echo '手动管理,不会自动更新'; } ?></td>
<input type="hidden" id="cache_ic_id_<?php echo $i; ?>" value="<?php echo $info->ic_id; ?>" />
</tr>
<?php
@ -105,7 +112,7 @@
</div>
<div class="col-sm-4">
<a href="javascript:void(0);" class="btn btn-danger" onclick="batch_update_amp(1);">开始更新</a>
<a href="javascript:void(0);" class="btn btn-danger" onclick="create_amp_data(1);">开始更新</a>
</div>

@ -303,7 +303,7 @@ function successfun(responseText, statusText, xhr, form) {
$.modaldialog.success(responseText[key].value)
} else {
if (responseText[key].name == "ok_go") {
$.modaldialog.success('提交成功,正在跳转到下个页面...');
$.modaldialog.success('提交成功,正在跳转到下个页面...');
setTimeout(function() {
window.location.href = responseText[key].value
},
@ -528,6 +528,12 @@ if (json.result == 'ok'){
});
}
//弹出静态化更新窗口,并自动点击更新
function show_cache_refresh_modal(url){
$('#static_html_url').val(url);
updateCache($('#static_html_url').val(), 'cache_refresh_modal_msg');
$('#cache_refresh_modal').modal('show');
}
$(document).ready(function() {

Loading…
Cancel
Save