set_fields($fields); $validation->set_rules($rules); $validation->set_error_delimiters('※','
'); if ($validation->run() == true) { if (isset($_POST['mode']) && ($_POST['mode'] == 'send')) { // SAVE CSV $today = gmdate("Y/m/d H:m:s", time() + (3600*9)); $row = ""; $head = ""; foreach ($fields as $key=>$value) { $tmp = $validation->$key; $tmp = str_replace("\r\n", ' ', $tmp); $tmp = str_replace("\n", ' ' , $tmp); if ($head != "") $head .= "," ; if ($row != "") $row .= "," ; $head .= '"'.$value.'"' ; $row .= '"'.$tmp.'"' ; } if (isset($config["csv_file"]) && ($config["csv_file"] != "")) { if (file_exists($config["csv_file"])) { $row_data = $row."\n"; } else { $row_data = $head."\n".$row."\n"; } $fp = fopen($config["csv_file"],"a"); flock($fp,LOCK_EX); fwrite($fp, $row_data); flock($fp, LOCK_UN); fclose($fp); } if (($config["template_email"] != "") && (file_exists($config["template_email"]))) { $mail_value = array(); foreach ($validation->_fields as $field=>$value) { $mail_value[$field] = $validation->$field; } if ($mail_value[family_adults] != "") $mail_value[family_adults] .= "人"; if ($mail_value[family_childrens] != "") $mail_value[family_childrens] .= "人"; if ($mail_value[land_area] != "") $mail_value[land_area] .= "坪"; if ($mail_value[hope_area] != "") $mail_value[hope_area] .= "坪"; require $config["template_email"]; $body = $email_body; $subj = $config["email_subject"]; $from = $config["email_from"]; $to = $config["email_to"]; if (isset($validation->email) && ($validation->email != '')) { $from = $config["email_from"] = $validation->email; } $body = mb_convert_encoding($body,"UTF-8","auto"); $subj = mb_convert_encoding($subj,"UTF-8","auto"); //$subj = mb_encode_mimeheader($subj); $subj = encode($subj); $swift =& new Swift(new Swift_Connection_Sendmail()); $message =& new Swift_Message($subj, $body); if (!$swift->send($message, $to, $from)) { $error = "エラーが発生しました"; } else { require_once($config["template_response"]); $body = $email_body_response; $subj = $config["email_resp_subj"]; $from = $config["email_from"]; $to = $validation->email; $body = mb_convert_encoding($body,"UTF-8","auto"); $subj = mb_convert_encoding($subj,"UTF-8","auto"); //$subj = mb_encode_mimeheader($subj); $subj = encode($subj); ///$swift =& new Swift(new Swift_Connection_Sendmail()); $message =& new Swift_Message($subj, $body); if (!$swift->send($message, $to, $from)) { $error = "エラーが発生しました"; } } } header("Location: thks.html"); exit; } else { $page = $config["template_check"]; require $page; } exit; } $page = $config["template_form"]; require $page; exit; function encode($str) { $str = mb_convert_encoding($str,'iso-2022-jp','auto'); $str = '=?iso-2022-jp?B?'.base64_encode($str).'?='; return $str; } function errHandler($errno, $errstr, $errfile, $errline) { if ($errno == 256) { require_once("error.html"); } return true; } ?>