From d3fc334525ad4c52994e968f95b97fa412187d04 Mon Sep 17 00:00:00 2001 From: LMR <59361885@qq.com> Date: Tue, 21 May 2024 16:00:49 +0800 Subject: [PATCH] fix --- application/controllers/infofix.php | 13 ++++++++++--- application/models/information_model.php | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/application/controllers/infofix.php b/application/controllers/infofix.php index a6337f97..d336aa09 100644 --- a/application/controllers/infofix.php +++ b/application/controllers/infofix.php @@ -16,7 +16,7 @@ class infofix extends CI_Controller function list_info_by_keys($site = '', $keys = []) { $site = 'cht'; - $keys = ['/beijing/', '/yangshuo/']; + $keys = ['/beijing/', '/shanghai/']; // 容错 if (empty($site) || empty($keys)) { @@ -33,9 +33,16 @@ class infofix extends CI_Controller foreach ($keys as $key) { $pos_url = stripos($info->ic_url, $key); $sub_url = $info->ic_url == $key ? $info->ic_url : ''; + + $pos_content = 0; $pos_content = stripos($info->ic_content, $key); - $sub_content = '[...' . substr($info->ic_content, $pos_content - 20, strlen($key) + 20 * 2) . '...]'; - if ($pos_url !== false || $pos_content !== false) { + $sub_content = array(); + while ($pos_content) { + array_push($sub_content, '[...' . substr($info->ic_content, $pos_content - 20, strlen($key) + 20 * 2) . '...]'); + $pos_content = stripos($info->ic_content, $key, $pos_content + strlen($key)); + } + + if ($sub_url != '' || count($sub_content) != 0) { array_push($keycount, array('key' => $key, 'sub_url' => $sub_url, 'sub_content' => $sub_content)); } } diff --git a/application/models/information_model.php b/application/models/information_model.php index 21cc30c6..b25b4c7e 100644 --- a/application/models/information_model.php +++ b/application/models/information_model.php @@ -797,7 +797,7 @@ class Information_model extends CI_Model } $search = ' AND (1=0 ' . $keysql . ')'; $sql = " - SELECT TOP 10 ic_id, ic_url, ic_content + SELECT ic_id, ic_url, ic_content FROM infoStructures is1 INNER JOIN infoContents ic ON ic.ic_id = is1.is_ic_id AND ic.ic_sitecode = is1.is_sitecode