source: branches/version-2_5-dev/data/class/pages/regist/LC_Page_Regist.php @ 19832

Revision 19832, 7.2 KB checked in by Seasoft, 13 years ago (diff)

#714(パス指定によるリダイレクトの記述を簡潔にする) 共通処理実装、個別処理の一部を実装
#869(create_date, update_date 列の定義が、表やDBによるバラツキがある)

  • NOT NULL 制約により実装漏れに気づいたので修正

#893(SC_Response#reload を使うべきであろう箇所で SC_Response#sendRedirect を利用している)
#628(未使用処理・定義などの削除)

  • 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$
33 */
34class LC_Page_Regist extends LC_Page {
35
36    // {{{ properties
37
38    /** 設定情報 */
39    var $CONF;
40
41    // }}}
42    // {{{ functions
43
44    /**
45     * Page を初期化する.
46     *
47     * @return void
48     */
49    function init() {
50        parent::init();
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    function process() {
59        parent::process();
60        $this->action();
61        $this->sendResponse();
62    }
63
64    /**
65     * Page のAction.
66     *
67     * @return void
68     */
69    function action() {
70        $objSiteInfo = $objView->objSiteInfo;
71        $objCustomer = new SC_Customer();
72        $objDb = new SC_Helper_DB_Ex();
73        $this->CONF = $objDb->sfGetBasisData();
74
75        //-- 本登録完了のためにメールから接続した場合
76        if ($_GET["mode"] == "regist") {
77            //-- 入力チェック
78            $this->arrErr = $this->lfErrorCheck($_GET);
79            if ($this->arrErr) {
80                SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, $this->arrErr["id"]);
81           
82            } else {
83                $registSecretKey = $this->lfRegistData($_GET);          //本会員登録(フラグ変更)
84                $this->lfSendRegistMail($registSecretKey);              //本会員登録完了メール送信
85
86                // ログイン済みの状態にする。
87                $objQuery = new SC_Query();
88                $arrRet = $objQuery->select("customer_id, email", "dtb_customer", "secret_key = ?", array($registSecretKey));
89                $objCustomer->setLogin($arrRet[0]['email']);
90                $etc_val['ci'] = $arrRet[0]['customer_id'];
91                SC_Response_Ex::sendRedirect('complete.php', $etc_val);
92                exit;
93            }
94
95        //-- それ以外のアクセスは無効とする
96        } else {
97            SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, "無効なアクセスです。");
98        }
99    }
100
101    /**
102     * デストラクタ.
103     *
104     * @return void
105     */
106    function destroy() {
107        parent::destroy();
108    }
109
110    //---- 登録
111    function lfRegistData($array) {
112        $objQuery = new SC_Query();
113
114        do {
115            $secret = SC_Utils_Ex::sfGetUniqRandomId("r");
116        } while( ($result = $objQuery->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?", array($secret)) ) != 0);
117
118        $sql = "SELECT email FROM dtb_customer WHERE secret_key = ? AND status = 1";
119        $email = $objQuery->getOne($sql, array($array["id"]));
120
121        $objQuery->begin();
122        $arrRegist["secret_key"] = $secret; // 本登録ID発行
123        $arrRegist["status"] = 2;
124        $arrRegist["update_date"] = "NOW()";
125
126        $where = "secret_key = ? AND status = 1";
127
128        $arrRet = $objQuery->select("point", "dtb_customer", $where, array($array["id"]));
129
130        $objQuery->update("dtb_customer", $arrRegist, $where, array($array["id"]));
131        $sql = "SELECT mailmaga_flg FROM dtb_customer WHERE email = ?";
132        $result = $objQuery->getOne($sql, array($email));
133
134        switch($result) {
135        // 仮HTML
136        case '4':
137            $arrRegistMail["mailmaga_flg"] = 1;
138            break;
139        // 仮TEXT
140        case '5':
141            $arrRegistMail["mailmaga_flg"] = 2;
142            break;
143        // 仮なし
144        case '6':
145            $arrRegistMail["mailmaga_flg"] = 3;
146            break;
147        default:
148            $arrRegistMail["mailmaga_flg"] = $result;
149            break;
150        }
151
152        $objQuery->update("dtb_customer", $arrRegistMail, "email = " . SC_Utils_Ex::sfQuoteSmart($email). " AND del_flg = 0");
153        $objQuery->commit();
154
155        return $secret;     // 本登録IDを返す
156    }
157
158    //---- 入力エラーチェック
159    function lfErrorCheck($array) {
160        $objQuery = new SC_Query();
161        $objErr = new SC_CheckError($array);
162
163        $objErr->doFunc(array("仮登録ID", 'id'), array("EXIST_CHECK"));
164        if (! EregI("^[[:alnum:]]+$",$array["id"] )) {
165            $objErr->arrErr["id"] = "無効なURLです。メールに記載されている本会員登録用URLを再度ご確認ください。";
166        }
167        if (! $objErr->arrErr["id"]) {
168
169            $sql = "SELECT customer_id FROM dtb_customer WHERE secret_key = ? AND status = 1 AND del_flg = 0";
170            $result = $objQuery->getOne($sql, array($array["id"]));
171
172            if (! is_numeric($result)) {
173                $objErr->arrErr["id"] = "※ 既に会員登録が完了しているか、無効なURLです。<br>";
174                return $objErr->arrErr;
175
176            }
177        }
178
179        return $objErr->arrErr;
180    }
181
182    //---- 正会員登録完了メール送信
183    function lfSendRegistMail($registSecretKey) {
184        $objQuery = new SC_Query();
185        $objHelperMail = new SC_Helper_Mail_Ex();
186
187        //-- 姓名を取得
188        $sql = "SELECT email, name01, name02 FROM dtb_customer WHERE secret_key = ?";
189        $result = $objQuery->getAll($sql, array($registSecretKey));
190        $data = $result[0];
191
192        //-- メール送信
193        $objMailText = new SC_SiteView();
194        $objMailText->assign("CONF", $this->CONF);
195        $objMailText->assign("name01", $data["name01"]);
196        $objMailText->assign("name02", $data["name02"]);
197        $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
198        $subject = $objHelperMail->sfMakesubject('会員登録が完了しました。');
199        $objMail = new SC_SendMail();
200
201        $objMail->setItem(
202                              ''                                // 宛先
203                            , $subject                          // サブジェクト
204                            , $toCustomerMail                   // 本文
205                            , $this->CONF["email03"]            // 配送元アドレス
206                            , $this->CONF["shop_name"]          // 配送元 名前
207                            , $this->CONF["email03"]            // reply_to
208                            , $this->CONF["email04"]            // return_path
209                            , $this->CONF["email04"]            // Errors_to
210                        );
211        // 宛先の設定
212        $name = $data["name01"] . $data["name02"] ." 様";
213        $objMail->setTo($data["email"], $name);
214        $objMail->sendMail();
215    }
216}
217?>
Note: See TracBrowser for help on using the repository browser.