| 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
| 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
| 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
| 8 | * |
---|
| 9 | * This program is free software; you can redistribute it and/or |
---|
| 10 | * modify it under the terms of the GNU General Public License |
---|
| 11 | * as published by the Free Software Foundation; either version 2 |
---|
| 12 | * of the License, or (at your option) any later version. |
---|
| 13 | * |
---|
| 14 | * This program is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this program; if not, write to the Free Software |
---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | /*---------------------------------------------------------------------- |
---|
| 25 | * [名称] SC_CheckError |
---|
| 26 | * [概要] エラーチェッククラス |
---|
| 27 | *---------------------------------------------------------------------- |
---|
| 28 | */ |
---|
| 29 | class SC_CheckError { |
---|
| 30 | var $arrErr = array(); |
---|
| 31 | var $arrParam; |
---|
| 32 | |
---|
| 33 | // チェック対象の値が含まれる配列をセットする。 |
---|
| 34 | function SC_CheckError($array = "") { |
---|
| 35 | if($array != "") { |
---|
| 36 | $this->arrParam = $array; |
---|
| 37 | } else { |
---|
| 38 | $this->arrParam = $_POST; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | function doFunc($value, $arrFunc) { |
---|
| 44 | foreach ( $arrFunc as $key ) { |
---|
| 45 | $this->$key($value); |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | /* HTMLのタグをチェックする */ |
---|
| 50 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 許可するタグが格納された配列 |
---|
| 51 | function HTML_TAG_CHECK($value) { |
---|
| 52 | if(isset($this->arrErr[$value[1]])) { |
---|
| 53 | return; |
---|
| 54 | } |
---|
| 55 | $this->createParam($value); |
---|
| 56 | // 含まれているタグを抽出する |
---|
| 57 | preg_match_all("/<([\/]?[a-z]+)/", $this->arrParam[$value[1]], $arrTag); |
---|
| 58 | |
---|
| 59 | foreach($arrTag[1] as $val) { |
---|
| 60 | $find = false; |
---|
| 61 | |
---|
| 62 | foreach($value[2] as $tag) { |
---|
| 63 | if(eregi("^" . $tag . "$", $val)) { |
---|
| 64 | $find = true; |
---|
| 65 | } else { |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | if(!$find) { |
---|
| 70 | $this->arrErr[$value[1]] = "※ " . $value[0] . "に許可されていないタグ[" . strtoupper($val) . "]が含まれています。<br />"; |
---|
| 71 | return; |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | /* 必須入力の判定 */ |
---|
| 77 | // value[0] = 項目名 value[1] = 判定対象 |
---|
| 78 | function EXIST_CHECK( $value ) { // 受け取りがない場合エラーを返す |
---|
| 79 | if(isset($this->arrErr[$value[1]])) { |
---|
| 80 | return; |
---|
| 81 | } |
---|
| 82 | $this->createParam($value); |
---|
| 83 | if(!is_array($this->arrParam[$value[1]]) and strlen($this->arrParam[$value[1]]) == 0 ){ |
---|
| 84 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が入力されていません。<br />"; |
---|
| 85 | }else if(is_array($this->arrParam[$value[1]]) and count($this->arrParam[$value[1]]) == 0) { |
---|
| 86 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が選択されていません。<br />"; |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | /* 必須入力の判定(逆順) */ |
---|
| 91 | // value[0] = 判定対象 value[1] = 項目名 |
---|
| 92 | function EXIST_CHECK_REVERSE( $value ) { // 受け取りがない場合エラーを返す |
---|
| 93 | if(isset($this->arrErr[$value[0]])) { |
---|
| 94 | return; |
---|
| 95 | } |
---|
| 96 | $this->createParam($value); |
---|
| 97 | if( strlen($this->arrParam[$value[0]]) == 0 ){ |
---|
| 98 | $this->arrErr[$value[0]] = "※ " . $value[0] . "が入力されていません。<br />"; |
---|
| 99 | } |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | /* スペース、タブの判定 */ |
---|
| 103 | // value[0] = 項目名 value[1] = 判定対象 |
---|
| 104 | function SPTAB_CHECK( $value ) { // 受け取りがない場合エラーを返す |
---|
| 105 | if(isset($this->arrErr[$value[1]])) { |
---|
| 106 | return; |
---|
| 107 | } |
---|
| 108 | $this->createParam($value); |
---|
| 109 | if(strlen($this->arrParam[$value[1]]) != 0 && ereg("^[ \t\r\n]+$", $this->arrParam[$value[1]])){ |
---|
| 110 | $this->arrErr[$value[1]] = "※ " . $value[0] . "にスペース、タブ、改行のみの入力はできません。<br />"; |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | /* スペース、タブの判定 */ |
---|
| 115 | // value[0] = 項目名 value[1] = 判定対象 |
---|
| 116 | function NO_SPTAB( $value ) { // 受け取りがない場合エラーを返す |
---|
| 117 | if(isset($this->arrErr[$value[1]])) { |
---|
| 118 | return; |
---|
| 119 | } |
---|
| 120 | $this->createParam($value); |
---|
| 121 | if(strlen($this->arrParam[$value[1]]) != 0 && mb_ereg("[ \t\r\n]+", $this->arrParam[$value[1]])){ |
---|
| 122 | $this->arrErr[$value[1]] = "※ " . $value[0] . "にスペース、タブ、改行は含めないで下さい。<br />"; |
---|
| 123 | } |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | /* ゼロで開始されている数値の判定 */ |
---|
| 127 | function ZERO_START($value) { |
---|
| 128 | if(isset($this->arrErr[$value[1]])) { |
---|
| 129 | return; |
---|
| 130 | } |
---|
| 131 | $this->createParam($value); |
---|
| 132 | if(strlen($this->arrParam[$value[1]]) != 0 && ereg("^[0]+[0-9]+$", $this->arrParam[$value[1]])){ |
---|
| 133 | $this->arrErr[$value[1]] = "※ " . $value[0] . "に0で始まる数値が入力されています。<br />"; |
---|
| 134 | } |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | /* 必須選択の判定 */ |
---|
| 138 | // value[0] = 項目名 value[1] = 判定対象 |
---|
| 139 | function SELECT_CHECK( $value ) { // プルダウンなどで選択されていない場合エラーを返す |
---|
| 140 | if(isset($this->arrErr[$value[1]])) { |
---|
| 141 | return; |
---|
| 142 | } |
---|
| 143 | $this->createParam($value); |
---|
| 144 | if( strlen($this->arrParam[$value[1]]) == 0 ){ |
---|
| 145 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が選択されていません。<br />"; |
---|
| 146 | } |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | /* 同一性の判定 */ |
---|
| 150 | // value[0] = 項目名1 value[1] = 項目名2 value[2] = 判定対象文字列1 value[3] = 判定対象文字列2 |
---|
| 151 | function EQUAL_CHECK( $value ) { // 入力が指定文字数以上ならエラーを返す |
---|
| 152 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
---|
| 153 | return; |
---|
| 154 | } |
---|
| 155 | $this->createParam($value); |
---|
| 156 | // 文字数の取得 |
---|
| 157 | if( $this->arrParam[$value[2]] != $this->arrParam[$value[3]]) { |
---|
| 158 | $this->arrErr[$value[2]] = "※ " . $value[0] . "と" . $value[1] . "が一致しません。<br />"; |
---|
| 159 | } |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | /* 値が異なることの判定 */ |
---|
| 163 | // value[0] = 項目名1 value[1] = 項目名2 value[2] = 判定対象文字列1 value[3] = 判定対象文字列2 |
---|
| 164 | function DIFFERENT_CHECK( $value ) { // 入力が指定文字数以上ならエラーを返す |
---|
| 165 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
---|
| 166 | return; |
---|
| 167 | } |
---|
| 168 | $this->createParam($value); |
---|
| 169 | // 文字数の取得 |
---|
| 170 | if( $this->arrParam[$value[2]] == $this->arrParam[$value[3]]) { |
---|
| 171 | $this->arrErr[$value[2]] = "※ " . $value[0] . "と" . $value[1] . "は、同じ値を使用できません。<br />"; |
---|
| 172 | } |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | /* 値の大きさを比較する value[2] < value[3]でなければエラー */ |
---|
| 176 | // value[0] = 項目名1 value[1] = 項目名2 value[2] = 判定対象文字列1 value[3] = 判定対象文字列2 |
---|
| 177 | function GREATER_CHECK($value) { // 入力が指定文字数以上ならエラーを返す |
---|
| 178 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
---|
| 179 | return; |
---|
| 180 | } |
---|
| 181 | $this->createParam($value); |
---|
| 182 | // 文字数の取得 |
---|
| 183 | if($this->arrParam[$value[2]] != "" && $this->arrParam[$value[3]] != "" && ($this->arrParam[$value[2]] > $this->arrParam[$value[3]])) { |
---|
| 184 | $this->arrErr[$value[2]] = "※ " . $value[0] . "は" . $value[1] . "より大きい値を入力できません。<br />"; |
---|
| 185 | } |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | |
---|
| 189 | /* 最大文字数制限の判定 */ |
---|
| 190 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最大文字数(半角も全角も1文字として数える) |
---|
| 191 | function MAX_LENGTH_CHECK( $value ) { // 入力が指定文字数以上ならエラーを返す |
---|
| 192 | if(isset($this->arrErr[$value[1]])) { |
---|
| 193 | return; |
---|
| 194 | } |
---|
| 195 | $this->createParam($value); |
---|
| 196 | // 文字数の取得 |
---|
| 197 | if( mb_strlen($this->arrParam[$value[1]]) > $value[2] ) { |
---|
| 198 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は" . $value[2] . "字以下で入力してください。<br />"; |
---|
| 199 | } |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | /* 最小文字数制限の判定 */ |
---|
| 203 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小文字数(半角も全角も1文字として数える) |
---|
| 204 | function MIN_LENGTH_CHECK( $value ) { // 入力が指定文字数未満ならエラーを返す |
---|
| 205 | if(isset($this->arrErr[$value[1]])) { |
---|
| 206 | return; |
---|
| 207 | } |
---|
| 208 | $this->createParam($value); |
---|
| 209 | // 文字数の取得 |
---|
| 210 | if( mb_strlen($this->arrParam[$value[1]]) < $value[2] ) { |
---|
| 211 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は" . $value[2] . "字以上で入力してください。<br />"; |
---|
| 212 | } |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | /* 最大文字数制限の判定 */ |
---|
| 216 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最大数 |
---|
| 217 | function MAX_CHECK( $value ) { // 入力が最大数以上ならエラーを返す |
---|
| 218 | if(isset($this->arrErr[$value[1]])) { |
---|
| 219 | return; |
---|
| 220 | } |
---|
| 221 | $this->createParam($value); |
---|
| 222 | // 文字数の取得 |
---|
| 223 | if($this->arrParam[$value[1]] > $value[2] ) { |
---|
| 224 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は" . $value[2] . "以下で入力してください。<br />"; |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | /* 最小数値制限の判定 */ |
---|
| 229 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小数 |
---|
| 230 | function MIN_CHECK( $value ) { // 入力が最小数未満ならエラーを返す |
---|
| 231 | if(isset($this->arrErr[$value[1]])) { |
---|
| 232 | return; |
---|
| 233 | } |
---|
| 234 | $this->createParam($value); |
---|
| 235 | if($this->arrParam[$value[1]] < $value[2] ) { |
---|
| 236 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は" . $value[2] . "以上で入力してください。<br />"; |
---|
| 237 | } |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | |
---|
| 241 | /* 数字の判定 */ |
---|
| 242 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 243 | function NUM_CHECK( $value ) { // 入力文字が数字以外ならエラーを返す |
---|
| 244 | if(isset($this->arrErr[$value[1]])) { |
---|
| 245 | return; |
---|
| 246 | } |
---|
| 247 | $this->createParam($value); |
---|
| 248 | if( strlen($this->arrParam[$value[1]]) > 0 && !EregI("^[[:digit:]]+$", $this->arrParam[$value[1]])) { |
---|
| 249 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は数字で入力してください。<br />"; |
---|
| 250 | } |
---|
| 251 | } |
---|
| 252 | |
---|
| 253 | /* 小数点を含む数字の判定 */ |
---|
| 254 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 255 | function NUM_POINT_CHECK( $value ) { // 入力文字が数字以外ならエラーを返す |
---|
| 256 | if(isset($this->arrErr[$value[1]])) { |
---|
| 257 | return; |
---|
| 258 | } |
---|
| 259 | $this->createParam($value); |
---|
| 260 | if( strlen($this->arrParam[$value[1]]) > 0 && !EregI("^[[:digit:]]+[\.]?[[:digit:]]+$", $this->arrParam[$value[1]])) { |
---|
| 261 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は数字で入力してください。<br />"; |
---|
| 262 | } |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | function ALPHA_CHECK($value) { |
---|
| 266 | if(isset($this->arrErr[$value[1]])) { |
---|
| 267 | return; |
---|
| 268 | } |
---|
| 269 | $this->createParam($value); |
---|
| 270 | if( strlen($this->arrParam[$value[1]]) > 0 && !EregI("^[[:alpha:]]+$", $this->arrParam[$value[1]])) { |
---|
| 271 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は半角英字で入力してください。<br />"; |
---|
| 272 | } |
---|
| 273 | } |
---|
| 274 | |
---|
| 275 | /** |
---|
| 276 | * 電話番号の判定 |
---|
| 277 | * |
---|
| 278 | * 数字チェックと文字数チェックを実施する。 |
---|
| 279 | * @param array $value 各要素は以下の通り。<br> |
---|
| 280 | * [0]: 項目名<br> |
---|
| 281 | * [1]: 電番1項目目<br> |
---|
| 282 | * [2]: 電番2項目目<br> |
---|
| 283 | * [3]: 電番3項目目<br> |
---|
| 284 | * [4]: 電話番号各項目制限 (指定なしの場合、TEL_ITEM_LEN)<br> |
---|
| 285 | * [5]: 電話番号総数 (指定なしの場合、TEL_LEN) |
---|
| 286 | */ |
---|
| 287 | function TEL_CHECK($value) { |
---|
| 288 | $telItemLen = isset($value[4]) ? $value[4] : TEL_ITEM_LEN; |
---|
| 289 | $telLen = isset($value[5]) ? $value[5] : TEL_LEN; |
---|
| 290 | |
---|
| 291 | if (isset($this->arrErr[$value[1]]) || isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
---|
| 292 | return; |
---|
| 293 | } |
---|
| 294 | $this->createParam($value); |
---|
| 295 | $cnt = 0; |
---|
| 296 | |
---|
| 297 | for($i = 1; $i <= 3; $i++) { |
---|
| 298 | if(strlen($this->arrParam[$value[$i]]) > 0) { |
---|
| 299 | $cnt++; |
---|
| 300 | } |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | // すべての項目が満たされていない場合を判定(一部だけ入力されている状態) |
---|
| 304 | if($cnt > 0 && $cnt < 3) { |
---|
| 305 | $this->arrErr[$value[1]] .= "※ " . $value[0] . "はすべての項目を入力してください。<br />"; |
---|
| 306 | } |
---|
| 307 | |
---|
| 308 | $total_count = 0; |
---|
| 309 | for($i = 1; $i <= 3; $i++) { |
---|
| 310 | if(strlen($this->arrParam[$value[$i]]) > 0 && strlen($this->arrParam[$value[$i]]) > $telItemLen) { |
---|
| 311 | $this->arrErr[$value[$i]] .= "※ " . $value[0] . $i . "は" . $telItemLen . "字以内で入力してください。<br />"; |
---|
| 312 | } else if (strlen($this->arrParam[$value[$i]]) > 0 && !EregI("^[[:digit:]]+$", $this->arrParam[$value[$i]])) { |
---|
| 313 | $this->arrErr[$value[$i]] .= "※ " . $value[0] . $i . "は数字で入力してください。<br />"; |
---|
| 314 | } |
---|
| 315 | $total_count += strlen($this->arrParam[$value[$i]]); |
---|
| 316 | } |
---|
| 317 | |
---|
| 318 | // 合計値チェック |
---|
| 319 | if ($total_count > $telLen) { |
---|
| 320 | $this->arrErr[$value[3]] .= "※ " . $value[0] . "は" . $telLen . "文字以内で入力してください。<br />"; |
---|
| 321 | } |
---|
| 322 | } |
---|
| 323 | |
---|
| 324 | /* 関連項目が完全に満たされているか判定 |
---|
| 325 | value[0] : 項目名 |
---|
| 326 | value[1] : 判定対象要素名 |
---|
| 327 | */ |
---|
| 328 | function FULL_EXIST_CHECK($value) { |
---|
| 329 | $max = count($value); |
---|
| 330 | $this->createParam($value); |
---|
| 331 | // 既に該当項目にエラーがある場合は、判定しない。 |
---|
| 332 | for($i = 1; $i < $max; $i++) { |
---|
| 333 | if(isset($this->arrErr[$value[$i]])) { |
---|
| 334 | return; |
---|
| 335 | } |
---|
| 336 | } |
---|
| 337 | |
---|
| 338 | $blank = false; |
---|
| 339 | |
---|
| 340 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
---|
| 341 | for($i = 1; $i < $max; $i++) { |
---|
| 342 | if(strlen($this->arrParam[$value[$i]]) <= 0) { |
---|
| 343 | $blank = true; |
---|
| 344 | } |
---|
| 345 | } |
---|
| 346 | |
---|
| 347 | if($blank) { |
---|
| 348 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が入力されていません。<br />"; |
---|
| 349 | } |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | /* 関連項目がすべて満たされているか判定 |
---|
| 353 | value[0] : 項目名 |
---|
| 354 | value[1] : 判定対象要素名 |
---|
| 355 | */ |
---|
| 356 | function ALL_EXIST_CHECK($value) { |
---|
| 357 | $max = count($value); |
---|
| 358 | |
---|
| 359 | // 既に該当項目にエラーがある場合は、判定しない。 |
---|
| 360 | for($i = 1; $i < $max; $i++) { |
---|
| 361 | if(isset($this->arrErr[$value[$i]])) { |
---|
| 362 | return; |
---|
| 363 | } |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | $blank = false; |
---|
| 367 | $input = false; |
---|
| 368 | |
---|
| 369 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
---|
| 370 | for($i = 1; $i < $max; $i++) { |
---|
| 371 | if(strlen($this->arrParam[$value[$i]]) <= 0) { |
---|
| 372 | $blank = true; |
---|
| 373 | } else { |
---|
| 374 | $input = true; |
---|
| 375 | } |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | if($blank && $input) { |
---|
| 379 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
---|
| 380 | } |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | /* 関連項目がどれか一つ満たされているか判定 |
---|
| 384 | value[0] : 項目名 |
---|
| 385 | value[1] : 判定対象要素名 |
---|
| 386 | */ |
---|
| 387 | function ONE_EXIST_CHECK($value) { |
---|
| 388 | $max = count($value); |
---|
| 389 | $this->createParam($value); |
---|
| 390 | // 既に該当項目にエラーがある場合は、判定しない。 |
---|
| 391 | for($i = 1; $i < $max; $i++) { |
---|
| 392 | if(isset($this->arrErr[$value[$i]])) { |
---|
| 393 | return; |
---|
| 394 | } |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | $input = false; |
---|
| 398 | |
---|
| 399 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
---|
| 400 | for($i = 1; $i < $max; $i++) { |
---|
| 401 | if(strlen($this->arrParam[$value[$i]]) > 0) { |
---|
| 402 | $input = true; |
---|
| 403 | } |
---|
| 404 | } |
---|
| 405 | |
---|
| 406 | if(!$input) { |
---|
| 407 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が入力されていません。<br />"; |
---|
| 408 | } |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | /* 上位の項目が満たされているか判定 |
---|
| 412 | value[0] : 項目名 |
---|
| 413 | value[1] : 判定対象要素名 |
---|
| 414 | */ |
---|
| 415 | function TOP_EXIST_CHECK($value) { |
---|
| 416 | $max = count($value); |
---|
| 417 | $this->createParam($value); |
---|
| 418 | |
---|
| 419 | // 既に該当項目にエラーがある場合は、判定しない。 |
---|
| 420 | for($i = 1; $i < $max; $i++) { |
---|
| 421 | if(isset($this->arrErr[$value[$i]])) { |
---|
| 422 | return; |
---|
| 423 | } |
---|
| 424 | } |
---|
| 425 | |
---|
| 426 | $blank = false; |
---|
| 427 | $error = false; |
---|
| 428 | |
---|
| 429 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
---|
| 430 | for($i = 1; $i < $max; $i++) { |
---|
| 431 | if(strlen($this->arrParam[$value[$i]]) <= 0) { |
---|
| 432 | $blank = true; |
---|
| 433 | } else { |
---|
| 434 | if($blank) { |
---|
| 435 | $error = true; |
---|
| 436 | } |
---|
| 437 | } |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | if($error) { |
---|
| 441 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は先頭の項目から順番に入力して下さい。<br />"; |
---|
| 442 | } |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | |
---|
| 446 | /* カタカナの判定 */ |
---|
| 447 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 448 | function KANA_CHECK( $value ) { // 入力文字がカナ以外ならエラーを返す |
---|
| 449 | if(isset($this->arrErr[$value[1]])) { |
---|
| 450 | return; |
---|
| 451 | } |
---|
| 452 | $this->createParam($value); |
---|
| 453 | if(strlen($this->arrParam[$value[1]]) > 0 && ! mb_ereg("^[ァ-ヶヲ-゚ー]+$", $this->arrParam[$value[1]])) { |
---|
| 454 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はカタカナで入力してください。<br />"; |
---|
| 455 | } |
---|
| 456 | } |
---|
| 457 | |
---|
| 458 | /* カタカナの判定2 (タブ、スペースは許可する) */ |
---|
| 459 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 460 | function KANABLANK_CHECK( $value ) { // 入力文字がカナ以外ならエラーを返す |
---|
| 461 | if(isset($this->arrErr[$value[1]])) { |
---|
| 462 | return; |
---|
| 463 | } |
---|
| 464 | $this->createParam($value); |
---|
| 465 | if(strlen($this->arrParam[$value[1]]) > 0 && ! mb_ereg("^([ \t\r\n]|[ァ-ヶ]|[ー])+$", $this->arrParam[$value[1]])) { |
---|
| 466 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はカタカナで入力してください。<br />"; |
---|
| 467 | } |
---|
| 468 | } |
---|
| 469 | |
---|
| 470 | /* 英数字の判定 */ |
---|
| 471 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 472 | function ALNUM_CHECK( $value ) { // 入力文字が英数字以外ならエラーを返す |
---|
| 473 | if(isset($this->arrErr[$value[1]])) { |
---|
| 474 | return; |
---|
| 475 | } |
---|
| 476 | $this->createParam($value); |
---|
| 477 | if( strlen($this->arrParam[$value[1]]) > 0 && ! EregI("^[[:alnum:]]+$", $this->arrParam[$value[1]] ) ) { |
---|
| 478 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は英数字で入力してください。<br />"; |
---|
| 479 | } |
---|
| 480 | } |
---|
| 481 | |
---|
| 482 | /* 英数記号の判定 */ |
---|
| 483 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 484 | function GRAPH_CHECK( $value ) { // 入力文字が英数記号以外ならエラーを返す |
---|
| 485 | if(isset($this->arrErr[$value[1]])) { |
---|
| 486 | return; |
---|
| 487 | } |
---|
| 488 | $this->createParam($value); |
---|
| 489 | if( strlen($this->arrParam[$value[1]]) > 0 && ! EregI("^[[:graph:]|[:space:]]+$", $this->arrParam[$value[1]] ) ) { |
---|
| 490 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は英数記号で入力してください。<br />"; |
---|
| 491 | } |
---|
| 492 | } |
---|
| 493 | |
---|
| 494 | /* 必須選択の判定 */ |
---|
| 495 | // value[0] = 項目名 value[1] = 判定対象 |
---|
| 496 | function ZERO_CHECK( $value ) { // 入力値で0が許されない場合エラーを返す |
---|
| 497 | $this->createParam($value); |
---|
| 498 | if($this->arrParam[$value[1]] == "0" ){ |
---|
| 499 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は1以上を入力してください。<br />"; |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | |
---|
| 503 | /* 桁数の判定 (最小最大)*/ |
---|
| 504 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小桁数 value[3] = 最大桁数 |
---|
| 505 | function NUM_RANGE_CHECK( $value ) { // 入力文字の桁数判定 → 最小桁数<入力文字列<最大桁数 |
---|
| 506 | if(isset($this->arrErr[$value[1]])) { |
---|
| 507 | return; |
---|
| 508 | } |
---|
| 509 | $this->createParam($value); |
---|
| 510 | // $this->arrParam[$value[0]] = mb_convert_kana($this->arrParam[$value[0]], "n"); |
---|
| 511 | $count = strlen($this->arrParam[$value[1]]); |
---|
| 512 | if( ( $count > 0 ) && $value[2] > $count || $value[3] < $count ) { |
---|
| 513 | $this->arrErr[$value[1]] = "※ $value[0]は$value[2]桁~$value[3]桁で入力して下さい。<br />"; |
---|
| 514 | } |
---|
| 515 | } |
---|
| 516 | |
---|
| 517 | /* 桁数の判定 */ |
---|
| 518 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 桁数 |
---|
| 519 | function NUM_COUNT_CHECK( $value ) { // 入力文字の桁数判定 → 入力文字列 = 桁数 以外はNGの場合 |
---|
| 520 | if(isset($this->arrErr[$value[1]])) { |
---|
| 521 | return; |
---|
| 522 | } |
---|
| 523 | $this->createParam($value); |
---|
| 524 | $count = strlen($this->arrParam[$value[1]]); |
---|
| 525 | if(($count > 0) && $count != $value[2] ) { |
---|
| 526 | $this->arrErr[$value[1]] = "※ $value[0]は$value[2]桁で入力して下さい。<br />"; |
---|
| 527 | } |
---|
| 528 | } |
---|
| 529 | |
---|
| 530 | /* メールアドレス形式の判定 */ |
---|
| 531 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
---|
| 532 | function EMAIL_CHECK( $value ){ // メールアドレスを正規表現で判定する |
---|
| 533 | if(isset($this->arrErr[$value[1]])) { |
---|
| 534 | return; |
---|
| 535 | } |
---|
| 536 | $this->createParam($value); |
---|
| 537 | |
---|
| 538 | $wsp = '[\x20\x09]'; |
---|
| 539 | $vchar = '[\x21-\x7e]'; |
---|
| 540 | $quoted_pair = "\\\\(?:$vchar|$wsp)"; |
---|
| 541 | $qtext = '[\x21\x23-\x5b\x5d-\x7e]'; |
---|
| 542 | $qcontent = "(?:$qtext|$quoted_pair)"; |
---|
| 543 | $quoted_string = "\"$qcontent*\""; |
---|
| 544 | $atext = '[a-zA-Z0-9!#$%&\'*+\-\/\=?^_`{|}~]'; |
---|
| 545 | $dot_atom_text = "$atext+(?:[.]$atext+)*"; |
---|
| 546 | $dot_atom = $dot_atom_text; |
---|
| 547 | $local_part = "(?:$dot_atom|$quoted_string)"; |
---|
| 548 | $domain = $dot_atom; |
---|
| 549 | $addr_spec = "${local_part}[@]$domain"; |
---|
| 550 | |
---|
| 551 | $dot_atom_loose = "$atext+(?:[.]|$atext)*"; |
---|
| 552 | $local_part_loose = "(?:$dot_atom_loose|$quoted_string)"; |
---|
| 553 | $addr_spec_loose = "${local_part_loose}[@]$domain"; |
---|
| 554 | |
---|
| 555 | if (RFC_COMPLIANT_EMAIL_CHECK) { |
---|
| 556 | $regexp = "/\A${addr_spec}\z/"; |
---|
| 557 | } else { |
---|
| 558 | // 携帯メールアドレス用に、..や.@を許容する。 |
---|
| 559 | $regexp = "/\A${addr_spec_loose}\z/"; |
---|
| 560 | } |
---|
| 561 | |
---|
| 562 | if(strlen($this->arrParam[$value[1]]) > 0 && !preg_match($regexp, $this->arrParam[$value[1]])) { |
---|
| 563 | $this->arrErr[$value[1]] = "※ " . $value[0] . "の形式が不正です。<br />"; |
---|
| 564 | } |
---|
| 565 | } |
---|
| 566 | |
---|
| 567 | /* メールアドレスに使用できる文字の判定 */ |
---|
| 568 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
---|
| 569 | function EMAIL_CHAR_CHECK( $value ){ // メールアドレスに使用する文字を正規表現で判定する |
---|
| 570 | if(isset($this->arrErr[$value[1]])) { |
---|
| 571 | return; |
---|
| 572 | } |
---|
| 573 | $this->createParam($value); |
---|
| 574 | if(strlen($this->arrParam[$value[1]]) > 0 && !ereg("^[a-zA-Z0-9_\.@\+\?-]+$",$this->arrParam[$value[1]]) ) { |
---|
| 575 | $this->arrErr[$value[1]] = "※ " . $value[0] . "に使用する文字を正しく入力してください。<br />"; |
---|
| 576 | } |
---|
| 577 | } |
---|
| 578 | |
---|
| 579 | /* URL形式の判定 */ |
---|
| 580 | // value[0] = 項目名 value[1] = 判定対象URL |
---|
| 581 | function URL_CHECK( $value ){ // URLを正規表現で判定する。デフォルトでhttp://があってもOK |
---|
| 582 | if(isset($this->arrErr[$value[1]])) { |
---|
| 583 | return; |
---|
| 584 | } |
---|
| 585 | if( strlen($this->arrParam[$value[1]]) > 0 && !ereg( "^https?://+($|[a-zA-Z0-9_~=:&\?\.\/-])+$", $this->arrParam[$value[1]] ) ) { |
---|
| 586 | $this->arrErr[$value[1]] = "※ " . $value[0] . "を正しく入力してください。<br />"; |
---|
| 587 | } |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | /* IPアドレスの判定 */ |
---|
| 591 | // value[0] = 項目名 value[1] = 判定対象IPアドレス文字列 |
---|
| 592 | function IP_CHECK( $value ){ |
---|
| 593 | if(isset($this->arrErr[$value[1]])) { |
---|
| 594 | return; |
---|
| 595 | } |
---|
| 596 | //改行コードが含まれている場合には配列に変換 |
---|
| 597 | $params = str_replace("\r","",$this->arrParam[$value[1]]); |
---|
| 598 | if(!empty($params)){ |
---|
| 599 | if(strpos($params,"\n") === false){ |
---|
| 600 | $params .= "\n"; |
---|
| 601 | } |
---|
| 602 | $params = explode("\n",$params); |
---|
| 603 | foreach($params as $param){ |
---|
| 604 | $param = trim($param); |
---|
| 605 | if(long2ip(ip2long($param)) != trim($param) and !empty($param)) { |
---|
| 606 | $this->arrErr[$value[1]] = "※ " . $value[0] . "に正しい形式のIPアドレスを入力してください。<br />"; |
---|
| 607 | } |
---|
| 608 | } |
---|
| 609 | } |
---|
| 610 | } |
---|
| 611 | |
---|
| 612 | /* 拡張子の判定 */ |
---|
| 613 | // value[0] = 項目名 value[1] = 判定対象 value[2]=array(拡張子) |
---|
| 614 | function FILE_EXT_CHECK( $value ) { // 受け取りがない場合エラーを返す |
---|
| 615 | if(isset($this->arrErr[$value[1]]) || count($value[2]) == 0) { |
---|
| 616 | return; |
---|
| 617 | } |
---|
| 618 | $this->createParam($value); |
---|
| 619 | |
---|
| 620 | if($_FILES[$value[1]]['name'] != "" ) { |
---|
| 621 | $errFlag = 1; |
---|
| 622 | $array_ext = explode(".", $_FILES[$value[1]]['name']); |
---|
| 623 | |
---|
| 624 | $strExt = ""; |
---|
| 625 | |
---|
| 626 | foreach ( $value[2] as $checkExt ){ |
---|
| 627 | $ext = ""; |
---|
| 628 | |
---|
| 629 | // チェック拡張子のピリオドの数を取得('tar.gz'の場合1個、'jpg'のように通常は0個) |
---|
| 630 | $count_period = substr_count($checkExt, "."); |
---|
| 631 | |
---|
| 632 | if($count_period > 0) { |
---|
| 633 | for($i = max(array_keys($array_ext)) - $count_period; $i < count($array_ext); $i++) { |
---|
| 634 | $ext .= $array_ext[$i] . "."; |
---|
| 635 | } |
---|
| 636 | $ext = preg_replace("/.$/", "" ,$ext); |
---|
| 637 | } else { |
---|
| 638 | $ext = $array_ext[ count ( $array_ext ) - 1 ]; |
---|
| 639 | } |
---|
| 640 | |
---|
| 641 | $ext = strtolower($ext); |
---|
| 642 | |
---|
| 643 | if ( $ext == $checkExt) { |
---|
| 644 | $errFlag = 0; |
---|
| 645 | } |
---|
| 646 | |
---|
| 647 | if($strExt == "") { |
---|
| 648 | $strExt.= $checkExt; |
---|
| 649 | } else { |
---|
| 650 | $strExt.= "・$checkExt"; |
---|
| 651 | } |
---|
| 652 | } |
---|
| 653 | } |
---|
| 654 | if ($errFlag == 1) { |
---|
| 655 | $this->arrErr[$value[1]] = "※ " . $value[0] . "で許可されている形式は、" . $strExt . "です。<br />"; |
---|
| 656 | } |
---|
| 657 | } |
---|
| 658 | |
---|
| 659 | /* ファイルが存在するかチェックする */ |
---|
| 660 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定ディレクトリ |
---|
| 661 | function FIND_FILE( $value ) { // 受け取りがない場合エラーを返す |
---|
| 662 | if(isset($this->arrErr[$value[1]])) { |
---|
| 663 | return; |
---|
| 664 | } |
---|
| 665 | |
---|
| 666 | $this->createParam($value); |
---|
| 667 | if($value[2] != "") { |
---|
| 668 | $dir = $value[2]; |
---|
| 669 | } else { |
---|
| 670 | $dir = IMAGE_SAVE_REALDIR; |
---|
| 671 | } |
---|
| 672 | |
---|
| 673 | $path = $dir . "/" . $this->arrParam[$value[1]]; |
---|
| 674 | $path = ereg_replace("//", "/", $path); |
---|
| 675 | |
---|
| 676 | if($this->arrParam[$value[1]] != "" && !file_exists($path)){ |
---|
| 677 | $this->arrErr[$value[1]] = "※ " . $path . "が見つかりません。<br />"; |
---|
| 678 | } |
---|
| 679 | } |
---|
| 680 | |
---|
| 681 | /* ファイルが上げられたか確認 */ |
---|
| 682 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定サイズ(KB) |
---|
| 683 | function FILE_EXIST_CHECK( $value ) { // 受け取りがない場合エラーを返す |
---|
| 684 | if(isset($this->arrErr[$value[1]])) { |
---|
| 685 | return; |
---|
| 686 | } |
---|
| 687 | $this->createParam($value); |
---|
| 688 | if(!($_FILES[$value[1]]['size'] != "" && $_FILES[$value[1]]['size'] > 0)){ |
---|
| 689 | $this->arrErr[$value[1]] = "※ " . $value[0] . "をアップロードして下さい。<br />"; |
---|
| 690 | } |
---|
| 691 | } |
---|
| 692 | |
---|
| 693 | /* ファイルサイズの判定 */ |
---|
| 694 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定サイズ(KB) |
---|
| 695 | function FILE_SIZE_CHECK( $value ) { // 受け取りがない場合エラーを返す |
---|
| 696 | if(isset($this->arrErr[$value[1]])) { |
---|
| 697 | return; |
---|
| 698 | } |
---|
| 699 | $this->createParam($value); |
---|
| 700 | if( $_FILES[$value[1]]['size'] > $value[2] * 1024 ){ |
---|
| 701 | $byte = "KB"; |
---|
| 702 | if( $value[2] >= 1000 ) { |
---|
| 703 | $value[2] = $value[2] / 1000; |
---|
| 704 | $byte = "MB"; |
---|
| 705 | } |
---|
| 706 | $this->arrErr[$value[1]] = "※ " . $value[0] . "のファイルサイズは" . $value[2] . $byte . "以下のものを使用してください。<br />"; |
---|
| 707 | } |
---|
| 708 | } |
---|
| 709 | |
---|
| 710 | /* ファイル名の判定 */ |
---|
| 711 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 712 | function FILE_NAME_CHECK( $value ) { // 入力文字が英数字,"_","-"以外ならエラーを返す |
---|
| 713 | if(isset($this->arrErr[$value[1]])) { |
---|
| 714 | return; |
---|
| 715 | } |
---|
| 716 | $this->createParam($value); |
---|
| 717 | if( strlen($_FILES[$value[1]]['name']) > 0 && ! EregI("^[[:alnum:]_\.-]+$", $_FILES[$value[1]]['name']) ) { |
---|
| 718 | $this->arrErr[$value[1]] = "※ " . $value[0] . "のファイル名に日本語やスペースは使用しないで下さい。<br />"; |
---|
| 719 | } |
---|
| 720 | } |
---|
| 721 | |
---|
| 722 | /* ファイル名の判定(アップロード以外の時) */ |
---|
| 723 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 724 | function FILE_NAME_CHECK_BY_NOUPLOAD( $value ) { // 入力文字が英数字,"_","-"以外ならエラーを返す |
---|
| 725 | if(isset($this->arrErr[$value[1]])) { |
---|
| 726 | return; |
---|
| 727 | } |
---|
| 728 | $this->createParam($value); |
---|
| 729 | if( strlen($this->arrParam[$value[1]]) > 0 && ! EregI("^[[:alnum:]_\.-]+$", $this->arrParam[$value[1]]) || EregI("[\\]" ,$this->arrParam[$value[1]])) { |
---|
| 730 | $this->arrErr[$value[1]] = "※ " . $value[0] . "のファイル名に日本語やスペースは使用しないで下さい。<br />"; |
---|
| 731 | } |
---|
| 732 | } |
---|
| 733 | |
---|
| 734 | //日付チェック |
---|
| 735 | // value[0] = 項目名 |
---|
| 736 | // value[1] = YYYY |
---|
| 737 | // value[2] = MM |
---|
| 738 | // value[3] = DD |
---|
| 739 | function CHECK_DATE($value) { |
---|
| 740 | if(isset($this->arrErr[$value[1]])) { |
---|
| 741 | return; |
---|
| 742 | } |
---|
| 743 | $this->createParam($value); |
---|
| 744 | // 少なくともどれか一つが入力されている。 |
---|
| 745 | if($this->arrParam[$value[1]] > 0 || $this->arrParam[$value[2]] > 0 || $this->arrParam[$value[3]] > 0) { |
---|
| 746 | // 年月日のどれかが入力されていない。 |
---|
| 747 | if(!(strlen($this->arrParam[$value[1]]) > 0 && strlen($this->arrParam[$value[2]]) > 0 && strlen($this->arrParam[$value[3]]) > 0)) { |
---|
| 748 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
---|
| 749 | } else if ( ! checkdate($this->arrParam[$value[2]], $this->arrParam[$value[3]], $this->arrParam[$value[1]])) { |
---|
| 750 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が正しくありません。<br />"; |
---|
| 751 | } |
---|
| 752 | } |
---|
| 753 | } |
---|
| 754 | |
---|
| 755 | //日付チェック |
---|
| 756 | // value[0] = 項目名 |
---|
| 757 | // value[1] = YYYY |
---|
| 758 | // value[2] = MM |
---|
| 759 | // value[3] = DD |
---|
| 760 | // value[4] = HH |
---|
| 761 | // value[5] = mm |
---|
| 762 | function CHECK_DATE2($value) { |
---|
| 763 | if(isset($this->arrErr[$value[1]])) { |
---|
| 764 | return; |
---|
| 765 | } |
---|
| 766 | $this->createParam($value); |
---|
| 767 | // 少なくともどれか一つが入力されている。 |
---|
| 768 | if($this->arrParam[$value[1]] > 0 || $this->arrParam[$value[2]] > 0 || $this->arrParam[$value[3]] > 0 || $this->arrParam[$value[4]] >= 0 || $this->arrParam[$value[5]] >= 0) { |
---|
| 769 | // 年月日時のどれかが入力されていない。 |
---|
| 770 | if(!(strlen($this->arrParam[$value[1]]) > 0 && strlen($this->arrParam[$value[2]]) > 0 && strlen($this->arrParam[$value[3]]) > 0 && strlen($this->arrParam[$value[4]]) > 0 && strlen($this->arrParam[$value[5]]) > 0 )) { |
---|
| 771 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
---|
| 772 | } else if ( ! checkdate($this->arrParam[$value[2]], $this->arrParam[$value[3]], $this->arrParam[$value[1]])) { |
---|
| 773 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が正しくありません。<br />"; |
---|
| 774 | } |
---|
| 775 | } |
---|
| 776 | } |
---|
| 777 | |
---|
| 778 | //日付チェック |
---|
| 779 | // value[0] = 項目名 |
---|
| 780 | // value[1] = YYYY |
---|
| 781 | // value[2] = MM |
---|
| 782 | function CHECK_DATE3($value) { |
---|
| 783 | if(isset($this->arrErr[$value[1]])) { |
---|
| 784 | return; |
---|
| 785 | } |
---|
| 786 | $this->createParam($value); |
---|
| 787 | // 少なくともどれか一つが入力されている。 |
---|
| 788 | if($this->arrParam[$value[1]] > 0 || $this->arrParam[$value[2]] > 0) { |
---|
| 789 | // 年月日時のどれかが入力されていない。 |
---|
| 790 | if(!(strlen($this->arrParam[$value[1]]) > 0 && strlen($this->arrParam[$value[2]]) > 0)) { |
---|
| 791 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
---|
| 792 | } else if ( ! checkdate($this->arrParam[$value[2]], 1, $this->arrParam[$value[1]])) { |
---|
| 793 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が正しくありません。<br />"; |
---|
| 794 | } |
---|
| 795 | } |
---|
| 796 | } |
---|
| 797 | |
---|
| 798 | //誕生日チェック |
---|
| 799 | // value[0] = 項目名 |
---|
| 800 | // value[1] = YYYY |
---|
| 801 | // value[2] = MM |
---|
| 802 | // value[3] = DD |
---|
| 803 | function CHECK_BIRTHDAY($value) { |
---|
| 804 | if (isset($this->arrErr[$value[1]])) { |
---|
| 805 | return; |
---|
| 806 | } |
---|
| 807 | |
---|
| 808 | $this->createParam($value); |
---|
| 809 | // 年が入力されている。 |
---|
| 810 | if ($this->arrParam[$value[1]] > 0) { |
---|
| 811 | |
---|
| 812 | // 年の数字チェック、最小数値制限チェック |
---|
| 813 | $this->doFunc(array($value[0].'(年)', $value[1], START_BIRTH_YEAR), array("NUM_CHECK", "MIN_CHECK")); |
---|
| 814 | // 上のチェックでエラーある場合、中断する。 |
---|
| 815 | if (isset($this->arrErr[$value[1]])) { |
---|
| 816 | return; |
---|
| 817 | } |
---|
| 818 | |
---|
| 819 | // 年の最大数値制限チェック |
---|
| 820 | $this->doFunc(array($value[0].'(年)', $value[1], date("Y",strtotime("now"))), array("MAX_CHECK")); |
---|
| 821 | // 上のチェックでエラーある場合、中断する。 |
---|
| 822 | if (isset($this->arrErr[$value[1]])) { |
---|
| 823 | return; |
---|
| 824 | } |
---|
| 825 | } |
---|
| 826 | |
---|
| 827 | // XXX createParam() が二重に呼ばれる問題を抱える |
---|
| 828 | $this->CHECK_DATE($value); |
---|
| 829 | } |
---|
| 830 | |
---|
| 831 | /*-----------------------------------------------------------------*/ |
---|
| 832 | /* CHECK_SET_TERM |
---|
| 833 | /* 年月日に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
---|
| 834 | /* 引数 (開始年,開始月,開始日,終了年,終了月,終了日) |
---|
| 835 | /* 戻値 array(1,2,3) |
---|
| 836 | /* 1.開始年月日 (YYYYMMDD 000000) |
---|
| 837 | /* 2.終了年月日 (YYYYMMDD 235959) |
---|
| 838 | /* 3.エラー ( 0 = OK, 1 = NG ) |
---|
| 839 | /*-----------------------------------------------------------------*/ |
---|
| 840 | // value[0] = 項目名1 |
---|
| 841 | // value[1] = 項目名2 |
---|
| 842 | // value[2] = start_year |
---|
| 843 | // value[3] = start_month |
---|
| 844 | // value[4] = start_day |
---|
| 845 | // value[5] = end_year |
---|
| 846 | // value[6] = end_month |
---|
| 847 | // value[7] = end_day |
---|
| 848 | function CHECK_SET_TERM ($value) { |
---|
| 849 | |
---|
| 850 | // 期間指定 |
---|
| 851 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[5]])) { |
---|
| 852 | return; |
---|
| 853 | } |
---|
| 854 | $this->createParam($value); |
---|
| 855 | $error = 0; |
---|
| 856 | if ( (strlen($this->arrParam[$value[2]]) > 0 || strlen($this->arrParam[$value[3]]) > 0 || strlen($this->arrParam[$value[4]] ) > 0) && ! checkdate($this->arrParam[$value[3]], $this->arrParam[$value[4]], $this->arrParam[$value[2]]) ) { |
---|
| 857 | $this->arrErr[$value[2]] = "※ " . $value[0] . "を正しく指定してください。<br />"; |
---|
| 858 | } |
---|
| 859 | if ( (strlen($this->arrParam[$value[5]]) > 0 || strlen($this->arrParam[$value[6]]) > 0 || strlen($this->arrParam[$value[7]] ) > 0) && ! checkdate($this->arrParam[$value[6]], $this->arrParam[$value[7]], $this->arrParam[$value[5]]) ) { |
---|
| 860 | $this->arrErr[$value[5]] = "※ " . $value[1] . "を正しく指定してください。<br />"; |
---|
| 861 | } |
---|
| 862 | if ( (strlen($this->arrParam[$value[2]]) > 0 && strlen($this->arrParam[$value[3]]) > 0 && strlen($this->arrParam[$value[4]] ) > 0) && (strlen($this->arrParam[$value[5]]) > 0 || strlen($this->arrParam[$value[6]]) > 0 || strlen($this->arrParam[$value[7]] ) > 0) ){ |
---|
| 863 | |
---|
| 864 | $date1 = $this->arrParam[$value[2]] .sprintf("%02d", $this->arrParam[$value[3]]) .sprintf("%02d",$this->arrParam[$value[4]]) ."000000"; |
---|
| 865 | $date2 = $this->arrParam[$value[5]] .sprintf("%02d", $this->arrParam[$value[6]]) .sprintf("%02d",$this->arrParam[$value[7]]) ."235959"; |
---|
| 866 | |
---|
| 867 | if (($this->arrErr[$value[2]] == "" && $this->arrErr[$value[5]] == "") && $date1 > $date2) { |
---|
| 868 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
---|
| 869 | } |
---|
| 870 | } |
---|
| 871 | } |
---|
| 872 | |
---|
| 873 | /*-----------------------------------------------------------------*/ |
---|
| 874 | /* CHECK_SET_TERM2 |
---|
| 875 | /* 年月日時に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
---|
| 876 | /* 引数 (開始年,開始月,開始日,開始時間,開始分,開始秒, |
---|
| 877 | /* 終了年,終了月,終了日,終了時間,終了分,終了秒) |
---|
| 878 | /* 戻値 array(1,2,3) |
---|
| 879 | /* 1.開始年月日 (YYYYMMDDHHmmss) |
---|
| 880 | /* 2.終了年月日 (YYYYMMDDHHmmss) |
---|
| 881 | /* 3.エラー ( 0 = OK, 1 = NG ) |
---|
| 882 | /*-----------------------------------------------------------------*/ |
---|
| 883 | // value[0] = 項目名1 |
---|
| 884 | // value[1] = 項目名2 |
---|
| 885 | // value[2] = start_year |
---|
| 886 | // value[3] = start_month |
---|
| 887 | // value[4] = start_day |
---|
| 888 | // value[5] = start_hour |
---|
| 889 | // value[6] = start_minute |
---|
| 890 | // value[7] = start_second |
---|
| 891 | // value[8] = end_year |
---|
| 892 | // value[9] = end_month |
---|
| 893 | // value[10] = end_day |
---|
| 894 | // value[11] = end_hour |
---|
| 895 | // value[12] = end_minute |
---|
| 896 | // value[13] = end_second |
---|
| 897 | |
---|
| 898 | /*-----------------------------------------------------------------*/ |
---|
| 899 | function CHECK_SET_TERM2 ($value) { |
---|
| 900 | |
---|
| 901 | // 期間指定 |
---|
| 902 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[8]])) { |
---|
| 903 | return; |
---|
| 904 | } |
---|
| 905 | $this->createParam($value); |
---|
| 906 | $error = 0; |
---|
| 907 | if ( (strlen($this->arrParam[$value[2]]) > 0 || strlen($this->arrParam[$value[3]]) > 0 || strlen($this->arrParam[$value[4]] ) > 0 || strlen($this->arrParam[$value[5]]) > 0) && ! checkdate($this->arrParam[$value[3]], $this->arrParam[$value[4]], $this->arrParam[$value[2]]) ) { |
---|
| 908 | $this->arrErr[$value[2]] = "※ " . $value[0] . "を正しく指定してください。<br />"; |
---|
| 909 | } |
---|
| 910 | if ( (strlen($this->arrParam[$value[8]]) > 0 || strlen($this->arrParam[$value[9]]) > 0 || strlen($this->arrParam[$value[10]] ) > 0 || strlen($this->arrParam[$value[11]] ) > 0) && ! checkdate($this->arrParam[$value[9]], $this->arrParam[$value[10]], $this->arrParam[$value[8]]) ) { |
---|
| 911 | $this->arrErr[$value[8]] = "※ " . $value[1] . "を正しく指定してください。<br />"; |
---|
| 912 | } |
---|
| 913 | if ( (strlen($this->arrParam[$value[2]]) > 0 && strlen($this->arrParam[$value[3]]) > 0 && strlen($this->arrParam[$value[4]] ) > 0 && strlen($this->arrParam[$value[5]] ) > 0) && (strlen($this->arrParam[$value[8]]) > 0 || strlen($this->arrParam[$value[9]]) > 0 || strlen($this->arrParam[$value[10]] ) > 0 || strlen($this->arrParam[$value[11]] ) > 0) ){ |
---|
| 914 | |
---|
| 915 | $date1 = $this->arrParam[$value[2]] .sprintf("%02d", $this->arrParam[$value[3]]) .sprintf("%02d",$this->arrParam[$value[4]]) .sprintf("%02d",$this->arrParam[$value[5]]).sprintf("%02d",$this->arrParam[$value[6]]).sprintf("%02d",$this->arrParam[$value[7]]); |
---|
| 916 | $date2 = $this->arrParam[$value[8]] .sprintf("%02d", $this->arrParam[$value[9]]) .sprintf("%02d",$this->arrParam[$value[10]]) .sprintf("%02d",$this->arrParam[$value[11]]).sprintf("%02d",$this->arrParam[$value[12]]).sprintf("%02d",$this->arrParam[$value[13]]); |
---|
| 917 | |
---|
| 918 | if (($this->arrErr[$value[2]] == "" && $this->arrErr[$value[8]] == "") && $date1 > $date2) { |
---|
| 919 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
---|
| 920 | } |
---|
| 921 | if($date1 == $date2) { |
---|
| 922 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
---|
| 923 | } |
---|
| 924 | |
---|
| 925 | } |
---|
| 926 | } |
---|
| 927 | |
---|
| 928 | /*-----------------------------------------------------------------*/ |
---|
| 929 | /* CHECK_SET_TERM3 |
---|
| 930 | /* 年月に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
---|
| 931 | /* 引数 (開始年,開始月,終了年,終了月) |
---|
| 932 | /* 戻値 array(1,2,3) |
---|
| 933 | /* 1.開始年月日 (YYYYMMDD 000000) |
---|
| 934 | /* 2.終了年月日 (YYYYMMDD 235959) |
---|
| 935 | /* 3.エラー ( 0 = OK, 1 = NG ) |
---|
| 936 | /*-----------------------------------------------------------------*/ |
---|
| 937 | // value[0] = 項目名1 |
---|
| 938 | // value[1] = 項目名2 |
---|
| 939 | // value[2] = start_year |
---|
| 940 | // value[3] = start_month |
---|
| 941 | // value[4] = end_year |
---|
| 942 | // value[5] = end_month |
---|
| 943 | function CHECK_SET_TERM3 ($value) { |
---|
| 944 | |
---|
| 945 | // 期間指定 |
---|
| 946 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[4]])) { |
---|
| 947 | return; |
---|
| 948 | } |
---|
| 949 | $this->createParam($value); |
---|
| 950 | $error = 0; |
---|
| 951 | if ( (strlen($this->arrParam[$value[2]]) > 0 || strlen($this->arrParam[$value[3]]) > 0) && ! checkdate($this->arrParam[$value[3]], 1, $this->arrParam[$value[2]]) ) { |
---|
| 952 | $this->arrErr[$value[2]] = "※ " . $value[0] . "を正しく指定してください。<br />"; |
---|
| 953 | } |
---|
| 954 | if ( (strlen($this->arrParam[$value[4]]) > 0 || strlen($this->arrParam[$value[5]]) > 0) && ! checkdate($this->arrParam[$value[5]], 1, $this->arrParam[$value[4]]) ) { |
---|
| 955 | $this->arrErr[$value[4]] = "※ " . $value[1] . "を正しく指定してください。<br />"; |
---|
| 956 | } |
---|
| 957 | if ( (strlen($this->arrParam[$value[2]]) > 0 && strlen($this->arrParam[$value[3]]) > 0 && (strlen($this->arrParam[$value[4]]) > 0 || strlen($this->arrParam[$value[5]]) > 0 ))) { |
---|
| 958 | |
---|
| 959 | $date1 = $this->arrParam[$value[2]] .sprintf("%02d", $this->arrParam[$value[3]]); |
---|
| 960 | $date2 = $this->arrParam[$value[4]] .sprintf("%02d", $this->arrParam[$value[5]]); |
---|
| 961 | |
---|
| 962 | if (($this->arrErr[$value[2]] == "" && $this->arrErr[$value[5]] == "") && $date1 > $date2) { |
---|
| 963 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
---|
| 964 | } |
---|
| 965 | } |
---|
| 966 | } |
---|
| 967 | |
---|
| 968 | //ディレクトリ存在チェック |
---|
| 969 | function DIR_CHECK ($value) { |
---|
| 970 | if(isset($this->arrErr[$value[1]])) { |
---|
| 971 | return; |
---|
| 972 | } |
---|
| 973 | $this->createParam($value); |
---|
| 974 | if(!is_dir($this->arrParam[$value[1]])) { |
---|
| 975 | $this->arrErr[$value[1]] = "※ 指定した" . $value[0] . "は存在しません。<br />"; |
---|
| 976 | } |
---|
| 977 | } |
---|
| 978 | |
---|
| 979 | //ディレクトリ存在チェック |
---|
| 980 | function DOMAIN_CHECK ($value) { |
---|
| 981 | if(isset($this->arrErr[$value[1]])) { |
---|
| 982 | return; |
---|
| 983 | } |
---|
| 984 | if(strlen($this->arrParam[$value[1]]) > 0 && !ereg("^\.[^.]+\..+", $this->arrParam[$value[1]])) { |
---|
| 985 | $this->arrErr[$value[1]] = "※ " . $value[0] . "の形式が不正です。<br />"; |
---|
| 986 | } |
---|
| 987 | } |
---|
| 988 | |
---|
| 989 | /* 携帯メールアドレスの判定 */ |
---|
| 990 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
---|
| 991 | function MOBILE_EMAIL_CHECK( $value ){ // メールアドレスを正規表現で判定する |
---|
| 992 | if(isset($this->arrErr[$value[1]])) { |
---|
| 993 | return; |
---|
| 994 | } |
---|
| 995 | $this->createParam($value); |
---|
| 996 | $objMobile = new SC_Helper_Mobile_Ex(); |
---|
| 997 | if(strlen($this->arrParam[$value[1]]) > 0 && !$objMobile->gfIsMobileMailAddress($this->arrParam[$value[1]])) { |
---|
| 998 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は携帯電話のものではありません。<br />"; |
---|
| 999 | } |
---|
| 1000 | } |
---|
| 1001 | |
---|
| 1002 | /** |
---|
| 1003 | * CHECK_REGIST_CUSTOMER_EMAIL |
---|
| 1004 | * |
---|
| 1005 | * メールアドレスが会員登録されているか調べる |
---|
| 1006 | * value[0] = 項目名 value[1] = 判定対象メールアドレス |
---|
| 1007 | * |
---|
| 1008 | * @param mixed $value |
---|
| 1009 | * @access public |
---|
| 1010 | * @return void |
---|
| 1011 | */ |
---|
| 1012 | function CHECK_REGIST_CUSTOMER_EMAIL ($value) { |
---|
| 1013 | if(isset($this->arrErr[$value[1]])) { |
---|
| 1014 | return; |
---|
| 1015 | } |
---|
| 1016 | $this->createParam($value); |
---|
| 1017 | |
---|
| 1018 | $register_user_flg = SC_Helper_Customer_Ex::sfCheckRegisterUserFromEmail($this->arrParam[$value[1]]); |
---|
| 1019 | switch($register_user_flg) { |
---|
| 1020 | case 1: |
---|
| 1021 | $this->arrErr[$value[1]] .= "※ すでに会員登録で使用されている" . $value[0] . "です。<br />"; |
---|
| 1022 | break; |
---|
| 1023 | case 2: |
---|
| 1024 | $this->arrErr[$value[1]] .= "※ 退会から一定期間の間は、同じ" . $value[0] . "を使用することはできません。<br />"; |
---|
| 1025 | break; |
---|
| 1026 | default: |
---|
| 1027 | break; |
---|
| 1028 | } |
---|
| 1029 | } |
---|
| 1030 | |
---|
| 1031 | |
---|
| 1032 | /** |
---|
| 1033 | * 禁止文字列のチェック |
---|
| 1034 | * value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 1035 | * value[2] = 入力を禁止する文字列(配列) |
---|
| 1036 | * |
---|
| 1037 | * @example $objErr->doFunc(array("URL", "contents", $arrReviewDenyURL), array("PROHIBITED_STR_CHECK")); |
---|
| 1038 | */ |
---|
| 1039 | function PROHIBITED_STR_CHECK( $value ) { |
---|
| 1040 | if( isset($this->arrErr[$value[1]]) || empty($this->arrParam[$value[1]]) ) { |
---|
| 1041 | return; |
---|
| 1042 | } |
---|
| 1043 | $this->createParam($value); |
---|
| 1044 | $targetStr = $this->arrParam[$value[1]]; |
---|
| 1045 | $prohibitedStr = str_replace(array('|', '/'), array('\|', '\/'), $value[2]); |
---|
| 1046 | |
---|
| 1047 | $pattern = '/' . join('|', $prohibitedStr) . '/i'; |
---|
| 1048 | if(preg_match_all($pattern, $this->arrParam[$value[1]], $matches)) { |
---|
| 1049 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は入力できません。<br />"; |
---|
| 1050 | } |
---|
| 1051 | } |
---|
| 1052 | |
---|
| 1053 | /** |
---|
| 1054 | * PHPコードとして評価可能かチェックする. |
---|
| 1055 | * |
---|
| 1056 | * @access private |
---|
| 1057 | * @param array $value [0] => 項目名, [1] => 評価する文字列 |
---|
| 1058 | * @return void |
---|
| 1059 | */ |
---|
| 1060 | function EVAL_CHECK($value) { |
---|
| 1061 | if (isset($this->arrErr[$value[0]])) { |
---|
| 1062 | return; |
---|
| 1063 | } |
---|
| 1064 | $this->createParam($value); |
---|
| 1065 | if ($this->evalCheck($value[1]) === false) { |
---|
| 1066 | $this->arrErr[$value[0]] = "※ " . $value[0] . " の形式が不正です。<br />"; |
---|
| 1067 | } |
---|
| 1068 | } |
---|
| 1069 | |
---|
| 1070 | /** |
---|
| 1071 | * $value が PHPコードとして評価可能かチェックする. |
---|
| 1072 | * |
---|
| 1073 | * @access private |
---|
| 1074 | * @param mixed PHPコードとして評価する文字列 |
---|
| 1075 | * @return mixed PHPコードとして評価できない場合 false, |
---|
| 1076 | * 評価可能な場合は評価した値 |
---|
| 1077 | */ |
---|
| 1078 | function evalCheck($value) { |
---|
| 1079 | // falseは、正当な式と評価する。 |
---|
| 1080 | if($value === "false") { |
---|
| 1081 | return true; |
---|
| 1082 | } |
---|
| 1083 | return @eval("return " . $value . ";"); |
---|
| 1084 | } |
---|
| 1085 | |
---|
| 1086 | /** |
---|
| 1087 | * 未定義の $this->arrParam に空要素を代入する. |
---|
| 1088 | * |
---|
| 1089 | * @access private |
---|
| 1090 | * @param array $value 配列 |
---|
| 1091 | * @return void |
---|
| 1092 | */ |
---|
| 1093 | function createParam($value) { |
---|
| 1094 | foreach ($value as $key) { |
---|
| 1095 | if (is_string($key) || is_int($key)) { |
---|
| 1096 | if (!isset($this->arrParam[$key])) $this->arrParam[$key] = ""; |
---|
| 1097 | } |
---|
| 1098 | } |
---|
| 1099 | } |
---|
| 1100 | } |
---|
| 1101 | ?> |
---|