Warning: Can't use blame annotator:
svn blame failed on branches/version-2_12-multilang/data/class/pages/entry/LC_Page_Entry.php: バイナリファイル 'file:///home/svn/open/branches/version-2_12-multilang/data/class/pages/entry/LC_Page_Entry.php' に対しては blame で各行の最終変更者を計算できません 195004

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

Revision 22205, 12.5 KB checked in by m_uehara, 11 years ago (diff)

#2004 郵便番号を2カラムから1カラムに変更しました。

  • 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
RevLine 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2012 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        $objFormParam = new SC_FormParam_Ex();
79
80        SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam);
81        $objFormParam->setParam($_POST);
82        $arrForm  = $objFormParam->getHashArray();
83
84        // PC時は規約ページからの遷移でなければエラー画面へ遷移する
85        if ($this->lfCheckReferer($arrForm, $_SERVER['HTTP_REFERER']) === false) {
86            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
87        }
88
89        // mobile用(戻るボタンでの遷移かどうかを判定)
90        if (!empty($arrForm['return'])) {
91            $_POST['mode'] = 'return';
92        }
93
94        switch ($this->getMode()) {
95            case 'confirm':
96                if (isset($_POST['submit_address'])) {
97                    // 入力エラーチェック
98                    $this->arrErr = $this->lfCheckError($_POST);
99                    // 入力エラーの場合は終了
100                    if (count($this->arrErr) == 0) {
101                        // 郵便番号検索文作成
102//                        $zipcode = $_POST['zip01'] . $_POST['zip02'];
103                        $zipcode = $_POST['zipcode'];
104
105                        // 郵便番号検索
106                        $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode);
107
108                        // 郵便番号が発見された場合
109                        if (!empty($arrAdsList)) {
110                            $data['pref'] = $arrAdsList[0]['state'];
111                            $data['addr01'] = $arrAdsList[0]['city']. $arrAdsList[0]['town'];
112                            $objFormParam->setParam($data);
113
114                            // 該当無し
115                        } else {
116                            $this->arrErr['zipcode'] = t('LC_Page_Entry_001');
117                        }
118                    }
119                    $this->arrForm  = $objFormParam->getHashArray();
120                    break;
121                }
122
123                //-- 確認
124                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
125                $this->arrForm  = $objFormParam->getHashArray();
126                // 入力エラーなし
127                if (empty($this->arrErr)) {
128                    //パスワード表示
129                    $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password']));
130
131                    $this->tpl_mainpage = 'entry/confirm.tpl';
132                    $this->tpl_title    = t('LC_Page_Entry_002');
133                }
134                break;
135            case 'complete':
136                //-- 会員登録と完了画面
137                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
138                $this->arrForm  = $objFormParam->getHashArray();
139                if (empty($this->arrErr)) {
140
141                    $uniqid             = $this->lfRegistCustomerData($this->lfMakeSqlVal($objFormParam));
142
143                    $this->lfSendMail($uniqid, $this->arrForm);
144
145                    // 仮会員が無効の場合
146                    if (CUSTOMER_CONFIRM_MAIL == false) {
147                        // ログイン状態にする
148                        $objCustomer = new SC_Customer_Ex();
149                        $objCustomer->setLogin($this->arrForm['email']);
150                    }
151
152                    // 完了ページに移動させる。
153                    SC_Response_Ex::sendRedirect('complete.php', array('ci' => SC_Helper_Customer_Ex::sfGetCustomerId($uniqid)));
154                }
155                break;
156            case 'return':
157                $this->arrForm  = $objFormParam->getHashArray();
158                break;
159            default:
160                break;
161        }
162
163    }
164
165    /**
166     * デストラクタ.
167     *
168     * @return void
169     */
170    function destroy() {
171        parent::destroy();
172    }
173
174    // }}}
175    // {{{ protected functions
176    /**
177     * 会員情報の登録
178     *
179     * @access private
180     * @return uniqid
181     */
182    function lfRegistCustomerData($sqlval) {
183        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval);
184        return $sqlval['secret_key'];
185    }
186
187    /**
188     * 会員登録に必要なSQLパラメーターの配列を生成する.
189     *
190     * フォームに入力された情報を元に, SQLパラメーターの配列を生成する.
191     * モバイル端末の場合は, email を email_mobile にコピーし,
192     * mobile_phone_id に携帯端末IDを格納する.
193     *
194     * @param mixed $objFormParam
195     * @access private
196     * @return $arrResults
197     */
198    function lfMakeSqlVal(&$objFormParam) {
199        $arrForm                = $objFormParam->getHashArray();
200        $arrResults             = $objFormParam->getDbArray();
201
202        // 生年月日の作成
203        $arrResults['birth']    = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']);
204
205        // 仮会員 1 本会員 2
206        $arrResults['status']   = (CUSTOMER_CONFIRM_MAIL == true) ? '1' : '2';
207
208        /*
209         * secret_keyは、テーブルで重複許可されていない場合があるので、
210         * 本会員登録では利用されないがセットしておく。
211         */
212        $arrResults['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey();
213
214        // 入会時ポイント
215        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
216        $arrResults['point'] = $CONF['welcome_point'];
217
218        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
219            // 携帯メールアドレス
220            $arrResults['email_mobile']     = $arrResults['email'];
221            // PHONE_IDを取り出す
222            $arrResults['mobile_phone_id']  =  SC_MobileUserAgent_Ex::getId();
223        }
224        return $arrResults;
225    }
226
227    /**
228     * 会員登録完了メール送信する
229     *
230     * @access private
231     * @return void
232     */
233    function lfSendMail($uniqid, $arrForm) {
234        $CONF           = SC_Helper_DB_Ex::sfGetBasisData();
235
236        $objMailText    = new SC_SiteView_Ex();
237        $objMailText->setPage($this);
238        $objMailText->assign('CONF', $CONF);
239        $objMailText->assign('name01', $arrForm['name01']);
240        $objMailText->assign('name02', $arrForm['name02']);
241        $objMailText->assign('uniqid', $uniqid);
242        $objMailText->assignobj($this);
243
244        $objHelperMail  = new SC_Helper_Mail_Ex();
245        $objHelperMail->setPage($this);
246
247        // 仮会員が有効の場合
248        if (CUSTOMER_CONFIRM_MAIL == true) {
249            $subject        = $objHelperMail->sfMakeSubject(t('LC_Page_Entry_003'));
250            $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl');
251        } else {
252            $subject        = $objHelperMail->sfMakeSubject(t('LC_Page_Entry_004'));
253            $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl');
254        }
255
256        $objMail = new SC_SendMail_Ex();
257        $objMail->setItem(
258            ''                    // 宛先
259            , $subject              // サブジェクト
260            , $toCustomerMail       // 本文
261            , $CONF['email03']      // 配送元アドレス
262            , $CONF['shop_name']    // 配送元 名前
263            , $CONF['email03']      // reply_to
264            , $CONF['email04']      // return_path
265            , $CONF['email04']      // Errors_to
266            , $CONF['email01']      // Bcc
267        );
268        // 宛先の設定
269        $objMail->setTo($arrForm['email'],
270                        t('LC_Page_Entry_007', array('T_FIELD01' => $arrForm['name01'], 'T_FIELD02' => $arrForm['name02'])));
271
272        $objMail->sendMail();
273    }
274
275    /**
276     * kiyaku.php からの遷移の妥当性をチェックする
277     *
278     * 以下の内容をチェックし, 妥当であれば true を返す.
279     * 1. 規約ページからの遷移かどうか
280     * 2. PC及びスマートフォンかどうか
281     * 3. $post に何も含まれていないかどうか
282     *
283     * @access protected
284     * @param array $post $_POST のデータ
285     * @param string $referer $_SERVER['HTTP_REFERER'] のデータ
286     * @return boolean kiyaku.php からの妥当な遷移であれば true
287     */
288    function lfCheckReferer(&$post, $referer) {
289
290        if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE
291            && empty($post)
292            && (preg_match('/kiyaku.php/', basename($referer)) === 0)) {
293            return false;
294            }
295        return true;
296    }
297
298    /**
299     * 入力エラーのチェック.
300     *
301     * @param array $arrRequest リクエスト値($_GET)
302     * @return array $arrErr エラーメッセージ配列
303     */
304    function lfCheckError($arrRequest) {
305        // パラメーター管理クラス
306        $objFormParam = new SC_FormParam_Ex();
307        // パラメーター情報の初期化
308//        $objFormParam->addParam(t('PARAM_LABEL_ZIP01'), 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
309//        $objFormParam->addParam(t('PARAM_LABEL_ZIP02'), 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
310        $objFormParam->addParam(t('PARAM_LABEL_ZIP'), 'zipcode', ZIPCODE_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
311
312        // リクエスト値をセット
313//        $arrData['zip01'] = $arrRequest['zip01'];
314//        $arrData['zip02'] = $arrRequest['zip02'];
315        $arrData['zipcode'] = $arrRequest['zipcode'];
316        $objFormParam->setParam($arrData);
317        // エラーチェック
318        $arrErr = $objFormParam->checkError();
319        // 親ウィンドウの戻り値を格納するinputタグのnameのエラーチェック
320        /*
321        if (!$this->lfInputNameCheck($addData['zip01'])) {
322            $arrErr['zip01'] = t('LC_Page_Entry_005');
323        }
324        if (!$this->lfInputNameCheck($arrdata['zip02'])) {
325            $arrErr['zip02'] = t('LC_Page_Entry_006');
326        }
327        */
328        if (!$this->lfInputNameCheck($arrData['zipcode'])) {
329            $arrErr['zipcode'] = t('LC_Page_Entry_005');
330        }
331
332        return $arrErr;
333    }
334
335    /**
336     * エラーチェック.
337     *
338     * @param string $value
339     * @return エラーなし:true エラー:false
340     */
341    function lfInputNameCheck($value) {
342        // 半角英数字と_(アンダーバー), []以外の文字を使用していたらエラー
343        if (strlen($value) > 0 && !preg_match("/^[a-zA-Z0-9_\[\]]+$/", $value)) {
344            return false;
345        }
346
347        return true;
348    }
349}
Note: See TracBrowser for help on using the repository browser.