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

Revision 20067, 14.4 KB checked in by yomoro, 13 years ago (diff)

不要なインスタンスの削除

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • 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-2010 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_REALDIR . "pages/LC_Page.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 {
35
36    // {{{ properties
37
38    /** フォームパラメータの配列 */
39    var $objFormParam;
40
41
42    // }}}
43    // {{{ functions
44
45    /**
46     * Page を初期化する.
47     * @return void
48     */
49    function init() {
50        parent::init();
51        $this->year = "";
52        $masterData = new SC_DB_MasterData_Ex();
53        $this->arrPref = $masterData->getMasterData('mtb_pref');
54        $this->arrJob = $masterData->getMasterData("mtb_job");
55        $this->arrReminder = $masterData->getMasterData("mtb_reminder");
56
57        // 生年月日選択肢の取得
58        $objDate = new SC_Date(START_BIRTH_YEAR, date("Y",strtotime("now")));
59        $this->arrYear = $objDate->getYear('', 1950, '');
60        $this->arrMonth = $objDate->getMonth(true);
61        $this->arrDay = $objDate->getDay(true);
62
63        $this->httpCacheControl('nocache');
64
65        $this->isMobile = Net_UserAgent_Mobile::isMobile();
66    }
67
68    /**
69     * Page のプロセス.
70     *
71     * @return void
72     */
73    function process() {
74        $this->action();
75        $this->sendResponse();
76    }
77
78    /* パラメータ情報の初期化 */
79    function lfInitParam() {
80
81        $this->objFormParam->addParam("お名前(姓)", 'name01', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
82        $this->objFormParam->addParam("お名前(名)", 'name02', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
83        $this->objFormParam->addParam("お名前(フリガナ・姓)", 'kana01', STEXT_LEN, "CKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
84        $this->objFormParam->addParam("お名前(フリガナ・名)", 'kana02', STEXT_LEN, "CKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
85        $this->objFormParam->addParam("パスワード", 'password', STEXT_LEN, "a", array("EXIST_CHECK", "SPTAB_CHECK" ,"ALNUM_CHECK"));
86        $this->objFormParam->addParam("パスワード確認用の質問", "reminder", STEXT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
87        $this->objFormParam->addParam("パスワード確認用の質問の答え", "reminder_answer", STEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
88        $this->objFormParam->addParam("郵便番号1", "zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
89        $this->objFormParam->addParam("郵便番号2", "zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
90        $this->objFormParam->addParam("都道府県", 'pref', INT_LEN, "n", array("EXIST_CHECK","NUM_CHECK"));
91        $this->objFormParam->addParam("住所1", "addr01", MTEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
92        $this->objFormParam->addParam("住所2", "addr02", MTEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
93        $this->objFormParam->addParam("お電話番号1", 'tel01', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
94        $this->objFormParam->addParam("お電話番号2", 'tel02', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
95        $this->objFormParam->addParam("お電話番号3", 'tel03', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
96        $this->objFormParam->addParam("性別", "sex", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
97        $this->objFormParam->addParam("職業", "job", INT_LEN, "n", array("NUM_CHECK"));
98        $this->objFormParam->addParam("年", "year", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
99        $this->objFormParam->addParam("月", "month", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
100        $this->objFormParam->addParam("日", "day", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
101        $this->objFormParam->addParam("メールマガジン", "mailmaga_flg", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
102
103        if ($this->isMobile === false){
104            $this->objFormParam->addParam("FAX番号1", 'fax01', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
105            $this->objFormParam->addParam("FAX番号2", 'fax02', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
106            $this->objFormParam->addParam("FAX番号3", 'fax03', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
107            $this->objFormParam->addParam("パスワード(確認)", 'password02', STEXT_LEN, "a", array("EXIST_CHECK", "SPTAB_CHECK" ,"ALNUM_CHECK"), "", false);
108            $this->objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
109            $this->objFormParam->addParam('メールアドレス(確認)', "email02", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK","SPTAB_CHECK" , "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"), "", false);
110        } else {
111            $this->objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("EXIST_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK","MOBILE_EMAIL_CHECK"));
112        }
113    }
114
115    /**
116     * Page のプロセス
117     * @return void
118     */
119    function action() {
120        $objDb = new SC_Helper_DB_Ex();
121        $CONF = $objDb->sfGetBasisData();
122        $objQuery = new SC_Query();
123
124        // PC時は規約ページからの遷移でなければエラー画面へ遷移する
125        $this->lfCheckReferer();
126
127        // mobile用(戻るボタンでの遷移かどうかを判定)
128        if (!empty($_POST["return"])) {
129            $_POST["mode"] = "return";
130        }
131
132        // パラメータ管理クラス,パラメータ情報の初期化
133        $this->objFormParam = new SC_FormParam();
134        $this->lfInitParam();
135        $this->objFormParam->setParam($_POST);    // POST値の取得
136
137        if ($_SERVER["REQUEST_METHOD"] == "POST") {
138
139            //CSRF対策
140            if (!SC_Helper_Session_Ex::isValidToken()) {
141                SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
142            }
143
144            $this->objFormParam->convParam();
145            $this->objFormParam->toLower('email');
146            $this->objFormParam->toLower('email02');
147            $this->arrForm = $this->objFormParam->getHashArray();
148
149            switch ($this->getMode()) {
150            case 'confirm':
151            //-- 確認
152                $this->arrErr = $this->lfErrorCheck();
153
154                // 入力エラーなし
155                if(count($this->arrErr) == 0) {
156
157                    $this->list_data = $this->objFormParam->getHashArray();
158
159                    //パスワード表示
160                    $passlen = strlen($this->arrForm['password']);
161                    $this->passlen = SC_Utils_Ex::lfPassLen($passlen);
162
163                    $this->tpl_mainpage = 'entry/confirm.tpl';
164                    $this->tpl_title = '会員登録(確認ページ)';
165                }
166                break;
167            case 'complete':
168                //-- 会員登録と完了画面
169
170                // 会員情報の登録
171                $this->CONF = $CONF;
172                $this->uniqid = $this->lfRegistData();
173
174                $this->tpl_mainpage = 'entry/complete.tpl';
175                $this->tpl_title = '会員登録(完了ページ)';
176
177                $this->lfSendMail();
178
179                // 完了ページに移動させる。
180                $customer_id = $objQuery->get("customer_id", "dtb_customer", "secret_key = ?", array($this->uniqid));
181                SC_Response_Ex::sendRedirect('complete.php', array("ci" => $customer_id));
182                exit;
183                break;
184            default:
185                break;
186            }
187        }
188        $this->transactionid = SC_Helper_Session_Ex::getToken();
189    }
190
191    /**
192     * デストラクタ.
193     *
194     * @return void
195     */
196    function destroy() {
197        parent::destroy();
198    }
199
200    // }}}
201    // {{{ protected functions
202
203    // 会員情報の登録
204    function lfRegistData() {
205
206        $objQuery = new SC_Query();
207        $arrRet = $this->objFormParam->getHashArray();
208        $sqlval = $this->objFormParam->getDbArray();
209
210        // 登録データの作成
211        $sqlval['birth'] = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
212
213        // 重複しない会員登録キーを発行する。
214        $count = 1;
215        while ($count != 0) {
216            $uniqid = SC_Utils_Ex::sfGetUniqRandomId("r");
217            $count = $objQuery->count("dtb_customer", "secret_key = ?", array($uniqid));
218        }
219
220        // 仮会員登録の場合
221        if(CUSTOMER_CONFIRM_MAIL == true) {
222            $sqlval["status"] = "1";                // 仮会員
223        } else {
224            $sqlval["status"] = "2";                // 本会員
225        }
226
227        /*
228          secret_keyは、テーブルで重複許可されていない場合があるので、
229                          本会員登録では利用されないがセットしておく。
230        */
231        $sqlval["secret_key"] = $uniqid;        // 会員登録キー
232        $sqlval["point"] = $this->CONF["welcome_point"]; // 入会時ポイント
233
234        if ($this->isMobile === true) {
235            // 携帯メールアドレス
236            $sqlval['email_mobile'] = $sqlval['email'];
237            //PHONE_IDを取り出す
238            $sqlval['mobile_phone_id'] =  SC_MobileUserAgent::getId();
239        }
240
241        //-- 登録実行
242        $objQuery->begin();
243        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval);
244        $objQuery->commit();
245
246        return $uniqid;
247    }
248
249    function lfSendMail(){
250        // 完了メール送信
251        $arrRet = $this->objFormParam->getHashArray();
252        $this->name01 = $arrRet['name01'];
253        $this->name02 = $arrRet['name02'];
254        $objMailText = new SC_SiteView();
255        $objMailText->assignobj($this);
256
257        $objHelperMail = new SC_Helper_Mail_Ex();
258        $objQuery = new SC_Query();
259        $objCustomer = new SC_Customer();
260        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
261
262        // 仮会員が有効の場合
263        if(CUSTOMER_CONFIRM_MAIL == true) {
264            $subject = $objHelperMail->sfMakeSubject('会員登録のご確認');
265            $toCustomerMail = $objMailText->fetch("mail_templates/customer_mail.tpl");
266        } else {
267            $subject = $objHelperMail->sfMakeSubject('会員登録のご完了');
268            $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
269            // ログイン状態にする
270            $objCustomer->setLogin($arrRet["email"]);
271        }
272
273        $objMail = new SC_SendMail();
274        $objMail->setItem(
275                              ''                    // 宛先
276                            , $subject              // サブジェクト
277                            , $toCustomerMail       // 本文
278                            , $CONF["email03"]      // 配送元アドレス
279                            , $CONF["shop_name"]    // 配送元 名前
280                            , $CONF["email03"]      // reply_to
281                            , $CONF["email04"]      // return_path
282                            , $CONF["email04"]      // Errors_to
283                            , $CONF["email01"]      // Bcc
284        );
285        // 宛先の設定
286        $name = $arrRet["name01"] . $arrRet["name02"] ." 様";
287        $objMail->setTo($arrRet["email"], $name);
288        $objMail->sendMail();
289    }
290
291
292    //---- 入力エラーチェック
293    function lfErrorCheck($array) {
294
295        // 入力データを渡す。
296        $arrRet = $this->objFormParam->getHashArray();
297        $objErr = new SC_CheckError($arrRet);
298        $objErr->arrErr = $this->objFormParam->checkError();
299
300        $objErr->doFunc(array("お電話番号", "tel01", "tel02", "tel03"),array("TEL_CHECK"));
301        $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
302        $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_BIRTHDAY"));
303        if ($this->isMobile === false){
304            $objErr->doFunc(array('パスワード', 'パスワード(確認)', "password", "password02") ,array("EQUAL_CHECK"));
305            $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', "email", "email02") ,array("EQUAL_CHECK"));
306            $objErr->doFunc(array("FAX番号", "fax01", "fax02", "fax03") ,array("TEL_CHECK"));
307        }
308
309        // 現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可
310        $register_user_flg =  SC_Helper_Customer_Ex::sfCheckRegisterUserFromEmail($arrRet["email"]);
311        switch($register_user_flg) {
312            case 1:
313                $objErr->arrErr["email"] .= "※ すでに会員登録で使用されているメールアドレスです。<br />";
314                break;
315            case 2:
316                $objErr->arrErr["email"] .= "※ 退会から一定期間の間は、同じメールアドレスを使用することはできません。<br />";
317                break;
318            default:
319                break;
320        }
321        return $objErr->arrErr;
322    }
323
324    function lfCheckReferer(){
325        /**
326         * 規約ページからの遷移でなければエラー画面へ遷移する
327         */
328        if ($this->isMobile === FALSE
329             && empty($_POST)
330             && !preg_match('/kiyaku.php/', basename($_SERVER['HTTP_REFERER']))
331            ) {
332            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
333        }
334    }
335}
336?>
Note: See TracBrowser for help on using the repository browser.