get_exception(); } } /* 出力準備 */ $smarty = new SmartyEx(); $smarty->prepare(); /* マイプロフィール */ include('common/myprofile.inc'); if ($need_login) { /* ログインチェック */ if ($is_login != 1 || empty($login_user_id)) { header('location: /login/?is_keep=1&rdr=/client_form/' . $dir . '/'); exit; } } // 設定 $smarty->assign("LIMIT", $stamp); $smarty->assign("TITLE", $title); $smarty->assign("TITLE_S", $title_s); $smarty->assign("FROM", $from); /* Validateクラスインスタンス生成 */ if ($err_str === "") { try { $validate = new Validate(); } catch (ValidateError $e) { $err_str .= $e->get_exception(); } } /* Areaクラスインスタンス生成 */ if ($err_str === "" && $is_login == 1) { try { $area = new Area($locomill->get_db3()); $temp = $area->get_data_array('area_master_01_tbl', true); foreach ($temp AS $v) { $area_01_array[$v['id']] = $v['name']; } $temp = $area->get_data_array('area_master_03_tbl', true); foreach ($temp AS $v) { $area_03_array[$v['id']] = $v['name']; } $temp = $area->get_data_array('area_tbl', true); foreach ($temp AS $v) { $area_04_array[$v['id']] = $v['name']; } } catch (AreaError $e) { $err_str .= $e->get_exception(); } } /* 期限切れ */ if ($err_str === "") { if (strtotime($stamp) < mktime() && LOCOMILL_HOSTNAME == 'www') { $err_str = '受付は終了致しました。'; } } /* 回答件数 */ $time_num = array(); if ($err_str === "") { foreach ($time AS $k => $v) { $time_num[$k] = 0; } $log_path = $log_dir . $num_file; $fp = fopen($log_path, 'r'); while ($row = fgetcsv($fp)) { $time_num[$row[1]]++; } } /* Request値の検証 */ if (isset($_GET['thanks'])) { $template_file = 'thanks.tpl'; $smarty->display($template_dir . $template_file); exit; } elseif ($err_str === "") { if (!empty($_POST)) { $rq = $_POST; } if (!empty($rq['action'])) { $action = $rq['action']; unset($rq['action']); } if ($action == 'check' || $action == 'return' || $action == 'exec') { if (!$validate->__range($rq['name'], 1, 255)) { $errmsg[] = '・お名前の入力が正しくありません。'; } if (!$validate->__range($rq['kana'], 1, 255)) { $errmsg[] = '・ふりがなの入力が正しくありません。'; } $rq['pcode1'] = mb_convert_kana($rq['pcode1'], 'a'); $rq['pcode2'] = mb_convert_kana($rq['pcode2'], 'a'); if (!preg_match('/^[0-9]{3}-[0-9]{4}$/', sprintf('%s-%s', $rq['pcode1'], $rq['pcode2']))) { $errmsg[] = '・郵便番号の入力が正しくありません。'; } if (!$validate->__range($rq['address'], 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['child'], 1, 255)) { $errmsg[] = '・一緒に来場するお子さんの人数の入力が正しくありません。'; } if (!isset($time[$rq['time']])) { $errmsg[] = '・ご来場予定時間帯の選択が正しくありません。'; } if (!isset($select[$rq['select']])) { $errmsg[] = '・キラキラママサークルの会員ですか?の選択が正しくありません。'; } if (empty($rq['media'])) { $errmsg[] = '・何を見てイベントを知りましたか?の選択が正しくありません。'; } if (empty($rq['agreement']) || $rq['agreement'] != 1) { $errmsg[] = '・利用規約をご確認ください。'; } if (empty($errmsg)) { if ($action == 'check') { $template_file = 'confirm.tpl'; } elseif ($action == 'return') { } elseif ($action == 'exec') { // 人数登録 $log = array(); $log[] = date('Y/m/d H:i'); $log[] = $rq['time']; 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); } // ログ登録 $rq['pcode'] = sprintf('%s-%s', $rq['pcode1'], $rq['pcode2']); $rq['tel'] = sprintf('%s-%s-%s', $rq['tel1'], $rq['tel2'], $rq['tel3']); $rq['time'] = (!empty($rq['time']))? $time[$rq['time']]: ''; $rq['select'] = (!empty($rq['select']))? $select[$rq['select']]: ''; $temp = array(); if (!empty($rq['media'])) { foreach ($rq['media'] AS $v) { $temp[] = $media[$v]; } } $rq['media'] = implode("\n", $temp); $log = array(); $log[] = date('Y/m/d H:i'); $log[] = $rq['name']; $log[] = $rq['kana']; $log[] = $rq['pcode']; $log[] = $rq['address']; $log[] = $rq['tel']; $log[] = $rq['email']; $log[] = $rq['child']; $log[] = $rq['time']; $log[] = $rq['select']; $log[] = $rq['media']; if ($need_login) { $log[] = $login_user_id; } 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); 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 .= '・送信に失敗しました(内部テンプレートエラー)。
'; } if ($err_str == "") { header('Location: ./?thanks'); exit; } } } } else { if ($is_login == 1) { $address = ''; if (!empty($member_data['prefect']) && isset($area_01_array[$member_data['prefect']])) { $address .= $area_01_array[$member_data['prefect']]; } if (!empty($member_data['city']) && isset($area_03_array[$member_data['city']])) { $address .= $area_03_array[$member_data['city']]; } if (!empty($member_data['town']) && isset($area_04_array[$member_data['town']])) { $address .= $area_04_array[$member_data['town']]; } if (!empty($member_data['email_pc'])) { $email = $member_data['email_pc']; } elseif (!empty($member_data['email_mobile'])) { $email = $member_data['email_mobile']; } else { $email = ''; } $rq = array('name' => $member_data['name_01'] . $member_data['name_02'], 'pcode1' => $member_data['zipcode_01'], 'pcode2' => $member_data['zipcode_02'], 'address' => $address . $member_data['address_01'], 'tel1' => $member_data['tel_01'], 'tel2' => $member_data['tel_02'], 'tel3' => $member_data['tel_03'], 'email' => $email, 'email_check' => $email); } 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); } } if (!isset($values['media'])) { $values['media'] = array(); } $smarty->assign("VALUES", $values); $smarty->assign("TIME", $time); $smarty->assign("TIME_NUM", $time_num); $smarty->assign("SELECT", $select); $smarty->assign("MEDIA", $media); // エラー文字列 $smarty->assign("ERRMSG", trim(join('
', $errmsg))); $smarty->assign("ERR_STR", $err_str); /* 出 力 */ $smarty->display($template_dir . $template_file);