Changeset 15177 for branches


Ignore:
Timestamp:
2007/08/03 21:22:52 (17 years ago)
Author:
nanasess
Message:

slib.php のクラス化対応

Location:
branches/feature-module-update/data/class
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/SC_CampaignSession.php

    r15080 r15177  
    88/* キャンペーン管理クラス */ 
    99class SC_CampaignSession { 
    10     var $key; 
    11     var $campaign_id = 'campaign_id'; 
    12     var $is_campaign = 'is_campaign'; 
    13     var $campaign_dir = 'campaign_dir'; 
    14      
    15     /* コンストラクタ */ 
    16     function SC_CampaignSession($key = "campaign") { 
    17         sfDomainSessionStart(); 
    18         $this->key = $key; 
    19     } 
     10    var $key; 
     11    var $campaign_id = 'campaign_id'; 
     12    var $is_campaign = 'is_campaign'; 
     13    var $campaign_dir = 'campaign_dir'; 
    2014 
    21     /* キャンペーンIDをセット */ 
    22     function setCampaignId($campaign_id) { 
    23         $_SESSION[$this->key][$this->campaign_id] = $campaign_id; 
    24     } 
    25      
    26     /* キャンペーンIDを取得 */ 
    27     function getCampaignId() { 
    28         return $_SESSION[$this->key][$this->campaign_id]; 
    29     } 
    30              
    31     /* キャンペーンページからの遷移情報を保持 */ 
    32     function setIsCampaign() { 
    33         $_SESSION[$this->key][$this->is_campaign] = true; 
    34     } 
     15    /* コンストラクタ */ 
     16    function SC_CampaignSession($key = "campaign") { 
     17        SC_Utils_Ex::sfDomainSessionStart(); 
     18        $this->key = $key; 
     19    } 
    3520 
    36     /* キャンペーンページからの遷移情報を取得 */ 
    37     function getIsCampaign() { 
    38         return $_SESSION[$this->key][$this->is_campaign]; 
    39     } 
     21    /* キャンペーンIDをセット */ 
     22    function setCampaignId($campaign_id) { 
     23        $_SESSION[$this->key][$this->campaign_id] = $campaign_id; 
     24    } 
    4025 
    41     /* キャンペーン情報を削除 */ 
    42     function delCampaign() { 
    43         unset($_SESSION[$this->key]); 
    44     } 
     26    /* キャンペーンIDを取得 */ 
     27    function getCampaignId() { 
     28        return $_SESSION[$this->key][$this->campaign_id]; 
     29    } 
    4530 
    46     /* キャンペーンディレクトリ名をセット */ 
    47     function setCampaignDir($campaign_dir) { 
    48         $_SESSION[$this->key][$this->campaign_dir] = $campaign_dir; 
    49     } 
    50      
    51     /* キャンペーンディレクトリ名を取得 */ 
    52     function getCampaignDir() { 
    53         return $_SESSION[$this->key][$this->campaign_dir]; 
    54     } 
    55      
    56     /* キャンペーンページならフレームを変更 */ 
    57     function pageView($objView, $site_frame = SITE_FRAME) { 
    58         if($this->getIsCampaign()) { 
    59             $objView->display(CAMPAIGN_TEMPLATE_PATH . $this->getCampaignDir()  . "/active/site_frame.tpl"); 
    60         } else { 
    61             $objView->display($site_frame); 
    62         } 
    63     } 
     31    /* キャンペーンページからの遷移情報を保持 */ 
     32    function setIsCampaign() { 
     33        $_SESSION[$this->key][$this->is_campaign] = true; 
     34    } 
     35 
     36    /* キャンペーンページからの遷移情報を取得 */ 
     37    function getIsCampaign() { 
     38        return $_SESSION[$this->key][$this->is_campaign]; 
     39    } 
     40 
     41    /* キャンペーン情報を削除 */ 
     42    function delCampaign() { 
     43        unset($_SESSION[$this->key]); 
     44    } 
     45 
     46    /* キャンペーンディレクトリ名をセット */ 
     47    function setCampaignDir($campaign_dir) { 
     48        $_SESSION[$this->key][$this->campaign_dir] = $campaign_dir; 
     49    } 
     50 
     51    /* キャンペーンディレクトリ名を取得 */ 
     52    function getCampaignDir() { 
     53        return $_SESSION[$this->key][$this->campaign_dir]; 
     54    } 
     55 
     56    /* キャンペーンページならフレームを変更 */ 
     57    function pageView($objView, $site_frame = SITE_FRAME) { 
     58        if($this->getIsCampaign()) { 
     59            $objView->display(CAMPAIGN_TEMPLATE_PATH . $this->getCampaignDir()  . "/active/site_frame.tpl"); 
     60        } else { 
     61            $objView->display($site_frame); 
     62        } 
     63    } 
    6464} 
    6565?> 
  • branches/feature-module-update/data/class/SC_CartSession.php

    r15080 r15177  
    8181                $price = $_SESSION[$this->key][$i]['price']; 
    8282                $quantity = $_SESSION[$this->key][$i]['quantity']; 
    83                 $pre_tax = sfPreTax($price, $arrInfo['tax'], $arrInfo['tax_rule']); 
     83                $pre_tax = SC_Utils_Ex::sfPreTax($price, $arrInfo['tax'], $arrInfo['tax_rule']); 
    8484                $total = $pre_tax * $quantity; 
    8585                return $total; 
     
    149149            $price = $_SESSION[$this->key][$i]['price']; 
    150150            $quantity = $_SESSION[$this->key][$i]['quantity']; 
    151             $tax = sfTax($price, $arrInfo['tax'], $arrInfo['tax_rule']); 
     151            $tax = SC_Utils_Ex::sfTax($price, $arrInfo['tax'], $arrInfo['tax_rule']); 
    152152            $total+= ($tax * $quantity); 
    153153        } 
     
    165165            $point_rate = $_SESSION[$this->key][$i]['point_rate']; 
    166166            $id = $_SESSION[$this->key][$i]['id'][0]; 
    167             $point = sfPrePoint($price, $point_rate, POINT_RULE, $id); 
     167            $point = SC_Utils_Ex::sfPrePoint($price, $point_rate, POINT_RULE, $id); 
    168168            $total+= ($point * $quantity); 
    169169        } 
  • branches/feature-module-update/data/class/SC_Customer.php

    r15080 r15177  
    1010 */ 
    1111class SC_Customer { 
    12      
    13     var $conn; 
    14     var $email; 
    15     var $customer_data;     // 会員情報    
    16          
    17     function SC_Customer( $conn = '', $email = '', $pass = '' ) { 
    18         // セッション開始 
    19         /* startSessionから移動 2005/11/04 中川 */ 
    20         sfDomainSessionStart(); 
    21          
    22         // DB接続オブジェクト生成 
    23         $DB_class_name = "SC_DbConn"; 
    24         if ( is_object($conn)){ 
    25             if ( is_a($conn, $DB_class_name)){ 
    26                 // $connが$DB_class_nameのインスタンスである 
    27                 $this->conn = $conn; 
    28             } 
    29         } else { 
    30             if (class_exists($DB_class_name)){ 
    31                 //$DB_class_nameのインスタンスを作成する 
    32                 $this->conn = new SC_DbConn();           
    33             } 
    34         } 
    35              
    36         if ( is_object($this->conn) ) {  
    37             // 正常にDBに接続できる 
    38             if ( $email ){ 
    39                 // emailから顧客情報を取得する 
    40                 // $this->setCustomerDataFromEmail( $email ); 
    41             } 
    42         } else { 
    43             echo "DB接続オブジェクトの生成に失敗しています"; 
    44             exit; 
    45         } 
    46          
    47         if ( strlen($email) > 0 && strlen($pass) > 0 ){ 
    48             $this->getCustomerDataFromEmailPass( $email, $pass ); 
    49         } 
    50     } 
    51      
    52     function getCustomerDataFromEmailPass( $pass, $email, $mobile = false ) { 
    53         $sql_mobile = $mobile ? ' OR email_mobile ILIKE ?' : ''; 
    54         $arrValues = array($email); 
    55         if ($mobile) { 
    56             $arrValues[] = $email; 
    57         } 
    58         // 本登録された会員のみ 
    59         $sql = "SELECT * FROM dtb_customer WHERE (email ILIKE ?" . $sql_mobile . ") AND del_flg = 0 AND status = 2"; 
    60         $result = $this->conn->getAll($sql, $arrValues); 
    61         $data = $result[0]; 
    62          
    63         // パスワードが合っていれば顧客情報をcustomer_dataにセットしてtrueを返す 
    64         if ( sha1($pass . ":" . AUTH_MAGIC) == $data['password'] ){ 
    65             $this->customer_data = $data; 
    66             $this->startSession(); 
    67             return true; 
    68         } 
    69         return false; 
    70     } 
    71  
    72     /** 
    73     * 携帯端末IDが一致する会員が存在するかどうかをチェックする。 
    74     * 
    75     * @return boolean 該当する会員が存在する場合は true、それ以外の場合 
    76     *                 は false を返す。 
    77     */ 
    78     function checkMobilePhoneId() { 
    79         if (!isset($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) { 
    80             return false; 
    81         } 
    82  
    83         // 携帯端末IDが一致し、本登録された会員を検索する。 
    84         $sql = 'SELECT count(*) FROM dtb_customer WHERE mobile_phone_id = ? AND del_flg = 0 AND status = 2'; 
    85         $result = $this->conn->getOne($sql, array($_SESSION['mobile']['phone_id'])); 
    86         return $result > 0; 
    87     } 
    88  
    89     /** 
    90     * 携帯端末IDを使用して会員を検索し、パスワードの照合を行う。 
    91     * パスワードが合っている場合は顧客情報を取得する。 
    92     * 
    93     * @param string $pass パスワード 
    94     * @return boolean 該当する会員が存在し、パスワードが合っている場合は true、 
    95     *                 それ以外の場合は false を返す。 
    96     */ 
    97     function getCustomerDataFromMobilePhoneIdPass($pass) { 
    98         if (!isset($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) { 
    99             return false; 
    100         } 
    101  
    102         // 携帯端末IDが一致し、本登録された会員を検索する。 
    103         $sql = 'SELECT * FROM dtb_customer WHERE mobile_phone_id = ? AND del_flg = 0 AND status = 2'; 
    104         @list($data) = $this->conn->getAll($sql, array($_SESSION['mobile']['phone_id'])); 
    105  
    106         // パスワードが合っている場合は、顧客情報をcustomer_dataに格納してtrueを返す。 
    107         if (sha1($pass . ':' . AUTH_MAGIC) == @$data['password']) { 
    108             $this->customer_data = $data; 
    109             $this->startSession(); 
    110             return true; 
    111         } 
    112         return false; 
    113     } 
    114  
    115     /** 
    116     * 携帯端末IDを登録する。 
    117     * 
    118     * @return void 
    119     */ 
    120     function updateMobilePhoneId() { 
    121         if (!isset($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) { 
    122             return; 
    123         } 
    124  
    125         if ($this->customer_data['mobile_phone_id'] == $_SESSION['mobile']['phone_id']) { 
    126             return; 
    127         } 
    128  
    129         $objQuery = new SC_Query; 
    130         $sqlval = array('mobile_phone_id' => $_SESSION['mobile']['phone_id']); 
    131         $where = 'customer_id = ? AND del_flg = 0 AND status = 2'; 
    132         $objQuery->update('dtb_customer', $sqlval, $where, array($this->customer_data['customer_id'])); 
    133  
    134         $this->customer_data['mobile_phone_id'] = $_SESSION['mobile']['phone_id']; 
    135     } 
    136  
    137     /** 
    138     * email から email_mobile へ携帯のメールアドレスをコピーする。 
    139     * 
    140     * @return void 
    141     */ 
    142     function updateEmailMobile() { 
    143         // すでに email_mobile に値が入っている場合は何もしない。 
    144         if ($this->customer_data['email_mobile'] != '') { 
    145             return; 
    146         } 
    147  
    148         // email が携帯のメールアドレスではない場合は何もしない。 
    149         if (!gfIsMobileMailAddress($this->customer_data['email'])) { 
    150             return; 
    151         } 
    152  
    153         // email から email_mobile へコピーする。 
    154         $objQuery = new SC_Query; 
    155         $sqlval = array('email_mobile' => $this->customer_data['email']); 
    156         $where = 'customer_id = ? AND del_flg = 0 AND status = 2'; 
    157         $objQuery->update('dtb_customer', $sqlval, $where, array($this->customer_data['customer_id'])); 
    158  
    159         $this->customer_data['email_mobile'] = $this->customer_data['email']; 
    160     } 
    161      
    162     // パスワードを確認せずにログイン 
    163     function setLogin($email) { 
    164         // 本登録された会員のみ 
    165         $sql = "SELECT * FROM dtb_customer WHERE email ILIKE ? AND del_flg = 0 AND status = 2"; 
    166         $result = $this->conn->getAll($sql, array($email)); 
    167         $data = $result[0]; 
    168         $this->customer_data = $data; 
    169         $this->startSession(); 
    170     } 
    171      
    172     // セッション情報を最新の情報に更新する 
    173     function updateSession() { 
    174         $sql = "SELECT * FROM dtb_customer WHERE customer_id = ? AND del_flg = 0"; 
    175         $customer_id = $this->getValue('customer_id'); 
    176         $arrRet = $this->conn->getAll($sql, array($customer_id)); 
    177         $this->customer_data = $arrRet[0]; 
    178         $_SESSION['customer'] = $this->customer_data; 
    179     } 
    180          
    181     // ログイン情報をセッションに登録し、ログに書き込む 
    182     function startSession() { 
    183         sfDomainSessionStart(); 
    184         $_SESSION['customer'] = $this->customer_data; 
    185         // セッション情報の保存 
    186         gfPrintLog("access : user=".$this->customer_data['customer_id'] ."\t"."ip=". $_SERVER['REMOTE_HOST'], CUSTOMER_LOG_PATH ); 
    187     } 
    188  
    189     // ログアウト $_SESSION['customer']を解放し、ログに書き込む 
    190     function EndSession() { 
    191         // $_SESSION['customer']の解放 
    192         unset($_SESSION['customer']); 
    193         // ログに記録する 
    194         gfPrintLog("logout : user=".$this->customer_data['customer_id'] ."\t"."ip=". $_SERVER['REMOTE_HOST'], CUSTOMER_LOG_PATH ); 
    195     } 
    196      
    197     // ログインに成功しているか判定する。 
    198     function isLoginSuccess($dont_check_email_mobile = false) { 
    199         // ログイン時のメールアドレスとDBのメールアドレスが一致している場合 
    200         if(sfIsInt($_SESSION['customer']['customer_id'])) { 
    201             $objQuery = new SC_Query(); 
    202             $email = $objQuery->get("dtb_customer", "email", "customer_id = ?", array($_SESSION['customer']['customer_id'])); 
    203             if($email == $_SESSION['customer']['email']) { 
    204                 // モバイルサイトの場合は携帯のメールアドレスが登録されていることもチェックする。 
    205                 // ただし $dont_check_email_mobile が true の場合はチェックしない。 
    206                 if (defined('MOBILE_SITE') && !$dont_check_email_mobile) { 
    207                     $email_mobile = $objQuery->get("dtb_customer", "email_mobile", "customer_id = ?", array($_SESSION['customer']['customer_id'])); 
    208                     return isset($email_mobile); 
    209                 } 
    210                 return true; 
    211             } 
    212         } 
    213         return false; 
    214     } 
    215          
    216     // パラメータの取得 
    217     function getValue($keyname) { 
    218         return $_SESSION['customer'][$keyname]; 
    219     } 
    220      
    221     // パラメータのセット 
    222     function setValue($keyname, $val) { 
    223         $_SESSION['customer'][$keyname] = $val; 
    224     } 
    225  
    226     // パラメータがNULLかどうかの判定 
    227     function hasValue($keyname) { 
    228         return isset($_SESSION['customer'][$keyname]); 
    229     } 
    230      
    231     // 誕生日月であるかどうかの判定 
    232     function isBirthMonth() { 
    233         $arrRet = split("[- :/]", $_SESSION['customer']['birth']); 
    234         $birth_month = intval($arrRet[1]); 
    235         $now_month = intval(date("m")); 
    236          
    237         if($birth_month == $now_month) { 
    238             return true; 
    239         } 
    240         return false; 
    241     } 
     12 
     13    var $conn; 
     14    var $email; 
     15    var $customer_data;     // 会員情報 
     16 
     17    function SC_Customer( $conn = '', $email = '', $pass = '' ) { 
     18        // セッション開始 
     19        /* startSessionから移動 2005/11/04 中川 */ 
     20        SC_Utils_Ex::sfDomainSessionStart(); 
     21 
     22        // DB接続オブジェクト生成 
     23        $DB_class_name = "SC_DbConn"; 
     24        if ( is_object($conn)){ 
     25            if ( is_a($conn, $DB_class_name)){ 
     26                // $connが$DB_class_nameのインスタンスである 
     27                $this->conn = $conn; 
     28            } 
     29        } else { 
     30            if (class_exists($DB_class_name)){ 
     31                //$DB_class_nameのインスタンスを作成する 
     32                $this->conn = new SC_DbConn(); 
     33            } 
     34        } 
     35 
     36        if ( is_object($this->conn) ) { 
     37            // 正常にDBに接続できる 
     38            if ( $email ){ 
     39                // emailから顧客情報を取得する 
     40                // $this->setCustomerDataFromEmail( $email ); 
     41            } 
     42        } else { 
     43            echo "DB接続オブジェクトの生成に失敗しています"; 
     44            exit; 
     45        } 
     46 
     47        if ( strlen($email) > 0 && strlen($pass) > 0 ){ 
     48            $this->getCustomerDataFromEmailPass( $email, $pass ); 
     49        } 
     50    } 
     51 
     52    function getCustomerDataFromEmailPass( $pass, $email, $mobile = false ) { 
     53        $sql_mobile = $mobile ? ' OR email_mobile ILIKE ?' : ''; 
     54        $arrValues = array($email); 
     55        if ($mobile) { 
     56            $arrValues[] = $email; 
     57        } 
     58        // 本登録された会員のみ 
     59        $sql = "SELECT * FROM dtb_customer WHERE (email ILIKE ?" . $sql_mobile . ") AND del_flg = 0 AND status = 2"; 
     60        $result = $this->conn->getAll($sql, $arrValues); 
     61        $data = $result[0]; 
     62 
     63        // パスワードが合っていれば顧客情報をcustomer_dataにセットしてtrueを返す 
     64        if ( sha1($pass . ":" . AUTH_MAGIC) == $data['password'] ){ 
     65            $this->customer_data = $data; 
     66            $this->startSession(); 
     67            return true; 
     68        } 
     69        return false; 
     70    } 
     71 
     72    /** 
     73    * 携帯端末IDが一致する会員が存在するかどうかをチェックする。 
     74    * 
     75    * @return boolean 該当する会員が存在する場合は true、それ以外の場合 
     76    *                 は false を返す。 
     77    */ 
     78    function checkMobilePhoneId() { 
     79        if (!isset($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) { 
     80            return false; 
     81        } 
     82 
     83        // 携帯端末IDが一致し、本登録された会員を検索する。 
     84        $sql = 'SELECT count(*) FROM dtb_customer WHERE mobile_phone_id = ? AND del_flg = 0 AND status = 2'; 
     85        $result = $this->conn->getOne($sql, array($_SESSION['mobile']['phone_id'])); 
     86        return $result > 0; 
     87    } 
     88 
     89    /** 
     90    * 携帯端末IDを使用して会員を検索し、パスワードの照合を行う。 
     91    * パスワードが合っている場合は顧客情報を取得する。 
     92    * 
     93    * @param string $pass パスワード 
     94    * @return boolean 該当する会員が存在し、パスワードが合っている場合は true、 
     95    *                 それ以外の場合は false を返す。 
     96    */ 
     97    function getCustomerDataFromMobilePhoneIdPass($pass) { 
     98        if (!isset($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) { 
     99            return false; 
     100        } 
     101 
     102        // 携帯端末IDが一致し、本登録された会員を検索する。 
     103        $sql = 'SELECT * FROM dtb_customer WHERE mobile_phone_id = ? AND del_flg = 0 AND status = 2'; 
     104        @list($data) = $this->conn->getAll($sql, array($_SESSION['mobile']['phone_id'])); 
     105 
     106        // パスワードが合っている場合は、顧客情報をcustomer_dataに格納してtrueを返す。 
     107        if (sha1($pass . ':' . AUTH_MAGIC) == @$data['password']) { 
     108            $this->customer_data = $data; 
     109            $this->startSession(); 
     110            return true; 
     111        } 
     112        return false; 
     113    } 
     114 
     115    /** 
     116    * 携帯端末IDを登録する。 
     117    * 
     118    * @return void 
     119    */ 
     120    function updateMobilePhoneId() { 
     121        if (!isset($_SESSION['mobile']['phone_id']) || $_SESSION['mobile']['phone_id'] === false) { 
     122            return; 
     123        } 
     124 
     125        if ($this->customer_data['mobile_phone_id'] == $_SESSION['mobile']['phone_id']) { 
     126            return; 
     127        } 
     128 
     129        $objQuery = new SC_Query; 
     130        $sqlval = array('mobile_phone_id' => $_SESSION['mobile']['phone_id']); 
     131        $where = 'customer_id = ? AND del_flg = 0 AND status = 2'; 
     132        $objQuery->update('dtb_customer', $sqlval, $where, array($this->customer_data['customer_id'])); 
     133 
     134        $this->customer_data['mobile_phone_id'] = $_SESSION['mobile']['phone_id']; 
     135    } 
     136 
     137    /** 
     138    * email から email_mobile へ携帯のメールアドレスをコピーする。 
     139    * 
     140    * @return void 
     141    */ 
     142    function updateEmailMobile() { 
     143        // すでに email_mobile に値が入っている場合は何もしない。 
     144        if ($this->customer_data['email_mobile'] != '') { 
     145            return; 
     146        } 
     147 
     148        // email が携帯のメールアドレスではない場合は何もしない。 
     149        if (!gfIsMobileMailAddress($this->customer_data['email'])) { 
     150            return; 
     151        } 
     152 
     153        // email から email_mobile へコピーする。 
     154        $objQuery = new SC_Query; 
     155        $sqlval = array('email_mobile' => $this->customer_data['email']); 
     156        $where = 'customer_id = ? AND del_flg = 0 AND status = 2'; 
     157        $objQuery->update('dtb_customer', $sqlval, $where, array($this->customer_data['customer_id'])); 
     158 
     159        $this->customer_data['email_mobile'] = $this->customer_data['email']; 
     160    } 
     161 
     162    // パスワードを確認せずにログイン 
     163    function setLogin($email) { 
     164        // 本登録された会員のみ 
     165        $sql = "SELECT * FROM dtb_customer WHERE email ILIKE ? AND del_flg = 0 AND status = 2"; 
     166        $result = $this->conn->getAll($sql, array($email)); 
     167        $data = $result[0]; 
     168        $this->customer_data = $data; 
     169        $this->startSession(); 
     170    } 
     171 
     172    // セッション情報を最新の情報に更新する 
     173    function updateSession() { 
     174        $sql = "SELECT * FROM dtb_customer WHERE customer_id = ? AND del_flg = 0"; 
     175        $customer_id = $this->getValue('customer_id'); 
     176        $arrRet = $this->conn->getAll($sql, array($customer_id)); 
     177        $this->customer_data = $arrRet[0]; 
     178        $_SESSION['customer'] = $this->customer_data; 
     179    } 
     180 
     181    // ログイン情報をセッションに登録し、ログに書き込む 
     182    function startSession() { 
     183        sfDomainSessionStart(); 
     184        $_SESSION['customer'] = $this->customer_data; 
     185        // セッション情報の保存 
     186        gfPrintLog("access : user=".$this->customer_data['customer_id'] ."\t"."ip=". $_SERVER['REMOTE_HOST'], CUSTOMER_LOG_PATH ); 
     187    } 
     188 
     189    // ログアウト $_SESSION['customer']を解放し、ログに書き込む 
     190    function EndSession() { 
     191        // $_SESSION['customer']の解放 
     192        unset($_SESSION['customer']); 
     193        // ログに記録する 
     194        gfPrintLog("logout : user=".$this->customer_data['customer_id'] ."\t"."ip=". $_SERVER['REMOTE_HOST'], CUSTOMER_LOG_PATH ); 
     195    } 
     196 
     197    // ログインに成功しているか判定する。 
     198    function isLoginSuccess($dont_check_email_mobile = false) { 
     199        // ログイン時のメールアドレスとDBのメールアドレスが一致している場合 
     200        if(SC_Utils_Ex::sfIsInt($_SESSION['customer']['customer_id'])) { 
     201            $objQuery = new SC_Query(); 
     202            $email = $objQuery->get("dtb_customer", "email", "customer_id = ?", array($_SESSION['customer']['customer_id'])); 
     203            if($email == $_SESSION['customer']['email']) { 
     204                // モバイルサイトの場合は携帯のメールアドレスが登録されていることもチェックする。 
     205                // ただし $dont_check_email_mobile が true の場合はチェックしない。 
     206                if (defined('MOBILE_SITE') && !$dont_check_email_mobile) { 
     207                    $email_mobile = $objQuery->get("dtb_customer", "email_mobile", "customer_id = ?", array($_SESSION['customer']['customer_id'])); 
     208                    return isset($email_mobile); 
     209                } 
     210                return true; 
     211            } 
     212        } 
     213        return false; 
     214    } 
     215 
     216    // パラメータの取得 
     217    function getValue($keyname) { 
     218        return $_SESSION['customer'][$keyname]; 
     219    } 
     220 
     221    // パラメータのセット 
     222    function setValue($keyname, $val) { 
     223        $_SESSION['customer'][$keyname] = $val; 
     224    } 
     225 
     226    // パラメータがNULLかどうかの判定 
     227    function hasValue($keyname) { 
     228        return isset($_SESSION['customer'][$keyname]); 
     229    } 
     230 
     231    // 誕生日月であるかどうかの判定 
     232    function isBirthMonth() { 
     233        $arrRet = split("[- :/]", $_SESSION['customer']['birth']); 
     234        $birth_month = intval($arrRet[1]); 
     235        $now_month = intval(date("m")); 
     236 
     237        if($birth_month == $now_month) { 
     238            return true; 
     239        } 
     240        return false; 
     241    } 
    242242} 
    243243?> 
  • branches/feature-module-update/data/class/SC_SiteSession.php

    r15080 r15177  
    88/* カートセッション管理クラス */ 
    99class SC_SiteSession { 
    10     /* コンストラクタ */ 
    11     function SC_SiteSession() { 
    12         sfDomainSessionStart(); 
    13         // 前ページでの登録成功判定を引き継ぐ 
    14         $_SESSION['site']['pre_regist_success'] = $_SESSION['site']['regist_success']; 
    15         $_SESSION['site']['regist_success'] = false; 
    16         $_SESSION['site']['pre_page'] = $_SESSION['site']['now_page']; 
    17         $_SESSION['site']['now_page'] = $_SERVER['PHP_SELF']; 
    18     } 
    19      
    20     /* 前ページが正当であるかの判定 */ 
    21     function isPrePage() { 
    22         if($_SESSION['site']['pre_page'] != "" && $_SESSION['site']['now_page'] != "") { 
    23             if($_SESSION['site']['pre_regist_success'] || $_SESSION['site']['pre_page'] == $_SESSION['site']['now_page']) { 
    24                 return true; 
    25             } 
    26         } 
    27         return false; 
    28     } 
    29      
    30     function setNowPage($path) { 
    31         $_SESSION['site']['now_page'] = $path; 
    32     } 
    33      
    34     /* 値の取得 */ 
    35     function getValue($keyname) { 
    36         return $_SESSION['site'][$keyname]; 
    37     } 
    38      
    39     /* ユニークIDの取得 */ 
    40     function getUniqId() { 
    41         // ユニークIDがセットされていない場合はセットする。 
    42         if(!isset($_SESSION['site']['uniqid']) || $_SESSION['site']['uniqid'] == "") { 
    43             $this->setUniqId(); 
    44         } 
    45         return $_SESSION['site']['uniqid']; 
    46     } 
    47      
    48     /* ユニークIDのセット */ 
    49     function setUniqId() { 
    50         // 予測されないようにランダム文字列を付与する。 
    51         $_SESSION['site']['uniqid'] = sfGetUniqRandomId(); 
    52     } 
    53      
    54     /* ユニークIDのチェック */ 
    55     function checkUniqId() { 
    56         if($_POST['uniqid'] != "") { 
    57             if($_POST['uniqid'] != $_SESSION['site']['uniqid']) { 
    58                 return false; 
    59             } 
    60         } 
    61         return true; 
    62     } 
    63      
    64     /* ユニークIDの解除 */ 
    65     function unsetUniqId() { 
    66         $_SESSION['site']['uniqid'] = ""; 
    67     } 
    68      
    69     /* 登録成功を記録 */ 
    70     function setRegistFlag() { 
    71         $_SESSION['site']['regist_success'] = true; 
    72     } 
     10    /* コンストラクタ */ 
     11    function SC_SiteSession() { 
     12        SC_Utils_Ex::sfDomainSessionStart(); 
     13        // 前ページでの登録成功判定を引き継ぐ 
     14        $_SESSION['site']['pre_regist_success'] = $_SESSION['site']['regist_success']; 
     15        $_SESSION['site']['regist_success'] = false; 
     16        $_SESSION['site']['pre_page'] = $_SESSION['site']['now_page']; 
     17        $_SESSION['site']['now_page'] = $_SERVER['PHP_SELF']; 
     18    } 
     19 
     20    /* 前ページが正当であるかの判定 */ 
     21    function isPrePage() { 
     22        if($_SESSION['site']['pre_page'] != "" && $_SESSION['site']['now_page'] != "") { 
     23            if($_SESSION['site']['pre_regist_success'] || $_SESSION['site']['pre_page'] == $_SESSION['site']['now_page']) { 
     24                return true; 
     25            } 
     26        } 
     27        return false; 
     28    } 
     29 
     30    function setNowPage($path) { 
     31        $_SESSION['site']['now_page'] = $path; 
     32    } 
     33 
     34    /* 値の取得 */ 
     35    function getValue($keyname) { 
     36        return $_SESSION['site'][$keyname]; 
     37    } 
     38 
     39    /* ユニークIDの取得 */ 
     40    function getUniqId() { 
     41        // ユニークIDがセットされていない場合はセットする。 
     42        if(!isset($_SESSION['site']['uniqid']) || $_SESSION['site']['uniqid'] == "") { 
     43            $this->setUniqId(); 
     44        } 
     45        return $_SESSION['site']['uniqid']; 
     46    } 
     47 
     48    /* ユニークIDのセット */ 
     49    function setUniqId() { 
     50        // 予測されないようにランダム文字列を付与する。 
     51        $_SESSION['site']['uniqid'] = SC_Utils_Ex::sfGetUniqRandomId(); 
     52    } 
     53 
     54    /* ユニークIDのチェック */ 
     55    function checkUniqId() { 
     56        if($_POST['uniqid'] != "") { 
     57            if($_POST['uniqid'] != $_SESSION['site']['uniqid']) { 
     58                return false; 
     59            } 
     60        } 
     61        return true; 
     62    } 
     63 
     64    /* ユニークIDの解除 */ 
     65    function unsetUniqId() { 
     66        $_SESSION['site']['uniqid'] = ""; 
     67    } 
     68 
     69    /* 登録成功を記録 */ 
     70    function setRegistFlag() { 
     71        $_SESSION['site']['regist_success'] = true; 
     72    } 
    7373} 
    7474?> 
Note: See TracChangeset for help on using the changeset viewer.