|
|
|
<?php
|
|
|
|
|
|
|
|
if (!defined('BASEPATH'))
|
|
|
|
exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Info_amp extends CI_Controller
|
|
|
|
{
|
|
|
|
|
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
//$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
|
|
|
|
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->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, '<style>'.$pc_css.'</style>'.$pc_html);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($icid && $json && $html) {
|
|
|
|
try {
|
|
|
|
//html
|
|
|
|
$meta = $this->InfoMetas_model->get($icid, 'AMP_BODY');
|
|
|
|
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) {
|
|
|
|
$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) {
|
|
|
|
$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) {
|
|
|
|
$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) {
|
|
|
|
$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) {
|
|
|
|
$this->InfoMetas_model->add($icid, 'AMP_STATUS', $status);
|
|
|
|
} else {
|
|
|
|
$this->InfoMetas_model->update($icid, 'AMP_STATUS', $status);
|
|
|
|
}
|
|
|
|
echo json_encode(array(
|
|
|
|
"succ" => true
|
|
|
|
));
|
|
|
|
} catch(Exception $e) {
|
|
|
|
echo json_encode(array(
|
|
|
|
"succ" => false,
|
|
|
|
"message" => "save_amp() -> ".$e->getMessage()
|
|
|
|
));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo json_encode(array(
|
|
|
|
"succ" => false,
|
|
|
|
"message" => "save_amp() -> 参数传递错误。"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function load_amp()
|
|
|
|
{
|
|
|
|
$icid = $this->input->get_post('icid');
|
|
|
|
if (!$icid) {
|
|
|
|
echo json_encode(array(
|
|
|
|
"succ" => false,
|
|
|
|
"message" => "load_amp() -> 参数传递错误。"
|
|
|
|
));
|
|
|
|
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');
|
|
|
|
if ($json) {
|
|
|
|
echo json_encode(array(
|
|
|
|
"succ" => true,
|
|
|
|
"icid" => $icid,
|
|
|
|
"icurl" => $site.$ic->ic_url,
|
|
|
|
"json" => $json,
|
|
|
|
"schema" => $schema,
|
|
|
|
"status" => $status
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
echo json_encode(array(
|
|
|
|
"succ" => false,
|
|
|
|
"message" => "load_amp() -> 无数据返回。"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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->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 ? $ic->ic_content : "<p>".$ic->ic_seo_description."</p>",
|
|
|
|
"title" => $ic->ic_title,
|
|
|
|
"photo" => $use_photo,
|
|
|
|
"url" => $ic->ic_url,
|
|
|
|
"site" => $this->config->item('site_url')
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
echo json_encode(array(
|
|
|
|
"succ" => false,
|
|
|
|
"message" => "load_info() -> 无数据返回。"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo json_encode(array(
|
|
|
|
"succ" => false,
|
|
|
|
"message" => "load_info() -> 参数传递错误。"
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
//转移文件
|
|
|
|
$md5_file = md5($file['name'].$file['size']);
|
|
|
|
//ext
|
|
|
|
$ext = mb_strtolower(strrchr($file["name"],'.'));
|
|
|
|
if ($ext != '.jpg') {
|
|
|
|
echo(json_encode(array(
|
|
|
|
'status' => 'error',
|
|
|
|
'msg' => '只能接收(.jpg)图片。'
|
|
|
|
)));
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
//转移文件
|
|
|
|
$md5_file = md5($file['name'].$file['size']);
|
|
|
|
//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\mammoth ';
|
|
|
|
$test_host = '';
|
|
|
|
}
|
|
|
|
$command = $yarnbin.$docx_path.' --output-dir='.$img_dir;
|
|
|
|
exec($command, $rs);
|
|
|
|
//图片处理
|
|
|
|
$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处理
|
|
|
|
$html = file_get_contents($html_parh);
|
|
|
|
$html = preg_replace('/src="([\d]+).jpeg"/i', 'src="'.$test_host.'/information-view/information/word_source/'.$md5_file.'/$1.jpg"', $html);
|
|
|
|
//删除临时html
|
|
|
|
@unlink($html_parh);
|
|
|
|
if ($html) {
|
|
|
|
echo(json_encode(array(
|
|
|
|
'status' => 'success',
|
|
|
|
'path' => $docx_path,
|
|
|
|
'html' => $html
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo(json_encode(array(
|
|
|
|
'status' => 'error',
|
|
|
|
'msg' => "word文件解析失败。"
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|