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

Revision 19803, 10.4 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある)

  • 一斉置換前の現状記録のためのコミット

#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_FILE_PATH . "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        //$objView = new SC_SiteView();
71        $objSiteInfo = $objView->objSiteInfo;
72        $objCustomer = new SC_Customer();
73        $objDb = new SC_Helper_DB_Ex();
74        $this->CONF = $objDb->sfGetBasisData();
75
76        // キャンペーンからの登録の場合の処理
77
78        if(!empty($_GET["cp"])) {
79            $etc_val['cp'] = $_GET['cp'];
80        }
81
82        //-- 本登録完了のためにメールから接続した場合
83        if ($_GET["mode"] == "regist") {
84            //-- 入力チェック
85            $this->arrErr = $this->lfErrorCheck($_GET);
86            if ($this->arrErr) {
87                SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, $this->arrErr["id"]);
88           
89            } else {
90                $registSecretKey = $this->lfRegistData($_GET);          //本会員登録(フラグ変更)
91                $this->lfSendRegistMail($registSecretKey);              //本会員登録完了メール送信
92
93                // ログイン済みの状態にする。
94                $objQuery = new SC_Query();
95                $arrRet = $objQuery->select("customer_id, email", "dtb_customer", "secret_key = ?", array($registSecretKey));
96                $objCustomer->setLogin($arrRet[0]['email']);
97                $etc_val['ci'] = $arrRet[0]['customer_id'];
98                $_SERVER['QUERY_STRING'] = NULL;
99                $this->objDisplay->redirect($this->getLocation("./complete.php", $etc_val));
100                exit;
101            }
102
103        //-- それ以外のアクセスは無効とする
104        } else {
105            SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, "無効なアクセスです。");
106        }
107
108        //---- ページ表示
109        //$objView->assignobj($this);
110        //$objView->display(SITE_FRAME);
111    }
112
113
114    /**
115     * モバイルページを初期化する.
116     *
117     * @return void
118     */
119    function mobileInit() {
120    }
121
122    /**
123     * Page のプロセス(モバイル).
124     *
125     * @return void
126     */
127    function mobileProcess() {
128        parent::mobileProcess();
129        $this->mobileAction();
130        $this->sendResponse();
131    }
132
133    /**
134     * Page のAction(モバイル).
135     *
136     * @return void
137     */
138    function mobileAction() {
139        //$objView = new SC_MobileView();
140        $objSiteInfo = $objView->objSiteInfo;
141        $objCustomer = new SC_Customer();
142        $objDb = new SC_Helper_DB_Ex();
143        $this->CONF = $objDb->sfGetBasisData();
144
145        //-- 本登録完了のためにメールから接続した場合
146        if ($_GET["mode"] == "regist") {
147
148            //-- 入力チェック
149            $this->arrErr = $this->lfErrorCheck($_GET);
150            if ($this->arrErr) {
151                $this->tpl_mainpage = 'regist/error.tpl';
152                $this->tpl_title = 'エラー';
153
154            } else {
155                $registSecretKey = $this->lfRegistData($_GET);          //本会員登録(フラグ変更)
156                $this->lfSendRegistMail($registSecretKey);              //本会員登録完了メール送信
157
158                // ログイン済みの状態にする。
159                $objQuery = new SC_Query();
160                $email = $objQuery->get("email", "dtb_customer", "secret_key = ?", array($registSecretKey));
161                $objCustomer->setLogin($email);
162                $this->objDisplay->redirect($this->getLocation("./complete.php"));
163                exit;
164            }
165
166            //-- それ以外のアクセスは無効とする
167        } else {
168            $this->arrErr["id"] = "無効なアクセスです。";
169            $this->tpl_mainpage = 'regist/error.tpl';
170            $this->tpl_title = 'エラー';
171        }
172
173        //---- ページ表示
174        //$objView->assignobj($this);
175        //$objView->display(SITE_FRAME);
176    }
177
178    /**
179     * デストラクタ.
180     *
181     * @return void
182     */
183    function destroy() {
184        parent::destroy();
185    }
186
187    //---- 登録
188    function lfRegistData($array) {
189        $objQuery = new SC_Query();
190
191        do {
192            $secret = SC_Utils_Ex::sfGetUniqRandomId("r");
193        } while( ($result = $objQuery->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?", array($secret)) ) != 0);
194
195        $sql = "SELECT email FROM dtb_customer WHERE secret_key = ? AND status = 1";
196        $email = $objQuery->getOne($sql, array($array["id"]));
197
198        $objQuery->begin();
199        $arrRegist["secret_key"] = $secret; // 本登録ID発行
200        $arrRegist["status"] = 2;
201        $arrRegist["update_date"] = "NOW()";
202
203        $where = "secret_key = ? AND status = 1";
204
205        $arrRet = $objQuery->select("point", "dtb_customer", $where, array($array["id"]));
206
207        $objQuery->update("dtb_customer", $arrRegist, $where, array($array["id"]));
208
209        /* 購入時の自動会員登録は行わないためDEL
210        // 購入時登録の場合、その回の購入を会員購入とみなす。
211        // 会員情報の読み込み
212        $where1 = "secret_key = ? AND status = 2";
213        $customer = $objQuery->select("*", "dtb_customer", $where1, array($secret));
214        // 初回購入情報の読み込み
215        $order_temp_id = $objQuery->get("order_temp_id", "dtb_order_temp");
216        // 購入情報の更新
217        if ($order_temp_id != null) {
218            $arrCustomer['customer_id'] = $customer[0]['customer_id'];
219            $where3 = "order_temp_id = ?";
220            $objQuery->update("dtb_order_temp", $arrCustomer, $where3, array($order_temp_id));
221            $objQuery->update("dtb_order", $arrCustomer, $where3, array($order_temp_id));
222        }
223        */
224
225        $sql = "SELECT mailmaga_flg FROM dtb_customer WHERE email = ?";
226        $result = $objQuery->getOne($sql, array($email));
227
228        switch($result) {
229        // 仮HTML
230        case '4':
231            $arrRegistMail["mailmaga_flg"] = 1;
232            break;
233        // 仮TEXT
234        case '5':
235            $arrRegistMail["mailmaga_flg"] = 2;
236            break;
237        // 仮なし
238        case '6':
239            $arrRegistMail["mailmaga_flg"] = 3;
240            break;
241        default:
242            $arrRegistMail["mailmaga_flg"] = $result;
243            break;
244        }
245
246        $objQuery->update("dtb_customer", $arrRegistMail, "email = " . SC_Utils_Ex::sfQuoteSmart($email). " AND del_flg = 0");
247        $objQuery->commit();
248
249        return $secret;     // 本登録IDを返す
250    }
251
252    //---- 入力エラーチェック
253    function lfErrorCheck($array) {
254        $objQuery = new SC_Query();
255        $objErr = new SC_CheckError($array);
256
257        $objErr->doFunc(array("仮登録ID", 'id'), array("EXIST_CHECK"));
258        if (! EregI("^[[:alnum:]]+$",$array["id"] )) {
259            $objErr->arrErr["id"] = "無効なURLです。メールに記載されている本会員登録用URLを再度ご確認ください。";
260        }
261        if (! $objErr->arrErr["id"]) {
262
263            $sql = "SELECT customer_id FROM dtb_customer WHERE secret_key = ? AND status = 1 AND del_flg = 0";
264            $result = $objQuery->getOne($sql, array($array["id"]));
265
266            if (! is_numeric($result)) {
267                $objErr->arrErr["id"] = "※ 既に会員登録が完了しているか、無効なURLです。<br>";
268                return $objErr->arrErr;
269
270            }
271        }
272
273        return $objErr->arrErr;
274    }
275
276    //---- 正会員登録完了メール送信
277    function lfSendRegistMail($registSecretKey) {
278        $objQuery = new SC_Query();
279        $objHelperMail = new SC_Helper_Mail_Ex();
280
281        //-- 姓名を取得
282        $sql = "SELECT email, name01, name02 FROM dtb_customer WHERE secret_key = ?";
283        $result = $objQuery->getAll($sql, array($registSecretKey));
284        $data = $result[0];
285
286        //-- メール送信
287        $objMailText = new SC_SiteView();
288        $objMailText->assign("CONF", $this->CONF);
289        $objMailText->assign("name01", $data["name01"]);
290        $objMailText->assign("name02", $data["name02"]);
291        $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
292        $subject = $objHelperMail->sfMakesubject('会員登録が完了しました。');
293        $objMail = new SC_SendMail();
294
295        $objMail->setItem(
296                              ''                                // 宛先
297                            , $subject                          // サブジェクト
298                            , $toCustomerMail                   // 本文
299                            , $this->CONF["email03"]            // 配送元アドレス
300                            , $this->CONF["shop_name"]          // 配送元 名前
301                            , $this->CONF["email03"]            // reply_to
302                            , $this->CONF["email04"]            // return_path
303                            , $this->CONF["email04"]            // Errors_to
304                        );
305        // 宛先の設定
306        $name = $data["name01"] . $data["name02"] ." 様";
307        $objMail->setTo($data["email"], $name);
308        $objMail->sendMail();
309    }
310}
311?>
Note: See TracBrowser for help on using the repository browser.