get_exception(); } } /* 出力準備 */ $smarty = new SmartyEx(); $smarty->prepare(); /* Validateクラスインスタンス生成 */ if( $err_str === "" ) { try { $validate = new Validate(); } catch( ValidateError $e ) { $err_str .= $e->get_exception(); } } /* Request値の検証 */ if( $err_str === "" ) { if (!empty($_POST)) $rq = $_POST; if (!empty($rq['action'])) { $action = $rq['action']; unset($rq['action']); } if (isset($_GET['thanks'])) { $template_file = 'thanks.tpl'; $smarty->display( $template_dir . $template_file ); exit; } elseif ($action == 'check' || $action == 'return' || $action == 'exec') { if (!$validate->__range($rq['name'], 1, 255)) { $errmsg[] = "・氏名の入力が正しくありません。"; } if (!$validate->__tel(sprintf('%s-%s-%s', $rq['tel1'], $rq['tel2'], $rq['tel3']))) { $errmsg[] = "・携帯電話番号の入力が正しくありません。"; } if (!$validate->__email($rq['email'])) { $errmsg[] = "・連絡用メールアドレスの入力が正しくありません。"; } elseif ($rq['email'] != $rq['email_check']) { $errmsg[] = "・連絡用メールアドレスが確認用と異なります。"; } if (!$validate->__range($rq['note'], 1, 2000)) { $errmsg[] = "・ご参加いただくお子さまと、保護者の方についての入力が正しくありません。"; } if (empty($errmsg)) { if( $action == 'check' ) { $template_file = 'confirm.tpl'; } elseif ($action == 'return') { } elseif ($action == 'exec') { // ログ登録 $log_file = 'logs.csv'; $log = array(); $log[] = date('Y/m/d H:i'); $log[] = $rq['name']; $log[] = sprintf('%s-%s-%s', $rq['tel1'], $rq['tel2'], $rq['tel3']); $log[] = $rq['email']; $log[] = $rq['note']; foreach ($log AS $k => $v) { $log[$k] = '"' . $v . '"'; } $csv = (!empty($log)) ? join(',', $log) . "\n":''; $csv = mb_convert_encoding($csv, 'SJIS-win', mb_detect_encoding($csv)); $log_path = $log_dir . $log_file; if (is_file($log_path) && is_writable($log_path)) { $fp = fopen($log_path, 'a+'); $result = fputs($fp,$csv); fclose($fp); } // サンクスメール $send_email = htmlspecialchars($rq['email']); if (file_exists($read_file)) { $send_data = file($read_file); if (!empty($send_data)) { $to = $send_email; $to_name = $send_email; $subject = array_shift($send_data); $subject = set_multibyte_mime($subject, 'UTF-8', 'ISO-2022-JP'); $message = implode('', $send_data); $message = str_replace( "{##NAME##}", $rq['name'], $message ); $message = str_replace( "{##TEL##}", sprintf('%s-%s-%s', $rq['tel1'], $rq['tel2'], $rq['tel3']), $message ); $message = str_replace( "{##EMAIL##}", $rq['email'], $message ); $message = str_replace( "{##NOTE##}", $rq['note'], $message ); $message = str_replace( "
", "\r", $message ); locomill_send_mail3( $to, $to_name, $from, $from_name, $return_to, $subject, $message ); locomill_send_mail3( $from, $to_name, $from, $from_name, $return_to, $subject, $message ); } else { $err_str .= "・送信に失敗しました(内部テンプレート欠損)。
"; } } else { $err_str .= "・送信に失敗しました(内部テンプレートエラー)。
"; } header( 'Location: index.shtml?thanks' ); exit; } } } else { $rq = array(); } } /* 変数の準備 */ foreach ($rq AS $k => $v) { if (is_array($v)) { foreach ($v AS $v2) { $values[$k][] = htmlspecialchars($v2); } } else { $values[$k] = htmlspecialchars($v); } } $smarty->assign( "VALUES", $values ); // エラー文字列 $smarty->assign( "ERRMSG", trim(join('
', $errmsg))); $smarty->assign( "ERR_STR", $err_str ); /* 出 力 */ $smarty->display( $template_dir . $template_file );