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

Revision 19853, 17.0 KB checked in by fukuda, 13 years ago (diff)

#880(mobile/sphoneディレクトリを削除)に対応。まずmobileのみ意図通りの動作になるように一部コミット(entryディレクトリ)
1.LC_Page_Entryをリファクタリング。(あとでLC_Page_MyPage_Changeと共通化する
2.トップページのentryディレクトリへのリンク先を /entry/new.php から /entry/kiyaku.php に変更

  • 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       
102        if ($this->isMobile === false){
103            $this->objFormParam->addParam("FAX番号1", 'fax01', "n", array("SPTAB_CHECK"));
104            $this->objFormParam->addParam("FAX番号2", 'fax02', "n", array("SPTAB_CHECK"));
105            $this->objFormParam->addParam("FAX番号3", 'fax03', "n", array("SPTAB_CHECK"));
106            $this->objFormParam->addParam("メールマガジン", "mailmaga_flg", INT_LEN, "n", array("EXIST_CHECK", "NUM_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        $objView = new SC_SiteView();
121        $objDb = new SC_Helper_DB_Ex();
122        $CONF = $objDb->sfGetBasisData();
123        $objQuery = new SC_Query();
124
125        // PC時は規約ページからの遷移でなければエラー画面へ遷移する
126        $this->lfCheckReferer();
127       
128        // mobile用(戻るボタンでの遷移かどうかを判定)
129        if (!empty($_POST["return"])) {
130            $_POST["mode"] = "return";
131        }
132       
133        // パラメータ管理クラス,パラメータ情報の初期化
134        $this->objFormParam = new SC_FormParam();
135        $this->lfInitParam();
136        $this->objFormParam->setParam($_POST);    // POST値の取得
137
138        if ($_SERVER["REQUEST_METHOD"] == "POST") {
139           
140            //CSRF対策
141            if (!SC_Helper_Session_Ex::isValidToken()) {
142                SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
143            }
144           
145            $this->objFormParam->convParam();
146            $this->objFormParam->toLower('email');
147            $this->objFormParam->toLower('email02');
148            $this->arrForm = $this->objFormParam->getHashArray();
149     
150            //-- 確認
151            if ($_POST["mode"] == "confirm") {
152
153                $this->arrErr = $this->lfErrorCheck();
154               
155                // 入力エラーなし
156                if(count($this->arrErr) == 0) {
157                   
158                    $this->list_data = $this->objFormParam->getHashArray();
159               
160                    //パスワード表示
161                    $passlen = strlen($this->arrForm['password']);
162                    $this->passlen = SC_Utils_Ex::lfPassLen($passlen);
163   
164                    $this->tpl_mainpage = 'entry/confirm.tpl';
165                    $this->tpl_title = '会員登録(確認ページ)';
166                }
167
168            } elseif ($_POST["mode"] == "complete") {
169                //-- 会員登録と完了画面
170           
171                // 会員情報の登録
172                $this->CONF = $CONF;
173                $this->uniqid = $this->lfRegistData();
174
175                $this->tpl_mainpage = 'entry/complete.tpl';
176                $this->tpl_title = '会員登録(完了ページ)';
177
178                $this->lfSendMail();
179
180                // 完了ページに移動させる。
181                $customer_id = $objQuery->get("customer_id", "dtb_customer", "secret_key = ?", array($this->uniqid));
182                SC_Response_Ex::sendRedirect('complete.php', array("ci" => $customer_id));
183                exit;
184               
185            }
186        }
187        $this->transactionid = SC_Helper_Session_Ex::getToken();
188    }
189
190    /**
191     * デストラクタ.
192     *
193     * @return void
194     */
195    function destroy() {
196        parent::destroy();
197    }
198
199    // }}}
200    // {{{ protected functions
201
202    // 会員情報の登録
203    function lfRegistData() {
204               
205        $objQuery = new SC_Query();
206        $arrRet = $this->objFormParam->getHashArray();
207        $sqlval = $this->objFormParam->getDbArray();
208       
209        // 登録データの作成
210        $sqlval['birth'] = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
211       
212        // パスワードの暗号化
213        $sqlval["password"] = sha1($arrRegist["password"] . ":" . AUTH_MAGIC);
214
215        // 重複しない会員登録キーを発行する。
216        $count = 1;
217        while ($count != 0) {
218            $uniqid = SC_Utils_Ex::sfGetUniqRandomId("r");
219            $count = $objQuery->count("dtb_customer", "secret_key = ?", array($uniqid));
220        }
221       
222        // 仮会員登録の場合
223        if(CUSTOMER_CONFIRM_MAIL == true) {
224            $sqlval["mailmaga_flg"] = $this->lfChangeMailFlg($sqlval["mailmaga_flg"]);
225            $sqlval["status"] = "1";                // 仮会員
226        } else {
227            $sqlval["status"] = "2";                // 本会員
228        }
229       
230        /*
231          secret_keyは、テーブルで重複許可されていない場合があるので、
232                          本会員登録では利用されないがセットしておく。
233        */
234        $sqlval["secret_key"] = $uniqid;        // 会員登録キー
235        $sqlval["create_date"] = "now()";   // 作成日
236        $sqlval["update_date"] = "now()";   // 更新日
237        $sqlval["first_buy_date"] = "";     // 最初の購入日
238        $sqlval["point"] = $this->CONF["welcome_point"]; // 入会時ポイント
239
240        if ($this->isMobile === true) {
241            // 携帯メールアドレス
242            $sqlval['email_mobile'] = $sqlval['email'];
243            //PHONE_IDを取り出す
244            $sqlval['mobile_phone_id'] =  SC_MobileUserAgent::getId();
245        }
246       
247        //-- 仮登録実行
248        $objQuery->begin();
249        $sqlval['customer_id'] = $objQuery->nextVal('dtb_customer_customer_id');
250        $objQuery->insert("dtb_customer", $sqlval);
251       
252        $objQuery->commit();
253       
254        return $uniqid;
255    }
256   
257    function lfSendMail(){
258        // 完了メール送信
259        $arrRet = $this->objFormParam->getHashArray();
260        $this->name01 = $arrRet['name01'];
261        $this->name02 = $arrRet['name02'];
262        $objMailText = new SC_SiteView();
263        $objMailText->assignobj($this);
264
265        $objHelperMail = new SC_Helper_Mail_Ex();
266        $objQuery = new SC_Query();
267        $objCustomer = new SC_Customer();
268
269        // 仮会員が有効の場合
270        if(CUSTOMER_CONFIRM_MAIL == true) {
271            $subject = $objHelperMail->sfMakeSubject('会員登録のご確認');
272            $toCustomerMail = $objMailText->fetch("mail_templates/customer_mail.tpl");
273        } else {
274            $subject = $objHelperMail->sfMakeSubject('会員登録のご完了');
275            $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
276            // ログイン状態にする
277            $objCustomer->setLogin($arrRet["email"]);
278        }
279
280        $objMail = new SC_SendMail();
281        $objMail->setItem(
282                              ''                    // 宛先
283                            , $subject              // サブジェクト
284                            , $toCustomerMail       // 本文
285                            , $CONF["email03"]      // 配送元アドレス
286                            , $CONF["shop_name"]    // 配送元 名前
287                            , $CONF["email03"]      // reply_to
288                            , $CONF["email04"]      // return_path
289                            , $CONF["email04"]      // Errors_to
290                            , $CONF["email01"]      // Bcc
291        );
292        // 宛先の設定
293        $name = $arrRet["name01"] . $arrRet["name02"] ." 様";
294        $objMail->setTo($arrRet["email"], $name);
295        $objMail->sendMail();
296    }
297
298
299    //---- 入力エラーチェック
300    function lfErrorCheck($array) {
301
302        // 入力データを渡す。
303        $arrRet = $this->objFormParam->getHashArray();
304        $objErr = new SC_CheckError($arrRet);
305        $objErr->arrErr = $this->objFormParam->checkError();
306
307        $objErr->doFunc(array("お電話番号", "tel01", "tel02", "tel03"),array("TEL_CHECK"));
308        $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
309        $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_BIRTHDAY"));
310        if ($this->isMobile === false){
311            $objErr->doFunc(array('パスワード', 'パスワード(確認)', "password", "password02") ,array("EQUAL_CHECK"));
312            $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', "email", "email02") ,array("EQUAL_CHECK"));
313            $objErr->doFunc(array("FAX番号", "fax01", "fax02", "fax03") ,array("TEL_CHECK"));
314        }
315       
316        // 現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可
317        $register_user_flg = $this->lfCheckRegisterUserForEmail($arrRet["email"]);
318        switch($register_user_flg) {
319            case 1:
320                $objErr->arrErr["email"] .= "※ すでに会員登録で使用されているメールアドレスです。<br />";
321                break;
322            case 2:
323                $objErr->arrErr["email"] .= "※ 退会から一定期間の間は、同じメールアドレスを使用することはできません。<br />";
324                break;
325            default:
326                break;
327        }
328        return $objErr->arrErr;
329    }
330
331    /**
332     *   emailアドレスから、登録済み会員や退会済み会員をチェックする
333     *   
334     *   @return integer  0:登録可能     1:登録済み   2:再登録制限期間内削除ユーザー
335     */
336    function lfCheckRegisterUserForEmail($email){
337        $return = 0;
338       
339        $objQuery = new SC_Query();
340        $arrRet = $objQuery->select("email, update_date, del_flg"
341                                    ,"dtb_customer"
342                                    ,"email = ? OR email_mobile = ? ORDER BY del_flg"
343                                    ,array($email, $email)
344                                    );
345
346        if(count($arrRet) > 0) {
347            if($arrRet[0]['del_flg'] != '1') {
348                // 会員である場合
349                if (!isset($objErr->arrErr['email'])) $objErr->arrErr['email'] = "";
350                $return = 1;
351            } else {
352                // 退会した会員である場合
353                $leave_time = SC_Utils_Ex::sfDBDatetoTime($arrRet[0]['update_date']);
354                $now_time = time();
355                $pass_time = $now_time - $leave_time;
356                // 退会から何時間-経過しているか判定する。
357                $limit_time = ENTRY_LIMIT_HOUR * 3600;
358                if($pass_time < $limit_time) {
359                    if (!isset($objErr->arrErr['email'])) $objErr->arrErr['email'] = "";
360                    $return = 2;
361                }
362            }
363        }
364        return $return;
365    }
366   
367    //確認ページ用パスワード表示用
368    function lfPassLen($passlen){
369        $ret = "";
370        for ($i=0;$i<$passlen;true){
371        $ret.="*";
372        $i++;
373        }
374        return $ret;
375    }
376   
377    function lfCheckReferer(){
378        /**
379         * 規約ページからの遷移でなければエラー画面へ遷移する
380         */
381        if ($this->isMobile === FALSE
382             && empty($_POST)
383             && !preg_match('/kiyaku.php/', basename($_SERVER['HTTP_REFERER']))
384            ) {
385            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
386        }
387    }
388   
389    function lfChangeMailFlg($mailmaga_flg){
390        switch($mailmaga_flg) {
391            case 1:
392                $mailmaga_flg = 4;
393                break;
394            case 2:
395                $mailmaga_flg = 5;
396                break;
397            default:
398                $mailmaga_flg = 6;
399                break;
400        }
401        return $mailmaga_flg;
402    }
403}
404?>
Note: See TracBrowser for help on using the repository browser.