|
|
@ -1,12 +1,11 @@
|
|
|
|
<?php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
if (!defined('BASEPATH'))
|
|
|
|
|
|
|
|
exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
|
|
class Amp extends CI_Controller
|
|
|
|
class Amp extends CI_Controller {
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function __construct()
|
|
|
|
function __construct() {
|
|
|
|
{
|
|
|
|
|
|
|
|
parent::__construct();
|
|
|
|
parent::__construct();
|
|
|
|
$this->permission->is_admin();
|
|
|
|
$this->permission->is_admin();
|
|
|
|
//$this->output->enable_profiler(TRUE);
|
|
|
|
//$this->output->enable_profiler(TRUE);
|
|
|
@ -14,16 +13,14 @@ class Amp extends CI_Controller
|
|
|
|
$this->load->model('InfoMetas_model');
|
|
|
|
$this->load->model('InfoMetas_model');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
public function index() {
|
|
|
|
{
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$data = array();
|
|
|
|
$this->load->view('bootstrap3/header', $data);
|
|
|
|
$this->load->view('bootstrap3/header', $data);
|
|
|
|
$this->load->view('amp_editor');
|
|
|
|
$this->load->view('amp_editor');
|
|
|
|
$this->load->view('bootstrap3/footer');
|
|
|
|
$this->load->view('bootstrap3/footer');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function edit($ic_id)
|
|
|
|
public function edit($ic_id) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$data = array();
|
|
|
|
$data['information'] = $this->Information_model->detail_by_ic_id($ic_id);
|
|
|
|
$data['information'] = $this->Information_model->detail_by_ic_id($ic_id);
|
|
|
|
if ($data['information'] == FALSE) {
|
|
|
|
if ($data['information'] == FALSE) {
|
|
|
@ -34,8 +31,7 @@ class Amp extends CI_Controller
|
|
|
|
$this->load->view('bootstrap3/footer');
|
|
|
|
$this->load->view('bootstrap3/footer');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function auto_create($ic_id)
|
|
|
|
public function auto_create($ic_id) {
|
|
|
|
{
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$data = array();
|
|
|
|
$data['information'] = $this->Information_model->detail_by_ic_id($ic_id);
|
|
|
|
$data['information'] = $this->Information_model->detail_by_ic_id($ic_id);
|
|
|
|
if ($data['information'] == FALSE) {
|
|
|
|
if ($data['information'] == FALSE) {
|
|
|
@ -43,7 +39,6 @@ class Amp extends CI_Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//144.76.185.44:8029
|
|
|
|
//144.76.185.44:8029
|
|
|
|
|
|
|
|
|
|
|
|
//根据站点不同,配置不同参数
|
|
|
|
//根据站点不同,配置不同参数
|
|
|
|
$site_code = strtolower($this->config->item('site_code'));
|
|
|
|
$site_code = strtolower($this->config->item('site_code'));
|
|
|
|
switch ($site_code) {
|
|
|
|
switch ($site_code) {
|
|
|
@ -79,8 +74,7 @@ class Amp extends CI_Controller
|
|
|
|
echo json_encode(array('result' => 'no', 'data' => '不知道哪里错了,看代码'));
|
|
|
|
echo json_encode(array('result' => 'no', 'data' => '不知道哪里错了,看代码'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function edit_save()
|
|
|
|
public function edit_save() {
|
|
|
|
{
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
$data = array();
|
|
|
|
$ic_id = $this->input->post('ic_id');
|
|
|
|
$ic_id = $this->input->post('ic_id');
|
|
|
|
$textarea_htmlcode = $this->input->post('textarea_htmlcode');
|
|
|
|
$textarea_htmlcode = $this->input->post('textarea_htmlcode');
|
|
|
@ -94,6 +88,18 @@ class Amp extends CI_Controller
|
|
|
|
//CH的页面没有canonical内容,在这里帮补上
|
|
|
|
//CH的页面没有canonical内容,在这里帮补上
|
|
|
|
$textarea_htmlcode = str_replace('<!--@CANONICAL@-->', $this->config->item('site_url') . $data['information']->ic_url, $textarea_htmlcode);
|
|
|
|
$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');
|
|
|
|
$amp = $this->InfoMetas_model->get($ic_id, 'AMP');
|
|
|
|
if ($amp === false) {
|
|
|
|
if ($amp === false) {
|
|
|
|
$this->InfoMetas_model->add($ic_id, 'AMP', $textarea_htmlcode);
|
|
|
|
$this->InfoMetas_model->add($ic_id, 'AMP', $textarea_htmlcode);
|
|
|
|