| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * This file is part of EC-CUBE |
|---|
| 4 | * |
|---|
| 5 | * Copyright(c) 2000-2007 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; |
|---|
| 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( strlen($this->arrParam[$value[1]]) == 0 ){ |
|---|
| 84 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が入力されていません。<br />"; |
|---|
| 85 | } |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | /* 必須入力の判定(逆順) */ |
|---|
| 89 | // value[0] = 判定対象 value[1] = 項目名 |
|---|
| 90 | function EXIST_CHECK_REVERSE( $value ) { // 受け取りがない場合エラーを返す |
|---|
| 91 | if(isset($this->arrErr[$value[0]])) { |
|---|
| 92 | return; |
|---|
| 93 | } |
|---|
| 94 | $this->createParam($value); |
|---|
| 95 | if( strlen($this->arrParam[$value[0]]) == 0 ){ |
|---|
| 96 | $this->arrErr[$value[0]] = "※ " . $value[0] . "が入力されていません。<br />"; |
|---|
| 97 | } |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | /* スペース、タブの判定 */ |
|---|
| 101 | // value[0] = 項目名 value[1] = 判定対象 |
|---|
| 102 | function SPTAB_CHECK( $value ) { // 受け取りがない場合エラーを返す |
|---|
| 103 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 104 | return; |
|---|
| 105 | } |
|---|
| 106 | $this->createParam($value); |
|---|
| 107 | if(strlen($this->arrParam[$value[1]]) != 0 && ereg("^[ \t\r\n]+$", $this->arrParam[$value[1]])){ |
|---|
| 108 | $this->arrErr[$value[1]] = "※ " . $value[0] . "にスペース、タブ、改行のみの入力はできません。<br />"; |
|---|
| 109 | } |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | /* スペース、タブの判定 */ |
|---|
| 113 | // value[0] = 項目名 value[1] = 判定対象 |
|---|
| 114 | function NO_SPTAB( $value ) { // 受け取りがない場合エラーを返す |
|---|
| 115 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 116 | return; |
|---|
| 117 | } |
|---|
| 118 | $this->createParam($value); |
|---|
| 119 | if(strlen($this->arrParam[$value[1]]) != 0 && mb_ereg("[ \t\r\n]+", $this->arrParam[$value[1]])){ |
|---|
| 120 | $this->arrErr[$value[1]] = "※ " . $value[0] . "にスペース、タブ、改行は含めないで下さい。<br />"; |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | /* ゼロで開始されている数値の判定 */ |
|---|
| 125 | function ZERO_START($value) { |
|---|
| 126 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 127 | return; |
|---|
| 128 | } |
|---|
| 129 | $this->createParam($value); |
|---|
| 130 | if(strlen($this->arrParam[$value[1]]) != 0 && ereg("^[0]+[0-9]+$", $this->arrParam[$value[1]])){ |
|---|
| 131 | $this->arrErr[$value[1]] = "※ " . $value[0] . "に0で始まる数値が入力されています。<br />"; |
|---|
| 132 | } |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | /* 必須選択の判定 */ |
|---|
| 136 | // value[0] = 項目名 value[1] = 判定対象 |
|---|
| 137 | function SELECT_CHECK( $value ) { // プルダウンなどで選択されていない場合エラーを返す |
|---|
| 138 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 139 | return; |
|---|
| 140 | } |
|---|
| 141 | $this->createParam($value); |
|---|
| 142 | if( strlen($this->arrParam[$value[1]]) == 0 ){ |
|---|
| 143 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が選択されていません。<br />"; |
|---|
| 144 | } |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | /* 同一性の判定 */ |
|---|
| 148 | // value[0] = 項目名1 value[1] = 項目名2 value[2] = 判定対象文字列1 value[3] = 判定対象文字列2 |
|---|
| 149 | function EQUAL_CHECK( $value ) { // 入力が指定文字数以上ならエラーを返す |
|---|
| 150 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
|---|
| 151 | return; |
|---|
| 152 | } |
|---|
| 153 | $this->createParam($value); |
|---|
| 154 | // 文字数の取得 |
|---|
| 155 | if( $this->arrParam[$value[2]] != $this->arrParam[$value[3]]) { |
|---|
| 156 | $this->arrErr[$value[2]] = "※ " . $value[0] . "と" . $value[1] . "が一致しません。<br />"; |
|---|
| 157 | } |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | /* 値が異なることの判定 */ |
|---|
| 161 | // value[0] = 項目名1 value[1] = 項目名2 value[2] = 判定対象文字列1 value[3] = 判定対象文字列2 |
|---|
| 162 | function DIFFERENT_CHECK( $value ) { // 入力が指定文字数以上ならエラーを返す |
|---|
| 163 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
|---|
| 164 | return; |
|---|
| 165 | } |
|---|
| 166 | $this->createParam($value); |
|---|
| 167 | // 文字数の取得 |
|---|
| 168 | if( $this->arrParam[$value[2]] == $this->arrParam[$value[3]]) { |
|---|
| 169 | $this->arrErr[$value[2]] = "※ " . $value[0] . "と" . $value[1] . "は、同じ値を使用できません。<br />"; |
|---|
| 170 | } |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | /* 値の大きさを比較する value[2] < value[3]でなければエラー */ |
|---|
| 174 | // value[0] = 項目名1 value[1] = 項目名2 value[2] = 判定対象文字列1 value[3] = 判定対象文字列2 |
|---|
| 175 | function GREATER_CHECK($value) { // 入力が指定文字数以上ならエラーを返す |
|---|
| 176 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
|---|
| 177 | return; |
|---|
| 178 | } |
|---|
| 179 | $this->createParam($value); |
|---|
| 180 | // 文字数の取得 |
|---|
| 181 | if($this->arrParam[$value[2]] != "" && $this->arrParam[$value[3]] != "" && ($this->arrParam[$value[2]] > $this->arrParam[$value[3]])) { |
|---|
| 182 | $this->arrErr[$value[2]] = "※ " . $value[0] . "は" . $value[1] . "より大きい値を入力できません。<br />"; |
|---|
| 183 | } |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | |
|---|
| 187 | /* 最大文字数制限の判定 */ |
|---|
| 188 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最大文字数(半角も全角も1文字として数える) |
|---|
| 189 | function MAX_LENGTH_CHECK( $value ) { // 入力が指定文字数以上ならエラーを返す |
|---|
| 190 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 191 | return; |
|---|
| 192 | } |
|---|
| 193 | $this->createParam($value); |
|---|
| 194 | // 文字数の取得 |
|---|
| 195 | if( mb_strlen($this->arrParam[$value[1]]) > $value[2] ) { |
|---|
| 196 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は" . $value[2] . "字以下で入力してください。<br />"; |
|---|
| 197 | } |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | /* 最小文字数制限の判定 */ |
|---|
| 201 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小文字数(半角も全角も1文字として数える) |
|---|
| 202 | function MIN_LENGTH_CHECK( $value ) { // 入力が指定文字数未満ならエラーを返す |
|---|
| 203 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 204 | return; |
|---|
| 205 | } |
|---|
| 206 | $this->createParam($value); |
|---|
| 207 | // 文字数の取得 |
|---|
| 208 | if( mb_strlen($this->arrParam[$value[1]]) < $value[2] ) { |
|---|
| 209 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は" . $value[2] . "字以上で入力してください。<br />"; |
|---|
| 210 | } |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | /* 最大文字数制限の判定 */ |
|---|
| 214 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最大数 |
|---|
| 215 | function MAX_CHECK( $value ) { // 入力が最大数以上ならエラーを返す |
|---|
| 216 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 217 | return; |
|---|
| 218 | } |
|---|
| 219 | $this->createParam($value); |
|---|
| 220 | // 文字数の取得 |
|---|
| 221 | if($this->arrParam[$value[1]] > $value[2] ) { |
|---|
| 222 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は" . $value[2] . "以下で入力してください。<br />"; |
|---|
| 223 | } |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | /* 最小数値制限の判定 */ |
|---|
| 227 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小数 |
|---|
| 228 | function MIN_CHECK( $value ) { // 入力が最小数未満ならエラーを返す |
|---|
| 229 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 230 | return; |
|---|
| 231 | } |
|---|
| 232 | $this->createParam($value); |
|---|
| 233 | if($this->arrParam[$value[1]] < $value[2] ) { |
|---|
| 234 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は" . $value[2] . "以上で入力してください。<br />"; |
|---|
| 235 | } |
|---|
| 236 | } |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | /* 数字の判定 */ |
|---|
| 240 | // value[0] = 項目名 value[1] = 判定対象文字列 |
|---|
| 241 | function NUM_CHECK( $value ) { // 入力文字が数字以外ならエラーを返す |
|---|
| 242 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 243 | return; |
|---|
| 244 | } |
|---|
| 245 | $this->createParam($value); |
|---|
| 246 | if( strlen($this->arrParam[$value[1]]) > 0 && !EregI("^[[:digit:]]+$", $this->arrParam[$value[1]])) { |
|---|
| 247 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は数字で入力してください。<br />"; |
|---|
| 248 | } |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | /* 小数点を含む数字の判定 */ |
|---|
| 252 | // value[0] = 項目名 value[1] = 判定対象文字列 |
|---|
| 253 | function NUM_POINT_CHECK( $value ) { // 入力文字が数字以外ならエラーを返す |
|---|
| 254 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 255 | return; |
|---|
| 256 | } |
|---|
| 257 | $this->createParam($value); |
|---|
| 258 | if( strlen($this->arrParam[$value[1]]) > 0 && !EregI("^[[:digit:]]+[\.]?[[:digit:]]+$", $this->arrParam[$value[1]])) { |
|---|
| 259 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は数字で入力してください。<br />"; |
|---|
| 260 | } |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | function ALPHA_CHECK($value) { |
|---|
| 264 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 265 | return; |
|---|
| 266 | } |
|---|
| 267 | $this->createParam($value); |
|---|
| 268 | if( strlen($this->arrParam[$value[1]]) > 0 && !EregI("^[[:alpha:]]+$", $this->arrParam[$value[1]])) { |
|---|
| 269 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は半角英字で入力してください。<br />"; |
|---|
| 270 | } |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | /* 電話番号の判定 (数字チェックと文字数チェックを実施する。) |
|---|
| 274 | value[0] : 項目名 |
|---|
| 275 | value[1] : 電番1項目目 |
|---|
| 276 | value[2] : 電番2項目目 |
|---|
| 277 | value[3] : 電番3項目目 |
|---|
| 278 | value[4] : 文字数制限 |
|---|
| 279 | */ |
|---|
| 280 | function TEL_CHECK($value) { |
|---|
| 281 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 282 | return; |
|---|
| 283 | } |
|---|
| 284 | $this->createParam($value); |
|---|
| 285 | $cnt = 0; |
|---|
| 286 | |
|---|
| 287 | for($i = 1; $i <= 3; $i++) { |
|---|
| 288 | if(strlen($this->arrParam[$value[$i]]) > 0) { |
|---|
| 289 | $cnt++; |
|---|
| 290 | } |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | // すべての項目が満たされていない場合を判定(一部だけ入力されている状態) |
|---|
| 294 | if($cnt > 0 && $cnt < 3) { |
|---|
| 295 | $this->arrErr[$value[1]] .= "※ " . $value[0] . "はすべての項目を入力してください。<br />"; |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | for($i = 1; $i <= 3; $i++) { |
|---|
| 299 | if(strlen($this->arrParam[$value[$i]]) > 0 && strlen($this->arrParam[$value[$i]]) > $value[4]) { |
|---|
| 300 | $this->arrErr[$value[$i]] .= "※ " . $value[0] . $i . "は" . $value[4] . "字以内で入力してください。<br />"; |
|---|
| 301 | } else if (strlen($this->arrParam[$value[$i]]) > 0 && !EregI("^[[:digit:]]+$", $this->arrParam[$value[$i]])) { |
|---|
| 302 | $this->arrErr[$value[$i]] .= "※ " . $value[0] . $i . "は数字で入力してください。<br />"; |
|---|
| 303 | } |
|---|
| 304 | } |
|---|
| 305 | } |
|---|
| 306 | |
|---|
| 307 | /* 関連項目が完全に満たされているか判定 |
|---|
| 308 | value[0] : 項目名 |
|---|
| 309 | value[1] : 判定対象要素名 |
|---|
| 310 | */ |
|---|
| 311 | function FULL_EXIST_CHECK($value) { |
|---|
| 312 | $max = count($value); |
|---|
| 313 | $this->createParam($value); |
|---|
| 314 | // 既に該当項目にエラーがある場合は、判定しない。 |
|---|
| 315 | for($i = 1; $i < $max; $i++) { |
|---|
| 316 | if(isset($this->arrErr[$value[$i]])) { |
|---|
| 317 | return; |
|---|
| 318 | } |
|---|
| 319 | } |
|---|
| 320 | |
|---|
| 321 | $blank = false; |
|---|
| 322 | |
|---|
| 323 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
|---|
| 324 | for($i = 1; $i < $max; $i++) { |
|---|
| 325 | if(strlen($this->arrParam[$value[$i]]) <= 0) { |
|---|
| 326 | $blank = true; |
|---|
| 327 | } |
|---|
| 328 | } |
|---|
| 329 | |
|---|
| 330 | if($blank) { |
|---|
| 331 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が入力されていません。<br />"; |
|---|
| 332 | } |
|---|
| 333 | } |
|---|
| 334 | |
|---|
| 335 | /* 関連項目がすべて満たされているか判定 |
|---|
| 336 | value[0] : 項目名 |
|---|
| 337 | value[1] : 判定対象要素名 |
|---|
| 338 | */ |
|---|
| 339 | function ALL_EXIST_CHECK($value) { |
|---|
| 340 | $max = count($value); |
|---|
| 341 | |
|---|
| 342 | // 既に該当項目にエラーがある場合は、判定しない。 |
|---|
| 343 | for($i = 1; $i < $max; $i++) { |
|---|
| 344 | if(isset($this->arrErr[$value[$i]])) { |
|---|
| 345 | return; |
|---|
| 346 | } |
|---|
| 347 | } |
|---|
| 348 | |
|---|
| 349 | $blank = false; |
|---|
| 350 | $input = false; |
|---|
| 351 | |
|---|
| 352 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
|---|
| 353 | for($i = 1; $i < $max; $i++) { |
|---|
| 354 | if(strlen($this->arrParam[$value[$i]]) <= 0) { |
|---|
| 355 | $blank = true; |
|---|
| 356 | } else { |
|---|
| 357 | $input = true; |
|---|
| 358 | } |
|---|
| 359 | } |
|---|
| 360 | |
|---|
| 361 | if($blank && $input) { |
|---|
| 362 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
|---|
| 363 | } |
|---|
| 364 | } |
|---|
| 365 | |
|---|
| 366 | /* 関連項目がどれか一つ満たされているか判定 |
|---|
| 367 | value[0] : 項目名 |
|---|
| 368 | value[1] : 判定対象要素名 |
|---|
| 369 | */ |
|---|
| 370 | function ONE_EXIST_CHECK($value) { |
|---|
| 371 | $max = count($value); |
|---|
| 372 | $this->createParam($value); |
|---|
| 373 | // 既に該当項目にエラーがある場合は、判定しない。 |
|---|
| 374 | for($i = 1; $i < $max; $i++) { |
|---|
| 375 | if(isset($this->arrErr[$value[$i]])) { |
|---|
| 376 | return; |
|---|
| 377 | } |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | $input = false; |
|---|
| 381 | |
|---|
| 382 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
|---|
| 383 | for($i = 1; $i < $max; $i++) { |
|---|
| 384 | if(strlen($this->arrParam[$value[$i]]) > 0) { |
|---|
| 385 | $input = true; |
|---|
| 386 | } |
|---|
| 387 | } |
|---|
| 388 | |
|---|
| 389 | if(!$input) { |
|---|
| 390 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が入力されていません。<br />"; |
|---|
| 391 | } |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | /* 上位の項目が満たされているか判定 |
|---|
| 395 | value[0] : 項目名 |
|---|
| 396 | value[1] : 判定対象要素名 |
|---|
| 397 | */ |
|---|
| 398 | function TOP_EXIST_CHECK($value) { |
|---|
| 399 | $max = count($value); |
|---|
| 400 | $this->createParam($value); |
|---|
| 401 | |
|---|
| 402 | // 既に該当項目にエラーがある場合は、判定しない。 |
|---|
| 403 | for($i = 1; $i < $max; $i++) { |
|---|
| 404 | if(isset($this->arrErr[$value[$i]])) { |
|---|
| 405 | return; |
|---|
| 406 | } |
|---|
| 407 | } |
|---|
| 408 | |
|---|
| 409 | $blank = false; |
|---|
| 410 | $error = false; |
|---|
| 411 | |
|---|
| 412 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
|---|
| 413 | for($i = 1; $i < $max; $i++) { |
|---|
| 414 | if(strlen($this->arrParam[$value[$i]]) <= 0) { |
|---|
| 415 | $blank = true; |
|---|
| 416 | } else { |
|---|
| 417 | if($blank) { |
|---|
| 418 | $error = true; |
|---|
| 419 | } |
|---|
| 420 | } |
|---|
| 421 | } |
|---|
| 422 | |
|---|
| 423 | if($error) { |
|---|
| 424 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は先頭の項目から順番に入力して下さい。<br />"; |
|---|
| 425 | } |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | |
|---|
| 429 | /* カタカナの判定 */ |
|---|
| 430 | // value[0] = 項目名 value[1] = 判定対象文字列 |
|---|
| 431 | function KANA_CHECK( $value ) { // 入力文字がカナ以外ならエラーを返す |
|---|
| 432 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 433 | return; |
|---|
| 434 | } |
|---|
| 435 | $this->createParam($value); |
|---|
| 436 | if(strlen($this->arrParam[$value[1]]) > 0 && ! mb_ereg("^[ァ-ヶヲ-゚ー]+$", $this->arrParam[$value[1]])) { |
|---|
| 437 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はカタカナで入力してください。<br />"; |
|---|
| 438 | } |
|---|
| 439 | } |
|---|
| 440 | |
|---|
| 441 | /* カタカナの判定2(タブ、スペースは許可する) */ |
|---|
| 442 | // value[0] = 項目名 value[1] = 判定対象文字列 |
|---|
| 443 | function KANABLANK_CHECK( $value ) { // 入力文字がカナ以外ならエラーを返す |
|---|
| 444 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 445 | return; |
|---|
| 446 | } |
|---|
| 447 | $this->createParam($value); |
|---|
| 448 | if(strlen($this->arrParam[$value[1]]) > 0 && ! mb_ereg("^([ \t\r\n]|[ァ-ヶ]|[ー])+$", $this->arrParam[$value[1]])) { |
|---|
| 449 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はカタカナで入力してください。<br />"; |
|---|
| 450 | } |
|---|
| 451 | } |
|---|
| 452 | |
|---|
| 453 | /* 英数字の判定 */ |
|---|
| 454 | // value[0] = 項目名 value[1] = 判定対象文字列 |
|---|
| 455 | function ALNUM_CHECK( $value ) { // 入力文字が英数字以外ならエラーを返す |
|---|
| 456 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 457 | return; |
|---|
| 458 | } |
|---|
| 459 | $this->createParam($value); |
|---|
| 460 | if( strlen($this->arrParam[$value[1]]) > 0 && ! EregI("^[[:alnum:]]+$", $this->arrParam[$value[1]] ) ) { |
|---|
| 461 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は英数字で入力してください。<br />"; |
|---|
| 462 | } |
|---|
| 463 | } |
|---|
| 464 | |
|---|
| 465 | /* 必須選択の判定 */ |
|---|
| 466 | // value[0] = 項目名 value[1] = 判定対象 |
|---|
| 467 | function ZERO_CHECK( $value ) { // 入力値で0が許されない場合エラーを返す |
|---|
| 468 | $this->createParam($value); |
|---|
| 469 | if($this->arrParam[$value[1]] == "0" ){ |
|---|
| 470 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は1以上を入力してください。<br />"; |
|---|
| 471 | } |
|---|
| 472 | } |
|---|
| 473 | |
|---|
| 474 | /* 桁数の判定 (最小最大)*/ |
|---|
| 475 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小桁数 value[3] = 最大桁数 |
|---|
| 476 | function NUM_RANGE_CHECK( $value ) { // 入力文字の桁数判定 → 最小桁数<入力文字列<最大桁数 |
|---|
| 477 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 478 | return; |
|---|
| 479 | } |
|---|
| 480 | $this->createParam($value); |
|---|
| 481 | // $this->arrParam[$value[0]] = mb_convert_kana($this->arrParam[$value[0]], "n"); |
|---|
| 482 | $count = strlen($this->arrParam[$value[1]]); |
|---|
| 483 | if( ( $count > 0 ) && $value[2] > $count || $value[3] < $count ) { |
|---|
| 484 | $this->arrErr[$value[1]] = "※ $value[0]は$value[2]桁〜$value[3]桁で入力して下さい。<br />"; |
|---|
| 485 | } |
|---|
| 486 | } |
|---|
| 487 | |
|---|
| 488 | /* 桁数の判定 */ |
|---|
| 489 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 桁数 |
|---|
| 490 | function NUM_COUNT_CHECK( $value ) { // 入力文字の桁数判定 → 入力文字列 = 桁数 以外はNGの場合 |
|---|
| 491 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 492 | return; |
|---|
| 493 | } |
|---|
| 494 | $this->createParam($value); |
|---|
| 495 | $count = strlen($this->arrParam[$value[1]]); |
|---|
| 496 | if(($count > 0) && $count != $value[2] ) { |
|---|
| 497 | $this->arrErr[$value[1]] = "※ $value[0]は$value[2]桁で入力して下さい。<br />"; |
|---|
| 498 | } |
|---|
| 499 | } |
|---|
| 500 | |
|---|
| 501 | /* メールアドレス形式の判定 */ |
|---|
| 502 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
|---|
| 503 | function EMAIL_CHECK( $value ){ // メールアドレスを正規表現で判定する |
|---|
| 504 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 505 | return; |
|---|
| 506 | } |
|---|
| 507 | $this->createParam($value); |
|---|
| 508 | if(strlen($this->arrParam[$value[1]]) > 0 && !ereg("^[^@]+@[^.]+\..+", $this->arrParam[$value[1]])) { |
|---|
| 509 | $this->arrErr[$value[1]] = "※ " . $value[0] . "の形式が不正です。<br />"; |
|---|
| 510 | } |
|---|
| 511 | } |
|---|
| 512 | |
|---|
| 513 | /* メールアドレスに使用できる文字の判定 */ |
|---|
| 514 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
|---|
| 515 | function EMAIL_CHAR_CHECK( $value ){ // メールアドレスに使用する文字を正規表現で判定する |
|---|
| 516 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 517 | return; |
|---|
| 518 | } |
|---|
| 519 | $this->createParam($value); |
|---|
| 520 | if(strlen($this->arrParam[$value[1]]) > 0 && !ereg("^[a-zA-Z0-9_\.@\+\?-]+$",$this->arrParam[$value[1]]) ) { |
|---|
| 521 | $this->arrErr[$value[1]] = "※ " . $value[0] . "に使用する文字を正しく入力してください。<br />"; |
|---|
| 522 | } |
|---|
| 523 | } |
|---|
| 524 | |
|---|
| 525 | /* URL形式の判定 */ |
|---|
| 526 | // value[0] = 項目名 value[1] = 判定対象URL |
|---|
| 527 | function URL_CHECK( $value ){ // URLを正規表現で判定する。デフォルトでhttp://があってもOK |
|---|
| 528 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 529 | return; |
|---|
| 530 | } |
|---|
| 531 | if( strlen($this->arrParam[$value[1]]) > 0 && !ereg( "^https?://+($|[a-zA-Z0-9_~=:&\?\.\/-])+$", $this->arrParam[$value[1]] ) ) { |
|---|
| 532 | $this->arrErr[$value[1]] = "※ " . $value[0] . "を正しく入力してください。<br />"; |
|---|
| 533 | } |
|---|
| 534 | } |
|---|
| 535 | |
|---|
| 536 | /* 拡張子の判定 */ |
|---|
| 537 | // value[0] = 項目名 value[1] = 判定対象 value[2]=array(拡張子) |
|---|
| 538 | function FILE_EXT_CHECK( $value ) { // 受け取りがない場合エラーを返す |
|---|
| 539 | if(isset($this->arrErr[$value[1]]) || count($value[2]) == 0) { |
|---|
| 540 | return; |
|---|
| 541 | } |
|---|
| 542 | $this->createParam($value); |
|---|
| 543 | |
|---|
| 544 | if($_FILES[$value[1]]['name'] != "" ) { |
|---|
| 545 | $errFlag = 1; |
|---|
| 546 | $array_ext = explode(".", $_FILES[$value[1]]['name']); |
|---|
| 547 | $ext = $array_ext[ count ( $array_ext ) - 1 ]; |
|---|
| 548 | $ext = strtolower($ext); |
|---|
| 549 | |
|---|
| 550 | $strExt = ""; |
|---|
| 551 | |
|---|
| 552 | foreach ( $value[2] as $checkExt ){ |
|---|
| 553 | if ( $ext == $checkExt) { |
|---|
| 554 | $errFlag = 0; |
|---|
| 555 | } |
|---|
| 556 | |
|---|
| 557 | if($strExt == "") { |
|---|
| 558 | $strExt.= $checkExt; |
|---|
| 559 | } else { |
|---|
| 560 | $strExt.= "・$checkExt"; |
|---|
| 561 | } |
|---|
| 562 | } |
|---|
| 563 | } |
|---|
| 564 | if ($errFlag == 1) { |
|---|
| 565 | $this->arrErr[$value[1]] = "※ " . $value[0] . "で許可されている形式は、" . $strExt . "です。<br />"; |
|---|
| 566 | } |
|---|
| 567 | } |
|---|
| 568 | |
|---|
| 569 | /* ファイルが存在するかチェックする */ |
|---|
| 570 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定ディレクトリ |
|---|
| 571 | function FIND_FILE( $value ) { // 受け取りがない場合エラーを返す |
|---|
| 572 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 573 | return; |
|---|
| 574 | } |
|---|
| 575 | |
|---|
| 576 | $this->createParam($value); |
|---|
| 577 | if($value[2] != "") { |
|---|
| 578 | $dir = $value[2]; |
|---|
| 579 | } else { |
|---|
| 580 | $dir = IMAGE_SAVE_DIR; |
|---|
| 581 | } |
|---|
| 582 | |
|---|
| 583 | $path = $dir . "/" . $this->arrParam[$value[1]]; |
|---|
| 584 | $path = ereg_replace("//", "/", $path); |
|---|
| 585 | |
|---|
| 586 | if($this->arrParam[$value[1]] != "" && !file_exists($path)){ |
|---|
| 587 | $this->arrErr[$value[1]] = "※ " . $path . "が見つかりません。<br />"; |
|---|
| 588 | } |
|---|
| 589 | } |
|---|
| 590 | |
|---|
| 591 | /* ファイルが上げられたか確認 */ |
|---|
| 592 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定サイズ(KB) |
|---|
| 593 | function FILE_EXIST_CHECK( $value ) { // 受け取りがない場合エラーを返す |
|---|
| 594 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 595 | return; |
|---|
| 596 | } |
|---|
| 597 | $this->createParam($value); |
|---|
| 598 | if(!($_FILES[$value[1]]['size'] != "" && $_FILES[$value[1]]['size'] > 0)){ |
|---|
| 599 | $this->arrErr[$value[1]] = "※ " . $value[0] . "をアップロードして下さい。<br />"; |
|---|
| 600 | } |
|---|
| 601 | } |
|---|
| 602 | |
|---|
| 603 | /* ファイルサイズの判定 */ |
|---|
| 604 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定サイズ(KB) |
|---|
| 605 | function FILE_SIZE_CHECK( $value ) { // 受け取りがない場合エラーを返す |
|---|
| 606 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 607 | return; |
|---|
| 608 | } |
|---|
| 609 | $this->createParam($value); |
|---|
| 610 | if( $_FILES[$value[1]]['size'] > $value[2] * 1024 ){ |
|---|
| 611 | $byte = "KB"; |
|---|
| 612 | if( $value[2] >= 1000 ) { |
|---|
| 613 | $value[2] = $value[2] / 1000; |
|---|
| 614 | $byte = "MB"; |
|---|
| 615 | } |
|---|
| 616 | $this->arrErr[$value[1]] = "※ " . $value[0] . "のファイルサイズは" . $value[2] . $byte . "以下のものを使用してください。<br />"; |
|---|
| 617 | } |
|---|
| 618 | } |
|---|
| 619 | |
|---|
| 620 | /* ファイル名の判定 */ |
|---|
| 621 | // value[0] = 項目名 value[1] = 判定対象文字列 |
|---|
| 622 | function FILE_NAME_CHECK( $value ) { // 入力文字が英数字,"_","-"以外ならエラーを返す |
|---|
| 623 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 624 | return; |
|---|
| 625 | } |
|---|
| 626 | $this->createParam($value); |
|---|
| 627 | if( strlen($_FILES[$value[1]]['name']) > 0 && ! EregI("^[[:alnum:]_\.-]+$", $_FILES[$value[1]]['name']) ) { |
|---|
| 628 | $this->arrErr[$value[1]] = "※ " . $value[0] . "のファイル名に日本語やスペースは使用しないで下さい。<br />"; |
|---|
| 629 | } |
|---|
| 630 | } |
|---|
| 631 | |
|---|
| 632 | /* ファイル名の判定(アップロード以外の時) */ |
|---|
| 633 | // value[0] = 項目名 value[1] = 判定対象文字列 |
|---|
| 634 | function FILE_NAME_CHECK_BY_NOUPLOAD( $value ) { // 入力文字が英数字,"_","-"以外ならエラーを返す |
|---|
| 635 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 636 | return; |
|---|
| 637 | } |
|---|
| 638 | $this->createParam($value); |
|---|
| 639 | if( strlen($this->arrParam[$value[1]]) > 0 && ! EregI("^[[:alnum:]_\.-]+$", $this->arrParam[$value[1]]) || EregI("[\\]" ,$this->arrParam[$value[1]])) { |
|---|
| 640 | $this->arrErr[$value[1]] = "※ " . $value[0] . "のファイル名に日本語やスペースは使用しないで下さい。<br />"; |
|---|
| 641 | } |
|---|
| 642 | } |
|---|
| 643 | |
|---|
| 644 | //日付チェック |
|---|
| 645 | // value[0] = 項目名 |
|---|
| 646 | // value[1] = YYYY |
|---|
| 647 | // value[2] = MM |
|---|
| 648 | // value[3] = DD |
|---|
| 649 | function CHECK_DATE($value) { |
|---|
| 650 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 651 | return; |
|---|
| 652 | } |
|---|
| 653 | $this->createParam($value); |
|---|
| 654 | // 少なくともどれか一つが入力されている。 |
|---|
| 655 | if($this->arrParam[$value[1]] > 0 || $this->arrParam[$value[2]] > 0 || $this->arrParam[$value[3]] > 0) { |
|---|
| 656 | // 年月日のどれかが入力されていない。 |
|---|
| 657 | if(!(strlen($this->arrParam[$value[1]]) > 0 && strlen($this->arrParam[$value[2]]) > 0 && strlen($this->arrParam[$value[3]]) > 0)) { |
|---|
| 658 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
|---|
| 659 | } else if ( ! checkdate($this->arrParam[$value[2]], $this->arrParam[$value[3]], $this->arrParam[$value[1]])) { |
|---|
| 660 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が正しくありません。<br />"; |
|---|
| 661 | } |
|---|
| 662 | } |
|---|
| 663 | } |
|---|
| 664 | |
|---|
| 665 | //日付チェック |
|---|
| 666 | // value[0] = 項目名 |
|---|
| 667 | // value[1] = YYYY |
|---|
| 668 | // value[2] = MM |
|---|
| 669 | // value[3] = DD |
|---|
| 670 | // value[4] = HH |
|---|
| 671 | // value[5] = mm |
|---|
| 672 | function CHECK_DATE2($value) { |
|---|
| 673 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 674 | return; |
|---|
| 675 | } |
|---|
| 676 | $this->createParam($value); |
|---|
| 677 | // 少なくともどれか一つが入力されている。 |
|---|
| 678 | 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) { |
|---|
| 679 | // 年月日時のどれかが入力されていない。 |
|---|
| 680 | 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 )) { |
|---|
| 681 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
|---|
| 682 | } else if ( ! checkdate($this->arrParam[$value[2]], $this->arrParam[$value[3]], $this->arrParam[$value[1]])) { |
|---|
| 683 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が正しくありません。<br />"; |
|---|
| 684 | } |
|---|
| 685 | } |
|---|
| 686 | } |
|---|
| 687 | |
|---|
| 688 | //日付チェック |
|---|
| 689 | // value[0] = 項目名 |
|---|
| 690 | // value[1] = YYYY |
|---|
| 691 | // value[2] = MM |
|---|
| 692 | function CHECK_DATE3($value) { |
|---|
| 693 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 694 | return; |
|---|
| 695 | } |
|---|
| 696 | $this->createParam($value); |
|---|
| 697 | // 少なくともどれか一つが入力されている。 |
|---|
| 698 | if($this->arrParam[$value[1]] > 0 || $this->arrParam[$value[2]] > 0) { |
|---|
| 699 | // 年月日時のどれかが入力されていない。 |
|---|
| 700 | if(!(strlen($this->arrParam[$value[1]]) > 0 && strlen($this->arrParam[$value[2]]) > 0)) { |
|---|
| 701 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
|---|
| 702 | } else if ( ! checkdate($this->arrParam[$value[2]], 1, $this->arrParam[$value[1]])) { |
|---|
| 703 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が正しくありません。<br />"; |
|---|
| 704 | } |
|---|
| 705 | } |
|---|
| 706 | } |
|---|
| 707 | |
|---|
| 708 | /*-----------------------------------------------------------------*/ |
|---|
| 709 | /* CHECK_SET_TERM |
|---|
| 710 | /* 年月日に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
|---|
| 711 | /* 引数 (開始年,開始月,開始日,終了年,終了月,終了日) |
|---|
| 712 | /* 戻値 array(1,2,3) |
|---|
| 713 | /* 1.開始年月日 (YYYYMMDD 000000) |
|---|
| 714 | /* 2.終了年月日 (YYYYMMDD 235959) |
|---|
| 715 | /* 3.エラー ( 0 = OK, 1 = NG ) |
|---|
| 716 | /*-----------------------------------------------------------------*/ |
|---|
| 717 | // value[0] = 項目名1 |
|---|
| 718 | // value[1] = 項目名2 |
|---|
| 719 | // value[2] = start_year |
|---|
| 720 | // value[3] = start_month |
|---|
| 721 | // value[4] = start_day |
|---|
| 722 | // value[5] = end_year |
|---|
| 723 | // value[6] = end_month |
|---|
| 724 | // value[7] = end_day |
|---|
| 725 | function CHECK_SET_TERM ($value) { |
|---|
| 726 | |
|---|
| 727 | // 期間指定 |
|---|
| 728 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[5]])) { |
|---|
| 729 | return; |
|---|
| 730 | } |
|---|
| 731 | $this->createParam($value); |
|---|
| 732 | $error = 0; |
|---|
| 733 | 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]]) ) { |
|---|
| 734 | $this->arrErr[$value[2]] = "※ " . $value[0] . "を正しく指定してください。<br />"; |
|---|
| 735 | } |
|---|
| 736 | 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]]) ) { |
|---|
| 737 | $this->arrErr[$value[5]] = "※ " . $value[1] . "を正しく指定してください。<br />"; |
|---|
| 738 | } |
|---|
| 739 | 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) ){ |
|---|
| 740 | |
|---|
| 741 | $date1 = $this->arrParam[$value[2]] .sprintf("%02d", $this->arrParam[$value[3]]) .sprintf("%02d",$this->arrParam[$value[4]]) ."000000"; |
|---|
| 742 | $date2 = $this->arrParam[$value[5]] .sprintf("%02d", $this->arrParam[$value[6]]) .sprintf("%02d",$this->arrParam[$value[7]]) ."235959"; |
|---|
| 743 | |
|---|
| 744 | if (($this->arrErr[$value[2]] == "" && $this->arrErr[$value[5]] == "") && $date1 > $date2) { |
|---|
| 745 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
|---|
| 746 | } |
|---|
| 747 | } |
|---|
| 748 | } |
|---|
| 749 | |
|---|
| 750 | /*-----------------------------------------------------------------*/ |
|---|
| 751 | /* CHECK_SET_TERM2 |
|---|
| 752 | /* 年月日時に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
|---|
| 753 | /* 引数 (開始年,開始月,開始日,開始時間,開始分,開始秒, |
|---|
| 754 | /* 終了年,終了月,終了日,終了時間,終了分,終了秒) |
|---|
| 755 | /* 戻値 array(1,2,3) |
|---|
| 756 | /* 1.開始年月日 (YYYYMMDDHHmmss) |
|---|
| 757 | /* 2.終了年月日 (YYYYMMDDHHmmss) |
|---|
| 758 | /* 3.エラー ( 0 = OK, 1 = NG ) |
|---|
| 759 | /*-----------------------------------------------------------------*/ |
|---|
| 760 | // value[0] = 項目名1 |
|---|
| 761 | // value[1] = 項目名2 |
|---|
| 762 | // value[2] = start_year |
|---|
| 763 | // value[3] = start_month |
|---|
| 764 | // value[4] = start_day |
|---|
| 765 | // value[5] = start_hour |
|---|
| 766 | // value[6] = start_minute |
|---|
| 767 | // value[7] = start_second |
|---|
| 768 | // value[8] = end_year |
|---|
| 769 | // value[9] = end_month |
|---|
| 770 | // value[10] = end_day |
|---|
| 771 | // value[11] = end_hour |
|---|
| 772 | // value[12] = end_minute |
|---|
| 773 | // value[13] = end_second |
|---|
| 774 | |
|---|
| 775 | /*-----------------------------------------------------------------*/ |
|---|
| 776 | function CHECK_SET_TERM2 ($value) { |
|---|
| 777 | |
|---|
| 778 | // 期間指定 |
|---|
| 779 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[8]])) { |
|---|
| 780 | return; |
|---|
| 781 | } |
|---|
| 782 | $this->createParam($value); |
|---|
| 783 | $error = 0; |
|---|
| 784 | 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]]) ) { |
|---|
| 785 | $this->arrErr[$value[2]] = "※ " . $value[0] . "を正しく指定してください。<br />"; |
|---|
| 786 | } |
|---|
| 787 | 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]]) ) { |
|---|
| 788 | $this->arrErr[$value[8]] = "※ " . $value[1] . "を正しく指定してください。<br />"; |
|---|
| 789 | } |
|---|
| 790 | 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) ){ |
|---|
| 791 | |
|---|
| 792 | $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]]); |
|---|
| 793 | $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]]); |
|---|
| 794 | |
|---|
| 795 | if (($this->arrErr[$value[2]] == "" && $this->arrErr[$value[8]] == "") && $date1 > $date2) { |
|---|
| 796 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
|---|
| 797 | } |
|---|
| 798 | if($date1 == $date2) { |
|---|
| 799 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
|---|
| 800 | } |
|---|
| 801 | |
|---|
| 802 | } |
|---|
| 803 | } |
|---|
| 804 | |
|---|
| 805 | /*-----------------------------------------------------------------*/ |
|---|
| 806 | /* CHECK_SET_TERM3 |
|---|
| 807 | /* 年月に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
|---|
| 808 | /* 引数 (開始年,開始月,終了年,終了月) |
|---|
| 809 | /* 戻値 array(1,2,3) |
|---|
| 810 | /* 1.開始年月日 (YYYYMMDD 000000) |
|---|
| 811 | /* 2.終了年月日 (YYYYMMDD 235959) |
|---|
| 812 | /* 3.エラー ( 0 = OK, 1 = NG ) |
|---|
| 813 | /*-----------------------------------------------------------------*/ |
|---|
| 814 | // value[0] = 項目名1 |
|---|
| 815 | // value[1] = 項目名2 |
|---|
| 816 | // value[2] = start_year |
|---|
| 817 | // value[3] = start_month |
|---|
| 818 | // value[4] = end_year |
|---|
| 819 | // value[5] = end_month |
|---|
| 820 | function CHECK_SET_TERM3 ($value) { |
|---|
| 821 | |
|---|
| 822 | // 期間指定 |
|---|
| 823 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[4]])) { |
|---|
| 824 | return; |
|---|
| 825 | } |
|---|
| 826 | $this->createParam($value); |
|---|
| 827 | $error = 0; |
|---|
| 828 | if ( (strlen($this->arrParam[$value[2]]) > 0 || strlen($this->arrParam[$value[3]]) > 0) && ! checkdate($this->arrParam[$value[3]], 1, $this->arrParam[$value[2]]) ) { |
|---|
| 829 | $this->arrErr[$value[2]] = "※ " . $value[0] . "を正しく指定してください。<br />"; |
|---|
| 830 | } |
|---|
| 831 | if ( (strlen($this->arrParam[$value[4]]) > 0 || strlen($this->arrParam[$value[5]]) > 0) && ! checkdate($this->arrParam[$value[5]], 1, $this->arrParam[$value[4]]) ) { |
|---|
| 832 | $this->arrErr[$value[4]] = "※ " . $value[1] . "を正しく指定してください。<br />"; |
|---|
| 833 | } |
|---|
| 834 | 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 ))) { |
|---|
| 835 | |
|---|
| 836 | $date1 = $this->arrParam[$value[2]] .sprintf("%02d", $this->arrParam[$value[3]]); |
|---|
| 837 | $date2 = $this->arrParam[$value[4]] .sprintf("%02d", $this->arrParam[$value[5]]); |
|---|
| 838 | |
|---|
| 839 | if (($this->arrErr[$value[2]] == "" && $this->arrErr[$value[5]] == "") && $date1 > $date2) { |
|---|
| 840 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
|---|
| 841 | } |
|---|
| 842 | } |
|---|
| 843 | } |
|---|
| 844 | |
|---|
| 845 | //ディレクトリ存在チェック |
|---|
| 846 | function DIR_CHECK ($value) { |
|---|
| 847 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 848 | return; |
|---|
| 849 | } |
|---|
| 850 | $this->createParam($value); |
|---|
| 851 | if(!is_dir($this->arrParam[$value[1]])) { |
|---|
| 852 | $this->arrErr[$value[1]] = "※ 指定した" . $value[0] . "は存在しません。<br />"; |
|---|
| 853 | } |
|---|
| 854 | } |
|---|
| 855 | |
|---|
| 856 | //ディレクトリ存在チェック |
|---|
| 857 | function DOMAIN_CHECK ($value) { |
|---|
| 858 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 859 | return; |
|---|
| 860 | } |
|---|
| 861 | if(strlen($this->arrParam[$value[1]]) > 0 && !ereg("^\.[^.]+\..+", $this->arrParam[$value[1]])) { |
|---|
| 862 | $this->arrErr[$value[1]] = "※ " . $value[0] . "の形式が不正です。<br />"; |
|---|
| 863 | } |
|---|
| 864 | } |
|---|
| 865 | |
|---|
| 866 | /* 携帯メールアドレスの判定 */ |
|---|
| 867 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
|---|
| 868 | function MOBILE_EMAIL_CHECK( $value ){ // メールアドレスを正規表現で判定する |
|---|
| 869 | if(isset($this->arrErr[$value[1]])) { |
|---|
| 870 | return; |
|---|
| 871 | } |
|---|
| 872 | $this->createParam($value); |
|---|
| 873 | $objMobile = new SC_Helper_Mobile_Ex(); |
|---|
| 874 | if(strlen($this->arrParam[$value[1]]) > 0 && !$objMobile->gfIsMobileMailAddress($this->arrParam[$value[1]])) { |
|---|
| 875 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は携帯電話のものではありません。<br />"; |
|---|
| 876 | } |
|---|
| 877 | } |
|---|
| 878 | /** |
|---|
| 879 | * 禁止文字列のチェック |
|---|
| 880 | * value[0] = 項目名 value[1] = 判定対象文字列 |
|---|
| 881 | * value[2] = 入力を禁止する文字列(配列) |
|---|
| 882 | * |
|---|
| 883 | * @example $objErr->doFunc(array("URL", "contents", $arrReviewDenyURL), array("PROHIBITED_STR_CHECK")); |
|---|
| 884 | */ |
|---|
| 885 | function PROHIBITED_STR_CHECK( $value ) { |
|---|
| 886 | if( isset($this->arrErr[$value[1]]) || empty($this->arrParam[$value[1]]) ) { |
|---|
| 887 | return; |
|---|
| 888 | } |
|---|
| 889 | $this->createParam($value); |
|---|
| 890 | $targetStr = $this->arrParam[$value[1]]; |
|---|
| 891 | $prohibitedStr = str_replace(array('|', '/'), array('\|', '\/'), $value[2]); |
|---|
| 892 | |
|---|
| 893 | $pattern = '/' . join('|', $prohibitedStr) . '/i'; |
|---|
| 894 | if(preg_match_all($pattern, $this->arrParam[$value[1]], $matches)) { |
|---|
| 895 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は入力できません。<br />"; |
|---|
| 896 | } |
|---|
| 897 | } |
|---|
| 898 | |
|---|
| 899 | /** |
|---|
| 900 | * PHPコードとして評価可能かチェックする. |
|---|
| 901 | * |
|---|
| 902 | * @access private |
|---|
| 903 | * @param array $value [0] => 項目名, [1] => 評価する文字列 |
|---|
| 904 | * @return void |
|---|
| 905 | */ |
|---|
| 906 | function EVAL_CHECK($value) { |
|---|
| 907 | if (isset($this->arrErr[$value[0]])) { |
|---|
| 908 | return; |
|---|
| 909 | } |
|---|
| 910 | $this->createParam($value); |
|---|
| 911 | if ($this->evalCheck($value[1]) === false) { |
|---|
| 912 | $this->arrErr[$value[0]] = "※ " . $value[0] . " の形式が不正です。<br />"; |
|---|
| 913 | } |
|---|
| 914 | } |
|---|
| 915 | |
|---|
| 916 | /** |
|---|
| 917 | * $value が PHPコードとして評価可能かチェックする. |
|---|
| 918 | * |
|---|
| 919 | * @access private |
|---|
| 920 | * @param mixed PHPコードとして評価する文字列 |
|---|
| 921 | * @return mixed PHPコードとして評価できない場合 false, |
|---|
| 922 | * 評価可能な場合は評価した値 |
|---|
| 923 | */ |
|---|
| 924 | function evalCheck($value) {
|
|---|
| 925 | // falseは、正当な式と評価する。
|
|---|
| 926 | if($value === "false") {
|
|---|
| 927 | return true;
|
|---|
| 928 | } |
|---|
| 929 | return @eval("return " . $value . ";"); |
|---|
| 930 | } |
|---|
| 931 | |
|---|
| 932 | /** |
|---|
| 933 | * 未定義の $this->arrParam に空要素を代入する. |
|---|
| 934 | * |
|---|
| 935 | * @access private |
|---|
| 936 | * @param array $value 配列 |
|---|
| 937 | * @return void |
|---|
| 938 | */ |
|---|
| 939 | function createParam($value) { |
|---|
| 940 | foreach ($value as $key) { |
|---|
| 941 | if (is_string($key) || is_int($key)) { |
|---|
| 942 | if (!isset($this->arrParam[$key])) $this->arrParam[$key] = ""; |
|---|
| 943 | } |
|---|
| 944 | } |
|---|
| 945 | } |
|---|
| 946 | } |
|---|
| 947 | ?> |
|---|