?php /* * Generated by phinagata 0.1.14070401 * (C) dotAster Inc. All Rights Reserved. * http://qiq.to/phinagata/ */ require_once '../system/config.php'; // %%tag_CONFIG_PHP_PATH%% function replaceCorruption($subject) { $search = Array('㈲','㈱'); $replace = Array('(有)','(株)'); $result = str_replace($search, $replace, $subject); return $result; } class contactClass extends qiqFramework { function contactClass() { $this->var = array( 'mode', 'type', 'name', 'name_sei', 'name_mei', 'kana', 'kana_sei', 'kana_mei', 'company', 'post', 'email', 'email_confirm', 'zip', 'zip_1', 'zip_2', 'prefecture', 'address_1', 'address_2', 'phone', 'category', 'body', 'ok', 'cancel', ); $this->labelType = array( 1 => '一般のお客様', 2 => '企業・法人のお客様', ); $this->labelCategory = array( 0x00000001 => 'OEM生産について', 0x00000002 => '新規取り扱いについて', 0x00000004 => '新製品開発・共同開発について', 0x00000008 => '商品について', 0x00000010 => 'お見積もりのお願い', 0x00000020 => 'その他', ); $this->labelPrefecture = array( 0 => SEL_DEFAULT, 1 => '北海道', 2 => '青森県', 3 => '岩手県', 4 => '宮城県', 5 => '秋田県', 6 => '山形県', 7 => '福島県', 8 => '茨城県', 9 => '栃木県', 10 => '群馬県', 11 => '埼玉県', 12 => '千葉県', 13 => '東京都', 14 => '神奈川県', 15 => '新潟県', 16 => '富山県', 17 => '石川県', 18 => '福井県', 19 => '山梨県', 20 => '長野県', 21 => '岐阜県', 22 => '静岡県', 23 => '愛知県', 24 => '三重県', 25 => '滋賀県', 26 => '京都府', 27 => '大阪府', 28 => '兵庫県', 29 => '奈良県', 30 => '和歌山県', 31 => '鳥取県', 32 => '島根県', 33 => '岡山県', 34 => '広島県', 35 => '山口県', 36 => '徳島県', 37 => '香川県', 38 => '愛媛県', 39 => '高知県', 40 => '福岡県', 41 => '佐賀県', 42 => '長崎県', 43 => '熊本県', 44 => '大分県', 45 => '宮崎県', 46 => '鹿児島県', 47 => '沖縄県', ); $this->import($this->var); $this->set_html_dir(HTMLDIR. '/contact'); $this->category_checkbox = new qiqCheckboxes(array( 'labelCheck' => $this->labelCategory, )); $this->category_check = $this->category_checkbox->input_check($this->category); if (!$this->mode) $this->mode = 'form'; } function form() { } function check() { if (!$this->type) { $err['type'] = "種別を選択してください"; } if (!$this->name_sei || !$this->name_mei) { $err['name'] = "お名前を入力してください"; } if (!$this->kana_sei || !$this->kana_mei) { $err[] = "フリガナを入力してください"; }elseif(!preg_match("/^([  \t\r\n]|[ァ-ヶー]|[ー])+$/u", $this->kana_sei) || !preg_match("/^([  \t\r\n]|[ァ-ヶー]|[ー])+$/u", $this->kana_mei)){ $err[] = "フリガナで入力してください"; } if (!$this->email) { $err['email'] = "メールアドレスを入力してください"; } elseif (!preg_match('/^[-\w\._+]+@[-\w]+\.[-\w\.]+$/', $this->email)) { $err['email'] = "メールアドレスを正しく入力してください"; } if ($this->type == 2 && !$this->company){ $err['company'] = "会社名を入力してください"; } /* if (!$this->email_confirm) { $err[] = "確認用メールアドレスを入力してください"; } elseif (!preg_match('/^[-\w\._+]+@[-\w]+\.[-\w\.]+$/', $this->email_confirm)) { $err[] = "確認用メールアドレスを正しく入力してください"; } elseif ($this->email != $this->email_confirm) { $err[] = "確認用メールアドレスがメールアドレスと異なっています。"; } */ if (($this->zip_1 && $this->zip_2) && (!preg_match('/^\d{3}$/', $this->zip_1) || !preg_match('/^\d{4}$/', $this->zip_2))) { $err['zip'] = "郵便番号を正しく入力してください"; } if(strstr($this->phone, "-")){ $this->__phone = str_replace("-", "", $this->phone); if ($this->phone && !preg_match('/^0\d{9,11}$/', $this->__phone)) { $err['phone'] = "電話番号を正しく入力してください"; } }elseif($this->phone && !preg_match('/^0\d{9,11}$/', $this->phone)) { $err['phone'] = "電話番号を正しく入力してください"; } if (!$this->category) { $err['category'] = "お問い合わせの内容を選択してください"; } if (!$this->body) { $err['body'] = "お問い合わせ内容を入力してください"; } if ($err) { $this->error = $err; return 0; } return 1; } function reload() { $this->mode = 'form'; } function confirm() { $this->_company = replaceCorruption($this->_company); $this->_address_2 = replaceCorruption($this->_address_2); if ($this->cancel) { $this->mode = 'form'; return; } if (!$this->check()) { $this->mode = 'form'; return; } $this->_name = sprintf('%s %s', $this->_name_sei, $this->_name_mei); $this->_kana = sprintf('%s %s', $this->_kana_sei, $this->_kana_mei); $this->_zip = sprintf('%03d-%04d', $this->_zip_1, $this->_zip_2); if ($this->_zip == '000-0000') $this->_zip = ''; $this->labelPrefecture[0] = ''; $this->__labelCategory = $this->category_checkbox->label($this->category); } function commit() { $this->mode = 'form'; if ($this->cancel) { return; } if (!$this->check()) { return; } $this->name = sprintf('%s %s', $this->_name_sei, $this->_name_mei); $this->kana = sprintf('%s %s', $this->_kana_sei, $this->_kana_mei); $this->zip = sprintf('%03d-%04d', $this->_zip_1, $this->_zip_2); if ($this->zip == '000-0000') $this->_zip = ''; $this->__labelCategory = $this->category_checkbox->label($this->category); /* メール送信 */ $param = '-f '. ADMINEMAIL; //user ob_start(); $this->mb_include(MAILDIR. '/contact.txt'); $body = ob_get_contents(); ob_end_clean(); $to = $this->email; $mailfrom = MAILFROM; $fromname = mb_encode_mimeheader(FROMNAME); $from = sprintf('From: %s <%s>', $fromname, $mailfrom); if (defined('BCC') && BCC) $from .= "\nBcc: " . BCC; $body = str_replace("\r\n", "\n", $body); mb_send_mail($to, SUBJECT_CONTACT, $body, $from, $param); //admin ob_start(); $this->mb_include(MAILDIR. '/admin/contact.txt'); $body = ob_get_contents(); ob_end_clean(); $to = ADMINEMAIL; //$mailfrom = $this->email; //$fromname = mb_encode_mimeheader($this->name); $mailfrom = MAILFROM; $fromname = mb_encode_mimeheader(FROMNAME); $from = sprintf('From: %s <%s>', $fromname, $mailfrom); if (defined('BCC') && BCC) $from .= "\nBcc: " . BCC; $body = str_replace("\r\n", "\n", $body); mb_send_mail($to, SUBJECT_CONTACT_ADMIN, $body, $from, $param); $this->mode = 'commit'; } } $_contactClass = new contactClass(); $_contactClass->main('UTF-8'); // vi:ts=8 sw=2 ?>