source: branches/version-2_12-dev/data/class/pages/entry/LC_Page_Entry.php @ 21683

Revision 21683, 12.8 KB checked in by Seasoft, 12 years ago (diff)

#1613 (typo修正・ソース整形・ソースコメントの改善)

  • 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-2011 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
24// {{{ requires
25require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
26
27/**
28 * 会員登録のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id:LC_Page_Entry.php 15532 2007-08-31 14:39:46Z nanasess $
33 */
34class LC_Page_Entry extends LC_Page_Ex {
35
36    // {{{ properties
37
38    // }}}
39    // {{{ functions
40
41    /**
42     * Page を初期化する.
43     * @return void
44     */
45    function init() {
46        parent::init();
47        $masterData         = new SC_DB_MasterData_Ex();
48        $this->arrPref      = $masterData->getMasterData('mtb_pref');
49        $this->arrJob       = $masterData->getMasterData('mtb_job');
50        $this->arrReminder  = $masterData->getMasterData('mtb_reminder');
51
52        // 生年月日選択肢の取得
53        $objDate            = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now')));
54        $this->arrYear      = $objDate->getYear('', START_BIRTH_YEAR, '');
55        $this->arrMonth     = $objDate->getMonth(true);
56        $this->arrDay       = $objDate->getDay(true);
57
58        $this->httpCacheControl('nocache');
59    }
60
61    /**
62     * Page のプロセス.
63     *
64     * @return void
65     */
66    function process() {
67        parent::process();
68        $this->action();
69        $this->sendResponse();
70    }
71
72    /**
73     * Page のプロセス
74     * @return void
75     */
76    function action() {
77        // フックポイント.
78        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
79        $objPlugin->doAction('lc_page_entry_action_start', array($this));
80
81        $objFormParam = new SC_FormParam_Ex();
82
83        SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam);
84        $objFormParam->setParam($_POST);
85        $arrForm  = $objFormParam->getHashArray();
86
87        // PC時は規約ページからの遷移でなければエラー画面へ遷移する
88        if ($this->lfCheckReferer($arrForm, $_SERVER['HTTP_REFERER']) === false) {
89            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
90        }
91
92        // mobile用(戻るボタンでの遷移かどうかを判定)
93        if (!empty($arrForm['return'])) {
94            $_POST['mode'] = 'return';
95        }
96
97        switch ($this->getMode()) {
98            case 'confirm':
99                if (isset($_POST['submit_address'])) {
100                    // 入力エラーチェック
101                    $this->arrErr = $this->fnErrorCheck($_POST);
102                    // 入力エラーの場合は終了
103                    if (count($this->arrErr) == 0) {
104                        // 郵便番号検索文作成
105                        $zipcode = $_POST['zip01'] . $_POST['zip02'];
106
107                        // 郵便番号検索
108                        $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode);
109
110                        // 郵便番号が発見された場合
111                        if (!empty($arrAdsList)) {
112                            $data['pref'] = $arrAdsList[0]['state'];
113                            $data['addr01'] = $arrAdsList[0]['city']. $arrAdsList[0]['town'];
114                            $objFormParam->setParam($data);
115
116                            // 該当無し
117                        } else {
118                            $this->arrErr['zip01'] = '※該当する住所が見つかりませんでした。<br>';
119                        }
120                    }
121                    $this->arrForm  = $objFormParam->getHashArray();
122                    break;
123                }
124
125                //-- 確認
126                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
127                $this->arrForm  = $objFormParam->getHashArray();
128                // 入力エラーなし
129                if (empty($this->arrErr)) {
130                    //パスワード表示
131                    $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password']));
132
133                    $this->tpl_mainpage = 'entry/confirm.tpl';
134                    $this->tpl_title    = '会員登録(確認ページ)';
135                }
136                break;
137            case 'complete':
138                //-- 会員登録と完了画面
139                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
140                $this->arrForm  = $objFormParam->getHashArray();
141                if (empty($this->arrErr)) {
142
143                    $uniqid             = $this->lfRegistCustomerData($this->lfMakeSqlVal($objFormParam));
144
145                    $this->tpl_mainpage = 'entry/complete.tpl';
146                    $this->tpl_title    = '会員登録(完了ページ)';
147                    $this->lfSendMail($uniqid, $this->arrForm);
148
149                    // 仮会員が無効の場合
150                    if (CUSTOMER_CONFIRM_MAIL == false) {
151                        // ログイン状態にする
152                        $objCustomer = new SC_Customer_Ex();
153                        $objCustomer->setLogin($this->arrForm['email']);
154                    }
155                    // フックポイント.
156                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
157                    $objPlugin->doAction('lc_page_entry_action_complete', array($this));
158
159                    // 完了ページに移動させる。
160                    SC_Response_Ex::sendRedirect('complete.php', array('ci' => SC_Helper_Customer_Ex::sfGetCustomerId($uniqid)));
161                }
162                break;
163            case 'return':
164                $this->arrForm  = $objFormParam->getHashArray();
165                break;
166            default:
167                break;
168        }
169        // フックポイント.
170        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
171        $objPlugin->doAction('lc_page_entry_action_end', array($this));
172    }
173
174    /**
175     * デストラクタ.
176     *
177     * @return void
178     */
179    function destroy() {
180        parent::destroy();
181    }
182
183    // }}}
184    // {{{ protected functions
185    /**
186     * 会員情報の登録
187     *
188     * @access private
189     * @return uniqid
190     */
191    function lfRegistCustomerData($sqlval) {
192        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval);
193        return $sqlval['secret_key'];
194    }
195
196    /**
197     * 会員登録に必要なSQLパラメーターの配列を生成する.
198     *
199     * フォームに入力された情報を元に, SQLパラメーターの配列を生成する.
200     * モバイル端末の場合は, email を email_mobile にコピーし,
201     * mobile_phone_id に携帯端末IDを格納する.
202     *
203     * @param mixed $objFormParam
204     * @access private
205     * @return $arrResults
206     */
207    function lfMakeSqlVal(&$objFormParam) {
208        $arrForm                = $objFormParam->getHashArray();
209        $arrResults             = $objFormParam->getDbArray();
210
211        // 生年月日の作成
212        $arrResults['birth']    = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']);
213
214        // 仮会員 1 本会員 2
215        $arrResults['status']   = (CUSTOMER_CONFIRM_MAIL == true) ? '1' : '2';
216
217        /*
218         * secret_keyは、テーブルで重複許可されていない場合があるので、
219         * 本会員登録では利用されないがセットしておく。
220         */
221        $arrResults['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey();
222
223        // 入会時ポイント
224        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
225        $arrResults['point'] = $CONF['welcome_point'];
226
227        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
228            // 携帯メールアドレス
229            $arrResults['email_mobile']     = $arrResults['email'];
230            // PHONE_IDを取り出す
231            $arrResults['mobile_phone_id']  =  SC_MobileUserAgent_Ex::getId();
232        }
233        return $arrResults;
234    }
235
236    /**
237     * 会員登録完了メール送信する
238     *
239     * @access private
240     * @return void
241     */
242    function lfSendMail($uniqid, $arrForm) {
243        $CONF           = SC_Helper_DB_Ex::sfGetBasisData();
244
245        $objMailText    = new SC_SiteView_Ex();
246        $objMailText->assign('CONF', $CONF);
247        $objMailText->assign('name01', $arrForm['name01']);
248        $objMailText->assign('name02', $arrForm['name02']);
249        $objMailText->assign('uniqid', $uniqid);
250        $objMailText->assignobj($this);
251
252        $objHelperMail  = new SC_Helper_Mail_Ex();
253
254        // 仮会員が有効の場合
255        if (CUSTOMER_CONFIRM_MAIL == true) {
256            $subject        = $objHelperMail->sfMakeSubject('会員登録のご確認');
257            $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl');
258        } else {
259            $subject        = $objHelperMail->sfMakeSubject('会員登録のご完了');
260            $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl');
261        }
262
263        $objMail = new SC_SendMail();
264        $objMail->setItem(
265            ''                    // 宛先
266            , $subject              // サブジェクト
267            , $toCustomerMail       // 本文
268            , $CONF['email03']      // 配送元アドレス
269            , $CONF['shop_name']    // 配送元 名前
270            , $CONF['email03']      // reply_to
271            , $CONF['email04']      // return_path
272            , $CONF['email04']      // Errors_to
273            , $CONF['email01']      // Bcc
274        );
275        // 宛先の設定
276        $objMail->setTo($arrForm['email'],
277                        $arrForm['name01'] . $arrForm['name02'] .' 様');
278
279        $objMail->sendMail();
280    }
281
282    /**
283     * kiyaku.php からの遷移の妥当性をチェックする
284     *
285     * 以下の内容をチェックし, 妥当であれば true を返す.
286     * 1. 規約ページからの遷移かどうか
287     * 2. PC及びスマートフォンかどうか
288     * 3. $post に何も含まれていないかどうか
289     *
290     * @access protected
291     * @param array $post $_POST のデータ
292     * @param string $referer $_SERVER['HTTP_REFERER'] のデータ
293     * @return boolean kiyaku.php からの妥当な遷移であれば true
294     */
295    function lfCheckReferer(&$post, $referer) {
296
297        if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE
298            && empty($post)
299            && (preg_match('/kiyaku.php/', basename($referer)) === 0)) {
300            return false;
301            }
302        return true;
303    }
304
305    /**
306     * 入力エラーのチェック.
307     *
308     * @param array $arrRequest リクエスト値($_GET)
309     * @return array $arrErr エラーメッセージ配列
310     */
311    function fnErrorCheck($arrRequest) {
312        // パラメーター管理クラス
313        $objFormParam = new SC_FormParam_Ex();
314        // パラメーター情報の初期化
315        $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
316        $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
317        // // リクエスト値をセット
318        $arrData['zip01'] = $arrRequest['zip01'];
319        $arrData['zip02'] = $arrRequest['zip02'];
320        $objFormParam->setParam($arrData);
321        // エラーチェック
322        $arrErr = $objFormParam->checkError();
323        // 親ウィンドウの戻り値を格納するinputタグのnameのエラーチェック
324        if (!$this->lfInputNameCheck($addData['zip01'])) {
325            $arrErr['zip01'] = '※ 入力形式が不正です。<br />';
326        }
327        if (!$this->lfInputNameCheck($arrdata['zip02'])) {
328            $arrErr['zip02'] = '※ 入力形式が不正です。<br />';
329        }
330
331        return $arrErr;
332    }
333
334    /**
335     * エラーチェック.
336     *
337     * @param string $value
338     * @return エラーなし:true エラー:false
339     */
340    function lfInputNameCheck($value) {
341        // 半角英数字と_(アンダーバー), []以外の文字を使用していたらエラー
342        if (strlen($value) > 0 && !preg_match("/^[a-zA-Z0-9_\[\]]+$/", $value)) {
343            return false;
344        }
345
346        return true;
347    }
348}
Note: See TracBrowser for help on using the repository browser.