diff --git a/application/controllers/cache.php b/application/controllers/cache.php index 8a1b6a78..aeaf464f 100644 --- a/application/controllers/cache.php +++ b/application/controllers/cache.php @@ -1,202 +1,195 @@ input->get('site_code')) { - $this->permission->is_admin(); - } - $this->load->model('Area_model'); - $this->load->model('InfoStructures_model'); - $this->load->model('Information_model'); - $this->site_code = $this->input->get('site_code') ? $this->input->get('site_code') : $this->config->item('site_code'); - } +if (! defined('BASEPATH')) { + exit('No direct script access allowed'); +} - /** - * - * 公有函数:扫描已有缓存文件并更新。 - * - * 必要参数: - * @param String $site_code - * - */ - public function update() - { - $returnType = $this->input->get('type'); - //设置缓存文件文件夹 - $cache_config = $this->config->item('cache'); - $current_cache_config = $cache_config[$this->site_code]; - $this->dir = $current_cache_config['cache_path']; - - //设置当前站点 - $this->current_domain = $current_cache_config['site_url']; //$this->config->item('site_url'); - //echo $this->config->item('site_url'); - //设置缓存更新接口及POST参数 - $this->cache_api = $current_cache_config['cache_api']; - $this->post_para = $current_cache_config['cache_api_para']; - //遍历缓存文件夹 - $this->tree($this->dir, $this->file, $this->path, $this->file_time); - //print_r($this->file); - //print_r($this->path); - //print_r($this->file_time); - //die(); - //按目录筛选结果 - $this->filter($this->file, $this->path); - - //整理需要传递到视图的数据 - $data['file'] = $this->file; - $data['path'] = $this->path; - $data['file_time'] = $this->file_time; - $data['cache_api'] = $this->cache_api; - $data['post_para'] = $this->post_para; - - if ($returnType === 'json') { - //print_r($cache_config[$this->site_code]); - //echo('json'); - //print_r($data['file']); - echo (json_encode($data['file'])); - } else { - //视图 - $this->load->view('cache/update', $data); - } +class Cache extends CI_Controller { + //缓存文件绝对路径 + private $dir = ''; + //存放缓存文件的数组 + private $file = []; + //存放缓存文件夹的数组 + private $path = []; + //缓存更新接口 + private $cache_api = ''; + //缓存更新参数 + private $post_para = ''; + //当前站点域名 + private $current_domain = ''; + //文件更新日期 + private $file_time = []; + + function __construct() { + parent::__construct(); + if (! $this->input->get('site_code')) { + $this->permission->is_admin(); } - - /** - * - * 公有函数:扫描已有缓存文件并更新。 - * - * 必要参数: - * @param String $site_code - * - */ - public function sitemap() - { - header("Content-type:text/xml"); - //设置缓存文件文件夹 - $cache_config = $this->config->item('cache'); - $current_cache_config = $cache_config[$this->site_code]; - $this->dir = $current_cache_config['cache_path']; - - //设置当前站点 - $this->current_domain = $this->config->item('site_url'); - //设置缓存更新接口及POST参数 - $this->cache_api = $current_cache_config['cache_api']; - $this->post_para = $current_cache_config['cache_api_para']; - //遍历缓存文件夹 - $this->tree($this->dir, $this->file, $this->path, $this->file_time); - //按目录筛选结果 - $this->filter($this->file, $this->path); - - //整理需要传递到视图的数据 - $data['file'] = $this->file; - $data['path'] = $this->path; - $data['file_time'] = $this->file_time; - $data['cache_api'] = $this->cache_api; - $data['post_para'] = $this->post_para; - - //排序file数组 - sort($data['file']); - - //生成sitemap - $dom = new DomDocument('1.0', 'utf-8'); - $urlset = $dom->createElement('urlset'); - $urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); - $dom->appendchild($urlset); - foreach ($data['file'] as $f) { - $url = $dom->createElement('url'); - $loc = $dom->createElement('loc'); - $text = $dom->createTextNode($f); - $loc->appendchild($text); - $url->appendchild($loc); - $urlset->appendchild($url); - } - - echo ($dom->saveXML()); + $this->load->model('Area_model'); + $this->load->model('InfoStructures_model'); + $this->load->model('Information_model'); + $this->site_code = $this->input->get('site_code') ? $this->input->get('site_code') : $this->config->item('site_code'); + } + + /** + * + * 公有函数:扫描已有缓存文件并更新。 + * + * 必要参数: + * @param String $site_code + * + */ + public function update() { + $returnType = $this->input->get('type'); + //设置缓存文件文件夹 + $cache_config = $this->config->item('cache'); + $current_cache_config = $cache_config[$this->site_code]; + $this->dir = $current_cache_config['cache_path']; + + //设置当前站点 + $this->current_domain = $current_cache_config['site_url']; //$this->config->item('site_url'); + //echo $this->config->item('site_url'); + //设置缓存更新接口及POST参数 + $this->cache_api = $current_cache_config['cache_api']; + $this->post_para = $current_cache_config['cache_api_para']; + //遍历缓存文件夹 + $this->tree($this->dir, $this->file, $this->path, $this->file_time); + //print_r($this->file); + //print_r($this->path); + //print_r($this->file_time); + //die(); + //按目录筛选结果 + $this->filter($this->file, $this->path); + + //整理需要传递到视图的数据 + $data['file'] = $this->file; + $data['path'] = $this->path; + $data['file_time'] = $this->file_time; + $data['cache_api'] = $this->cache_api; + $data['post_para'] = $this->post_para; + + if ($returnType === 'json') { + //print_r($cache_config[$this->site_code]); + //echo('json'); + //print_r($data['file']); + echo(json_encode($data['file'])); + } else { + //视图 + $this->load->view('cache/update', $data); } - - - /** - * - * 私有函数:递归遍历缓存文件夹,将目录存放到$path,文件存放到$file。 - * - * 必要参数: - * @param String $dir - 需要遍历的目录 - * @param Array $file - 存放文件结果的数组引用 - * @param Array $path - 存放路径结果的数组引用 - * @param Array $file_time - 存放文件更新日期的数组引用 - * - */ - private function tree($dir, &$file, &$path, &$file_time) - { - $mydir = dir($dir); - while ($f = $mydir->read()) { - if (is_dir("$dir/$f") && $f != "." && $f != ".." && (strpos($dir, '/cn/') === false) && (strpos($dir, '/amp/') === false) && (strpos($dir, '/js/') === false)) { - $path[] = "$dir/$f"; - $this->tree("$dir/$f", $file, $path, $file_time); - } else { - if ($f != '.' && $f != '..' && (strpos($f, '/cn/') === false) && (strpos($f, '/amp/') === false) && (strpos($f, '.pdf') === false) && (strpos($f, '.mobile.htm') === false) && (strpos($f, '/js/') === false) && (strpos($f, '.amp') === false)) { - $file_temp = str_replace('/index.htm###', '', $f . '###'); - $file_temp = str_replace('###', '', $file_temp); - $path_temp = str_replace($this->dir, '', $dir); - $url_temp = $this->current_domain . $path_temp . '/' . $file_temp; - $url_temp = str_replace('/index.htm', '/', $url_temp); - $file_time[$url_temp] = date("F d Y H:i:s", filemtime("$dir/$f")); - - $encode = mb_detect_encoding($url_temp, array('ASCII', 'GBK', 'ISO-8859-1', 'UTF-8')); - $_url_temp = mb_convert_encoding($url_temp, 'UTF8', $encode); - - $file[] = $_url_temp; - } - } - } - $mydir->close(); + } + + /** + * + * 公有函数:扫描已有缓存文件并更新。 + * + * 必要参数: + * @param String $site_code + * + */ + public function sitemap() { + header("Content-type:text/xml"); + //设置缓存文件文件夹 + $cache_config = $this->config->item('cache'); + $current_cache_config = $cache_config[$this->site_code]; + $this->dir = $current_cache_config['cache_path']; + + //设置当前站点 + $this->current_domain = $this->config->item('site_url'); + //设置缓存更新接口及POST参数 + $this->cache_api = $current_cache_config['cache_api']; + $this->post_para = $current_cache_config['cache_api_para']; + //遍历缓存文件夹 + $this->tree($this->dir, $this->file, $this->path, $this->file_time); + //按目录筛选结果 + $this->filter($this->file, $this->path); + + //整理需要传递到视图的数据 + $data['file'] = $this->file; + $data['path'] = $this->path; + $data['file_time'] = $this->file_time; + $data['cache_api'] = $this->cache_api; + $data['post_para'] = $this->post_para; + + //排序file数组 + sort($data['file']); + + //生成sitemap + $dom = new DomDocument('1.0', 'utf-8'); + $urlset = $dom->createElement('urlset'); + $urlset->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); + $dom->appendchild($urlset); + foreach ($data['file'] as $f) { + $url = $dom->createElement('url'); + $loc = $dom->createElement('loc'); + $text = $dom->createTextNode($f); + $loc->appendchild($text); + $url->appendchild($loc); + $urlset->appendchild($url); } - - /** - * - * 私有函数:筛选目录和文件。 - * - * 必要参数: - * @param Array $file - 存放文件结果的数组引用 - * @param Array $path - 存放路径结果的数组引用 - * - * 可选参数:POST参数 - $_POST['p'] - * - */ - private function filter(&$file, &$path) - { - if (isset($_POST['p']) && !empty($_POST['p'])) { - //删选文件 - foreach ($file as &$f) { - (stripos($f, $_POST['p']) !== false) or $f = false; - } - $file = array_filter($file); - //删选目录 - foreach ($path as &$p) { - (stripos($p, $_POST['p']) !== false) or $p = false; - } - $path = array_filter($path); + echo($dom->saveXML()); + } + + /** + * + * 私有函数:递归遍历缓存文件夹,将目录存放到$path,文件存放到$file。 + * + * 必要参数: + * @param String $dir - 需要遍历的目录 + * @param Array $file - 存放文件结果的数组引用 + * @param Array $path - 存放路径结果的数组引用 + * @param Array $file_time - 存放文件更新日期的数组引用 + * + */ + private function tree($dir, &$file, &$path, &$file_time) { + $mydir = dir($dir); + while ($f = $mydir->read()) { + if (is_dir("$dir/$f") && $f != "." && $f != ".." && (strpos($dir, '/cn/') === false) && (strpos($dir, '/amp/') === false) && (strpos($dir, '/js/') === false) && (strpos($dir, 'stfolder') === false)) { + $path[] = "$dir/$f"; + $this->tree("$dir/$f", $file, $path, $file_time); + } else { + if ($f != '.' && $f != '..' && (strpos($f, 'stfolder') === false) && (strpos($f, '/cn/') === false) && (strpos($f, '/amp/') === false) && (strpos($f, '.pdf') === false) && (strpos($f, '.mobile.htm') === false) && (strpos($f, '.txt') === false) && (strpos($f, '/js/') === false) && (strpos($f, '.amp') === false) && (strpos($f, 'stignore') === false)) { + $file_temp = str_replace('/index.htm###', '', $f . '###'); + $file_temp = str_replace('###', '', $file_temp); + $path_temp = str_replace($this->dir, '', $dir); + $url_temp = $this->current_domain . $path_temp . '/' . $file_temp; + $url_temp = str_replace('/index.htm', '/', $url_temp); + $file_time[$url_temp] = date("F d Y H:i:s", filemtime("$dir/$f")); + + $encode = mb_detect_encoding($url_temp, ['ASCII', 'GBK', 'ISO-8859-1', 'UTF-8']); + $_url_temp = mb_convert_encoding($url_temp, 'UTF8', $encode); + + $file[] = $_url_temp; } + } + } + $mydir->close(); + } + + /** + * + * 私有函数:筛选目录和文件。 + * + * 必要参数: + * @param Array $file - 存放文件结果的数组引用 + * @param Array $path - 存放路径结果的数组引用 + * + * 可选参数:POST参数 - $_POST['p'] + * + */ + private function filter(&$file, &$path) { + if (isset($_POST['p']) && ! empty($_POST['p'])) { + //删选文件 + foreach ($file as &$f) { + (stripos($f, $_POST['p']) !== false) or $f = false; + } + $file = array_filter($file); + //删选目录 + foreach ($path as &$p) { + (stripos($p, $_POST['p']) !== false) or $p = false; + } + $path = array_filter($path); } + } } //end of Cache diff --git a/application/controllers/infofix.php b/application/controllers/infofix.php index ff254a4a..4e0e59e1 100644 --- a/application/controllers/infofix.php +++ b/application/controllers/infofix.php @@ -30,9 +30,9 @@ class infofix extends CI_Controller { // 容错 if ( - empty($site) || - empty($keys) || - mb_stripos($keys, '/') === false + empty($site) + || empty($keys) + // || mb_stripos($keys, '/') === false ) { echo json_encode([]); return false; @@ -101,7 +101,7 @@ class infofix extends CI_Controller { // } // } - if ($sub_url != '' || count($sub_content) != 0 || count($sub_content2) != 0 || count($sub_content3) != 0) { + if ($sub_url != '' || $sub_ic_photo != '' || count($sub_content) != 0 || count($sub_content2) != 0 || count($sub_content3) != 0) { array_push( $key_with_content, [ @@ -140,7 +140,7 @@ class infofix extends CI_Controller { if ( empty($site) || count($keyArr) != 4 || - mb_stripos($keys, '/') === false || + // mb_stripos($keys, '/') === false || mb_stripos($keys, 'undefined') !== false || mb_stripos($keys, 'null') !== false || mb_stripos($keys, '@@') !== false || @@ -158,39 +158,41 @@ class infofix extends CI_Controller { // 容错2 if ( - empty($ic_id) || - empty($is_id) || - empty($newStr) || - empty($oldStr) || - mb_stripos($newStr, '/') === false || - mb_stripos($oldStr, '/') === false + empty($ic_id) + || empty($is_id) + || empty($newStr) + || empty($oldStr) + // || mb_stripos($newStr, '/') === false + // || mb_stripos($oldStr, '/') === false ) { echo json_encode(['err' => '容错2']); return false; } - // ic_content + // ic_info $ic = $this->infoContents_model->get_ic_contents2($ic_id); if (! empty($ic)) { $ic->ic_content = str_ireplace($oldStr, $newStr, $ic->ic_content); $this->infoContents_model->force_update($ic_id, $ic->ic_content); $ic->ic_url = str_ireplace($oldStr, $newStr, $ic->ic_url); $this->infoContents_model->force_update_url($ic_id, $ic->ic_url); + $ic->ic_photo = str_ireplace($oldStr, $newStr, $ic->ic_photo); + $this->infoContents_model->force_update_ic_photo($ic_id, $ic->ic_photo); } // amp_json - $meta = $this->infoMetas_model->get($ic_id, 'AMP_JSON'); - if (! empty($meta)) { - $meta = str_ireplace($oldStr, $newStr, $meta); - $this->infoMetas_model->update($ic_id, 'AMP_JSON', $meta); - } + // $meta = $this->infoMetas_model->get($ic_id, 'AMP_JSON'); + // if (! empty($meta)) { + // $meta = str_ireplace($oldStr, $newStr, $meta); + // $this->infoMetas_model->update($ic_id, 'AMP_JSON', $meta); + // } // amp_body_pc - $meta = $this->infoMetas_model->get($ic_id, 'AMP_BODY_PC'); - if (! empty($meta)) { - $meta = str_ireplace($oldStr, $newStr, $meta); - $this->infoMetas_model->update($ic_id, 'AMP_BODY_PC', $meta); - } + // $meta = $this->infoMetas_model->get($ic_id, 'AMP_BODY_PC'); + // if (! empty($meta)) { + // $meta = str_ireplace($oldStr, $newStr, $meta); + // $this->infoMetas_model->update($ic_id, 'AMP_BODY_PC', $meta); + // } echo json_encode($keyArr); diff --git a/application/models/infoContents_model.php b/application/models/infoContents_model.php index 422997de..7b95c79f 100644 --- a/application/models/infoContents_model.php +++ b/application/models/infoContents_model.php @@ -1,36 +1,81 @@ HT = $this->load->database('INFORMATION', TRUE); - } + function __construct() { + parent::__construct(); + $this->HT = $this->load->database('INFORMATION', TRUE); + } - public function add_use_ORM($table, $data) - { - if ($this->HT->insert($table, $data)) { - return $this->HT->last_id($table); - } else { - return false; - } + public function add_use_ORM($table, $data) { + if ($this->HT->insert($table, $data)) { + return $this->HT->last_id($table); + } else { + return false; } + } - public function update_use_ORM($table, $data, $where) - { - $this->HT->update($table, $data, $where); - } + public function update_use_ORM($table, $data, $where) { + $this->HT->update($table, $data, $where); + } - function Add( + function Add( + $ic_url, + $ic_url_title, + $ic_type, + $ic_title, + $ic_content, + $ic_summary, + $ic_seo_title, + $ic_seo_description, + $ic_seo_keywords, + $ic_show_bread_crumbs, + $ic_status, + $ic_template, + $ic_photo, + $ic_photo_width, + $ic_photo_height, + $ic_recommend_tours, + $ic_recommend_packages, + $ic_ht_area_id, + $ic_ht_area_type, + $ic_ht_product_id, + $ic_ht_product_type, + $ic_author + ) { + $ic_content = str_replace('http:' . $this->config->item('site_image_url'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace('#textarea#', 'textarea', $ic_content); + $ic_content = str_replace('t_e_x_t_a_r_e_a', 'textarea', $ic_content); + $sql = "INSERT INTO infoContents \n" + . " ( \n" + . " ic_url, ic_url_title, ic_type, ic_title, ic_content, ic_summary, ic_seo_title, \n" + . " ic_seo_description, ic_seo_keywords, ic_show_bread_crumbs, ic_status, \n" + . " ic_template, ic_photo,ic_photo_width,ic_photo_height, ic_sitecode, ic_recommend_tours, ic_recommend_packages, \n" + . " ic_ht_area_id, ic_ht_area_type,ic_ht_product_id,ic_ht_product_type,ic_author, ic_datetime \n" + . " ) \n" + . "VALUES \n" + . " ( N?,N?,?,N?,N?,N?,N?,N?,N?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,getdate() )"; + $query = $this->HT->query( + $sql, + [ $ic_url, $ic_url_title, $ic_type, $ic_title, - $ic_content, + str_replace( + $this->config->item('media_image_url'), + $this->config->item('site_image_url'), + $ic_content + ), $ic_summary, $ic_seo_title, $ic_seo_description, @@ -41,75 +86,79 @@ class InfoContents_model extends CI_Model $ic_photo, $ic_photo_width, $ic_photo_height, + $this->config->item('site_code'), $ic_recommend_tours, $ic_recommend_packages, $ic_ht_area_id, $ic_ht_area_type, $ic_ht_product_id, $ic_ht_product_type, - $ic_author - ) { - $ic_content = str_replace('http:' . $this->config->item('site_image_url'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace('#textarea#', 'textarea', $ic_content); - $ic_content = str_replace('t_e_x_t_a_r_e_a', 'textarea', $ic_content); - $sql = "INSERT INTO infoContents \n" - . " ( \n" - . " ic_url, ic_url_title, ic_type, ic_title, ic_content, ic_summary, ic_seo_title, \n" - . " ic_seo_description, ic_seo_keywords, ic_show_bread_crumbs, ic_status, \n" - . " ic_template, ic_photo,ic_photo_width,ic_photo_height, ic_sitecode, ic_recommend_tours, ic_recommend_packages, \n" - . " ic_ht_area_id, ic_ht_area_type,ic_ht_product_id,ic_ht_product_type,ic_author, ic_datetime \n" - . " ) \n" - . "VALUES \n" - . " ( N?,N?,?,N?,N?,N?,N?,N?,N?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,getdate() )"; - $query = $this->HT->query( - $sql, - array( - $ic_url, - $ic_url_title, - $ic_type, - $ic_title, - str_replace( - $this->config->item('media_image_url'), - $this->config->item('site_image_url'), - $ic_content - ), - $ic_summary, - $ic_seo_title, - $ic_seo_description, - $ic_seo_keywords, - $ic_show_bread_crumbs, - $ic_status, - $ic_template, - $ic_photo, - $ic_photo_width, - $ic_photo_height, - $this->config->item('site_code'), - $ic_recommend_tours, - $ic_recommend_packages, - $ic_ht_area_id, - $ic_ht_area_type, - $ic_ht_product_id, - $ic_ht_product_type, - $ic_author - ) - ); - $this->insert_id = $this->HT->last_id('infoContents'); - return $query; - } + $ic_author, + ] + ); + $this->insert_id = $this->HT->last_id('infoContents'); + return $query; + } - function Add_with_sitecode( + function Add_with_sitecode( + $ic_url, + $ic_url_title, + $ic_type, + $ic_title, + $ic_content, + $ic_summary, + $ic_seo_title, + $ic_seo_description, + $ic_seo_keywords, + $ic_show_bread_crumbs, + $ic_status, + $ic_template, + $ic_photo, + $ic_photo_width, + $ic_photo_height, + $ic_recommend_tours, + $ic_recommend_packages, + $ic_ht_area_id, + $ic_ht_area_type, + $ic_ht_product_id, + $ic_ht_product_type, + $ic_author, + $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); + $ic_content = str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace('#textarea#', 'textarea', $ic_content); + $ic_content = str_replace('t_e_x_t_a_r_e_a', 'textarea', $ic_content); + $sql = "INSERT INTO infoContents \n" + . " ( \n" + . " ic_url, ic_url_title, ic_type, ic_title, ic_content, ic_summary, ic_seo_title, \n" + . " ic_seo_description, ic_seo_keywords, ic_show_bread_crumbs, ic_status, \n" + . " ic_template, ic_photo,ic_photo_width,ic_photo_height, ic_sitecode, ic_recommend_tours, ic_recommend_packages, \n" + . " ic_ht_area_id, ic_ht_area_type,ic_ht_product_id,ic_ht_product_type,ic_author, ic_datetime \n" + . " ) \n" + . "VALUES \n" + . " ( N?,N?,?,N?,N?,N?,N?,N?,N?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,getdate() )"; + $query = $this->HT->query( + $sql, + [ $ic_url, $ic_url_title, $ic_type, $ic_title, - $ic_content, + str_replace( + $this->config->item('media_image_url'), + $this->config->item('site_image_url'), + $ic_content + ), $ic_summary, $ic_seo_title, $ic_seo_description, @@ -120,6 +169,7 @@ class InfoContents_model extends CI_Model $ic_photo, $ic_photo_width, $ic_photo_height, + $site_code, $ic_recommend_tours, $ic_recommend_packages, $ic_ht_area_id, @@ -127,68 +177,80 @@ class InfoContents_model extends CI_Model $ic_ht_product_id, $ic_ht_product_type, $ic_author, - $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); - $ic_content = str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace('#textarea#', 'textarea', $ic_content); - $ic_content = str_replace('t_e_x_t_a_r_e_a', 'textarea', $ic_content); - $sql = "INSERT INTO infoContents \n" - . " ( \n" - . " ic_url, ic_url_title, ic_type, ic_title, ic_content, ic_summary, ic_seo_title, \n" - . " ic_seo_description, ic_seo_keywords, ic_show_bread_crumbs, ic_status, \n" - . " ic_template, ic_photo,ic_photo_width,ic_photo_height, ic_sitecode, ic_recommend_tours, ic_recommend_packages, \n" - . " ic_ht_area_id, ic_ht_area_type,ic_ht_product_id,ic_ht_product_type,ic_author, ic_datetime \n" - . " ) \n" - . "VALUES \n" - . " ( N?,N?,?,N?,N?,N?,N?,N?,N?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,getdate() )"; - $query = $this->HT->query( - $sql, - array( - $ic_url, - $ic_url_title, - $ic_type, - $ic_title, - str_replace( - $this->config->item('media_image_url'), - $this->config->item('site_image_url'), - $ic_content - ), - $ic_summary, - $ic_seo_title, - $ic_seo_description, - $ic_seo_keywords, - $ic_show_bread_crumbs, - $ic_status, - $ic_template, - $ic_photo, - $ic_photo_width, - $ic_photo_height, - $site_code, - $ic_recommend_tours, - $ic_recommend_packages, - $ic_ht_area_id, - $ic_ht_area_type, - $ic_ht_product_id, - $ic_ht_product_type, - $ic_author - ) - ); - $this->insert_id = $this->HT->last_id('infoContents'); - return $query; - } + ] + ); + $this->insert_id = $this->HT->last_id('infoContents'); + return $query; + } - function Update( - $ic_id, + function Update( + $ic_id, + $ic_url, + $ic_url_title, + $ic_type, + $ic_title, + $ic_content, + $ic_summary, + $ic_seo_title, + $ic_seo_description, + $ic_seo_keywords, + $ic_show_bread_crumbs, + $ic_status, + $ic_template, + $ic_photo, + $ic_photo_width, + $ic_photo_height, + $ic_recommend_tours, + $ic_recommend_packages, + $ic_ht_area_id, + $ic_ht_area_type, + $ic_ht_product_id, + $ic_ht_product_type, + $ic_author + ) { + $ic_content = str_replace('http:' . $this->config->item('site_image_url'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'), $ic_content); + $ic_content = str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'), $ic_content); + //todo:临时替换,等发布一段时间后取消,AH把japan板块搬迁到了JH网站用的 + if ($this->config->item('site_code') == 'jh') {$ic_content = str_replace('https://images.asiahighlights.com', 'https://images.japanhighlights.com', $ic_content);} + if ($this->config->item('site_code') == 'jh') {$ic_content = str_replace('https://data.asiahighlights.com', 'https://data.japanhighlights.com', $ic_content);} + $ic_content = str_replace('#textarea#', 'textarea', $ic_content); + $ic_content = str_replace('t_e_x_t_a_r_e_a', 'textarea', $ic_content); + + $sql = "UPDATE infoContents \n" + . "SET ic_url = N?, \n" + . " ic_url_title = N?, \n" + . " ic_type = ?, \n" + . " ic_title = N?, \n" + . " ic_content = N?, \n" + . " ic_summary = N?, \n" + . " ic_seo_title = N?, \n" + . " ic_seo_description = N?, \n" + . " ic_seo_keywords = N?, \n" + . " ic_show_bread_crumbs = ?, \n" + . " ic_status = ?, \n" + . " ic_template = ?, \n" + . " ic_photo = ?, \n" + . " ic_photo_width = ?, \n" + . " ic_photo_height = ?, \n" + . " ic_recommend_tours = ?, \n" + . " ic_recommend_packages = ?, \n" + . " ic_datetime = GETDATE() , \n" + . " ic_ht_area_id = ?, \n" + . " ic_ht_area_type = ?, \n" + . " ic_ht_product_id = ?, \n" + . " ic_ht_product_type = ?, \n" + . " ic_author = ? \n" + . "WHERE ic_id = ? \n" + . "AND ic_sitecode = ? "; + $query = $this->HT->query( + $sql, + [ $ic_url, $ic_url_title, $ic_type, @@ -210,172 +272,104 @@ class InfoContents_model extends CI_Model $ic_ht_area_type, $ic_ht_product_id, $ic_ht_product_type, - $ic_author - ) { - $ic_content = str_replace('http:' . $this->config->item('site_image_url'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url2'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_org'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_remote'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_remote2'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url3'), $this->config->item('site_image_url'), $ic_content); - $ic_content = str_replace($this->config->item('media_image_url_org2'), $this->config->item('site_image_url'), $ic_content); - //todo:临时替换,等发布一段时间后取消,AH把japan板块搬迁到了JH网站用的 - if ($this->config->item('site_code')=='jh'){ $ic_content = str_replace('https://images.asiahighlights.com', 'https://images.japanhighlights.com', $ic_content);} - if ($this->config->item('site_code')=='jh'){ $ic_content = str_replace('https://data.asiahighlights.com', 'https://data.japanhighlights.com', $ic_content);} - $ic_content = str_replace('#textarea#', 'textarea', $ic_content); - $ic_content = str_replace('t_e_x_t_a_r_e_a', 'textarea', $ic_content); + $ic_author, + $ic_id, + $this->config->item('site_code'), + ] + ); + return $query; + } - $sql = "UPDATE infoContents \n" - . "SET ic_url = N?, \n" - . " ic_url_title = N?, \n" - . " ic_type = ?, \n" - . " ic_title = N?, \n" - . " ic_content = N?, \n" - . " ic_summary = N?, \n" - . " ic_seo_title = N?, \n" - . " ic_seo_description = N?, \n" - . " ic_seo_keywords = N?, \n" - . " ic_show_bread_crumbs = ?, \n" - . " ic_status = ?, \n" - . " ic_template = ?, \n" - . " ic_photo = ?, \n" - . " ic_photo_width = ?, \n" - . " ic_photo_height = ?, \n" - . " ic_recommend_tours = ?, \n" - . " ic_recommend_packages = ?, \n" - . " ic_datetime = GETDATE() , \n" - . " ic_ht_area_id = ?, \n" - . " ic_ht_area_type = ?, \n" - . " ic_ht_product_id = ?, \n" - . " ic_ht_product_type = ?, \n" - . " ic_author = ? \n" - . "WHERE ic_id = ? \n" - . "AND ic_sitecode = ? "; - $query = $this->HT->query( - $sql, - array( - $ic_url, - $ic_url_title, - $ic_type, - $ic_title, - $ic_content, - $ic_summary, - $ic_seo_title, - $ic_seo_description, - $ic_seo_keywords, - $ic_show_bread_crumbs, - $ic_status, - $ic_template, - $ic_photo, - $ic_photo_width, - $ic_photo_height, - $ic_recommend_tours, - $ic_recommend_packages, - $ic_ht_area_id, - $ic_ht_area_type, - $ic_ht_product_id, - $ic_ht_product_type, - $ic_author, - $ic_id, - $this->config->item('site_code') - ) - ); - return $query; - } + //强制更新信息 + function force_update($ic_id, $ic_content) { + $sql = "UPDATE infoContents SET ic_content = N? WHERE ic_id = ?"; + $query = $this->HT->query($sql, [$ic_content, $ic_id]); + return $query; + } - //强制更新信息 - function force_update($ic_id, $ic_content) - { - $sql = "UPDATE infoContents SET ic_content = N? WHERE ic_id = ?"; - $query = $this->HT->query($sql, array($ic_content, $ic_id)); - 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, [$ic_url, $ic_id]); + 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 force_update_ic_photo($ic_id, $ic_photo) { + $sql = "UPDATE infoContents SET ic_photo = N? WHERE ic_id = ?"; + $query = $this->HT->query($sql, [$ic_photo, $ic_id]); + return $query; + } - //删除信息 - function Delete($ic_id) - { - $sql = "DELETE \n" - . "FROM infoContents \n" - . "WHERE ic_id = ?"; - $query = $this->HT->query($sql, array($ic_id)); - return $query; - } + //删除信息 + function Delete($ic_id) { + $sql = "DELETE \n" + . "FROM infoContents \n" + . "WHERE ic_id = ?"; + $query = $this->HT->query($sql, [$ic_id]); + return $query; + } - //递增浏览量 - function inc_views($sitecode, $page_url) - { - //查询信息需要过滤url上的域名 - if ($page_url && $sitecode) { - $page_url = substr($page_url, strpos($page_url, '/', 8)); //过滤掉url前面的http:// - $sql = "UPDATE infoContents \n" - . "SET ic_view = ISNULL(ic_view,0) + 1 \n" - . "WHERE ic_sitecode = ? AND ic_url = N?"; - return $this->HT->query($sql, array($sitecode, $page_url)); - } + //递增浏览量 + function inc_views($sitecode, $page_url) { + //查询信息需要过滤url上的域名 + if ($page_url && $sitecode) { + $page_url = substr($page_url, strpos($page_url, '/', 8)); //过滤掉url前面的http:// + $sql = "UPDATE infoContents \n" + . "SET ic_view = ISNULL(ic_view,0) + 1 \n" + . "WHERE ic_sitecode = ? AND ic_url = N?"; + return $this->HT->query($sql, [$sitecode, $page_url]); } + } - public function get_ic_contents($ic_id) - { - $sql = "SELECT top 1 ic_id from infoContents where ic_id=?"; - $query = $this->HT->query($sql, array($ic_id)); - if ($query->result()) { - $row = $query->row(); - return $row; - } else { - return FALSE; - } + public function get_ic_contents($ic_id) { + $sql = "SELECT top 1 ic_id from infoContents where ic_id=?"; + $query = $this->HT->query($sql, [$ic_id]); + if ($query->result()) { + $row = $query->row(); + return $row; + } else { + return FALSE; } + } - public function get_ic_contents2($ic_id) - { - $sql = "SELECT top 1 * from infoContents where ic_id=?"; - $query = $this->HT->query($sql, array($ic_id)); - if ($query->result()) { - $row = $query->row(); - return $row; - } else { - return FALSE; - } + public function get_ic_contents2($ic_id) { + $sql = "SELECT top 1 * from infoContents where ic_id=?"; + $query = $this->HT->query($sql, [$ic_id]); + if ($query->result()) { + $row = $query->row(); + return $row; + } else { + return FALSE; } + } - public function get_ic_contents2_gm($ic_id) - { - $sql = "SELECT top 1 * from information_gm.dbo.infoContents where ic_id=?"; - $query = $this->HT->query($sql, array($ic_id)); - if ($query->result()) { - $row = $query->row(); - return $row; - } else { - return FALSE; - } + public function get_ic_contents2_gm($ic_id) { + $sql = "SELECT top 1 * from information_gm.dbo.infoContents where ic_id=?"; + $query = $this->HT->query($sql, [$ic_id]); + if ($query->result()) { + $row = $query->row(); + return $row; + } else { + return FALSE; } + } - public function get_ic_contents_by_list($ic_id_list) - { - $ic_id_list = trim($ic_id_list); - $ic_id_list .= 0; - $sql = "SELECT * from infoContents where ic_id in ($ic_id_list) order by charindex(','+ltrim(ic_id)+',', ',$ic_id_list,')"; - $query = $this->HT->query($sql); - if ($query->result()) { - $row = $query->result(); - return $row; - } else { - return FALSE; - } + public function get_ic_contents_by_list($ic_id_list) { + $ic_id_list = trim($ic_id_list); + $ic_id_list .= 0; + $sql = "SELECT * from infoContents where ic_id in ($ic_id_list) order by charindex(','+ltrim(ic_id)+',', ',$ic_id_list,')"; + $query = $this->HT->query($sql); + if ($query->result()) { + $row = $query->result(); + return $row; + } else { + return FALSE; } + } - public function list_use_hb($site) - { - $sql = " + public function list_use_hb($site) { + $sql = " SELECT c.ic_id, c.ic_url FROM infoContents c INNER JOIN infoMetas m @@ -384,17 +378,16 @@ class InfoContents_model extends CI_Model AND CONVERT(nvarchar(max), m.im_value) = 'yes' AND c.ic_sitecode = ? "; - $query = $this->HT->query($sql, array($site)); - return $query->result(); - } + $query = $this->HT->query($sql, [$site]); + return $query->result(); + } - public function get_isid_by_icid($ic_id) - { - $sql = " + public function get_isid_by_icid($ic_id) { + $sql = " select is_id from infoStructures s where s.is_ic_id=? "; - $query = $this->HT->query($sql, array($ic_id)); - return $query->row(); - } + $query = $this->HT->query($sql, [$ic_id]); + return $query->row(); + } } diff --git a/application/models/information_model.php b/application/models/information_model.php index 3085872d..9b14aeb7 100644 --- a/application/models/information_model.php +++ b/application/models/information_model.php @@ -759,22 +759,16 @@ class Information_model extends CI_Model { $keysql .= ' OR ic_content like \'%' . $key . '%\''; $keysql .= ' OR ic_url like \'%' . $key . '%\''; $keysql .= ' OR ic_photo like \'%' . $key . '%\''; - $keysql .= ' OR m1.im_value like \'%' . $key . '%\''; - $keysql .= ' OR m2.im_value like \'%' . $key . '%\''; + // $keysql .= ' OR m1.im_value like \'%' . $key . '%\''; + // $keysql .= ' OR m2.im_value like \'%' . $key . '%\''; } $search = ' AND (1=0 ' . $keysql . ')'; $sql = " - SELECT is_id, ic_id, ic_url, ic_content, ic_photo, m1.im_value AS amp_json, m2.im_value AS amp_body + SELECT is_id, ic_id, ic_url, ic_content, ic_photo FROM infoStructures is1 INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id AND ic.ic_sitecode = is1.is_sitecode - LEFT JOIN infoMetas m1 - ON m1.im_ic_id = ic.ic_id - AND m1.im_key = 'AMP_JSON' - LEFT JOIN infoMetas m2 - ON m2.im_ic_id = ic.ic_id - AND m2.im_key = 'AMP_BODY_PC' WHERE ic_status = 1 AND is1.is_sitecode = ? AND ic_status = 1