diff --git a/application/controllers/info_amp.php b/application/controllers/info_amp.php index 4e77ad13..5718c589 100644 --- a/application/controllers/info_amp.php +++ b/application/controllers/info_amp.php @@ -19,13 +19,13 @@ class Info_amp extends CI_Controller public function save_amp() { - $icid = $this->input->post('icid'); - $json = $this->input->post('json'); - $html = $this->input->post('html'); - $css = $this->input->post('css'); - $schema = $this->input->post('schema'); - $script = $this->input->post('script'); - $status = $this->input->post('status'); + $icid = $this->input->get_post('icid'); + $json = $this->input->get_post('json'); + $html = $this->input->get_post('html'); + $css = $this->input->get_post('css'); + $schema = $this->input->get_post('schema'); + $script = $this->input->get_post('script'); + $status = $this->input->get_post('status'); if ($icid && $json && $html) { try { //html @@ -89,7 +89,7 @@ class Info_amp extends CI_Controller public function load_amp() { - $icid = $this->input->post('icid'); + $icid = $this->input->get_post('icid'); if (!$icid) { echo json_encode(array( "succ" => false, @@ -97,6 +97,42 @@ class Info_amp extends CI_Controller )); 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'); @@ -104,6 +140,7 @@ class Info_amp extends CI_Controller echo json_encode(array( "succ" => true, "icid" => $icid, + "icurl" => $site.$ic->ic_url, "json" => $json, "schema" => $schema, "status" => $status @@ -116,9 +153,56 @@ class Info_amp extends CI_Controller } } + 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 load_info() { - $icid = $this->input->post('icid'); + $icid = $this->input->get_post('icid'); if ($icid) { $ic = $this->InfoContents_model->get_ic_contents2($icid); if ($ic) { @@ -143,6 +227,4 @@ class Info_amp extends CI_Controller )); } } - } - diff --git a/application/models/infoContents_model.php b/application/models/infoContents_model.php index aa37343e..25667ef8 100644 --- a/application/models/infoContents_model.php +++ b/application/models/infoContents_model.php @@ -126,7 +126,7 @@ class InfoContents_model extends CI_Model public function get_ic_contents2($ic_id) { - $sql="SELECT top 1 ic_id, ic_content, ic_title, ic_url, ic_photo from infoContents where ic_id=?"; + $sql="SELECT top 1 ic_id, ic_content, ic_title, ic_url, ic_photo, ic_sitecode from infoContents where ic_id=?"; $query=$this->HT->query($sql,array($ic_id)); if ($query->result()) { diff --git a/application/models/infoMetas_model.php b/application/models/infoMetas_model.php index 1010b214..4dfd3dc0 100644 --- a/application/models/infoMetas_model.php +++ b/application/models/infoMetas_model.php @@ -34,6 +34,26 @@ class InfoMetas_model extends CI_Model { return $query->result(); } + public function list_amp($site_code) { + $sql = " + SELECT im.im_id + ,im.im_ic_id + ,c.ic_url + FROM infoMetas im + inner join infoContents c + on c.ic_id = im.im_ic_id + left join infoMetas im2 + on im2.im_ic_id = im.im_ic_id and im2.im_key = 'AMP_STATUS' + left join infoMetas im3 + on im3.im_ic_id = im.im_ic_id and im2.im_key = 'AMP_SCHEMA' + WHERE im.im_key = 'AMP_JSON' + and c.ic_sitecode = ? + and CONVERT(varchar, im2.im_value) = '1' + "; + $query = $this->HT->query($sql, array($site_code)); + return $query->result(); + } + function get($im_ic_id, $im_key) { $sql = "SELECT im.im_value \n" . "FROM infoMetas im \n"