diff --git a/application/controllers/infofix.php b/application/controllers/infofix.php index b38bddb7..bce0c7b5 100644 --- a/application/controllers/infofix.php +++ b/application/controllers/infofix.php @@ -12,6 +12,7 @@ class infofix extends CI_Controller $this->load->model('Information_model'); $this->load->model('infoContents_model'); $this->load->model('logs_model'); + $this->load->model('infoMetas_model'); $this->site_code = $this->input->get('site_code') ? $this->input->get('site_code') : $this->config->item('site_code'); } @@ -106,7 +107,7 @@ class infofix extends CI_Controller // json参数 $site = $this->input->get_post('site'); $keys = $this->input->get_post('keys'); - $keyArr = explode('@', $keys); // 250000343@oldurl@newurl@ + $keyArr = explode('@', $keys); // 250000343@oldurl@newurl@250000462 sleep(2); echo ($keys); @@ -124,11 +125,31 @@ class infofix extends CI_Controller $newStr = $keyArr[2]; $is_id = $keyArr[3]; - // 先备份 - //$this->logs_model->backup() - //$ic = $this->infoContents_model->get_ic_contents2($ic_id); - //$ic->info_content = mb_str_replace($oldStr, $newStr, $keyArr); + // ic_content + $ic = $this->infoContents_model->get_ic_contents2($ic_id); + if ($ic) { + $this->logs_model->backup($is_id, $ic->ic_content); // 备份 + $ic->ic_content = mb_str_replace($oldStr, $newStr, $ic->ic_content); + $this->infoContents_model->force_update($ic_id, $ic->ic_content); + $ic->ic_url = mb_str_replace($oldStr, $newStr, $ic->ic_url); + $this->infoContents_model->force_update_url($ic_id, $ic->ic_url); + } + + // amp_json + $meta = $this->infoMetas_model->get($ic_id, 'AMP_JSON'); + if ($meta) { + $this->logs_model->backup_meta($is_id, $meta->im_value, 'AMP_JSON'); // 备份 + $meta->im_value = mb_str_replace($oldStr, $newStr, $meta->im_value); + $this->infoMetas_model->update($is_id, 'AMP_JSON', $meta->im_value); + } + // amp_body_pc + $meta = $this->infoMetas_model->get($ic_id, 'AMP_BODY_PC'); + if ($meta) { + $this->logs_model->backup_meta($is_id, $meta->im_value, 'AMP_BODY_PC'); // 备份 + $meta->im_value = mb_str_replace($oldStr, $newStr, $meta->im_value); + $this->infoMetas_model->update($is_id, 'AMP_BODY_PC', $meta->im_value); + } } } diff --git a/application/models/infoContents_model.php b/application/models/infoContents_model.php index 2dbf35ab..c13ef3d0 100644 --- a/application/models/infoContents_model.php +++ b/application/models/infoContents_model.php @@ -129,7 +129,7 @@ class InfoContents_model extends CI_Model $ic_author, $site_code = '' ) { - if (empty ($site_code)) { + if (empty($site_code)) { $site_code = $this->config->item('site_code'); } $ic_content = str_replace('http:' . $this->config->item('site_image_url'), $this->config->item('site_image_url'), $ic_content); @@ -281,7 +281,7 @@ class InfoContents_model extends CI_Model return $query; } - //删除信息 + //强制更新信息 function force_update($ic_id, $ic_content) { $sql = "UPDATE infoContents SET ic_content = N? WHERE ic_id = ?"; @@ -289,6 +289,14 @@ class InfoContents_model extends CI_Model return $query; } + //强制更新信息 + function force_update_url($ic_id, $ic_url) + { + $sql = "UPDATE infoContents SET ic_url = N? WHERE ic_id = ?"; + $query = $this->HT->query($sql, array($ic_url, $ic_id)); + return $query; + } + //删除信息 function Delete($ic_id) {