• R/O
  • SSH
  • HTTPS

jinrousiki: Commit


Commit MetaInfo

Revision2306 (tree)
Time2018-12-25 02:48:46
Authorumethyl

Log Message

Text::Quote()

Change Summary

Incremental Difference

--- trunk/include/database/db_class.php (revision 2305)
+++ trunk/include/database/db_class.php (revision 2306)
@@ -358,7 +358,7 @@
358358
359359 //LIKE 句生成
360360 public static function GetLike($str) {
361- return '%' . $str . '%';
361+ return Text::Quote($str, '%', '%');
362362 }
363363
364364 //-- オブジェクト生成型 --//
--- trunk/include/functions.php (revision 2305)
+++ trunk/include/functions.php (revision 2306)
@@ -15,7 +15,7 @@
1515
1616 //検索
1717 public static function Search($str, $target) {
18- return strpos($str, $target) !== false;
18+ return false !== strpos($str, $target);
1919 }
2020
2121 //先頭
@@ -50,6 +50,16 @@
5050 return ArrayFilter::Concat($stack, self::BRLF);
5151 }
5252
53+ //改行コードを <br> に変換する (PHP5.3 以下の nl2br() だと <br /> 固定なので HTML 4.01 だと不向き)
54+ public static function ConvertLine($str) {
55+ return str_replace(self::LF, self::BR, $str);
56+ }
57+
58+ //折り返し
59+ public static function Fold($count, $str, $base = Position::BASE) {
60+ return ($count > 0 && $count % $base == 0) ? self::LineFeed($str) : null;
61+ }
62+
5363 //ヘッダ追加
5464 public static function AddHeader($str, $header, $delimiter = ': ') {
5565 return self::Exists($header) ? $header . $delimiter . $str : $str;
@@ -60,19 +70,14 @@
6070 return self::Exists($footer) ? $str . $delimiter . $footer : $str;
6171 }
6272
63- //折り返し
64- public static function Fold($count, $str, $base = Position::BASE) {
65- return ($count > 0 && $count % $base == 0) ? self::LineFeed($str) : null;
66- }
67-
6873 //カッコで括る
69- public static function Quote($str) {
70- return '(' . $str . ')';
74+ public static function Quote($str, $before = '(', $after = ')') {
75+ return $before . $str . $after;
7176 }
7277
7378 //カッコで括る (ブラケット版)
7479 public static function QuoteBracket($str) {
75- return '[' . $str . ']';
80+ return self::Quote($str, '[', ']');
7681 }
7782
7883 //分離 (explode() ラッパー)
@@ -108,11 +113,6 @@
108113 return $str;
109114 }
110115
111- //改行コードを <br> に変換する (PHP5.3 以下の nl2br() だと <br /> 固定なので HTML 4.01 だと不向き)
112- public static function Line($str) {
113- return str_replace(self::LF, self::BR, $str);
114- }
115-
116116 //暗号化
117117 public static function Crypt($str) {
118118 return sha1(ServerConfig::SALT . $str);
Show on old repository browser