getVar( "act" ); $mode = $request->getVar( "mode" ); // ========================================================================== //DB接続(MySQL) // ========================================================================== $mysql = new DBAction(); $conn = $mysql->getConnection(); if ( !$conn ) { //エラー処理 echo( "システムエラーです" ); exit(); } unset( $account_name ); unset( $account_id ); $account_id = "contact"; if ( !isset( $account_id ) || !$account_id || $account_id=="" ) { $sql = "SELECT account_id,account_name FROM " . TABLENAME_PREFIX . "contact_account WHERE flag > 0 ORDER BY id ASC Limit 0, 1"; } else { $sql = "SELECT account_id,account_name FROM " . TABLENAME_PREFIX . "contact_account WHERE flag > 0 AND account_id = '$account_id'"; } $rs = $conn->Execute( $sql ); if ( $rs && $rs->NumRows()>0 ) { while ( $row = $rs->FetchRow(DB_FETCHMODE_ASSOC) ) { $account_id = $row['account_id']; $account_name = $row['account_name']; if ( $_SERVER['REQUEST_METHOD'] == "POST" ) { $_POST['account_id'] = $account_id; } else { $_GET['account_id'] = $account_id; } break; } } switch ( $act ) { default: $act = "Contact"; // ========================================================================== //お問い合わせ処理 // ========================================================================== case "Contact": switch ( $mode ) { default: $mode = "Form"; //お問い合わせ入力 --- Contact(Form) case "Form": unset( $dlist ); $dlist = getContactDefine( $conn, $account_id ); require_once( "ViewContactForm.class.php" ); $list = array(); if ( isset( $_SESSION['contact_detail_' . $account_id] ) ) { $list = $_SESSION['contact_detail_' . $account_id]; } $view = new ViewContactForm(); $view -> assign( $list ); $view -> assign_define( $dlist ); $view -> assign_account_id( $account_id ); $view -> assign_account_name( $account_name ); $view -> display(); break; //お問い合わせ確認 --- Contact(Conf) case "Conf": unset( $list ); unset( $dlist ); unset( $error ); if ( $_SERVER['REQUEST_METHOD'] == "POST" ) { $list = $_POST; } else { $list = $_GET; } if ( $list ) { foreach ( $list as $key => $val ){ if ( ($key=="zip" || $key=="tel" || $key=="fax" || $key=="mobile") && $val && $val!="" ) { $val = mb_convert_kana( $val, "a", "UTF-8" ); $val = str_replace( "-", "-", $val ); $val = str_replace( "-", "", $val ); $val = str_replace( "+", "+", $val ); } if ( ($key=="name" || $key=="kana_name") && $val && $val!="" ) { $val = str_replace( " ", "", $val ); $val = str_replace( " ", "", $val ); } $val = str_replace( "\'", "’", $val ); $list[$key] = mb_convert_kana( $val, "KV", "UTF-8" ); } $str1 = '\"'; $str2 = '”'; $list['body'] = str_replace( $str1, $str2, $list['body'] ); } $dlist = getContactDefine( $conn, $account_id ); $error = checkInputData( $dlist, $account_id, $account_name, $list ); if ( $error ) { require_once( "ViewContactForm.class.php" ); $view = new ViewContactForm(); $view -> assign( $list ); $view -> assign_define( $dlist ); $view -> assign_error( $error ); $view -> assign_account_id( $account_id ); $view -> assign_account_name( $account_name ); $view -> display(); break; } $_SESSION['contact_detail_' . $account_id] = $list; if ( $list ) { foreach ( $list as $key => $val ){ $list[$key] = nl2br( $val ); } } require_once( "ViewContactConf.class.php" ); $view = new ViewContactConf(); $view -> assign( $list ); $view -> assign_define( $dlist ); $view -> assign_account_id( $account_id ); $view -> assign_account_name( $account_name ); $view -> display(); break; //お問い合わせ完了 --- Contact(Comp) case "Comp": unset( $post ); unset( $list ); unset( $dlist ); unset( $error ); if ( $_SERVER['REQUEST_METHOD'] == "POST" ) { $post = $_POST; } else { $post = $_GET; } //戻るボタン if ( $post[prev_x] || $post[prev] ) { header("Location: contact.php?act=Contact&mode=Form"); break; } $dlist = getContactDefine( $conn, $account_id ); if ( isset( $_SESSION['contact_detail_' . $account_id] ) ) { $list = $_SESSION['contact_detail_' . $account_id]; } else { $list = $post; if ( $list ) { foreach ( $list as $key => $val ){ if ( ($key=="zip" || $key=="tel" || $key=="fax" || $key=="mobile") && $val && $val!="" ) { $val = mb_convert_kana( $val, "a", "UTF-8" ); $val = str_replace( "-", "-", $val ); $val = str_replace( "-", "", $val ); $val = str_replace( "+", "+", $val ); } if ( ($key=="name" || $key=="kana_name") && $val && $val!="" ) { $val = str_replace( " ", "", $val ); $val = str_replace( " ", "", $val ); } $val = str_replace( "\'", "’", $val ); $val = str_replace( "/", "/", $val ); $list[$key] = mb_convert_kana( $val, "KV", "UTF-8" ); } } } if ( isset( $_SESSION['contact_detail_' . $account_id] ) ) { if ( isset( $post['prev'] ) || isset( $post['prev_x'] ) || isset( $post['prev_y'] ) ) { require_once( "ViewContactForm.class.php" ); $view = new ViewContactForm(); $view -> assign( $list ); $view -> assign_define( $dlist ); $view -> assign_account_id( $account_id ); $view -> assign_account_name( $account_name ); $view -> display(); break; } } else { $error = checkInputData( $dlist, $account_id, $account_name, $list ); if ( $error ) { require_once( "ViewContactForm.class.php" ); $view = new ViewContactForm(); $view -> assign( $list ); $view -> assign_define( $dlist ); $view -> assign_error( $error ); $view -> assign_account_id( $account_id ); $view -> assign_account_name( $account_name ); $view -> display(); break; } } if ( $list ) { $list = insertContactDefine( $conn, $account_id, $account_name, $list, $date ); /*----相談場所の希望 free_02-free_04----*/ $free_02 = ""; for( $i=2; $i<=4; $i++ ){ $no = "free_0".$i; if( $list[$no] ){ if( $free_02 == "" ){ $free_02 = $list[$no] ; } else { $free_02 .= "、".$list[$no] ; } } } $list['free_02'] = $free_02; /*-----葬儀の規模 free_05-free_07-----*/ $free_05 = ""; for( $i=5; $i<=7; $i++ ){ $no = "free_0".$i; if( $list[$no] ){ if( $free_05 == "" ){ $free_05 = $list[$no] ; } else { $free_05 .= "、".$list[$no] ; } } } $list['free_05'] = $free_05; /*------心配事 free_10-free_13------*/ $free_10 = ""; for( $i=10; $i<=13; $i++ ){ $no = "free_".$i; if( $list[$no] ){ if( $free_10 == "" ){ $free_10 = $list[$no] ; } else { $free_10 .= "、".$list[$no] ; } } } $list['free_10'] = $free_10; /*------葬儀の種類 free_14-free_17------*/ $free_14 = ""; for( $i=14; $i<=17; $i++ ){ $no = "free_".$i; if( $list[$no] ){ if( $free_14 == "" ){ $free_14 = $list[$no] ; } else { $free_14 .= "、".$list[$no] ; } } } $list['free_14'] = $free_14; sendContactMail( $conn, $dlist, $account_id, $account_name, $list ); } session_unset(); require_once( "ViewContactComp.class.php" ); $view = new ViewContactComp(); $view -> assign( $list ); $view -> assign_define( $dlist ); $view -> assign_account_id( $account_id ); $view -> assign_account_name( $account_name ); $view -> display(); break; } break; } exit(); // ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ // ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ // ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ --- 関数 --- ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ // ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ // ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ // ========================================================================== function getContactDefine( $conn, $account_id ) { unset( $dlist ); $sql = "SELECT * FROM " . TABLENAME_PREFIX . "contact_define WHERE account_id = '$account_id'"; $rs = $conn->Execute( $sql ); if ( $rs && $rs->NumRows()>0 ) { while ( $row = $rs->FetchRow(DB_FETCHMODE_ASSOC) ) { $dlist = $row; } } return $dlist; } // ========================================================================== function checkInputData( $dlist, $account_id, $account_name, $list ) { unset( $error ); if ( $dlist ) { if ( is_int($key) || $key=="serial" || $key=="id" || $key=="account_id" || $key=="reg_date" || $key=="up_date" ) { continue; } //お問い合わせ if ( $dlist['type'] == 2 ) { if ( !$list['type'] ) { $error['type'] = "お問い合わせ内容は必須項目です。"; } } //お名前 if ( $dlist['name'] == 2 ) { if ( !$list['name'] ) { $error['name'] = "お名前は必須項目です。"; } } //お名前 ふりがな if ( $dlist['kana_name'] == 2 ) { if ( !$list['kana_name'] ) { $error['kana_name'] = "ひらがなは必須項目です。"; } elseif ( !preg_match("/^[ぁ-んァ-ン]+$/u", $list['kana_name']) ){ $error['kana_name'] = "ひらがなで入力してください。"; } } //メールアドレス if ( $dlist['email'] == 2 ) { if ( !$list['email'] ) { $error['email'] = "メールアドレスは必須項目です。"; } else { if ( !preg_match('/^[a-zA-Z0-9_\.\-]+?@[A-Za-z0-9_\.\-]+$/', $list[email]) ) { $error['email'] = "メールアドレスが正しくありません。"; } } } //電話番号 if ( $list['tel'] && $list['tel'] !="" ) { if ( !preg_match('/^[0-9]+$/', $list[tel]) ) { $error['tel'] = "電話番号は半角数字で入力してください。"; } } //希望の連絡方法 if( $dlist['free_01'] == '2' ){ if ( !$list['free_01'] ){ $error['free_01'] = "希望の連絡方法は必須項目です。"; } } //郵便番号 if( $dlist['zip'] == '2' ){ if ( !$list['zip'] ){ $error['zip'] = "郵便番号は必須項目です。"; } elseif ( preg_match("/^[0-9]+$/", $list[zip]) == 0 ){ $error['zip'] = "郵便番号は半角数字で入力してください。"; } } //都道府県 if( $dlist['address_1'] == '2' ){ if ( !$list['address_1'] ){ $error['address_1'] = "都道府県は必須項目です。"; } } //市区町村番地 if( $dlist['address_2'] == '2' ){ if ( !$list['address_2'] ){ $error['address_2'] = "市区町村番地は必須項目です。"; } } //自由記入欄 if ( $dlist['body'] == 2 ) { if ( !$list['body'] ) { $error['body'] = "お問い合わせ内容は必須項目です。"; } } } return $error; } // ========================================================================== function insertContactDefine( $conn, $account_id, $account_name, $list, $date ) { $id = intval( $conn->GetOne( "SELECT MAX(id) FROM " . TABLENAME_PREFIX . "contact_detail" ) ); $list['id'] = $id+1; $sql_ins = "INSERT INTO " . TABLENAME_PREFIX . "contact_detail ( `id`, `name`, `kana_name`, `email`, `birthday`, `sex`, `zip`, `address_1`, `address_2`, `address_3`, `address_4`, `tel`, `fax`, `mobile`, `mobile_mail`, `subject`, `body`, `free_01`, `free_02`, `free_03`, `free_04`, `free_05`, `free_06`, `free_07`, `free_08`, `free_09`, `free_10`, `free_11`, `free_12`, `free_13`, `free_14`, `free_15`, `free_16`, `free_17`, `free_18`, `free_19`, `free_20`, `free_21`, `free_22`, `free_23`, `free_24`, `free_25`, `free_26`, `free_27`, `free_28`, `free_29`, `free_30`, `free_31`, `free_32`, `free_33`, `free_34`, `free_35`, `free_36`, `free_37`, `free_38`, `free_39`, `free_40`, `free_41`, `free_42`, `free_43`, `free_44`, `free_45`, `free_46`, `free_47`, `free_48`, `free_49`, `free_50`, `free_51`, `free_52`, `free_53`, `free_54`, `free_55`, `free_56`, `free_57`, `free_58`, `free_59`, `free_60`, `free_61`, `free_62`, `free_63`, `free_64`, `free_65`, `free_66`, `free_67`, `free_68`, `free_69`, `free_70`, `free_71`, `free_72`, `free_73`, `free_74`, `free_75`, `free_76`, `free_77`, `free_78`, `free_79`, `free_80`, `free_81`, `free_82`, `free_83`, `free_84`, `free_85`, `free_86`, `free_87`, `free_88`, `free_89`, `free_90`, `free_91`, `free_92`, `free_93`, `free_94`, `free_95`, `free_96`, `free_97`, `free_98`, `free_99`, `charge`, `re_subject`, `re_body`, `re_sign`, `re_date`, `account`, `status`, `type`, `feedback`, `reg_date`, `up_date`, `up_id` ) VALUES ( '$list[id]', '$list[name]', '$list[kana_name]', '$list[email]', '$list[birthday]', '$list[sex]', '$list[zip]', '$list[address_1]', '$list[address_2]', '$list[address_3]', '$list[address_4]', '$list[tel]', '$list[fax]', '$list[mobile]', '$list[mobile_mail]', '$list[subject]', '$list[body]', '$list[free_01]', '$list[free_02]', '$list[free_03]', '$list[free_04]', '$list[free_05]', '$list[free_06]', '$list[free_07]', '$list[free_08]', '$list[free_09]', '$list[free_10]', '$list[free_11]', '$list[free_12]', '$list[free_13]', '$list[free_14]', '$list[free_15]', '$list[free_16]', '$list[free_17]', '$list[free_18]', '$list[free_19]', '$list[free_20]', '$list[free_21]', '$list[free_22]', '$list[free_23]', '$list[free_24]', '$list[free_25]', '$list[free_26]', '$list[free_27]', '$list[free_28]', '$list[free_29]', '$list[free_30]', '$list[free_31]', '$list[free_32]', '$list[free_33]', '$list[free_34]', '$list[free_35]', '$list[free_36]', '$list[free_37]', '$list[free_38]', '$list[free_39]', '$list[free_40]', '$list[free_41]', '$list[free_42]', '$list[free_43]', '$list[free_44]', '$list[free_45]', '$list[free_46]', '$list[free_47]', '$list[free_48]', '$list[free_49]', '$list[free_50]', '$list[free_51]', '$list[free_52]', '$list[free_53]', '$list[free_54]', '$list[free_55]', '$list[free_56]', '$list[free_57]', '$list[free_58]', '$list[free_59]', '$list[free_60]', '$list[free_61]', '$list[free_62]', '$list[free_63]', '$list[free_64]', '$list[free_65]', '$list[free_66]', '$list[free_67]', '$list[free_68]', '$list[free_69]', '$list[free_70]', '$list[free_71]', '$list[free_72]', '$list[free_73]', '$list[free_74]', '$list[free_75]', '$list[free_76]', '$list[free_77]', '$list[free_78]', '$list[free_79]', '$list[free_80]', '$list[free_81]', '$list[free_82]', '$list[free_83]', '$list[free_84]', '$list[free_85]', '$list[free_86]', '$list[free_87]', '$list[free_88]', '$list[free_89]', '$list[free_90]', '$list[free_91]', '$list[free_92]', '$list[free_93]', '$list[free_94]', '$list[free_95]', '$list[free_96]', '$list[free_97]', '$list[free_98]', '$list[free_99]', '', '', '', '', '', '$account_id', '未対応', '$list[type]', '', '$date', '$date', '$account_id' )"; $rs_ins = $conn->Execute( $sql_ins ); return $list; } // ========================================================================== function sendContactMail( $conn, $dlist, $account_id, $account_name, $list ) { unset( $m_list ); $sql = "SELECT * FROM " . TABLENAME_PREFIX . "contact_mail_setup WHERE account_id = '$account_id'"; $rs = $conn->Execute( $sql ); if ( $rs && $rs->NumRows()>0 ) { while ( $row = $rs->FetchRow(DB_FETCHMODE_ASSOC) ) { $m_list = $row; } } if ( $m_list['conf_mail_flag']>0 ) { unset( $old ); unset( $new ); unset( $sbj ); unset( $bd ); unset( $recipients ); unset( $headers ); unset( $params ); unset( $objMail ); unset( $result ); $old = array ( '$id' , '$name' , '$kana_name' , '$email' , '$birthday' , '$sex' , '$zip' , '$address_1' , '$address_2' , '$address_3' , '$address_4' , '$tel' , '$fax' , '$mobile' , '$mobile_mail' , '$subject' , '$body' , '$free_99' , '$free_98' , '$free_97' , '$free_96' , '$free_95' , '$free_94' , '$free_93' , '$free_92' , '$free_91' , '$free_90' , '$free_89' , '$free_88' , '$free_87' , '$free_86' , '$free_85' , '$free_84' , '$free_83' , '$free_82' , '$free_81' , '$free_80' , '$free_79' , '$free_78' , '$free_77' , '$free_76' , '$free_75' , '$free_74' , '$free_73' , '$free_72' , '$free_71' , '$free_70' , '$free_69' , '$free_68' , '$free_67' , '$free_66' , '$free_65' , '$free_64' , '$free_63' , '$free_62' , '$free_61' , '$free_60' , '$free_59' , '$free_58' , '$free_57' , '$free_56' , '$free_55' , '$free_54' , '$free_53' , '$free_52' , '$free_51' , '$free_50' , '$free_49' , '$free_48' , '$free_47' , '$free_46' , '$free_45' , '$free_44' , '$free_43' , '$free_42' , '$free_41' , '$free_40' , '$free_39' , '$free_38' , '$free_37' , '$free_36' , '$free_35' , '$free_34' , '$free_33' , '$free_32' , '$free_31' , '$free_30' , '$free_29' , '$free_28' , '$free_27' , '$free_26' , '$free_25' , '$free_24' , '$free_23' , '$free_22' , '$free_21' , '$free_20' , '$free_19' , '$free_18' , '$free_17' , '$free_16' , '$free_15' , '$free_14' , '$free_13' , '$free_12' , '$free_11' , '$free_10' , '$free_09' , '$free_08' , '$free_07' , '$free_06' , '$free_05' , '$free_04' , '$free_03' , '$free_02' , '$free_01' , '$charge' , '$type' ); $new = array ( $list['id'] , $list['name'] , $list['kana_name'] , $list['email'] , $list['birthday'] , $list['sex'] , $list['zip'] , $list['address_1'] , $list['address_2'] , $list['address_3'] , $list['address_4'] , $list['tel'] , $list['fax'] , $list['mobile'] , $list['mobile_mail'] , $list['subject'] , $list['body'] , $list['free_99'] , $list['free_98'] , $list['free_97'] , $list['free_96'] , $list['free_95'] , $list['free_94'] , $list['free_93'] , $list['free_92'] , $list['free_91'] , $list['free_90'] , $list['free_89'] , $list['free_88'] , $list['free_87'] , $list['free_86'] , $list['free_85'] , $list['free_84'] , $list['free_83'] , $list['free_82'] , $list['free_81'] , $list['free_80'] , $list['free_79'] , $list['free_78'] , $list['free_77'] , $list['free_76'] , $list['free_75'] , $list['free_74'] , $list['free_73'] , $list['free_72'] , $list['free_71'] , $list['free_70'] , $list['free_69'] , $list['free_68'] , $list['free_67'] , $list['free_66'] , $list['free_65'] , $list['free_64'] , $list['free_63'] , $list['free_62'] , $list['free_61'] , $list['free_60'] , $list['free_59'] , $list['free_58'] , $list['free_57'] , $list['free_56'] , $list['free_55'] , $list['free_54'] , $list['free_53'] , $list['free_52'] , $list['free_51'] , $list['free_50'] , $list['free_49'] , $list['free_48'] , $list['free_47'] , $list['free_46'] , $list['free_45'] , $list['free_44'] , $list['free_43'] , $list['free_42'] , $list['free_41'] , $list['free_40'] , $list['free_39'] , $list['free_38'] , $list['free_37'] , $list['free_36'] , $list['free_35'] , $list['free_34'] , $list['free_33'] , $list['free_32'] , $list['free_31'] , $list['free_30'] , $list['free_29'] , $list['free_28'] , $list['free_27'] , $list['free_26'] , $list['free_25'] , $list['free_24'] , $list['free_23'] , $list['free_22'] , $list['free_21'] , $list['free_20'] , $list['free_19'] , $list['free_18'] , $list['free_17'] , $list['free_16'] , $list['free_15'] , $list['free_14'] , $list['free_13'] , $list['free_12'] , $list['free_11'] , $list['free_10'] , $list['free_09'] , $list['free_08'] , $list['free_07'] , $list['free_06'] , $list['free_05'] , $list['free_04'] , $list['free_03'] , $list['free_02'] , $list['free_01'] , $list['charge'] , $list['type'] ); $sbj = str_replace( $old, $new, $m_list['mail_subject'] ); $bd = str_replace( $old, $new, $m_list['mail_body'] ); $bd = mb_convert_encoding( $bd, "ISO-2022-JP", "UTF-8" ); $bd = str_replace( "\r\n", "\n", $bd ); $bd = str_replace( "\r", "", $bd ); $recipients = $list['email']; if ( $m_list['mail_cc'] ) { $recipients = $recipients . "," . $m_list['mail_cc']; } if ( $m_list['mail_bcc'] ) { $recipients = $recipients . "," . $m_list['mail_bcc']; } //mb_language(’Japanese’); $headers['Subject'] = '=?ISO-2022-JP?B?' . base64_encode( mb_convert_encoding( $sbj, 'JIS', 'UTF-8' ) ) . '?='; //$headers['From'] = mb_encode_mimeheader( mb_convert_encoding( $m_list['mail_from_name'], "ISO-2022-JP", "UTF-8" ) ) . "<" . $m_list['mail_from'] . ">"; $headers['From'] = mb_encode_mimeheader($m_list['mail_from_name']) . "<" . $m_list['mail_from'] . ">"; $headers['To'] = $list['email']; $headers['Cc'] = $m_list['mail_cc']; $headers['Bcc'] = $m_list['mail_bcc']; require_once "Mail.php"; $params['sendmail_args'] = "-f" . $m_list['mail_from']; $objMail =& Mail::factory( 'sendmail', $params ); $result = $objMail->send( $recipients , $headers, $bd ); if ( PEAR::isError( $result ) ) { die( $result->getMessage() ); } } return; } ?>