Source for file LC_Page_Regist.php

Documentation is available at LC_Page_Regist.php

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

Documentation generated on Tue, 28 Apr 2009 18:12:47 +0900 by phpDocumentor 1.4.2