get_exception();
}
}
/* 出力準備 */
$smarty = new SmartyEx();
$smarty->prepare();
/* Validateクラスインスタンス生成 */
if( $err_str === "" )
{
try
{
$validate = new Validate();
}
catch( ValidateError $e )
{
$err_str .= $e->get_exception();
}
}
/* 期限切れ */
if( $err_str === "" )
{
if (strtotime($stamp) < mktime()) {
$err_str = '受付は終了致しました。';
}
}
/* 回答制限 */
if( $err_str === "" )
{
//$log_path = $log_dir . $num_file;
//$temp = file($log_path);
//$count = count($temp);
//if ($limit <= $count) $err_str = '定員を超えたため、応募を締切らせていただきました。';
}
/* 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[] = "・氏名の入力が正しくありません。";
}
$rq['tel1'] = mb_convert_kana($rq['tel1'], 'a');
$rq['tel2'] = mb_convert_kana($rq['tel2'], 'a');
$rq['tel3'] = mb_convert_kana($rq['tel3'], 'a');
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 (!$validate->__range($rq['area'], 1, 20)) {
$errmsg[] = "・お住まいのエリアの入力が正しくありません。";
}
if (empty($errmsg))
{
if( $action == 'check' ) {
$template_file = 'confirm.tpl';
} elseif ($action == 'return') {
} elseif ($action == 'exec') {
// ログ登録
$rq['tel'] = sprintf('%s-%s-%s', $rq['tel1'], $rq['tel2'], $rq['tel3']);
$log = array();
$log[] = date('Y/m/d H:i');
$log[] = $rq['name'];
$log[] = $rq['tel'];
$log[] = $rq['email'];
$log[] = $rq['note'];
$log[] = $rq['area'];
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);
}
// 人数登録
$log = array();
$log[] = date('Y/m/d H:i');
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 . $num_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);
foreach ($rq AS $k => $v) {
$key = strtoupper($k);
$message = str_replace( "{##".$key."##}", $v, $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( "NUM", ($limit - $count) );
// エラー文字列
$smarty->assign( "ERRMSG", trim(join('
', $errmsg)));
$smarty->assign( "ERR_STR", $err_str );
/* 出 力 */
$smarty->display( $template_dir . $template_file );