source: branches/version-2_13_0/data/class/pages/entry/LC_Page_Entry.php @ 23168

Revision 23168, 11.6 KB checked in by m_uehara, 11 years ago (diff)

#2348 r23142, r23154 - r23156, r23160 - r23162 をマージ

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26/**
27 * 会員登録のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id:LC_Page_Entry.php 15532 2007-08-31 14:39:46Z nanasess $
32 */
33class LC_Page_Entry extends LC_Page_Ex
34{
35    /**
36     * Page を初期化する.
37     * @return void
38     */
39    public function init()
40    {
41        parent::init();
42        $masterData         = new SC_DB_MasterData_Ex();
43        $this->arrPref      = $masterData->getMasterData('mtb_pref');
44        $this->arrJob       = $masterData->getMasterData('mtb_job');
45        $this->arrReminder  = $masterData->getMasterData('mtb_reminder');
46        $this->arrCountry   = $masterData->getMasterData('mtb_country');
47        $this->arrSex       = $masterData->getMasterData('mtb_sex');
48        $this->arrMAILMAGATYPE = $masterData->getMasterData('mtb_mail_magazine_type');
49
50        // 生年月日選択肢の取得
51        $objDate            = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now')));
52        $this->arrYear      = $objDate->getYear('', START_BIRTH_YEAR, '');
53        $this->arrMonth     = $objDate->getMonth(true);
54        $this->arrDay       = $objDate->getDay(true);
55
56        $this->httpCacheControl('nocache');
57    }
58
59    /**
60     * Page のプロセス.
61     *
62     * @return void
63     */
64    public function process()
65    {
66        parent::process();
67        $this->action();
68        $this->sendResponse();
69    }
70
71    /**
72     * Page のプロセス
73     * @return void
74     */
75    public function action()
76    {
77        //決済処理中ステータスのロールバック
78        $objPurchase = new SC_Helper_Purchase_Ex();
79        $objPurchase->checkSessionPendingOrder();
80        $objPurchase->checkDbMyPendignOrder();
81        $objPurchase->checkDbAllPendingOrder();
82
83        $objFormParam = new SC_FormParam_Ex();
84
85        // PC時は規約ページからの遷移でなければエラー画面へ遷移する
86        if ($this->lfCheckReferer() === false) {
87            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
88        }
89
90        SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam);
91        $objFormParam->setParam($_POST);
92
93        // mobile用(戻るボタンでの遷移かどうかを判定)
94        if (!empty($_POST['return'])) {
95            $_REQUEST['mode'] = 'return';
96        }
97
98        switch ($this->getMode()) {
99            case 'confirm':
100                if (isset($_POST['submit_address'])) {
101                    // 入力エラーチェック
102                    $this->arrErr = $this->lfCheckError($_POST);
103                    // 入力エラーの場合は終了
104                    if (count($this->arrErr) == 0) {
105                        // 郵便番号検索文作成
106                        $zipcode = $_POST['zip01'] . $_POST['zip02'];
107
108                        // 郵便番号検索
109                        $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode);
110
111                        // 郵便番号が発見された場合
112                        if (!empty($arrAdsList)) {
113                            $data['pref'] = $arrAdsList[0]['state'];
114                            $data['addr01'] = $arrAdsList[0]['city']. $arrAdsList[0]['town'];
115                            $objFormParam->setParam($data);
116
117                            // 該当無し
118                        } else {
119                            $this->arrErr['zip01'] = '※該当する住所が見つかりませんでした。<br>';
120                        }
121                    }
122                    break;
123                }
124
125                //-- 確認
126                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
127                // 入力エラーなし
128                if (empty($this->arrErr)) {
129                    //パスワード表示
130                    $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($objFormParam->getValue('password')));
131
132                    $this->tpl_mainpage = 'entry/confirm.tpl';
133                    $this->tpl_title    = '会員登録(確認ページ)';
134                }
135                break;
136            case 'complete':
137                //-- 会員登録と完了画面
138                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
139                if (empty($this->arrErr)) {
140                    $uniqid             = $this->lfRegistCustomerData($this->lfMakeSqlVal($objFormParam));
141
142                    $this->lfSendMail($uniqid, $objFormParam->getHashArray());
143
144                    // 仮会員が無効の場合
145                    if (CUSTOMER_CONFIRM_MAIL == false) {
146                        // ログイン状態にする
147                        $objCustomer = new SC_Customer_Ex();
148                        $objCustomer->setLogin($objFormParam->getValue('email'));
149                    }
150
151                    // 完了ページに移動させる。
152                    SC_Response_Ex::sendRedirect('complete.php', array('ci' => SC_Helper_Customer_Ex::sfGetCustomerId($uniqid)));
153                }
154                break;
155            case 'return':
156                // quiet.
157                break;
158            default:
159                break;
160        }
161        $this->arrForm = $objFormParam->getFormParamList();
162    }
163
164    /**
165     * 会員情報の登録
166     *
167     * @access private
168     * @return uniqid
169     */
170    public function lfRegistCustomerData($sqlval)
171    {
172        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval);
173
174        return $sqlval['secret_key'];
175    }
176
177    /**
178     * 会員登録に必要なSQLパラメーターの配列を生成する.
179     *
180     * フォームに入力された情報を元に, SQLパラメーターの配列を生成する.
181     * モバイル端末の場合は, email を email_mobile にコピーし,
182     * mobile_phone_id に携帯端末IDを格納する.
183     *
184     * @param mixed $objFormParam
185     * @access private
186     * @return $arrResults
187     */
188    public function lfMakeSqlVal(&$objFormParam)
189    {
190        $arrForm                = $objFormParam->getHashArray();
191        $arrResults             = $objFormParam->getDbArray();
192
193        // 生年月日の作成
194        $arrResults['birth']    = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']);
195
196        // 仮会員 1 本会員 2
197        $arrResults['status']   = (CUSTOMER_CONFIRM_MAIL == true) ? '1' : '2';
198
199        /*
200         * secret_keyは、テーブルで重複許可されていない場合があるので、
201         * 本会員登録では利用されないがセットしておく。
202         */
203        $arrResults['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey();
204
205        // 入会時ポイント
206        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
207        $arrResults['point'] = $CONF['welcome_point'];
208
209        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
210            // 携帯メールアドレス
211            $arrResults['email_mobile']     = $arrResults['email'];
212            // PHONE_IDを取り出す
213            $arrResults['mobile_phone_id']  =  SC_MobileUserAgent_Ex::getId();
214        }
215
216        return $arrResults;
217    }
218
219    /**
220     * 会員登録完了メール送信する
221     *
222     * @access private
223     * @return void
224     */
225    public function lfSendMail($uniqid, $arrForm)
226    {
227        $CONF           = SC_Helper_DB_Ex::sfGetBasisData();
228
229        $objMailText    = new SC_SiteView_Ex();
230        $objMailText->setPage($this);
231        $objMailText->assign('CONF', $CONF);
232        $objMailText->assign('name01', $arrForm['name01']);
233        $objMailText->assign('name02', $arrForm['name02']);
234        $objMailText->assign('uniqid', $uniqid);
235        $objMailText->assignobj($this);
236
237        $objHelperMail  = new SC_Helper_Mail_Ex();
238        $objHelperMail->setPage($this);
239
240        // 仮会員が有効の場合
241        if (CUSTOMER_CONFIRM_MAIL == true) {
242            $subject        = $objHelperMail->sfMakeSubject('会員登録のご確認');
243            $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl');
244        } else {
245            $subject        = $objHelperMail->sfMakeSubject('会員登録のご完了');
246            $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl');
247        }
248
249        $objMail = new SC_SendMail_Ex();
250        $objMail->setItem(
251            ''                    // 宛先
252            , $subject              // サブジェクト
253            , $toCustomerMail       // 本文
254            , $CONF['email03']      // 配送元アドレス
255            , $CONF['shop_name']    // 配送元 名前
256            , $CONF['email03']      // reply_to
257            , $CONF['email04']      // return_path
258            , $CONF['email04']      // Errors_to
259            , $CONF['email01']      // Bcc
260        );
261        // 宛先の設定
262        $objMail->setTo($arrForm['email'],
263                        $arrForm['name01'] . $arrForm['name02'] .' 様');
264
265        $objMail->sendMail();
266    }
267
268    /**
269     * kiyaku.php からの遷移の妥当性をチェックする
270     *
271     * 以下の内容をチェックし, 妥当であれば true を返す.
272     * 1. 規約ページからの遷移かどうか
273     * 2. PC及びスマートフォンかどうか
274     * 3. 自分自身(会員登録ページ)からの遷移はOKとする
275     *
276     * @access protected
277     * @return boolean kiyaku.php からの妥当な遷移であれば true
278     */
279    public function lfCheckReferer()
280    {
281        $arrRefererParseUrl = parse_url($_SERVER['HTTP_REFERER']);
282        $referer_urlpath = $arrRefererParseUrl['path'];
283
284        $kiyaku_urlpath = ROOT_URLPATH . 'entry/kiyaku.php';
285
286        $arrEntryParseUrl = parse_url(ENTRY_URL);
287        $entry_urlpath = $arrEntryParseUrl['path'];
288
289        $allowed_urlpath = array(
290            $kiyaku_urlpath,
291            $entry_urlpath,
292        );
293
294        if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE
295            && !in_array($referer_urlpath, $allowed_urlpath)) {
296            return false;
297        }
298
299        return true;
300    }
301
302    /**
303     * 入力エラーのチェック.
304     *
305     * @param  array $arrRequest リクエスト値($_GET)
306     * @return array $arrErr エラーメッセージ配列
307     */
308    public function lfCheckError($arrRequest)
309    {
310        // パラメーター管理クラス
311        $objFormParam = new SC_FormParam_Ex();
312        // パラメーター情報の初期化
313        $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
314        $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
315        // // リクエスト値をセット
316        $arrData['zip01'] = $arrRequest['zip01'];
317        $arrData['zip02'] = $arrRequest['zip02'];
318        $objFormParam->setParam($arrData);
319        // エラーチェック
320        $arrErr = $objFormParam->checkError();
321
322        return $arrErr;
323    }
324}
Note: See TracBrowser for help on using the repository browser.