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 GRAPH_CHECK( $value ) { // 入力文字が英数記号以外ならエラーを返す |
---|
468 | if(isset($this->arrErr[$value[1]])) { |
---|
469 | return; |
---|
470 | } |
---|
471 | $this->createParam($value); |
---|
472 | if( strlen($this->arrParam[$value[1]]) > 0 && ! EregI("^[[:graph:]]+$", $this->arrParam[$value[1]] ) ) { |
---|
473 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は英数記号で入力してください。<br />"; |
---|
474 | } |
---|
475 | } |
---|
476 | |
---|
477 | /* 必須選択の判定 */ |
---|
478 | // value[0] = 項目名 value[1] = 判定対象 |
---|
479 | function ZERO_CHECK( $value ) { // 入力値で0が許されない場合エラーを返す |
---|
480 | $this->createParam($value); |
---|
481 | if($this->arrParam[$value[1]] == "0" ){ |
---|
482 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は1以上を入力してください。<br />"; |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | /* 桁数の判定 (最小最大)*/ |
---|
487 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小桁数 value[3] = 最大桁数 |
---|
488 | function NUM_RANGE_CHECK( $value ) { // 入力文字の桁数判定 → 最小桁数<入力文字列<最大桁数 |
---|
489 | if(isset($this->arrErr[$value[1]])) { |
---|
490 | return; |
---|
491 | } |
---|
492 | $this->createParam($value); |
---|
493 | // $this->arrParam[$value[0]] = mb_convert_kana($this->arrParam[$value[0]], "n"); |
---|
494 | $count = strlen($this->arrParam[$value[1]]); |
---|
495 | if( ( $count > 0 ) && $value[2] > $count || $value[3] < $count ) { |
---|
496 | $this->arrErr[$value[1]] = "※ $value[0]は$value[2]桁~$value[3]桁で入力して下さい。<br />"; |
---|
497 | } |
---|
498 | } |
---|
499 | |
---|
500 | /* 桁数の判定 */ |
---|
501 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 桁数 |
---|
502 | function NUM_COUNT_CHECK( $value ) { // 入力文字の桁数判定 → 入力文字列 = 桁数 以外はNGの場合 |
---|
503 | if(isset($this->arrErr[$value[1]])) { |
---|
504 | return; |
---|
505 | } |
---|
506 | $this->createParam($value); |
---|
507 | $count = strlen($this->arrParam[$value[1]]); |
---|
508 | if(($count > 0) && $count != $value[2] ) { |
---|
509 | $this->arrErr[$value[1]] = "※ $value[0]は$value[2]桁で入力して下さい。<br />"; |
---|
510 | } |
---|
511 | } |
---|
512 | |
---|
513 | /* メールアドレス形式の判定 */ |
---|
514 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
---|
515 | function EMAIL_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("^[^@]+@[^.]+\..+", $this->arrParam[$value[1]])) { |
---|
521 | $this->arrErr[$value[1]] = "※ " . $value[0] . "の形式が不正です。<br />"; |
---|
522 | } |
---|
523 | } |
---|
524 | |
---|
525 | /* メールアドレスに使用できる文字の判定 */ |
---|
526 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
---|
527 | function EMAIL_CHAR_CHECK( $value ){ // メールアドレスに使用する文字を正規表現で判定する |
---|
528 | if(isset($this->arrErr[$value[1]])) { |
---|
529 | return; |
---|
530 | } |
---|
531 | $this->createParam($value); |
---|
532 | if(strlen($this->arrParam[$value[1]]) > 0 && !ereg("^[a-zA-Z0-9_\.@\+\?-]+$",$this->arrParam[$value[1]]) ) { |
---|
533 | $this->arrErr[$value[1]] = "※ " . $value[0] . "に使用する文字を正しく入力してください。<br />"; |
---|
534 | } |
---|
535 | } |
---|
536 | |
---|
537 | /* URL形式の判定 */ |
---|
538 | // value[0] = 項目名 value[1] = 判定対象URL |
---|
539 | function URL_CHECK( $value ){ // URLを正規表現で判定する。デフォルトでhttp://があってもOK |
---|
540 | if(isset($this->arrErr[$value[1]])) { |
---|
541 | return; |
---|
542 | } |
---|
543 | if( strlen($this->arrParam[$value[1]]) > 0 && !ereg( "^https?://+($|[a-zA-Z0-9_~=:&\?\.\/-])+$", $this->arrParam[$value[1]] ) ) { |
---|
544 | $this->arrErr[$value[1]] = "※ " . $value[0] . "を正しく入力してください。<br />"; |
---|
545 | } |
---|
546 | } |
---|
547 | |
---|
548 | /* 拡張子の判定 */ |
---|
549 | // value[0] = 項目名 value[1] = 判定対象 value[2]=array(拡張子) |
---|
550 | function FILE_EXT_CHECK( $value ) { // 受け取りがない場合エラーを返す |
---|
551 | if(isset($this->arrErr[$value[1]]) || count($value[2]) == 0) { |
---|
552 | return; |
---|
553 | } |
---|
554 | $this->createParam($value); |
---|
555 | |
---|
556 | if($_FILES[$value[1]]['name'] != "" ) { |
---|
557 | $errFlag = 1; |
---|
558 | $array_ext = explode(".", $_FILES[$value[1]]['name']); |
---|
559 | $ext = $array_ext[ count ( $array_ext ) - 1 ]; |
---|
560 | $ext = strtolower($ext); |
---|
561 | |
---|
562 | $strExt = ""; |
---|
563 | |
---|
564 | foreach ( $value[2] as $checkExt ){ |
---|
565 | if ( $ext == $checkExt) { |
---|
566 | $errFlag = 0; |
---|
567 | } |
---|
568 | |
---|
569 | if($strExt == "") { |
---|
570 | $strExt.= $checkExt; |
---|
571 | } else { |
---|
572 | $strExt.= "・$checkExt"; |
---|
573 | } |
---|
574 | } |
---|
575 | } |
---|
576 | if ($errFlag == 1) { |
---|
577 | $this->arrErr[$value[1]] = "※ " . $value[0] . "で許可されている形式は、" . $strExt . "です。<br />"; |
---|
578 | } |
---|
579 | } |
---|
580 | |
---|
581 | /* ファイルが存在するかチェックする */ |
---|
582 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定ディレクトリ |
---|
583 | function FIND_FILE( $value ) { // 受け取りがない場合エラーを返す |
---|
584 | if(isset($this->arrErr[$value[1]])) { |
---|
585 | return; |
---|
586 | } |
---|
587 | |
---|
588 | $this->createParam($value); |
---|
589 | if($value[2] != "") { |
---|
590 | $dir = $value[2]; |
---|
591 | } else { |
---|
592 | $dir = IMAGE_SAVE_DIR; |
---|
593 | } |
---|
594 | |
---|
595 | $path = $dir . "/" . $this->arrParam[$value[1]]; |
---|
596 | $path = ereg_replace("//", "/", $path); |
---|
597 | |
---|
598 | if($this->arrParam[$value[1]] != "" && !file_exists($path)){ |
---|
599 | $this->arrErr[$value[1]] = "※ " . $path . "が見つかりません。<br />"; |
---|
600 | } |
---|
601 | } |
---|
602 | |
---|
603 | /* ファイルが上げられたか確認 */ |
---|
604 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定サイズ(KB) |
---|
605 | function FILE_EXIST_CHECK( $value ) { // 受け取りがない場合エラーを返す |
---|
606 | if(isset($this->arrErr[$value[1]])) { |
---|
607 | return; |
---|
608 | } |
---|
609 | $this->createParam($value); |
---|
610 | if(!($_FILES[$value[1]]['size'] != "" && $_FILES[$value[1]]['size'] > 0)){ |
---|
611 | $this->arrErr[$value[1]] = "※ " . $value[0] . "をアップロードして下さい。<br />"; |
---|
612 | } |
---|
613 | } |
---|
614 | |
---|
615 | /* ファイルサイズの判定 */ |
---|
616 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定サイズ(KB) |
---|
617 | function FILE_SIZE_CHECK( $value ) { // 受け取りがない場合エラーを返す |
---|
618 | if(isset($this->arrErr[$value[1]])) { |
---|
619 | return; |
---|
620 | } |
---|
621 | $this->createParam($value); |
---|
622 | if( $_FILES[$value[1]]['size'] > $value[2] * 1024 ){ |
---|
623 | $byte = "KB"; |
---|
624 | if( $value[2] >= 1000 ) { |
---|
625 | $value[2] = $value[2] / 1000; |
---|
626 | $byte = "MB"; |
---|
627 | } |
---|
628 | $this->arrErr[$value[1]] = "※ " . $value[0] . "のファイルサイズは" . $value[2] . $byte . "以下のものを使用してください。<br />"; |
---|
629 | } |
---|
630 | } |
---|
631 | |
---|
632 | /* ファイル名の判定 */ |
---|
633 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
634 | function FILE_NAME_CHECK( $value ) { // 入力文字が英数字,"_","-"以外ならエラーを返す |
---|
635 | if(isset($this->arrErr[$value[1]])) { |
---|
636 | return; |
---|
637 | } |
---|
638 | $this->createParam($value); |
---|
639 | if( strlen($_FILES[$value[1]]['name']) > 0 && ! EregI("^[[:alnum:]_\.-]+$", $_FILES[$value[1]]['name']) ) { |
---|
640 | $this->arrErr[$value[1]] = "※ " . $value[0] . "のファイル名に日本語やスペースは使用しないで下さい。<br />"; |
---|
641 | } |
---|
642 | } |
---|
643 | |
---|
644 | /* ファイル名の判定(アップロード以外の時) */ |
---|
645 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
646 | function FILE_NAME_CHECK_BY_NOUPLOAD( $value ) { // 入力文字が英数字,"_","-"以外ならエラーを返す |
---|
647 | if(isset($this->arrErr[$value[1]])) { |
---|
648 | return; |
---|
649 | } |
---|
650 | $this->createParam($value); |
---|
651 | if( strlen($this->arrParam[$value[1]]) > 0 && ! EregI("^[[:alnum:]_\.-]+$", $this->arrParam[$value[1]]) || EregI("[\\]" ,$this->arrParam[$value[1]])) { |
---|
652 | $this->arrErr[$value[1]] = "※ " . $value[0] . "のファイル名に日本語やスペースは使用しないで下さい。<br />"; |
---|
653 | } |
---|
654 | } |
---|
655 | |
---|
656 | //日付チェック |
---|
657 | // value[0] = 項目名 |
---|
658 | // value[1] = YYYY |
---|
659 | // value[2] = MM |
---|
660 | // value[3] = DD |
---|
661 | function CHECK_DATE($value) { |
---|
662 | if(isset($this->arrErr[$value[1]])) { |
---|
663 | return; |
---|
664 | } |
---|
665 | $this->createParam($value); |
---|
666 | // 少なくともどれか一つが入力されている。 |
---|
667 | if($this->arrParam[$value[1]] > 0 || $this->arrParam[$value[2]] > 0 || $this->arrParam[$value[3]] > 0) { |
---|
668 | // 年月日のどれかが入力されていない。 |
---|
669 | if(!(strlen($this->arrParam[$value[1]]) > 0 && strlen($this->arrParam[$value[2]]) > 0 && strlen($this->arrParam[$value[3]]) > 0)) { |
---|
670 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
---|
671 | } else if ( ! checkdate($this->arrParam[$value[2]], $this->arrParam[$value[3]], $this->arrParam[$value[1]])) { |
---|
672 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が正しくありません。<br />"; |
---|
673 | } |
---|
674 | } |
---|
675 | } |
---|
676 | |
---|
677 | //日付チェック |
---|
678 | // value[0] = 項目名 |
---|
679 | // value[1] = YYYY |
---|
680 | // value[2] = MM |
---|
681 | // value[3] = DD |
---|
682 | // value[4] = HH |
---|
683 | // value[5] = mm |
---|
684 | function CHECK_DATE2($value) { |
---|
685 | if(isset($this->arrErr[$value[1]])) { |
---|
686 | return; |
---|
687 | } |
---|
688 | $this->createParam($value); |
---|
689 | // 少なくともどれか一つが入力されている。 |
---|
690 | 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) { |
---|
691 | // 年月日時のどれかが入力されていない。 |
---|
692 | 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 )) { |
---|
693 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
---|
694 | } else if ( ! checkdate($this->arrParam[$value[2]], $this->arrParam[$value[3]], $this->arrParam[$value[1]])) { |
---|
695 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が正しくありません。<br />"; |
---|
696 | } |
---|
697 | } |
---|
698 | } |
---|
699 | |
---|
700 | //日付チェック |
---|
701 | // value[0] = 項目名 |
---|
702 | // value[1] = YYYY |
---|
703 | // value[2] = MM |
---|
704 | function CHECK_DATE3($value) { |
---|
705 | if(isset($this->arrErr[$value[1]])) { |
---|
706 | return; |
---|
707 | } |
---|
708 | $this->createParam($value); |
---|
709 | // 少なくともどれか一つが入力されている。 |
---|
710 | if($this->arrParam[$value[1]] > 0 || $this->arrParam[$value[2]] > 0) { |
---|
711 | // 年月日時のどれかが入力されていない。 |
---|
712 | if(!(strlen($this->arrParam[$value[1]]) > 0 && strlen($this->arrParam[$value[2]]) > 0)) { |
---|
713 | $this->arrErr[$value[1]] = "※ " . $value[0] . "はすべての項目を入力して下さい。<br />"; |
---|
714 | } else if ( ! checkdate($this->arrParam[$value[2]], 1, $this->arrParam[$value[1]])) { |
---|
715 | $this->arrErr[$value[1]] = "※ " . $value[0] . "が正しくありません。<br />"; |
---|
716 | } |
---|
717 | } |
---|
718 | } |
---|
719 | |
---|
720 | //誕生日チェック |
---|
721 | // value[0] = 項目名 |
---|
722 | // value[1] = YYYY |
---|
723 | // value[2] = MM |
---|
724 | // value[3] = DD |
---|
725 | function CHECK_BIRTHDAY($value) { |
---|
726 | if (isset($this->arrErr[$value[1]])) { |
---|
727 | return; |
---|
728 | } |
---|
729 | |
---|
730 | $this->createParam($value); |
---|
731 | // 年が入力されている。 |
---|
732 | if ($this->arrParam[$value[1]] > 0) { |
---|
733 | |
---|
734 | // 年の数字チェック、最小数値制限チェック |
---|
735 | $this->doFunc(array($value[0].'(年)', $value[1], START_BIRTH_YEAR), array("NUM_CHECK", "MIN_CHECK")); |
---|
736 | // 上のチェックでエラーある場合、中断する。 |
---|
737 | if (isset($this->arrErr[$value[1]])) { |
---|
738 | return; |
---|
739 | } |
---|
740 | |
---|
741 | // 年の最大数値制限チェック |
---|
742 | $this->doFunc(array($value[0].'(年)', $value[1], date("Y",strtotime("now"))), array("MAX_CHECK")); |
---|
743 | // 上のチェックでエラーある場合、中断する。 |
---|
744 | if (isset($this->arrErr[$value[1]])) { |
---|
745 | return; |
---|
746 | } |
---|
747 | } |
---|
748 | |
---|
749 | // XXX createParam() が二重に呼ばれる問題を抱える |
---|
750 | $this->CHECK_DATE($value); |
---|
751 | } |
---|
752 | |
---|
753 | /*-----------------------------------------------------------------*/ |
---|
754 | /* CHECK_SET_TERM |
---|
755 | /* 年月日に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
---|
756 | /* 引数 (開始年,開始月,開始日,終了年,終了月,終了日) |
---|
757 | /* 戻値 array(1,2,3) |
---|
758 | /* 1.開始年月日 (YYYYMMDD 000000) |
---|
759 | /* 2.終了年月日 (YYYYMMDD 235959) |
---|
760 | /* 3.エラー ( 0 = OK, 1 = NG ) |
---|
761 | /*-----------------------------------------------------------------*/ |
---|
762 | // value[0] = 項目名1 |
---|
763 | // value[1] = 項目名2 |
---|
764 | // value[2] = start_year |
---|
765 | // value[3] = start_month |
---|
766 | // value[4] = start_day |
---|
767 | // value[5] = end_year |
---|
768 | // value[6] = end_month |
---|
769 | // value[7] = end_day |
---|
770 | function CHECK_SET_TERM ($value) { |
---|
771 | |
---|
772 | // 期間指定 |
---|
773 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[5]])) { |
---|
774 | return; |
---|
775 | } |
---|
776 | $this->createParam($value); |
---|
777 | $error = 0; |
---|
778 | 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]]) ) { |
---|
779 | $this->arrErr[$value[2]] = "※ " . $value[0] . "を正しく指定してください。<br />"; |
---|
780 | } |
---|
781 | 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]]) ) { |
---|
782 | $this->arrErr[$value[5]] = "※ " . $value[1] . "を正しく指定してください。<br />"; |
---|
783 | } |
---|
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 || strlen($this->arrParam[$value[6]]) > 0 || strlen($this->arrParam[$value[7]] ) > 0) ){ |
---|
785 | |
---|
786 | $date1 = $this->arrParam[$value[2]] .sprintf("%02d", $this->arrParam[$value[3]]) .sprintf("%02d",$this->arrParam[$value[4]]) ."000000"; |
---|
787 | $date2 = $this->arrParam[$value[5]] .sprintf("%02d", $this->arrParam[$value[6]]) .sprintf("%02d",$this->arrParam[$value[7]]) ."235959"; |
---|
788 | |
---|
789 | if (($this->arrErr[$value[2]] == "" && $this->arrErr[$value[5]] == "") && $date1 > $date2) { |
---|
790 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
---|
791 | } |
---|
792 | } |
---|
793 | } |
---|
794 | |
---|
795 | /*-----------------------------------------------------------------*/ |
---|
796 | /* CHECK_SET_TERM2 |
---|
797 | /* 年月日時に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
---|
798 | /* 引数 (開始年,開始月,開始日,開始時間,開始分,開始秒, |
---|
799 | /* 終了年,終了月,終了日,終了時間,終了分,終了秒) |
---|
800 | /* 戻値 array(1,2,3) |
---|
801 | /* 1.開始年月日 (YYYYMMDDHHmmss) |
---|
802 | /* 2.終了年月日 (YYYYMMDDHHmmss) |
---|
803 | /* 3.エラー ( 0 = OK, 1 = NG ) |
---|
804 | /*-----------------------------------------------------------------*/ |
---|
805 | // value[0] = 項目名1 |
---|
806 | // value[1] = 項目名2 |
---|
807 | // value[2] = start_year |
---|
808 | // value[3] = start_month |
---|
809 | // value[4] = start_day |
---|
810 | // value[5] = start_hour |
---|
811 | // value[6] = start_minute |
---|
812 | // value[7] = start_second |
---|
813 | // value[8] = end_year |
---|
814 | // value[9] = end_month |
---|
815 | // value[10] = end_day |
---|
816 | // value[11] = end_hour |
---|
817 | // value[12] = end_minute |
---|
818 | // value[13] = end_second |
---|
819 | |
---|
820 | /*-----------------------------------------------------------------*/ |
---|
821 | function CHECK_SET_TERM2 ($value) { |
---|
822 | |
---|
823 | // 期間指定 |
---|
824 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[8]])) { |
---|
825 | return; |
---|
826 | } |
---|
827 | $this->createParam($value); |
---|
828 | $error = 0; |
---|
829 | 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]]) ) { |
---|
830 | $this->arrErr[$value[2]] = "※ " . $value[0] . "を正しく指定してください。<br />"; |
---|
831 | } |
---|
832 | 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]]) ) { |
---|
833 | $this->arrErr[$value[8]] = "※ " . $value[1] . "を正しく指定してください。<br />"; |
---|
834 | } |
---|
835 | 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) ){ |
---|
836 | |
---|
837 | $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]]); |
---|
838 | $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]]); |
---|
839 | |
---|
840 | if (($this->arrErr[$value[2]] == "" && $this->arrErr[$value[8]] == "") && $date1 > $date2) { |
---|
841 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
---|
842 | } |
---|
843 | if($date1 == $date2) { |
---|
844 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
---|
845 | } |
---|
846 | |
---|
847 | } |
---|
848 | } |
---|
849 | |
---|
850 | /*-----------------------------------------------------------------*/ |
---|
851 | /* CHECK_SET_TERM3 |
---|
852 | /* 年月に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
---|
853 | /* 引数 (開始年,開始月,終了年,終了月) |
---|
854 | /* 戻値 array(1,2,3) |
---|
855 | /* 1.開始年月日 (YYYYMMDD 000000) |
---|
856 | /* 2.終了年月日 (YYYYMMDD 235959) |
---|
857 | /* 3.エラー ( 0 = OK, 1 = NG ) |
---|
858 | /*-----------------------------------------------------------------*/ |
---|
859 | // value[0] = 項目名1 |
---|
860 | // value[1] = 項目名2 |
---|
861 | // value[2] = start_year |
---|
862 | // value[3] = start_month |
---|
863 | // value[4] = end_year |
---|
864 | // value[5] = end_month |
---|
865 | function CHECK_SET_TERM3 ($value) { |
---|
866 | |
---|
867 | // 期間指定 |
---|
868 | if(isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[4]])) { |
---|
869 | return; |
---|
870 | } |
---|
871 | $this->createParam($value); |
---|
872 | $error = 0; |
---|
873 | if ( (strlen($this->arrParam[$value[2]]) > 0 || strlen($this->arrParam[$value[3]]) > 0) && ! checkdate($this->arrParam[$value[3]], 1, $this->arrParam[$value[2]]) ) { |
---|
874 | $this->arrErr[$value[2]] = "※ " . $value[0] . "を正しく指定してください。<br />"; |
---|
875 | } |
---|
876 | if ( (strlen($this->arrParam[$value[4]]) > 0 || strlen($this->arrParam[$value[5]]) > 0) && ! checkdate($this->arrParam[$value[5]], 1, $this->arrParam[$value[4]]) ) { |
---|
877 | $this->arrErr[$value[4]] = "※ " . $value[1] . "を正しく指定してください。<br />"; |
---|
878 | } |
---|
879 | 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 ))) { |
---|
880 | |
---|
881 | $date1 = $this->arrParam[$value[2]] .sprintf("%02d", $this->arrParam[$value[3]]); |
---|
882 | $date2 = $this->arrParam[$value[4]] .sprintf("%02d", $this->arrParam[$value[5]]); |
---|
883 | |
---|
884 | if (($this->arrErr[$value[2]] == "" && $this->arrErr[$value[5]] == "") && $date1 > $date2) { |
---|
885 | $this->arrErr[$value[2]] = "※ " .$value[0]. "と" .$value[1]. "の期間指定が不正です。<br />"; |
---|
886 | } |
---|
887 | } |
---|
888 | } |
---|
889 | |
---|
890 | //ディレクトリ存在チェック |
---|
891 | function DIR_CHECK ($value) { |
---|
892 | if(isset($this->arrErr[$value[1]])) { |
---|
893 | return; |
---|
894 | } |
---|
895 | $this->createParam($value); |
---|
896 | if(!is_dir($this->arrParam[$value[1]])) { |
---|
897 | $this->arrErr[$value[1]] = "※ 指定した" . $value[0] . "は存在しません。<br />"; |
---|
898 | } |
---|
899 | } |
---|
900 | |
---|
901 | //ディレクトリ存在チェック |
---|
902 | function DOMAIN_CHECK ($value) { |
---|
903 | if(isset($this->arrErr[$value[1]])) { |
---|
904 | return; |
---|
905 | } |
---|
906 | if(strlen($this->arrParam[$value[1]]) > 0 && !ereg("^\.[^.]+\..+", $this->arrParam[$value[1]])) { |
---|
907 | $this->arrErr[$value[1]] = "※ " . $value[0] . "の形式が不正です。<br />"; |
---|
908 | } |
---|
909 | } |
---|
910 | |
---|
911 | /* 携帯メールアドレスの判定 */ |
---|
912 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
---|
913 | function MOBILE_EMAIL_CHECK( $value ){ // メールアドレスを正規表現で判定する |
---|
914 | if(isset($this->arrErr[$value[1]])) { |
---|
915 | return; |
---|
916 | } |
---|
917 | $this->createParam($value); |
---|
918 | $objMobile = new SC_Helper_Mobile_Ex(); |
---|
919 | if(strlen($this->arrParam[$value[1]]) > 0 && !$objMobile->gfIsMobileMailAddress($this->arrParam[$value[1]])) { |
---|
920 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は携帯電話のものではありません。<br />"; |
---|
921 | } |
---|
922 | } |
---|
923 | /** |
---|
924 | * 禁止文字列のチェック |
---|
925 | * value[0] = 項目名 value[1] = 判定対象文字列 |
---|
926 | * value[2] = 入力を禁止する文字列(配列) |
---|
927 | * |
---|
928 | * @example $objErr->doFunc(array("URL", "contents", $arrReviewDenyURL), array("PROHIBITED_STR_CHECK")); |
---|
929 | */ |
---|
930 | function PROHIBITED_STR_CHECK( $value ) { |
---|
931 | if( isset($this->arrErr[$value[1]]) || empty($this->arrParam[$value[1]]) ) { |
---|
932 | return; |
---|
933 | } |
---|
934 | $this->createParam($value); |
---|
935 | $targetStr = $this->arrParam[$value[1]]; |
---|
936 | $prohibitedStr = str_replace(array('|', '/'), array('\|', '\/'), $value[2]); |
---|
937 | |
---|
938 | $pattern = '/' . join('|', $prohibitedStr) . '/i'; |
---|
939 | if(preg_match_all($pattern, $this->arrParam[$value[1]], $matches)) { |
---|
940 | $this->arrErr[$value[1]] = "※ " . $value[0] . "は入力できません。<br />"; |
---|
941 | } |
---|
942 | } |
---|
943 | |
---|
944 | /** |
---|
945 | * PHPコードとして評価可能かチェックする. |
---|
946 | * |
---|
947 | * @access private |
---|
948 | * @param array $value [0] => 項目名, [1] => 評価する文字列 |
---|
949 | * @return void |
---|
950 | */ |
---|
951 | function EVAL_CHECK($value) { |
---|
952 | if (isset($this->arrErr[$value[0]])) { |
---|
953 | return; |
---|
954 | } |
---|
955 | $this->createParam($value); |
---|
956 | if ($this->evalCheck($value[1]) === false) { |
---|
957 | $this->arrErr[$value[0]] = "※ " . $value[0] . " の形式が不正です。<br />"; |
---|
958 | } |
---|
959 | } |
---|
960 | |
---|
961 | /** |
---|
962 | * $value が PHPコードとして評価可能かチェックする. |
---|
963 | * |
---|
964 | * @access private |
---|
965 | * @param mixed PHPコードとして評価する文字列 |
---|
966 | * @return mixed PHPコードとして評価できない場合 false, |
---|
967 | * 評価可能な場合は評価した値 |
---|
968 | */ |
---|
969 | function evalCheck($value) { |
---|
970 | // falseは、正当な式と評価する。 |
---|
971 | if($value === "false") { |
---|
972 | return true; |
---|
973 | } |
---|
974 | return @eval("return " . $value . ";"); |
---|
975 | } |
---|
976 | |
---|
977 | /** |
---|
978 | * 未定義の $this->arrParam に空要素を代入する. |
---|
979 | * |
---|
980 | * @access private |
---|
981 | * @param array $value 配列 |
---|
982 | * @return void |
---|
983 | */ |
---|
984 | function createParam($value) { |
---|
985 | foreach ($value as $key) { |
---|
986 | if (is_string($key) || is_int($key)) { |
---|
987 | if (!isset($this->arrParam[$key])) $this->arrParam[$key] = ""; |
---|
988 | } |
---|
989 | } |
---|
990 | } |
---|
991 | } |
---|
992 | ?> |
---|