source: tmp/version-2_5-test/data/class/pages/regist/LC_Page_Regist.php @ 18609

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