| 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
| 5 | * Copyright(c) 2000-2012 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 __construct($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 | /** |
---|
| 50 | * HTMLのタグをチェックする |
---|
| 51 | * |
---|
| 52 | * @param array $value value[0] = 項目名 value[1] = 判定対象 value[2] = 許可するタグが格納された配列 |
---|
| 53 | * @return void |
---|
| 54 | */ |
---|
| 55 | function HTML_TAG_CHECK($value) { |
---|
| 56 | if (isset($this->arrErr[$value[1]])) { |
---|
| 57 | return; |
---|
| 58 | } |
---|
| 59 | $this->createParam($value); |
---|
| 60 | // HTMLに含まれているタグを抽出する |
---|
| 61 | preg_match_all('/<\/?([a-z]+)/i', $this->arrParam[$value[1]], $arrTagIncludedHtml = array()); |
---|
| 62 | |
---|
| 63 | $arrDiffTag = array_diff($arrTagIncludedHtml[1], $value[2]); |
---|
| 64 | |
---|
| 65 | if (empty($arrDiffTag)) return; |
---|
| 66 | |
---|
| 67 | // 少々荒っぽいが、表示用 HTML に変換する |
---|
| 68 | foreach ($arrDiffTag as &$tag) { |
---|
| 69 | $tag = '[' . htmlspecialchars($tag) . ']'; |
---|
| 70 | } |
---|
| 71 | $html_diff_tag_list = implode(', ', $arrDiffTag); |
---|
| 72 | |
---|
| 73 | $this->arrErr[$value[1]] = t('c_* T_ARG2 contains the tag T_ARG1 which is not allowed. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $html_diff_tag_list)); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | /** |
---|
| 77 | * 必須入力の判定 |
---|
| 78 | * |
---|
| 79 | * 受け取りがない場合エラーを返す |
---|
| 80 | * @param array $value value[0] = 項目名 value[1] = 判定対象 |
---|
| 81 | * @return void |
---|
| 82 | */ |
---|
| 83 | function EXIST_CHECK($value) { |
---|
| 84 | if (isset($this->arrErr[$value[1]])) { |
---|
| 85 | return; |
---|
| 86 | } |
---|
| 87 | $this->createParam($value); |
---|
| 88 | if (!is_array($this->arrParam[$value[1]]) && strlen($this->arrParam[$value[1]]) == 0) { |
---|
| 89 | $this->arrErr[$value[1]] = t('c_* T_ARG1 is blank. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 90 | } else if (is_array($this->arrParam[$value[1]]) && count($this->arrParam[$value[1]]) == 0) { |
---|
| 91 | $this->arrErr[$value[1]] = t('c_* T_ARG1 is not selected. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | /** |
---|
| 96 | * 必須入力の判定(逆順) |
---|
| 97 | * |
---|
| 98 | * 受け取りがない場合エラーを返す |
---|
| 99 | * @param array $value value[0] = 判定対象 value[1] = 項目名 |
---|
| 100 | * @return void |
---|
| 101 | */ |
---|
| 102 | function EXIST_CHECK_REVERSE($value) { |
---|
| 103 | if (isset($this->arrErr[$value[0]])) { |
---|
| 104 | return; |
---|
| 105 | } |
---|
| 106 | // $this->createParam($value); |
---|
| 107 | if (strlen($this->arrParam[$value[0]]) == 0) { |
---|
| 108 | $this->arrErr[$value[0]] = t('c_* T_ARG1 is blank. <br />_01', array('T_ARG1' => $value[1])); |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | /** |
---|
| 113 | * スペース、タブの判定 |
---|
| 114 | * |
---|
| 115 | * 受け取りがない場合エラーを返す |
---|
| 116 | * @param array $value value[0] = 項目名 value[1] = 判定対象 |
---|
| 117 | * @return void |
---|
| 118 | */ |
---|
| 119 | function SPTAB_CHECK($value) { |
---|
| 120 | if (isset($this->arrErr[$value[1]])) { |
---|
| 121 | return; |
---|
| 122 | } |
---|
| 123 | $this->createParam($value); |
---|
| 124 | if (strlen($this->arrParam[$value[1]]) != 0 && preg_match("/^[ \t\r\n]+$/", $this->arrParam[$value[1]])) { |
---|
| 125 | $this->arrErr[$value[1]] = t('c_* Spaces, tabs and line breaks are not possible in T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | /** |
---|
| 130 | * スペース、タブの判定 |
---|
| 131 | * |
---|
| 132 | * 受け取りがない場合エラーを返す |
---|
| 133 | * @param array $value value[0] = 項目名 value[1] = 判定対象 |
---|
| 134 | * @return void |
---|
| 135 | */ |
---|
| 136 | function NO_SPTAB($value) { |
---|
| 137 | if (isset($this->arrErr[$value[1]])) { |
---|
| 138 | return; |
---|
| 139 | } |
---|
| 140 | $this->createParam($value); |
---|
| 141 | if (strlen($this->arrParam[$value[1]]) != 0 && preg_match("/[ \t\r\n]+/u", $this->arrParam[$value[1]])) { |
---|
| 142 | $this->arrErr[$value[1]] = t('c_* Do not include spaces, tabs or line breaks in T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 143 | } |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | /* ゼロで開始されている数値の判定 */ |
---|
| 147 | function ZERO_START($value) { |
---|
| 148 | if (isset($this->arrErr[$value[1]])) { |
---|
| 149 | return; |
---|
| 150 | } |
---|
| 151 | $this->createParam($value); |
---|
| 152 | if (strlen($this->arrParam[$value[1]]) != 0 && preg_match("/^[0]+[0-9]+$/", $this->arrParam[$value[1]])) { |
---|
| 153 | $this->arrErr[$value[1]] = t('c_* A numerical value that starts with 0 has been entered for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 154 | } |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | /** |
---|
| 158 | * 必須選択の判定 |
---|
| 159 | * |
---|
| 160 | * プルダウンなどで選択されていない場合エラーを返す |
---|
| 161 | * @param array $value value[0] = 項目名 value[1] = 判定対象 |
---|
| 162 | * @return void |
---|
| 163 | */ |
---|
| 164 | function SELECT_CHECK($value) { |
---|
| 165 | if (isset($this->arrErr[$value[1]])) { |
---|
| 166 | return; |
---|
| 167 | } |
---|
| 168 | $this->createParam($value); |
---|
| 169 | if (strlen($this->arrParam[$value[1]]) == 0) { |
---|
| 170 | $this->arrErr[$value[1]] = t('c_* T_ARG1 is not selected. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 171 | } |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | /** |
---|
| 175 | * 同一性の判定 |
---|
| 176 | * |
---|
| 177 | * 入力が指定文字数以上ならエラーを返す |
---|
| 178 | * @param array $value value[0] = 項目名1 value[1] = 項目名2 value[2] = 判定対象文字列1 value[3] = 判定対象文字列2 |
---|
| 179 | * @return void |
---|
| 180 | */ |
---|
| 181 | function EQUAL_CHECK($value) { |
---|
| 182 | if (isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
---|
| 183 | return; |
---|
| 184 | } |
---|
| 185 | // $this->createParam($value); |
---|
| 186 | // 文字数の取得 |
---|
| 187 | if ($this->arrParam[$value[2]] !== $this->arrParam[$value[3]]) { |
---|
| 188 | $this->arrErr[$value[2]] = t('c_* T_ARG1 and T_ARG2 do not match. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[1])); |
---|
| 189 | } |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | /** |
---|
| 193 | * 値が異なることの判定 |
---|
| 194 | * |
---|
| 195 | * 入力が指定文字数以上ならエラーを返す |
---|
| 196 | * @param array $value value[0] = 項目名1 value[1] = 項目名2 value[2] = 判定対象文字列1 value[3] = 判定対象文字列2 |
---|
| 197 | * @return void |
---|
| 198 | */ |
---|
| 199 | function DIFFERENT_CHECK($value) { |
---|
| 200 | if (isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
---|
| 201 | return; |
---|
| 202 | } |
---|
| 203 | // $this->createParam($value); |
---|
| 204 | // 文字数の取得 |
---|
| 205 | if ($this->arrParam[$value[2]] == $this->arrParam[$value[3]]) { |
---|
| 206 | $this->arrErr[$value[2]] = t('c_* The same value cannot be used for T_ARG1 and T_ARG2. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[1])); |
---|
| 207 | } |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | /** |
---|
| 211 | * 値の大きさを比較する value[2] < value[3]でなければエラー |
---|
| 212 | * |
---|
| 213 | * 入力が指定文字数以上ならエラーを返す |
---|
| 214 | * @param array $value value[0] = 項目名1 value[1] = 項目名2 value[2] = 判定対象文字列1 value[3] = 判定対象文字列2 |
---|
| 215 | * @return void |
---|
| 216 | */ |
---|
| 217 | function GREATER_CHECK($value) { |
---|
| 218 | if (isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
---|
| 219 | return; |
---|
| 220 | } |
---|
| 221 | // $this->createParam($value); |
---|
| 222 | // 文字数の取得 |
---|
| 223 | if ($this->arrParam[$value[2]] != '' && $this->arrParam[$value[3]] != '' && ($this->arrParam[$value[2]] > $this->arrParam[$value[3]])) { |
---|
| 224 | $this->arrErr[$value[2]] = t('c_* It is not possible to enter a larger value for T_ARG1 than for T_ARG2. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[1])); |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | /** |
---|
| 229 | * 最大文字数制限の判定 |
---|
| 230 | * |
---|
| 231 | * 入力が指定文字数以上ならエラーを返す |
---|
| 232 | * @param array $value value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最大文字数(半角も全角も1文字として数える) |
---|
| 233 | * @return void |
---|
| 234 | */ |
---|
| 235 | function MAX_LENGTH_CHECK($value) { |
---|
| 236 | if (isset($this->arrErr[$value[1]])) { |
---|
| 237 | return; |
---|
| 238 | } |
---|
| 239 | $this->createParam($value); |
---|
| 240 | // 文字数の取得 |
---|
| 241 | if (mb_strlen($this->arrParam[$value[1]]) > $value[2]) { |
---|
| 242 | $this->arrErr[$value[1]] = t('c_* For T_ARG1, enter T_ARG2 characters or less. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[2])); |
---|
| 243 | } |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | /** |
---|
| 247 | * 最小文字数制限の判定 |
---|
| 248 | * |
---|
| 249 | * 入力が指定文字数未満ならエラーを返す |
---|
| 250 | * @param array $value value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小文字数(半角も全角も1文字として数える) |
---|
| 251 | * @return void |
---|
| 252 | */ |
---|
| 253 | function MIN_LENGTH_CHECK($value) { |
---|
| 254 | if (isset($this->arrErr[$value[1]])) { |
---|
| 255 | return; |
---|
| 256 | } |
---|
| 257 | $this->createParam($value); |
---|
| 258 | // 文字数の取得 |
---|
| 259 | if (mb_strlen($this->arrParam[$value[1]]) < $value[2]) { |
---|
| 260 | $this->arrErr[$value[1]] = t_plural($value[2], 'c_* For T_ARG1, enter T_COUNT character or more. <br />_01', 'c_* For T_ARG1, enter T_COUNT characters or more. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 261 | } |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | /** |
---|
| 265 | * 最大文字数制限の判定 |
---|
| 266 | * |
---|
| 267 | * 入力が最大数以上ならエラーを返す |
---|
| 268 | * @param array $value value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最大数] |
---|
| 269 | * @return void |
---|
| 270 | */ |
---|
| 271 | function MAX_CHECK($value) { |
---|
| 272 | if (isset($this->arrErr[$value[1]])) { |
---|
| 273 | return; |
---|
| 274 | } |
---|
| 275 | $this->createParam($value); |
---|
| 276 | // 文字数の取得 |
---|
| 277 | if ($this->arrParam[$value[1]] > $value[2]) { |
---|
| 278 | $this->arrErr[$value[1]] = t('c_* For T_ARG1, enter T_ARG2 or smaller. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[2])); |
---|
| 279 | } |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | /** |
---|
| 283 | * 最小数値制限の判定 |
---|
| 284 | * |
---|
| 285 | * 入力が最小数未満ならエラーを返す |
---|
| 286 | * @param array $value value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小数 |
---|
| 287 | * @return void |
---|
| 288 | */ |
---|
| 289 | function MIN_CHECK($value) { |
---|
| 290 | if (isset($this->arrErr[$value[1]])) { |
---|
| 291 | return; |
---|
| 292 | } |
---|
| 293 | $this->createParam($value); |
---|
| 294 | if ($this->arrParam[$value[1]] < $value[2]) { |
---|
| 295 | $this->arrErr[$value[1]] = t_plural($value[2], 'c_* Enter T_COUNT or higher for T_ARG1. <br />_01', 'c_* Enter T_COUNT or higher for T_ARG1. <br />_02', array('T_ARG1' => $value[0])); |
---|
| 296 | } |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | /** |
---|
| 300 | * 数字の判定 |
---|
| 301 | * |
---|
| 302 | * 入力文字が数字以外ならエラーを返す |
---|
| 303 | * @param array $value value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 304 | * @return void |
---|
| 305 | */ |
---|
| 306 | function NUM_CHECK($value) { |
---|
| 307 | if (isset($this->arrErr[$value[1]])) { |
---|
| 308 | return; |
---|
| 309 | } |
---|
| 310 | $this->createParam($value); |
---|
| 311 | if ($this->numelicCheck($this->arrParam[$value[1]])) { |
---|
| 312 | $this->arrErr[$value[1]] = t('c_* Enter only numbers for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 313 | } |
---|
| 314 | } |
---|
| 315 | |
---|
| 316 | /** |
---|
| 317 | * 小数点を含む数字の判定 |
---|
| 318 | * |
---|
| 319 | * 入力文字が数字以外ならエラーを返す |
---|
| 320 | * @param array $value value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 321 | * @return void |
---|
| 322 | */ |
---|
| 323 | function NUM_POINT_CHECK($value) { |
---|
| 324 | if (isset($this->arrErr[$value[1]])) { |
---|
| 325 | return; |
---|
| 326 | } |
---|
| 327 | $this->createParam($value); |
---|
| 328 | if (strlen($this->arrParam[$value[1]]) > 0 && !is_numeric($this->arrParam[$value[1]])) { |
---|
| 329 | $this->arrErr[$value[1]] = t('c_* Enter only numbers for T_ARG1. <br />_02', array('T_ARG1' => $value[0])); |
---|
| 330 | } |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | function ALPHA_CHECK($value) { |
---|
| 334 | if (isset($this->arrErr[$value[1]])) { |
---|
| 335 | return; |
---|
| 336 | } |
---|
| 337 | $this->createParam($value); |
---|
| 338 | if (strlen($this->arrParam[$value[1]]) > 0 && !ctype_alpha($this->arrParam[$value[1]])) { |
---|
| 339 | $this->arrErr[$value[1]] = t('c_* Enter alphabetical characters for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 340 | } |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | /** |
---|
| 344 | * 電話番号の判定 |
---|
| 345 | * |
---|
| 346 | * 数字チェックと文字数チェックを実施する。 |
---|
| 347 | * @param array $value 各要素は以下の通り。<br> |
---|
| 348 | * [0]: 項目名<br> |
---|
| 349 | * [1]: 電番1項目目<br> |
---|
| 350 | * [2]: 電番2項目目<br> |
---|
| 351 | * [3]: 電番3項目目<br> |
---|
| 352 | * [4]: 電話番号各項目制限 (指定なしの場合、TEL_ITEM_LEN)<br> |
---|
| 353 | * [5]: 電話番号総数 (指定なしの場合、TEL_LEN) |
---|
| 354 | * @return void |
---|
| 355 | */ |
---|
| 356 | function TEL_CHECK($value) { |
---|
| 357 | $telItemLen = isset($value[4]) ? $value[4] : TEL_ITEM_LEN; |
---|
| 358 | $telLen = isset($value[5]) ? $value[5] : TEL_LEN; |
---|
| 359 | |
---|
| 360 | if (isset($this->arrErr[$value[1]]) || isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[3]])) { |
---|
| 361 | return; |
---|
| 362 | } |
---|
| 363 | $this->createParam($value); |
---|
| 364 | $cnt = 0; |
---|
| 365 | |
---|
| 366 | for ($i = 1; $i <= 3; $i++) { |
---|
| 367 | if (strlen($this->arrParam[$value[$i]]) > 0) { |
---|
| 368 | $cnt++; |
---|
| 369 | } |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | // すべての項目が満たされていない場合を判定(一部だけ入力されている状態) |
---|
| 373 | if ($cnt > 0 && $cnt < 3) { |
---|
| 374 | $this->arrErr[$value[1]] .= t('c_* Enter all items for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | $total_count = 0; |
---|
| 378 | for ($i = 1; $i <= 3; $i++) { |
---|
| 379 | if (strlen($this->arrParam[$value[$i]]) > 0 && strlen($this->arrParam[$value[$i]]) > $telItemLen) { |
---|
| 380 | $this->arrErr[$value[$i]] .= t('c_* T_ARG1 must be T_ARG2 characters or less. <br />_01', array('T_ARG1' => $value[0] . $i, 'T_ARG2' => $telItemLen)); |
---|
| 381 | } else if ($this->numelicCheck($this->arrParam[$value[1]])) { |
---|
| 382 | $this->arrErr[$value[$i]] .= t('c_* Enter numbers for T_ARG1. <br />_01', array('T_ARG1' => $value[0] . $i)); |
---|
| 383 | } |
---|
| 384 | $total_count += strlen($this->arrParam[$value[$i]]); |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | // 合計値チェック |
---|
| 388 | if ($total_count > $telLen) { |
---|
| 389 | $this->arrErr[$value[3]] .= t('c_* For T_ARG1, enter within a text length of T_ARG2. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $telLen)); |
---|
| 390 | } |
---|
| 391 | } |
---|
| 392 | |
---|
| 393 | /* 関連項目が完全に満たされているか判定 |
---|
| 394 | value[0] : 項目名 |
---|
| 395 | value[1] : 判定対象要素名 |
---|
| 396 | */ |
---|
| 397 | function FULL_EXIST_CHECK($value) { |
---|
| 398 | $max = count($value); |
---|
| 399 | $this->createParam($value); |
---|
| 400 | // 既に該当項目にエラーがある場合は、判定しない。 |
---|
| 401 | for ($i = 1; $i < $max; $i++) { |
---|
| 402 | if (isset($this->arrErr[$value[$i]])) { |
---|
| 403 | return; |
---|
| 404 | } |
---|
| 405 | } |
---|
| 406 | |
---|
| 407 | // すべての項目が入力されていない場合はエラーとする。 |
---|
| 408 | $blank = false; |
---|
| 409 | |
---|
| 410 | for ($i = 1; $i < $max; $i++) { |
---|
| 411 | if (strlen($this->arrParam[$value[$i]]) <= 0) { |
---|
| 412 | $blank = true; |
---|
| 413 | } |
---|
| 414 | } |
---|
| 415 | |
---|
| 416 | if ($blank) { |
---|
| 417 | $this->arrErr[$value[1]] = t('c_* T_ARG1 is blank. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 418 | } |
---|
| 419 | } |
---|
| 420 | |
---|
| 421 | /* 関連項目がすべて満たされているか判定 |
---|
| 422 | value[0] : 項目名 |
---|
| 423 | value[1] : 判定対象要素名 |
---|
| 424 | */ |
---|
| 425 | function ALL_EXIST_CHECK($value) { |
---|
| 426 | $max = count($value); |
---|
| 427 | |
---|
| 428 | // 既に該当項目にエラーがある場合は、判定しない。 |
---|
| 429 | for ($i = 1; $i < $max; $i++) { |
---|
| 430 | if (isset($this->arrErr[$value[$i]])) { |
---|
| 431 | return; |
---|
| 432 | } |
---|
| 433 | } |
---|
| 434 | |
---|
| 435 | $blank = false; |
---|
| 436 | $input = false; |
---|
| 437 | |
---|
| 438 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
---|
| 439 | for ($i = 1; $i < $max; $i++) { |
---|
| 440 | if (strlen($this->arrParam[$value[$i]]) <= 0) { |
---|
| 441 | $blank = true; |
---|
| 442 | } else { |
---|
| 443 | $input = true; |
---|
| 444 | } |
---|
| 445 | } |
---|
| 446 | |
---|
| 447 | if ($blank && $input) { |
---|
| 448 | $this->arrErr[$value[1]] = t('c_* Enter all items for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 449 | } |
---|
| 450 | } |
---|
| 451 | |
---|
| 452 | /* 関連項目がどれか一つ満たされているか判定 |
---|
| 453 | value[0] : 項目名 |
---|
| 454 | value[1] : 判定対象要素名 |
---|
| 455 | */ |
---|
| 456 | function ONE_EXIST_CHECK($value) { |
---|
| 457 | $max = count($value); |
---|
| 458 | $this->createParam($value); |
---|
| 459 | // 既に該当項目にエラーがある場合は、判定しない。 |
---|
| 460 | for ($i = 1; $i < $max; $i++) { |
---|
| 461 | if (isset($this->arrErr[$value[$i]])) { |
---|
| 462 | return; |
---|
| 463 | } |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | $input = false; |
---|
| 467 | |
---|
| 468 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
---|
| 469 | for ($i = 1; $i < $max; $i++) { |
---|
| 470 | if (strlen($this->arrParam[$value[$i]]) > 0) { |
---|
| 471 | $input = true; |
---|
| 472 | } |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | if (!$input) { |
---|
| 476 | $this->arrErr[$value[1]] = t('c_* T_ARG1 is blank. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 477 | } |
---|
| 478 | } |
---|
| 479 | |
---|
| 480 | /* 上位の項目が満たされているか判定 |
---|
| 481 | value[0] : 項目名 |
---|
| 482 | value[1] : 判定対象要素名 |
---|
| 483 | */ |
---|
| 484 | function TOP_EXIST_CHECK($value) { |
---|
| 485 | $max = count($value); |
---|
| 486 | $this->createParam($value); |
---|
| 487 | |
---|
| 488 | // 既に該当項目にエラーがある場合は、判定しない。 |
---|
| 489 | for ($i = 1; $i < $max; $i++) { |
---|
| 490 | if (isset($this->arrErr[$value[$i]])) { |
---|
| 491 | return; |
---|
| 492 | } |
---|
| 493 | } |
---|
| 494 | |
---|
| 495 | $blank = false; |
---|
| 496 | $error = false; |
---|
| 497 | |
---|
| 498 | // すべての項目がブランクでないか、すべての項目が入力されていない場合はエラーとする。 |
---|
| 499 | for ($i = 1; $i < $max; $i++) { |
---|
| 500 | if (strlen($this->arrParam[$value[$i]]) <= 0) { |
---|
| 501 | $blank = true; |
---|
| 502 | } else { |
---|
| 503 | if ($blank) { |
---|
| 504 | $error = true; |
---|
| 505 | } |
---|
| 506 | } |
---|
| 507 | } |
---|
| 508 | |
---|
| 509 | if ($error) { |
---|
| 510 | $this->arrErr[$value[1]] = t('c_* Enter items in order, starting at the beginning. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 511 | } |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | /* カタカナの判定 */ |
---|
| 515 | // 入力文字がカナ以外ならエラーを返す |
---|
| 516 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 517 | function KANA_CHECK($value) { |
---|
| 518 | if (isset($this->arrErr[$value[1]])) { |
---|
| 519 | return; |
---|
| 520 | } |
---|
| 521 | $this->createParam($value); |
---|
| 522 | if (strlen($this->arrParam[$value[1]]) > 0 && !preg_match("/^[ァ-ヶヲ-゚ー]+$/u", $this->arrParam[$value[1]])) { |
---|
| 523 | $this->arrErr[$value[1]] = t('c_* For T_ARG1, enter katakana characters. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 524 | } |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | /* カタカナの判定2 (タブ、スペースは許可する) */ |
---|
| 528 | // 入力文字がカナ以外ならエラーを返す |
---|
| 529 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 530 | function KANABLANK_CHECK($value) { |
---|
| 531 | if (isset($this->arrErr[$value[1]])) { |
---|
| 532 | return; |
---|
| 533 | } |
---|
| 534 | $this->createParam($value); |
---|
| 535 | if (strlen($this->arrParam[$value[1]]) > 0 && !preg_match("/^([ \t\r\n]|[ァ-ヶ]|[ー])+$/u", $this->arrParam[$value[1]])) { |
---|
| 536 | $this->arrErr[$value[1]] = t('c_* For T_ARG1, enter katakana characters. <br />_02', array('T_ARG1' => $value[0])); |
---|
| 537 | } |
---|
| 538 | } |
---|
| 539 | |
---|
| 540 | /* 英数字の判定 */ |
---|
| 541 | // 入力文字が英数字以外ならエラーを返す |
---|
| 542 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 543 | function ALNUM_CHECK($value) { |
---|
| 544 | if (isset($this->arrErr[$value[1]])) { |
---|
| 545 | return; |
---|
| 546 | } |
---|
| 547 | $this->createParam($value); |
---|
| 548 | if (strlen($this->arrParam[$value[1]]) > 0 && !ctype_alnum($this->arrParam[$value[1]])) { |
---|
| 549 | $this->arrErr[$value[1]] = t('c_* Enter alphanumeric characters for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 550 | } |
---|
| 551 | } |
---|
| 552 | |
---|
| 553 | /* 英数記号の判定 */ |
---|
| 554 | // 入力文字が英数記号以外ならエラーを返す |
---|
| 555 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 556 | function GRAPH_CHECK($value) { |
---|
| 557 | if (isset($this->arrErr[$value[1]])) { |
---|
| 558 | return; |
---|
| 559 | } |
---|
| 560 | $this->createParam($value); |
---|
| 561 | if (strlen($this->arrParam[$value[1]]) > 0 && !preg_match("/^[[:graph:][:space:]]+$/i", $this->arrParam[$value[1]])) { |
---|
| 562 | $this->arrErr[$value[1]] = t('c_* Enter alphanumeric symbols for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 563 | } |
---|
| 564 | } |
---|
| 565 | |
---|
| 566 | /* 必須選択の判定 */ |
---|
| 567 | // 入力値で0が許されない場合エラーを返す |
---|
| 568 | // value[0] = 項目名 value[1] = 判定対象 |
---|
| 569 | function ZERO_CHECK($value) { |
---|
| 570 | $this->createParam($value); |
---|
| 571 | if ($this->arrParam[$value[1]] == '0') { |
---|
| 572 | $this->arrErr[$value[1]] = t('c_* Enter at least 1 for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 573 | } |
---|
| 574 | } |
---|
| 575 | |
---|
| 576 | /* 桁数の判定 (最小最大)*/ |
---|
| 577 | // 入力文字の桁数判定 → 最小桁数<入力文字列<最大桁数 |
---|
| 578 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小桁数 value[3] = 最大桁数 |
---|
| 579 | function NUM_RANGE_CHECK($value) { |
---|
| 580 | if (isset($this->arrErr[$value[1]])) { |
---|
| 581 | return; |
---|
| 582 | } |
---|
| 583 | $this->createParam($value); |
---|
| 584 | // $this->arrParam[$value[0]] = mb_convert_kana($this->arrParam[$value[0]], 'n'); |
---|
| 585 | $count = strlen($this->arrParam[$value[1]]); |
---|
| 586 | if (($count > 0) && $value[2] > $count || $value[3] < $count) { |
---|
| 587 | $this->arrErr[$value[1]] = t('c_* T_ARG1 must be between T_ARG2 - T_ARG3 digits. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[2], 'T_ARG3' => $value[3])); |
---|
| 588 | } |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | /* 桁数の判定 */ |
---|
| 592 | // 入力文字の桁数判定 → 入力文字列 = 桁数 以外はNGの場合 |
---|
| 593 | // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 桁数 |
---|
| 594 | function NUM_COUNT_CHECK($value) { |
---|
| 595 | if (isset($this->arrErr[$value[1]])) { |
---|
| 596 | return; |
---|
| 597 | } |
---|
| 598 | $this->createParam($value); |
---|
| 599 | $count = strlen($this->arrParam[$value[1]]); |
---|
| 600 | if (($count > 0) && $count != $value[2]) { |
---|
| 601 | $this->arrErr[$value[1]] = t_plural($value[2], 'c_* For T_ARG1, enter T_COUNT digit. <br />_01', 'c_* For T_ARG1, enter T_COUNT digits. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 602 | } |
---|
| 603 | } |
---|
| 604 | |
---|
| 605 | /** |
---|
| 606 | * メールアドレス形式の判定 |
---|
| 607 | * |
---|
| 608 | * @param array $value 各要素は以下の通り。<br> |
---|
| 609 | * [0]: 項目名<br> |
---|
| 610 | * [1]: 判定対象を格納している配列キー |
---|
| 611 | * @return void |
---|
| 612 | */ |
---|
| 613 | function EMAIL_CHECK($value) { |
---|
| 614 | if (isset($this->arrErr[$value[1]])) { |
---|
| 615 | return; |
---|
| 616 | } |
---|
| 617 | |
---|
| 618 | $this->createParam($value); |
---|
| 619 | |
---|
| 620 | // 入力がない場合処理しない |
---|
| 621 | if (strlen($this->arrParam[$value[1]]) === 0) { |
---|
| 622 | return; |
---|
| 623 | } |
---|
| 624 | |
---|
| 625 | $wsp = '[\x20\x09]'; |
---|
| 626 | $vchar = '[\x21-\x7e]'; |
---|
| 627 | $quoted_pair = "\\\\(?:$vchar|$wsp)"; |
---|
| 628 | $qtext = '[\x21\x23-\x5b\x5d-\x7e]'; |
---|
| 629 | $qcontent = "(?:$qtext|$quoted_pair)"; |
---|
| 630 | $quoted_string = "\"$qcontent*\""; |
---|
| 631 | $atext = '[a-zA-Z0-9!#$%&\'*+\-\/\=?^_`{|}~]'; |
---|
| 632 | $dot_atom = "$atext+(?:[.]$atext+)*"; |
---|
| 633 | $local_part = "(?:$dot_atom|$quoted_string)"; |
---|
| 634 | $domain = $dot_atom; |
---|
| 635 | $addr_spec = "{$local_part}[@]$domain"; |
---|
| 636 | |
---|
| 637 | $dot_atom_loose = "$atext+(?:[.]|$atext)*"; |
---|
| 638 | $local_part_loose = "(?:$dot_atom_loose|$quoted_string)"; |
---|
| 639 | $addr_spec_loose = "{$local_part_loose}[@]$domain"; |
---|
| 640 | |
---|
| 641 | if (RFC_COMPLIANT_EMAIL_CHECK) { |
---|
| 642 | $regexp = "/\A{$addr_spec}\z/"; |
---|
| 643 | } else { |
---|
| 644 | // 携帯メールアドレス用に、..や.@を許容する。 |
---|
| 645 | $regexp = "/\A{$addr_spec_loose}\z/"; |
---|
| 646 | } |
---|
| 647 | |
---|
| 648 | if (!preg_match($regexp, $this->arrParam[$value[1]])) { |
---|
| 649 | $this->arrErr[$value[1]] = t('c_* The T_ARG1 format is incorrect. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 650 | return; |
---|
| 651 | } |
---|
| 652 | |
---|
| 653 | // 最大文字数制限の判定 (#871) |
---|
| 654 | $arrValueTemp = $value; |
---|
| 655 | $arrValueTemp[2] = 256; |
---|
| 656 | $this->MAX_LENGTH_CHECK($arrValueTemp); |
---|
| 657 | } |
---|
| 658 | |
---|
| 659 | /* メールアドレスに使用できる文字の判定 */ |
---|
| 660 | // メールアドレスに使用する文字を正規表現で判定する |
---|
| 661 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
---|
| 662 | function EMAIL_CHAR_CHECK($value) { |
---|
| 663 | if (isset($this->arrErr[$value[1]])) { |
---|
| 664 | return; |
---|
| 665 | } |
---|
| 666 | $this->createParam($value); |
---|
| 667 | if (strlen($this->arrParam[$value[1]]) > 0 && !preg_match("/^[a-zA-Z0-9_\.@\+\?-]+$/i",$this->arrParam[$value[1]])) { |
---|
| 668 | $this->arrErr[$value[1]] = t('c_* Enter the characters to be used in T_ARG1 correctly. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 669 | } |
---|
| 670 | } |
---|
| 671 | |
---|
| 672 | /* URL形式の判定 */ |
---|
| 673 | // URLを正規表現で判定する。デフォルトでhttp://があってもOK |
---|
| 674 | // value[0] = 項目名 value[1] = 判定対象URL |
---|
| 675 | function URL_CHECK($value) { |
---|
| 676 | if (isset($this->arrErr[$value[1]])) { |
---|
| 677 | return; |
---|
| 678 | } |
---|
| 679 | if (strlen($this->arrParam[$value[1]]) > 0 && !preg_match("@^https?://+($|[a-zA-Z0-9_~=:&\?\.\/-])+$@i", $this->arrParam[$value[1]])) { |
---|
| 680 | $this->arrErr[$value[1]] = t('c_* Enter T_ARG1 correctly. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 681 | } |
---|
| 682 | } |
---|
| 683 | |
---|
| 684 | /* IPアドレスの判定 */ |
---|
| 685 | // value[0] = 項目名 value[1] = 判定対象IPアドレス文字列 |
---|
| 686 | function IP_CHECK($value) { |
---|
| 687 | if (isset($this->arrErr[$value[1]])) { |
---|
| 688 | return; |
---|
| 689 | } |
---|
| 690 | //改行コードが含まれている場合には配列に変換 |
---|
| 691 | $params = str_replace("\r",'',$this->arrParam[$value[1]]); |
---|
| 692 | if (!empty($params)) { |
---|
| 693 | if (strpos($params,"\n") === false) { |
---|
| 694 | $params .= "\n"; |
---|
| 695 | } |
---|
| 696 | $params = explode("\n",$params); |
---|
| 697 | foreach ($params as $param) { |
---|
| 698 | $param = trim($param); |
---|
| 699 | if (long2ip(ip2long($param)) != trim($param) && !empty($param)) { |
---|
| 700 | $this->arrErr[$value[1]] = t('c_* Enter an IP address in the proper format in T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 701 | } |
---|
| 702 | } |
---|
| 703 | } |
---|
| 704 | } |
---|
| 705 | |
---|
| 706 | /* 拡張子の判定 */ |
---|
| 707 | // 受け取りがない場合エラーを返す |
---|
| 708 | // value[0] = 項目名 value[1] = 判定対象 value[2]=array(拡張子) |
---|
| 709 | function FILE_EXT_CHECK($value) { |
---|
| 710 | if (isset($this->arrErr[$value[1]]) || count($value[2]) == 0) { |
---|
| 711 | return; |
---|
| 712 | } |
---|
| 713 | $this->createParam($value); |
---|
| 714 | |
---|
| 715 | $match = false; |
---|
| 716 | if (strlen($_FILES[$value[1]]['name']) >= 1) { |
---|
| 717 | $filename = $_FILES[$value[1]]['name']; |
---|
| 718 | |
---|
| 719 | foreach ($value[2] as $check_ext) { |
---|
| 720 | $match = preg_match('/' . preg_quote('.' . $check_ext) . '$/i', $filename) >= 1; |
---|
| 721 | if ($match === true) { |
---|
| 722 | break 1; |
---|
| 723 | } |
---|
| 724 | } |
---|
| 725 | } |
---|
| 726 | if ($match === false) { |
---|
| 727 | $str_ext = implode('・', $value[2]); |
---|
| 728 | $this->arrErr[$value[1]] = t('c_* The format permitted for T_ARG1 is T_ARG2. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $str_ext)); |
---|
| 729 | } |
---|
| 730 | } |
---|
| 731 | |
---|
| 732 | /* ファイルが存在するかチェックする */ |
---|
| 733 | // 受け取りがない場合エラーを返す |
---|
| 734 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定ディレクトリ |
---|
| 735 | function FIND_FILE($value) { |
---|
| 736 | if (isset($this->arrErr[$value[1]])) { |
---|
| 737 | return; |
---|
| 738 | } |
---|
| 739 | |
---|
| 740 | $this->createParam($value); |
---|
| 741 | if ($value[2] != '') { |
---|
| 742 | $dir = $value[2]; |
---|
| 743 | } else { |
---|
| 744 | $dir = IMAGE_SAVE_REALDIR; |
---|
| 745 | } |
---|
| 746 | |
---|
| 747 | $path = $dir . '/' . $this->arrParam[$value[1]]; |
---|
| 748 | $path = str_replace('//', '/', $path); |
---|
| 749 | |
---|
| 750 | if ($this->arrParam[$value[1]] != '' && !file_exists($path)) { |
---|
| 751 | $this->arrErr[$value[1]] = t('c_* T_ARG1 cannot be found. <br />_01', array('T_ARG1' => $path)); |
---|
| 752 | } |
---|
| 753 | } |
---|
| 754 | |
---|
| 755 | /* ファイルが上げられたか確認 */ |
---|
| 756 | // 受け取りがない場合エラーを返す |
---|
| 757 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定サイズ(KB) |
---|
| 758 | function FILE_EXIST_CHECK($value) { |
---|
| 759 | if (isset($this->arrErr[$value[1]])) { |
---|
| 760 | return; |
---|
| 761 | } |
---|
| 762 | $this->createParam($value); |
---|
| 763 | if (!($_FILES[$value[1]]['size'] != '' && $_FILES[$value[1]]['size'] > 0)) { |
---|
| 764 | $this->arrErr[$value[1]] = t('c_* Upload T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 765 | } |
---|
| 766 | } |
---|
| 767 | |
---|
| 768 | /* ファイルサイズの判定 */ |
---|
| 769 | // 受け取りがない場合エラーを返す |
---|
| 770 | // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定サイズ(KB) |
---|
| 771 | function FILE_SIZE_CHECK($value) { |
---|
| 772 | if (isset($this->arrErr[$value[1]])) { |
---|
| 773 | return; |
---|
| 774 | } |
---|
| 775 | $this->createParam($value); |
---|
| 776 | if ($_FILES[$value[1]]['size'] > $value[2] * 1024) { |
---|
| 777 | $byte = 'KB'; |
---|
| 778 | if ($value[2] >= 1000) { |
---|
| 779 | $value[2] = $value[2] / 1000; |
---|
| 780 | $byte = 'MB'; |
---|
| 781 | } |
---|
| 782 | $this->arrErr[$value[1]] = t('c_* For the T_ARG1 file size, use a size that is T_ARG2T_ARG3 or less. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[2], 'T_ARG3' => $byte)); |
---|
| 783 | } |
---|
| 784 | } |
---|
| 785 | |
---|
| 786 | /* ファイル名の判定 */ |
---|
| 787 | // 入力文字が英数字,'_','-'以外ならエラーを返す |
---|
| 788 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 789 | function FILE_NAME_CHECK($value) { |
---|
| 790 | if (isset($this->arrErr[$value[1]])) { |
---|
| 791 | return; |
---|
| 792 | } |
---|
| 793 | $this->createParam($value); |
---|
| 794 | if (strlen($_FILES[$value[1]]['name']) > 0 && !preg_match("/^[[:alnum:]_\.-]+$/i", $_FILES[$value[1]]['name'])) { |
---|
| 795 | $this->arrErr[$value[1]] = t('c_* Do not use Japanese or spaces in the file name for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 796 | } |
---|
| 797 | } |
---|
| 798 | |
---|
| 799 | /* ファイル名の判定(アップロード以外の時) */ |
---|
| 800 | // 入力文字が英数字,'_','-'以外ならエラーを返す |
---|
| 801 | // value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 802 | function FILE_NAME_CHECK_BY_NOUPLOAD($value) { |
---|
| 803 | if (isset($this->arrErr[$value[1]])) { |
---|
| 804 | return; |
---|
| 805 | } |
---|
| 806 | $this->createParam($value); |
---|
| 807 | if (strlen($this->arrParam[$value[1]]) > 0 && !preg_match("/^[[:alnum:]_\.-]+$/i", $this->arrParam[$value[1]]) || preg_match('/[\\]/' ,$this->arrParam[$value[1]])) { |
---|
| 808 | $this->arrErr[$value[1]] = t('c_* Do not use Japanese or spaces in the file name for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 809 | } |
---|
| 810 | } |
---|
| 811 | |
---|
| 812 | //日付チェック |
---|
| 813 | // value[0] = 項目名 |
---|
| 814 | // value[1] = YYYY |
---|
| 815 | // value[2] = MM |
---|
| 816 | // value[3] = DD |
---|
| 817 | function CHECK_DATE($value) { |
---|
| 818 | if (isset($this->arrErr[$value[1]])) { |
---|
| 819 | return; |
---|
| 820 | } |
---|
| 821 | $this->createParam($value); |
---|
| 822 | // 少なくともどれか一つが入力されている。 |
---|
| 823 | if ($this->arrParam[$value[1]] > 0 || $this->arrParam[$value[2]] > 0 || $this->arrParam[$value[3]] > 0) { |
---|
| 824 | // 年月日のどれかが入力されていない。 |
---|
| 825 | if (!(strlen($this->arrParam[$value[1]]) > 0 && strlen($this->arrParam[$value[2]]) > 0 && strlen($this->arrParam[$value[3]]) > 0)) { |
---|
| 826 | $this->arrErr[$value[1]] = t('c_* Enter all items for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 827 | } else if (! checkdate($this->arrParam[$value[2]], $this->arrParam[$value[3]], $this->arrParam[$value[1]])) { |
---|
| 828 | $this->arrErr[$value[1]] = t('c_* T_ARG1 is not correct. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 829 | } |
---|
| 830 | } |
---|
| 831 | } |
---|
| 832 | |
---|
| 833 | //日付チェック |
---|
| 834 | // value[0] = 項目名 |
---|
| 835 | // value[1] = YYYY |
---|
| 836 | // value[2] = MM |
---|
| 837 | // value[3] = DD |
---|
| 838 | // value[4] = HH |
---|
| 839 | // value[5] = mm |
---|
| 840 | function CHECK_DATE2($value) { |
---|
| 841 | if (isset($this->arrErr[$value[1]])) { |
---|
| 842 | return; |
---|
| 843 | } |
---|
| 844 | $this->createParam($value); |
---|
| 845 | // 少なくともどれか一つが入力されている。 |
---|
| 846 | 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) { |
---|
| 847 | // 年月日時のどれかが入力されていない。 |
---|
| 848 | 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)) { |
---|
| 849 | $this->arrErr[$value[1]] = t('c_* Enter all items for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 850 | } else if (! checkdate($this->arrParam[$value[2]], $this->arrParam[$value[3]], $this->arrParam[$value[1]])) { |
---|
| 851 | $this->arrErr[$value[1]] = t('c_* T_ARG1 is not correct. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 852 | } |
---|
| 853 | } |
---|
| 854 | } |
---|
| 855 | |
---|
| 856 | //日付チェック |
---|
| 857 | // value[0] = 項目名 |
---|
| 858 | // value[1] = YYYY |
---|
| 859 | // value[2] = MM |
---|
| 860 | function CHECK_DATE3($value) { |
---|
| 861 | if (isset($this->arrErr[$value[1]])) { |
---|
| 862 | return; |
---|
| 863 | } |
---|
| 864 | $this->createParam($value); |
---|
| 865 | // 少なくともどれか一つが入力されている。 |
---|
| 866 | if ($this->arrParam[$value[1]] > 0 || $this->arrParam[$value[2]] > 0) { |
---|
| 867 | // 年月日時のどれかが入力されていない。 |
---|
| 868 | if (!(strlen($this->arrParam[$value[1]]) > 0 && strlen($this->arrParam[$value[2]]) > 0)) { |
---|
| 869 | $this->arrErr[$value[1]] = t('c_* Enter all items for T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 870 | } else if (! checkdate($this->arrParam[$value[2]], 1, $this->arrParam[$value[1]])) { |
---|
| 871 | $this->arrErr[$value[1]] = t('c_* T_ARG1 is not correct. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 872 | } |
---|
| 873 | } |
---|
| 874 | } |
---|
| 875 | |
---|
| 876 | //誕生日チェック |
---|
| 877 | // value[0] = 項目名 |
---|
| 878 | // value[1] = YYYY |
---|
| 879 | // value[2] = MM |
---|
| 880 | // value[3] = DD |
---|
| 881 | function CHECK_BIRTHDAY($value) { |
---|
| 882 | if (isset($this->arrErr[$value[1]])) { |
---|
| 883 | return; |
---|
| 884 | } |
---|
| 885 | |
---|
| 886 | $this->createParam($value); |
---|
| 887 | // 年が入力されている。 |
---|
| 888 | if ($this->arrParam[$value[1]] > 0) { |
---|
| 889 | |
---|
| 890 | // 年の数字チェック、最小数値制限チェック |
---|
| 891 | $this->doFunc(array($value[0].'(' . t('c_Year_01') . ')', $value[1], BIRTH_YEAR), array('NUM_CHECK', 'MIN_CHECK')); |
---|
| 892 | // 上のチェックでエラーある場合、中断する。 |
---|
| 893 | if (isset($this->arrErr[$value[1]])) { |
---|
| 894 | return; |
---|
| 895 | } |
---|
| 896 | |
---|
| 897 | // 年の最大数値制限チェック |
---|
| 898 | $this->doFunc(array($value[0].'(' . t('c_Year_01') . ')', $value[1], date('Y',strtotime('now'))), array('MAX_CHECK')); |
---|
| 899 | // 上のチェックでエラーある場合、中断する。 |
---|
| 900 | if (isset($this->arrErr[$value[1]])) { |
---|
| 901 | return; |
---|
| 902 | } |
---|
| 903 | } |
---|
| 904 | |
---|
| 905 | // XXX createParam() が二重に呼ばれる問題を抱える |
---|
| 906 | $this->CHECK_DATE($value); |
---|
| 907 | } |
---|
| 908 | |
---|
| 909 | /*-----------------------------------------------------------------*/ |
---|
| 910 | /* CHECK_SET_TERM |
---|
| 911 | /* 年月日に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
---|
| 912 | /* 引数 (開始年,開始月,開始日,終了年,終了月,終了日) |
---|
| 913 | /* 戻値 array(1,2,3) |
---|
| 914 | /* 1.開始年月日 (YYYYMMDD 000000) |
---|
| 915 | /* 2.終了年月日 (YYYYMMDD 235959) |
---|
| 916 | /* 3.エラー (0 = OK, 1 = NG) |
---|
| 917 | /*-----------------------------------------------------------------*/ |
---|
| 918 | // value[0] = 項目名1 |
---|
| 919 | // value[1] = 項目名2 |
---|
| 920 | // value[2] = start_year |
---|
| 921 | // value[3] = start_month |
---|
| 922 | // value[4] = start_day |
---|
| 923 | // value[5] = end_year |
---|
| 924 | // value[6] = end_month |
---|
| 925 | // value[7] = end_day |
---|
| 926 | function CHECK_SET_TERM($value) { |
---|
| 927 | |
---|
| 928 | // 期間指定 |
---|
| 929 | if (isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[5]])) { |
---|
| 930 | return; |
---|
| 931 | } |
---|
| 932 | // $this->createParam($value); |
---|
| 933 | 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]])) { |
---|
| 934 | $this->arrErr[$value[2]] = t('c_* Specify T_ARG1 correctly. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 935 | } |
---|
| 936 | 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]])) { |
---|
| 937 | $this->arrErr[$value[5]] = t('c_* Specify T_ARG1 correctly. <br />_01', array('T_ARG1' => $value[1])); |
---|
| 938 | } |
---|
| 939 | 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)) { |
---|
| 940 | |
---|
| 941 | $date1 = $this->arrParam[$value[2]] .sprintf('%02d', $this->arrParam[$value[3]]) .sprintf('%02d',$this->arrParam[$value[4]]) .'000000'; |
---|
| 942 | $date2 = $this->arrParam[$value[5]] .sprintf('%02d', $this->arrParam[$value[6]]) .sprintf('%02d',$this->arrParam[$value[7]]) .'235959'; |
---|
| 943 | |
---|
| 944 | if (($this->arrErr[$value[2]] == '' && $this->arrErr[$value[5]] == '') && $date1 > $date2) { |
---|
| 945 | $this->arrErr[$value[2]] = t('c_* The period specification for T_ARG1 and T_ARG2 is not correct. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[1])); |
---|
| 946 | } |
---|
| 947 | } |
---|
| 948 | } |
---|
| 949 | |
---|
| 950 | /*-----------------------------------------------------------------*/ |
---|
| 951 | /* CHECK_SET_TERM2 |
---|
| 952 | /* 年月日時に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
---|
| 953 | /* 引数 (開始年,開始月,開始日,開始時間,開始分,開始秒, |
---|
| 954 | /* 終了年,終了月,終了日,終了時間,終了分,終了秒) |
---|
| 955 | /* 戻値 array(1,2,3) |
---|
| 956 | /* 1.開始年月日 (YYYYMMDDHHmmss) |
---|
| 957 | /* 2.終了年月日 (YYYYMMDDHHmmss) |
---|
| 958 | /* 3.エラー (0 = OK, 1 = NG) |
---|
| 959 | /*-----------------------------------------------------------------*/ |
---|
| 960 | // value[0] = 項目名1 |
---|
| 961 | // value[1] = 項目名2 |
---|
| 962 | // value[2] = start_year |
---|
| 963 | // value[3] = start_month |
---|
| 964 | // value[4] = start_day |
---|
| 965 | // value[5] = start_hour |
---|
| 966 | // value[6] = start_minute |
---|
| 967 | // value[7] = start_second |
---|
| 968 | // value[8] = end_year |
---|
| 969 | // value[9] = end_month |
---|
| 970 | // value[10] = end_day |
---|
| 971 | // value[11] = end_hour |
---|
| 972 | // value[12] = end_minute |
---|
| 973 | // value[13] = end_second |
---|
| 974 | |
---|
| 975 | /*-----------------------------------------------------------------*/ |
---|
| 976 | function CHECK_SET_TERM2($value) { |
---|
| 977 | |
---|
| 978 | // 期間指定 |
---|
| 979 | if (isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[8]])) { |
---|
| 980 | return; |
---|
| 981 | } |
---|
| 982 | // $this->createParam($value); |
---|
| 983 | 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]])) { |
---|
| 984 | $this->arrErr[$value[2]] = t('c_* Specify T_ARG1 correctly. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 985 | } |
---|
| 986 | 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]])) { |
---|
| 987 | $this->arrErr[$value[8]] = t('c_* Specify T_ARG1 correctly. <br />_01', array('T_ARG1' => $value[1])); |
---|
| 988 | } |
---|
| 989 | 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)) { |
---|
| 990 | |
---|
| 991 | $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]]); |
---|
| 992 | $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]]); |
---|
| 993 | |
---|
| 994 | if (($this->arrErr[$value[2]] == '' && $this->arrErr[$value[8]] == '') && $date1 > $date2) { |
---|
| 995 | $this->arrErr[$value[2]] = t('c_* The period specification for T_ARG1 and T_ARG2 is not correct. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[1])); |
---|
| 996 | } |
---|
| 997 | if ($date1 == $date2) { |
---|
| 998 | $this->arrErr[$value[2]] = t('c_* The period specification for T_ARG1 and T_ARG2 is not correct. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[1])); |
---|
| 999 | } |
---|
| 1000 | |
---|
| 1001 | } |
---|
| 1002 | } |
---|
| 1003 | |
---|
| 1004 | /*-----------------------------------------------------------------*/ |
---|
| 1005 | /* CHECK_SET_TERM3 |
---|
| 1006 | /* 年月に別れた2つの期間の妥当性をチェックし、整合性と期間を返す |
---|
| 1007 | /* 引数 (開始年,開始月,終了年,終了月) |
---|
| 1008 | /* 戻値 array(1,2,3) |
---|
| 1009 | /* 1.開始年月日 (YYYYMMDD 000000) |
---|
| 1010 | /* 2.終了年月日 (YYYYMMDD 235959) |
---|
| 1011 | /* 3.エラー (0 = OK, 1 = NG) |
---|
| 1012 | /*-----------------------------------------------------------------*/ |
---|
| 1013 | // value[0] = 項目名1 |
---|
| 1014 | // value[1] = 項目名2 |
---|
| 1015 | // value[2] = start_year |
---|
| 1016 | // value[3] = start_month |
---|
| 1017 | // value[4] = end_year |
---|
| 1018 | // value[5] = end_month |
---|
| 1019 | function CHECK_SET_TERM3($value) { |
---|
| 1020 | |
---|
| 1021 | // 期間指定 |
---|
| 1022 | if (isset($this->arrErr[$value[2]]) || isset($this->arrErr[$value[4]])) { |
---|
| 1023 | return; |
---|
| 1024 | } |
---|
| 1025 | // $this->createParam($value); |
---|
| 1026 | if ((strlen($this->arrParam[$value[2]]) > 0 || strlen($this->arrParam[$value[3]]) > 0) && ! checkdate($this->arrParam[$value[3]], 1, $this->arrParam[$value[2]])) { |
---|
| 1027 | $this->arrErr[$value[2]] = t('c_* Specify T_ARG1 correctly. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 1028 | } |
---|
| 1029 | if ((strlen($this->arrParam[$value[4]]) > 0 || strlen($this->arrParam[$value[5]]) > 0) && ! checkdate($this->arrParam[$value[5]], 1, $this->arrParam[$value[4]])) { |
---|
| 1030 | $this->arrErr[$value[4]] = t('c_* Specify T_ARG1 correctly. <br />_01', array('T_ARG1' => $value[1])); |
---|
| 1031 | } |
---|
| 1032 | 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))) { |
---|
| 1033 | |
---|
| 1034 | $date1 = $this->arrParam[$value[2]] .sprintf('%02d', $this->arrParam[$value[3]]); |
---|
| 1035 | $date2 = $this->arrParam[$value[4]] .sprintf('%02d', $this->arrParam[$value[5]]); |
---|
| 1036 | |
---|
| 1037 | if (($this->arrErr[$value[2]] == '' && $this->arrErr[$value[5]] == '') && $date1 > $date2) { |
---|
| 1038 | $this->arrErr[$value[2]] = t('c_* The period specification for T_ARG1 and T_ARG2 is not correct. <br />_01', array('T_ARG1' => $value[0], 'T_ARG2' => $value[1])); |
---|
| 1039 | } |
---|
| 1040 | } |
---|
| 1041 | } |
---|
| 1042 | |
---|
| 1043 | //ディレクトリ存在チェック |
---|
| 1044 | function DIR_CHECK($value) { |
---|
| 1045 | if (isset($this->arrErr[$value[1]])) { |
---|
| 1046 | return; |
---|
| 1047 | } |
---|
| 1048 | $this->createParam($value); |
---|
| 1049 | if (!is_dir($this->arrParam[$value[1]])) { |
---|
| 1050 | $this->arrErr[$value[1]] = t('c_* The designated T_ARG1 does not exist. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 1051 | } |
---|
| 1052 | } |
---|
| 1053 | |
---|
| 1054 | // ドメインチェック |
---|
| 1055 | function DOMAIN_CHECK($value) { |
---|
| 1056 | if (isset($this->arrErr[$value[1]])) { |
---|
| 1057 | return; |
---|
| 1058 | } |
---|
| 1059 | if (strlen($this->arrParam[$value[1]]) > 0 && !preg_match("/^\.[^.]+\..+/i", $this->arrParam[$value[1]])) { |
---|
| 1060 | $this->arrErr[$value[1]] = t('c_* The T_ARG1 format is incorrect. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 1061 | } |
---|
| 1062 | } |
---|
| 1063 | |
---|
| 1064 | /* 携帯メールアドレスの判定 */ |
---|
| 1065 | // メールアドレスを正規表現で判定する |
---|
| 1066 | // value[0] = 項目名 value[1] = 判定対象メールアドレス |
---|
| 1067 | function MOBILE_EMAIL_CHECK($value) { |
---|
| 1068 | if (isset($this->arrErr[$value[1]])) { |
---|
| 1069 | return; |
---|
| 1070 | } |
---|
| 1071 | $this->createParam($value); |
---|
| 1072 | $objMobile = new SC_Helper_Mobile_Ex(); |
---|
| 1073 | if (strlen($this->arrParam[$value[1]]) > 0 && !$objMobile->gfIsMobileMailAddress($this->arrParam[$value[1]])) { |
---|
| 1074 | $this->arrErr[$value[1]] = t('c_* T_ARG1 is not for mobile phones. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 1075 | } |
---|
| 1076 | } |
---|
| 1077 | |
---|
| 1078 | /** |
---|
| 1079 | * CHECK_REGIST_CUSTOMER_EMAIL |
---|
| 1080 | * |
---|
| 1081 | * メールアドレスが会員登録されているか調べる |
---|
| 1082 | * @param array $value value[0] = 項目名 value[1] = 判定対象メールアドレス |
---|
| 1083 | * @access public |
---|
| 1084 | * @return void |
---|
| 1085 | */ |
---|
| 1086 | function CHECK_REGIST_CUSTOMER_EMAIL($value) { |
---|
| 1087 | if (isset($this->arrErr[$value[1]])) { |
---|
| 1088 | return; |
---|
| 1089 | } |
---|
| 1090 | $this->createParam($value); |
---|
| 1091 | |
---|
| 1092 | $register_user_flg = SC_Helper_Customer_Ex::sfCheckRegisterUserFromEmail($this->arrParam[$value[1]]); |
---|
| 1093 | switch ($register_user_flg) { |
---|
| 1094 | case 1: |
---|
| 1095 | $this->arrErr[$value[1]] .= t('c_* T_ARG1 already used in member registration. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 1096 | break; |
---|
| 1097 | case 2: |
---|
| 1098 | $this->arrErr[$value[1]] .= t('c_* For a certain period of time after membership withdrawal, it is not possible to use the same T_ARG1. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 1099 | break; |
---|
| 1100 | default: |
---|
| 1101 | break; |
---|
| 1102 | } |
---|
| 1103 | } |
---|
| 1104 | |
---|
| 1105 | /** |
---|
| 1106 | * 禁止文字列のチェック |
---|
| 1107 | * value[0] = 項目名 value[1] = 判定対象文字列 |
---|
| 1108 | * value[2] = 入力を禁止する文字列(配列) |
---|
| 1109 | * |
---|
| 1110 | * @example $objErr->doFunc(array(t('c_URL_01'), 'contents', $arrReviewDenyURL), array('PROHIBITED_STR_CHECK')); |
---|
| 1111 | */ |
---|
| 1112 | function PROHIBITED_STR_CHECK($value) { |
---|
| 1113 | if (isset($this->arrErr[$value[1]]) || empty($this->arrParam[$value[1]])) { |
---|
| 1114 | return; |
---|
| 1115 | } |
---|
| 1116 | $this->createParam($value); |
---|
| 1117 | $targetStr = $this->arrParam[$value[1]]; |
---|
| 1118 | $prohibitedStr = str_replace(array('|', '/'), array('\|', '\/'), $value[2]); |
---|
| 1119 | |
---|
| 1120 | $pattern = '/' . join('|', $prohibitedStr) . '/i'; |
---|
| 1121 | if (preg_match_all($pattern, $targetStr, $matches = array())) { |
---|
| 1122 | $this->arrErr[$value[1]] = t('c_* T_ARG1 cannot be entered. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 1123 | } |
---|
| 1124 | } |
---|
| 1125 | |
---|
| 1126 | /** |
---|
| 1127 | * パラメーターとして適切な文字列かチェックする. |
---|
| 1128 | * |
---|
| 1129 | * @access private |
---|
| 1130 | * @param array $value [0] => 項目名, [1] => 評価する文字列 |
---|
| 1131 | * @return void |
---|
| 1132 | */ |
---|
| 1133 | function EVAL_CHECK($value) { |
---|
| 1134 | if (isset($this->arrErr[$value[0]])) { |
---|
| 1135 | return; |
---|
| 1136 | } |
---|
| 1137 | // $this->createParam($value); |
---|
| 1138 | if ($this->evalCheck($value[1]) === false) { |
---|
| 1139 | $this->arrErr[$value[0]] = t('c_* The T_ARG1 format is incorrect. <br />_01', array('T_ARG1' => $value[0])); |
---|
| 1140 | } |
---|
| 1141 | } |
---|
| 1142 | |
---|
| 1143 | /** |
---|
| 1144 | * パラメーターとして適切な文字列かチェックする.(サブルーチン) |
---|
| 1145 | * |
---|
| 1146 | * 下記を満たす場合を真とする。 |
---|
| 1147 | * ・PHPコードとして評価可能であること。 |
---|
| 1148 | * ・評価した結果がスカラデータ(定数に指定できる値)であること。 |
---|
| 1149 | * 本メソッドの利用や改訂にあたっては、eval 関数の危険性を意識する必要がある。 |
---|
| 1150 | * @access private |
---|
| 1151 | * @param string 評価する文字列 |
---|
| 1152 | * @return bool パラメーターとして適切な文字列か |
---|
| 1153 | */ |
---|
| 1154 | function evalCheck($value) { |
---|
| 1155 | return @eval('return is_scalar(' . $value . ');'); |
---|
| 1156 | } |
---|
| 1157 | |
---|
| 1158 | /** |
---|
| 1159 | * 未定義の $this->arrParam に空要素を代入する. |
---|
| 1160 | * |
---|
| 1161 | * @access private |
---|
| 1162 | * @param array $value 配列 |
---|
| 1163 | * @return void |
---|
| 1164 | */ |
---|
| 1165 | function createParam($value) { |
---|
| 1166 | foreach ($value as $val_key => $key) { |
---|
| 1167 | if ($val_key != 0 && (is_string($key) || is_int($key))) { |
---|
| 1168 | if (!is_numeric($key) && preg_match('/^[a-z0-9_]+$/i', $key)) { |
---|
| 1169 | if (!isset($this->arrParam[$key])) $this->arrParam[$key] = ''; |
---|
| 1170 | if (strlen($this->arrParam[$key]) > 0 |
---|
| 1171 | && (preg_match('/^[[:alnum:]\-\_]*[\.\/\\\\]*\.\.(\/|\\\\)/',$this->arrParam[$key]) || !preg_match('/\A[^\x00-\x08\x0b\x0c\x0e-\x1f\x7f]+\z/u', $this->arrParam[$key]))) |
---|
| 1172 | ) { |
---|
| 1173 | $this->arrErr[$value[1]] = '※ ' . $value[0] . ' is not a valid character.<br />'; |
---|
| 1174 | } |
---|
| 1175 | } else if (preg_match('/[^a-z0-9_]/i', $key)) { |
---|
| 1176 | trigger_error('', E_USER_ERROR); |
---|
| 1177 | } |
---|
| 1178 | } |
---|
| 1179 | } |
---|
| 1180 | } |
---|
| 1181 | |
---|
| 1182 | /** |
---|
| 1183 | * 値が数字だけかどうかチェックする |
---|
| 1184 | * |
---|
| 1185 | * @access private |
---|
| 1186 | * @param string $string チェックする文字列 |
---|
| 1187 | * @return boolean 値が10進数の数値表現のみの場合 true |
---|
| 1188 | */ |
---|
| 1189 | function numelicCheck($string) { |
---|
| 1190 | /* |
---|
| 1191 | * XXX 10進数の数値表現か否かを調べたいだけだが, |
---|
| 1192 | * ctype_digit() は文字列以外 false を返す. |
---|
| 1193 | * string ではなく int 型の数値が入る場合がある. |
---|
| 1194 | */ |
---|
| 1195 | $string = (string) $string; |
---|
| 1196 | return strlen($string) > 0 && !ctype_digit($string); |
---|
| 1197 | } |
---|
| 1198 | } |
---|