Page
[ class tree: Page ] [ index: Page ] [ all elements ]

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-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
  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 18734 2010-06-22 08:45:33Z nanasess $
  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.         $this->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.  
  174.         do {
  175.             $secret = SC_Utils_Ex::sfGetUniqRandomId("r");
  176.         } while( ($result = $objQuery->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?", array($secret)) ) != 0);
  177.  
  178.         $sql = "SELECT email FROM dtb_customer WHERE secret_key = ? AND status = 1";
  179.         $email = $objQuery->getOne($sql, array($array["id"]));
  180.  
  181.         $objQuery->begin();
  182.         $arrRegist["secret_key"] = $secret;    // 本登録ID発行
  183.         $arrRegist["status"] = 2;
  184.         $arrRegist["update_date"] = "NOW()";
  185.  
  186.         $where = "secret_key = ? AND status = 1";
  187.  
  188.         // 会員登録時の加算ポイント(購入時会員登録かつ仮会員登録専用)
  189.         //$arrRet = $objQuery->select("point", "dtb_customer", $where, array($array["id"]));
  190.         //$arrRegist['point'] = $arrRet[0]['point'] + $this->arrInfo['welcome_point'];
  191.  
  192.         $objQuery->update("dtb_customer", $arrRegist, $where, array($array["id"]));
  193.  
  194.         /* 購入時の自動会員登録は行わないためDEL
  195.         // 購入時登録の場合、その回の購入を会員購入とみなす。
  196.         // 会員情報の読み込み
  197.         $where1 = "secret_key = ? AND status = 2";
  198.         $customer = $objQuery->select("*", "dtb_customer", $where1, array($secret));
  199.         // 初回購入情報の読み込み
  200.         $order_temp_id = $objQuery->get("dtb_order_temp", "order_temp_id");
  201.         // 購入情報の更新
  202.         if ($order_temp_id != null) {
  203.             $arrCustomer['customer_id'] = $customer[0]['customer_id'];
  204.             $where3 = "order_temp_id = ?";
  205.             $objQuery->update("dtb_order_temp", $arrCustomer, $where3, array($order_temp_id));
  206.             $objQuery->update("dtb_order", $arrCustomer, $where3, array($order_temp_id));
  207.         }
  208.         */
  209.  
  210.         $sql = "SELECT mailmaga_flg FROM dtb_customer WHERE email = ?";
  211.         $result = $objQuery->getOne($sql, array($email));
  212.  
  213.         switch($result) {
  214.         // 仮HTML
  215.         case '4':
  216.             $arrRegistMail["mailmaga_flg"] = 1;
  217.             break;
  218.         // 仮TEXT
  219.         case '5':
  220.             $arrRegistMail["mailmaga_flg"] = 2;
  221.             break;
  222.         // 仮なし
  223.         case '6':
  224.             $arrRegistMail["mailmaga_flg"] = 3;
  225.             break;
  226.         default:
  227.             $arrRegistMail["mailmaga_flg"] = $result;
  228.             break;
  229.         }
  230.  
  231.         $objQuery->update("dtb_customer", $arrRegistMail, "email = " . SC_Utils_Ex::sfQuoteSmart($email). " AND del_flg = 0");
  232.         $objQuery->commit();
  233.  
  234.         return $secret;        // 本登録IDを返す
  235.     }
  236.  
  237.     //---- 入力エラーチェック
  238.     function lfErrorCheck($array) {
  239.         $objQuery = new SC_Query();
  240.         $objErr = new SC_CheckError($array);
  241.  
  242.         $objErr->doFunc(array("仮登録ID", 'id'), array("EXIST_CHECK"));
  243.         if (! EregI("^[[:alnum:]]+$",$array["id"] )) {
  244.             $objErr->arrErr["id"] = "無効なURLです。メールに記載されている本会員登録用URLを再度ご確認ください。";
  245.         }
  246.         if (! $objErr->arrErr["id"]) {
  247.  
  248.             $sql = "SELECT customer_id FROM dtb_customer WHERE secret_key = ? AND status = 1 AND del_flg = 0";
  249.             $result = $objQuery->getOne($sql, array($array["id"]));
  250.  
  251.             if (! is_numeric($result)) {
  252.                 $objErr->arrErr["id"] = "※ 既に会員登録が完了しているか、無効なURLです。<br>";
  253.                 return $objErr->arrErr;
  254.  
  255.             }
  256.         }
  257.  
  258.         return $objErr->arrErr;
  259.     }
  260.  
  261.     //---- 正会員登録完了メール送信
  262.     function lfSendRegistMail($registSecretKey) {
  263.         $objQuery = new SC_Query();
  264.         $objHelperMail = new SC_Helper_Mail_Ex();
  265.  
  266.         //-- 姓名を取得
  267.         $sql = "SELECT email, name01, name02 FROM dtb_customer WHERE secret_key = ?";
  268.         $result = $objQuery->getAll($sql, array($registSecretKey));
  269.         $data = $result[0];
  270.  
  271.         //-- メール送信
  272.         $objMailText = new SC_SiteView();
  273.         $objMailText->assign("CONF", $this->CONF);
  274.         $objMailText->assign("name01", $data["name01"]);
  275.         $objMailText->assign("name02", $data["name02"]);
  276.         $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
  277.         $subject = $objHelperMail->sfMakesubject($objQuery, $objMailText, $this, '会員登録が完了しました。');
  278.         $objMail = new SC_SendMail();
  279.  
  280.         $objMail->setItem(
  281.                               ''                                // 宛先
  282.                             , $subject                          // サブジェクト
  283.                             , $toCustomerMail                   // 本文
  284.                             , $this->CONF["email03"]            // 配送元アドレス
  285.                             , $this->CONF["shop_name"]          // 配送元 名前
  286.                             , $this->CONF["email03"]            // reply_to
  287.                             , $this->CONF["email04"]            // return_path
  288.                             , $this->CONF["email04"]            // Errors_to
  289.                         );
  290.         // 宛先の設定
  291.         $name = $data["name01"] . $data["name02"] ." 様";
  292.         $objMail->setTo($data["email"], $name);
  293.         $objMail->sendMail();
  294.     }
  295. }
  296. ?>

Documentation generated on Fri, 24 Feb 2012 13:59:45 +0900 by Seasoft