• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-jp-ancient: Commit

Nucleus CMS日本語版SVNをgit-svnしたもの。リポジトリの変換作業用


Commit MetaInfo

Revisão08c339012fc4a8dabd142f9683e08881091766c0 (tree)
Hora2008-02-07 15:26:07
Autorkimitake <kimitake@1ca2...>
Commiterkimitake

Mensagem de Log

use "BINARY" for jp search

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/branches/branch-3-3@370 1ca29b6e-896d-4ea0-84a5-967f57386b96

Mudança Sumário

Diff

--- a/euc/nucleus/libs/SEARCH.php
+++ b/euc/nucleus/libs/SEARCH.php
@@ -20,8 +20,8 @@
2020 *
2121 * @license http://nucleuscms.org/license.txt GNU General Public License
2222 * @copyright Copyright (C) 2002-2007 The Nucleus Group
23- * @version $Id: SEARCH.php,v 1.6 2007-03-27 12:13:56 kimitake Exp $
24- * @version $NucleusJP: SEARCH.php,v 1.8 2007/02/04 06:28:46 kimitake Exp $
23+ * @version $Id: SEARCH.php,v 1.6.2.1 2008-02-07 06:25:50 kimitake Exp $
24+ * @version $NucleusJP: SEARCH.php,v 1.6 2007/03/27 12:13:56 kimitake Exp $
2525 */
2626
2727
@@ -200,30 +200,36 @@ class SEARCH {
200200 return $result;
201201 }
202202
203+ function create_temp_a($match, $key, $substrflag){
204+ $key = $substrflag ? substr($key, 1) : $key;
205+ return "(i.$match LIKE " . (preg_match('/[a-zA-Z]/', $key) ? '' : 'BINARY ') . "'%" .
206+ addslashes($key) . "%') ";
207+ }
203208
204209 function boolean_sql_where_jp_short($string,$match){
205210 $match_a = explode(',',$match);
206- $key_a = explode(' ',$string);
211+ $key_a = explode(' ',$string);
207212
208213 for($ith=0;$ith<count($match_a);$ith++){
209- $temp_a[$ith] = "(i.$match_a[$ith] LIKE '%" . addslashes($key_a[0]) . "%') ";
214+ $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[0], 0);
215+
210216 }
211217 $like = '('.implode(' or ',$temp_a).')';
212218
213- for($kn=1; $kn<count($key_a); $kn++){
214- if(substr($key_a[$kn],0,1) == ","){
219+ for($kn=1; $kn<count($key_a); $kn++){
220+ if(substr($key_a[$kn],0,1) == ","){
215221 for($ith=0;$ith<count($match_a);$ith++){
216- $temp_a[$ith] = " (i.$match_a[$ith] LIKE '%" . addslashes(substr($key_a[$kn],1)) . "%') ";
222+ $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 1);
217223 }
218224 $like .=' OR ('. implode(' or ',$temp_a).')';
219225 }elseif(substr($key_a[$kn],0,1) != '-'){
220226 for($ith=0;$ith<count($match_a);$ith++){
221- $temp_a[$ith] = " (i.$match_a[$ith] LIKE '%" . addslashes($key_a[$kn]) . "%') ";
227+ $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 0);
222228 }
223229 $like .=' AND ('. implode(' or ',$temp_a).')';
224230 }else{
225231 for($ith=0;$ith<count($match_a);$ith++){
226- $temp_a[$ith] = " NOT(i.$match_a[$ith] LIKE '%" . addslashes(substr($key_a[$kn],1)) . "%') ";
232+ $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 1);
227233 }
228234 $like .=' AND ('. implode(' and ',$temp_a).')';
229235 }
--- a/utf8/nucleus/libs/SEARCH.php
+++ b/utf8/nucleus/libs/SEARCH.php
@@ -20,8 +20,8 @@
2020 *
2121 * @license http://nucleuscms.org/license.txt GNU General Public License
2222 * @copyright Copyright (C) 2002-2007 The Nucleus Group
23- * @version $Id: SEARCH.php,v 1.8 2007-02-04 06:28:46 kimitake Exp $
24- * @version $NucleusJP: SEARCH.php,v 1.7 2006/07/20 08:01:52 kimitake Exp $
23+ * @version $Id: SEARCH.php,v 1.8.2.1 2008-02-07 06:26:07 kimitake Exp $
24+ * @version $NucleusJP: SEARCH.php,v 1.8 2007/02/04 06:28:46 kimitake Exp $
2525 */
2626
2727
@@ -237,30 +237,36 @@ class SEARCH {
237237 return $result;
238238 }
239239
240+ function create_temp_a($match, $key, $substrflag){
241+ $key = $substrflag ? substr($key, 1) : $key;
242+ return "(i.$match LIKE " . (preg_match('/[a-zA-Z]/', $key) ? '' : 'BINARY ') . "'%" .
243+ addslashes($key) . "%') ";
244+ }
240245
241246 function boolean_sql_where_jp_short($string,$match){
242247 $match_a = explode(',',$match);
243- $key_a = explode(' ',$string);
248+ $key_a = explode(' ',$string);
244249
245250 for($ith=0;$ith<count($match_a);$ith++){
246- $temp_a[$ith] = "(i.$match_a[$ith] LIKE '%" . addslashes($key_a[0]) . "%') ";
251+ $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[0], 0);
252+
247253 }
248254 $like = '('.implode(' or ',$temp_a).')';
249255
250- for($kn=1; $kn<count($key_a); $kn++){
251- if(substr($key_a[$kn],0,1) == ","){
256+ for($kn=1; $kn<count($key_a); $kn++){
257+ if(substr($key_a[$kn],0,1) == ","){
252258 for($ith=0;$ith<count($match_a);$ith++){
253- $temp_a[$ith] = " (i.$match_a[$ith] LIKE '%" . addslashes(substr($key_a[$kn],1)) . "%') ";
259+ $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 1);
254260 }
255261 $like .=' OR ('. implode(' or ',$temp_a).')';
256262 }elseif(substr($key_a[$kn],0,1) != '-'){
257263 for($ith=0;$ith<count($match_a);$ith++){
258- $temp_a[$ith] = " (i.$match_a[$ith] LIKE '%" . addslashes($key_a[$kn]) . "%') ";
264+ $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 0);
259265 }
260266 $like .=' AND ('. implode(' or ',$temp_a).')';
261267 }else{
262268 for($ith=0;$ith<count($match_a);$ith++){
263- $temp_a[$ith] = " NOT(i.$match_a[$ith] LIKE '%" . addslashes(substr($key_a[$kn],1)) . "%') ";
269+ $temp_a[$ith] = $this->create_temp_a($match_a[$ith], $key_a[$kn], 1);
264270 }
265271 $like .=' AND ('. implode(' and ',$temp_a).')';
266272 }
Show on old repository browser