\n'; #$errormes_template = '$insert_error_mes
\n'; $errormes_max_show_chars ='240'; // 携帯判定用 $mobilephone_domain = "do(c|k)omo\.ne\.jp|ezweb\.ne\.jp|jp-(d|h|t|c|r|k|n|s|q)\.ne\.jp|vodafone\.ne\.jp|\.ido\.ne\.jp|email\.sky\.tdp\.ne\.jp|email\.sky\.kdp\.ne\.jp|email\.sky\.cdp\.ne\.jp|sky\.tu-ka\.ne\.jp|cara\.tu-ka\.ne\.jp|sky\.tkk\.ne\.jp|sky\.tkc\.ne\.jp|pdx\.ne\.jp|nttpnet\.ne\.jp|phone\.ne\.jp|mozio\.ne\.jp|page\.docomonet\.or\.jp|page\.ttm\.ne\.jp|pho\.ne\.jp|moco\.ne\.jp|emcm\.ne\.jp|p1\.foomoon\.com|\.i-get\.ne\.jp|softbank\.ne\.jp"; $imode_domain ='docomo\.ne\.jp'; $ezweb_domain = 'ezweb\.ne\.jp|\.ido\.ne\.jp|email\.sky\.tdp\.ne\.jp|email\.sky\.kdp\.ne\.jp|email\.sky\.cdp\.ne\.jp|sky\.tu-ka\.ne\.jp|cara\.tu-ka\.ne\.jp|sky\.tkk\.ne\.jp|sky\.tkc\.ne\.jp'; $jsky_domain = 'jp-(d|h|t|c|r|k|n|s|q)\.ne\.jp|vodafone\.ne\.jp|softbank\.ne\.jp'; ?> 全角カナ,全角英字->半角英字,全角空白->半角空白処理,両端空白文字処理 function convert_string($Value_Name) { global ${$Value_Name}; $tmp_value = ${$Value_Name}; $tmp_value = mb_convert_kana($tmp_value,"KVanrs"); ${$Value_Name} = trim($tmp_value); }; // 半角カナ->全角カナ処理,,両端空白文字処理 function convert_string_kana($Value_Name) { global ${$Value_Name}; $tmp_value = ${$Value_Name}; $tmp_value = mb_convert_kana($tmp_value,"KVCanrs"); ${$Value_Name} = trim($tmp_value); }; // 改行、TABコード削除 function strip_returns($Value_Name) { global ${$Value_Name}; $tmp_value = ${$Value_Name}; ${$Value_Name} = ereg_replace("\r|\n|\t","",$tmp_value); }; // 記入漏れ、文字数オーバーチェック function checkQuery($abname,$inputValue,$maxLength,$mode) { global $badInput; global ${$inputValue}; global $errormes_template; $zenMaxlength = $maxLength / 2; if($mode == "1") { if(${$inputValue} != "0") { if((${$inputValue} == FALSE) or (${$inputValue} == "dmy")) { insertErrormes("$abname が入力されていません",$errormes_template); $badInput = 1; } } } if(strlen(${$inputValue}) > $maxLength) { insertErrormes("$abname が長すぎます、半角$maxLength(全角$zenMaxlength)文字以内で記入してください",$errormes_template); $badInput = 1; } }; function minimumQuery($abname,$inputValue,$minLength,$mode) { global $badInput; global ${$inputValue}; global $errormes_template; $zen_minLength = $minLength / 2; if(($mode == "1") and ((${$inputValue} != "dmy") and (${$inputValue}))) { if(strlen(${$inputValue}) < $minLength) { insertErrormes("$abname が短すぎます、半角$minLength(全角$zen_minLength)文字以上記入してください",$errormes_template); $badInput = 1; } } }; function makeUrlEncode($inputValue) { global ${$inputValue}; $tmp_value = ${$inputValue}; ${$inputValue} = rawurlencode($tmp_value); }; function makeUrlDecode($inputValue) { global ${$inputValue}; $tmp_value = ${$inputValue}; ${$inputValue} = rawurldecode($tmp_value); }; function makeHtmlEncode($inputValue) { global ${$inputValue}; $tmp_value = ${$inputValue}; # $tmp_value = trim(strip_tags($tmp_value)); ${$inputValue} = htmlspecialchars($tmp_value); }; // DB追加変数作成 function makeInsertValue(&$inputValue) { global ${$inputValue}; $tmp_value = ${$inputValue}; if($tmp_value == "on") { $tmp_value = 1; } ${$inputValue} = addslashes($tmp_value); }; // checkbox 記入済みcheck function fillCheckBox($CheckBoxName) { global ${$CheckBoxName}; global $form_body; if(${$CheckBoxName}) { $form_body = eregi_replace("\"$CheckBoxName\"","\"$CheckBoxName\" checked",$form_body); } }; // RADIOボタンcheck function fillRadioButton($ButtonName) { global ${$ButtonName}; global $form_body; $form_body = eregi_replace("\"$ButtonName\" value=\"${$ButtonName}\"","\"$ButtonName\" value=\"${$ButtonName}\" checked","$form_body"); }; // Selectメニューチェック function fillSelectMenu($SelectName) { global ${$SelectName}; global $form_body; if(${$SelectName} != "dmy") { $form_body = eregi_replace("option value=\"${$SelectName}\"","option value=\"${$SelectName}\" selected",$form_body); } }; // TextBox -> Checkbox補間 function fillTextBox($inputArray) { $count_values = count($inputArray); for($i = 0; $i < $count_values; $i++) { $current_value = $inputArray[$i]; global ${$current_value}; if((${$current_value} != "dmy") and (${$current_value})) { $fillCheckBox = eregi_replace("(_name|_name[0-9])","",$current_value); global ${$fillCheckBox}; ${$fillCheckBox} = 1; } } }; // checkbox 選択数制限 function limitCheckBox ($abname,$inputArray,$limit) { global $errormes_template; global $badInput; $count_values = count($inputArray); for($i = 0; $i <= $count_values; $i++) { $current_value = $inputArray[$i]; global ${$current_value}; if(${$current_value}) { $counter++; } } if($counter > $limit) { insertErrormes("$abname の選択されている項目が多すぎます。$limit 個までにして下さい",$errormes_template); $badInput = 1; } }; // チェックボックス最低数check function minimumCheckbox($abname,$inputArray,$minimum) { global $errormes_template; global $badInput; $count_values = count($inputArray); for($i = 0; $i <= $count_values; $i++) { $selected_value = $inputArray[$i]; global ${$selected_value}; if(${$selected_value}) { $counter++; } } if($counter < $minimum) { insertErrormes("$abname は最低 $minimum 個選択して下さい。",$errormes_template); $badInput = 1; } }; // RFC821,822(メールアドレス表現)チェック function checkValidMailAddress($EmailAddress) { global $badInput; global $errormes_template; //半角空白若しくは全角空白があった場合は取り除く $EmailAddress = ereg_replace("(\r|\n|\t| )","",$EmailAddress); $address_notfound = "メールアドレス が入力されていません"; $invalid_address = "$EmailAddress は有効なメールアドレスではありません"; if(!$EmailAddress) { insertErrormes($address_notfound,$errormes_template); $badInput = 1; $badAddress = 1; } if(mb_detect_encoding($EmailAddress) != "ASCII") { insertErrormes($invalid_address,$errormes_template); $badInput = 1; $badAddress = 1; } $splitMailPart = split("\@",$EmailAddress); $UserPart = $splitMailPart[0]; $DomainPart = $splitMailPart[1]; if(((!$UserPart) or (!$DomainPart) or (count($splitMailPart) > 2)) and (!$badAddress)) { insertErrormes($invalid_address,$errormes_template); $badInput = 1; $badAddress = 1; } if(!$badAddress) { if(eregi("\(|\)|\<|\>|\<|\>|\@|\,|\;|\[|\]",$UserPart)) { insertErrormes($invalid_address,$errormes_template); $badInput = 1; $badAddress = 1; } } if(!$badAddress) { if(eregi("\ー|\.\.|\!|\"|\#|\\$|\%|\&|\'|\(|\)|\=|\~|\||\^|\\@|\`|\{|\[|\}|\]|\;|\+|\:|\*|\,|\<|\>|\?|\/|\_|\\|",$DomainPart)) { insertErrormes($invalid_address,$errormes_template); $badInput = 1; $badAddress = 1; } } if(!$badAddress) { $splitDomainPart = split("\.",$DomainPart); $num_of_parts = count($splitDomainPart); if($num_of_parts < 2) { insertErrormes($invalid_address,$errormes_template); $badInput = 1; $badAddress = 1; } } if(!$badAddress) { $last_parts = $splitDomainPart[$num_of_parts - 1]; $TLD_chars = strlen($last_parts); if(($TLD_chars < 2) or ($TLD_chars >= 4)) { insertErrormes($invalid_address,$errormes_template); $badInput = 1; $badAddress = 1; } } if(!$badAddress) { $first_Char = substr($DomainPart,0,1); $last_Char = substr($DomainPart,-1,1); if((eregi("\-|\.","$first_Char")) or (eregi("\-",$last_Char))) { insertErrormes($invalid_address,$errormes_template); $badInput = 1; $badAddress = 1; } } return $EmailAddress; }; function checkMobilePhone($email) { global $mobilephone_domain; global $imode_domain; global $ezweb_domain; global $jsky_domain; $split_email = split("@",$email); $domain_part = $split_email[1]; if(eregi($mobilephone_domain,$domain_part)) { if(eregi($imode_domain,$domain_part)) { $mail_domain = '1'; } elseif(eregi($ezweb_domain,$domain_part)) { $mail_domain = '2'; } elseif(eregi($jsky_domain,$domain_part)) { $mail_domain = '3'; } else { $mail_domain = '4'; } } else { $mail_domain = '0'; } return $mail_domain; }; function checkValidDate ($abname,&$date) { global $badInput; global $errormes_template; $tmp_date = eregi_replace("[a-z]","",$date); $split_date = split("-","$tmp_date","3"); if(($split_date[0]) and ($split_date[1]) and ($split_date[2])) { $validdate = checkdate($split_date[1],$split_date[2],$split_date[0]); if(!$validdate) { $indicate_date = $split_date[0] . "年" . $split_date[1] . "月" . $split_date[2] . "日"; insertErrormes("$indicate_date は有効な日付ではありません",$errormes_template); $badInput = 1; } else { $date = $tmp_date; } } else { insertErrormes("$abname が入力されていません",$errormes_template); $badInput = 1; } }; // Unique Key 生成 function genUniqueKey($con_id,$table_name,$column_name,$max_char){ do{ $key_salt = uniqid("s","true"); $unique_key = strtoupper(md5($key_salt)); $unique_key = substr($unique_key,0,$max_char); // Insert対象となるcolumn内で重複しないかチェックする $check_dup_key_sql = <<< EOM select oid from $table_name where $column_name = '$unique_key' EOM; $check_dup_key = pg_exec($con_id,$check_dup_key_sql); if(!pg_numrows($check_dup_key)){ $key_is_unique = 1; } } while(!$key_is_unique); return $unique_key; unset($unique_key); @pg_freeresult($check_dup_key); }; //郵便番号チェック function checkValidPostalCode ($abname,&$postal_code){ global $badInput; global $errormes_template; if(!(ereg("^[0-9]{7}$",$postal_code))){ insertErrormes("郵便番号は\"-\"(ハイフン)をつけず数字7桁で記入してください。",$errormes_template); $badInput = 1; } }; ?>