Changeset 20108


Ignore:
Timestamp:
2011/02/07 13:27:19 (13 years ago)
Author:
yomoro
Message:

#986 リファクタリング

Location:
branches/version-2_5-dev/data/class/pages/frontparts
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/frontparts/LC_Page_FrontParts_LoginCheck.php

    r20086 r20108  
    6666    function action() { 
    6767        // URLチェック 
    68         $this->lfCheckValidAccess(); 
     68        if ( !SC_Helper_Session_Ex::isValidToken() ) { 
     69            GC_Utils_Ex::gfPrintLog('invalid access :login_check.php $POST["url"]=' . $_POST['url']); 
     70            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); 
     71        } 
    6972         
    7073        // 会員管理クラス 
     
    8487        switch ($this->getMode()) { 
    8588        case 'login': 
    86             // ログイン 
    87             $this->lfLogin($objCustomer, $objCookie); 
     89            // --- ログイン 
     90             
     91            // 入力値のエラーチェック 
     92            $this->objFormParam->toLower('login_email'); 
     93            $arrErr = $this->objFormParam->checkError(); 
     94             
     95            // エラーの場合はエラー画面に遷移 
     96            if (count($arrErr) > 0) { 
     97                SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); 
     98            } 
     99             
     100            // 入力チェック後の値を取得 
     101            $arrForm = $this->objFormParam->getHashArray(); 
     102             
     103            // クッキー保存判定 
     104            if ($arrForm['login_memory'] == '1' && $arrForm['login_email'] != '') { 
     105                $objCookie->setCookie('login_email', $arrForm['login_email']); 
     106            } else { 
     107                $objCookie->setCookie('login_email', ''); 
     108            } 
     109             
     110            // 遷移先の制御 
     111            if (count($arrErr) == 0) { 
     112                // ログイン処理 
     113                if ($objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) { 
     114                    // --- ログインに成功した場合 
     115                    SC_Response_Ex::sendRedirect(HTTP_URL); 
     116                    exit; 
     117                } else { 
     118                    // --- ログインに失敗した場合 
     119                    $arrForm['login_email'] = strtolower($arrForm['login_email']); 
     120                    $objQuery = SC_Query::getSingletonInstance(); 
     121                    $where = '(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0'; 
     122                    $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email'])); 
     123                    // ログインエラー表示 
     124                    if($ret > 0) { 
     125                        SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); 
     126                    } else { 
     127                        SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR); 
     128                    } 
     129                } 
     130            } else { 
     131                // 入力エラーの場合、元のアドレスに戻す。 
     132                // FIXME $_POST['url'] には、URL ではなく、url-path が渡るもよう。HTTPS 利用に関わる問題も考えられるので、URL が渡るように改善した方が良いように感じる。 
     133                SC_Response_Ex::sendRedirect($_POST['url']); 
     134                exit; 
     135            } 
     136             
    88137            break; 
    89138        case 'logout': 
    90             // ログアウト 
    91             $this->lfLogout($objCustomer); 
     139            // --- ログアウト 
     140             
     141            // ログイン情報の解放 
     142            $objCustomer->EndSession(); 
     143            // 画面遷移の制御 
     144            $mypage_url_search = strpos('.'.$_POST['url'], 'mypage'); 
     145            if ($mypage_url_search == 2) { 
     146                // マイページログイン中はログイン画面へ移行 
     147                SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php'); 
     148            } else { 
     149                // 上記以外の場合、トップへ遷移 
     150                SC_Response_Ex::sendRedirect(HTTP_URL); 
     151            } 
     152            exit; 
     153             
    92154            break; 
    93155        default: 
     
    104166    function destroy() { 
    105167        parent::destroy(); 
    106     } 
    107  
    108     /** 
    109      * 正常なアクセスかチェックする. 
    110      * 
    111      * @return void 
    112      */ 
    113     function lfCheckValidAccess() { 
    114          
    115         // 不正なURLがPOSTされた場合はエラー表示 
    116         if (!SC_Helper_Session_Ex::isValidToken()) { 
    117             GC_Utils_Ex::gfPrintLog('invalid access :login_check.php $POST["url"]=' . $_POST['url']); 
    118             SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); 
    119         } 
    120          
    121168    } 
    122169 
     
    151198    } 
    152199 
    153     /** 
    154      * ログイン. 
    155      * 
    156      * @param SC_Customer $objCustomer 会員管理クラス 
    157      * @param SC_Cookie $objCookie クッキー管理クラス 
    158      * @return void 
    159      */ 
    160     function lfLogin($objCustomer, $objCookie) { 
    161         // 入力値のエラーチェック 
    162         $this->objFormParam->toLower('login_email'); 
    163         $arrErr = $this->objFormParam->checkError(); 
    164          
    165         // エラーの場合はエラー画面に遷移 
    166         if (count($arrErr) > 0) { 
    167             SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); 
    168         } 
    169          
    170         // 入力チェック後の値を取得 
    171         $arrForm = $this->objFormParam->getHashArray(); 
    172          
    173         // クッキー保存判定 
    174         if ($arrForm['login_memory'] == '1' && $arrForm['login_email'] != '') { 
    175             $objCookie->setCookie('login_email', $arrForm['login_email']); 
    176         } else { 
    177             $objCookie->setCookie('login_email', ''); 
    178         } 
    179          
    180         // 遷移先の制御 
    181         if (count($arrErr) == 0) { 
    182             // ログイン処理 
    183             if ($objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) { 
    184                 // --- ログインに成功した場合 
    185                 SC_Response_Ex::sendRedirect(HTTP_URL); 
    186                 exit; 
    187             } else { 
    188                 // --- ログインに失敗した場合 
    189                 $arrForm['login_email'] = strtolower($arrForm['login_email']); 
    190                 $objQuery = SC_Query::getSingletonInstance(); 
    191                 $where = '(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0'; 
    192                 $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email'])); 
    193                 // ログインエラー表示 
    194                 if($ret > 0) { 
    195                     SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); 
    196                 } else { 
    197                     SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR); 
    198                 } 
    199             } 
    200         } else { 
    201             // 入力エラーの場合、元のアドレスに戻す。 
    202             // FIXME $_POST['url'] には、URL ではなく、url-path が渡るもよう。HTTPS 利用に関わる問題も考えられるので、URL が渡るように改善した方が良いように感じる。 
    203             SC_Response_Ex::sendRedirect($_POST['url']); 
    204             exit; 
    205         } 
    206     } 
    207  
    208     /** 
    209      * ログアウト. 
    210      * 
    211      * @param SC_Customer $objCustomer 会員管理クラス 
    212      * @return void 
    213      */ 
    214     function lfLogout($objCustomer) { 
    215         // ログイン情報の解放 
    216         $objCustomer->EndSession(); 
    217          
    218         // 画面遷移の制御 
    219         $mypage_url_search = strpos('.'.$_POST['url'], 'mypage'); 
    220         if ($mypage_url_search == 2) { 
    221             // マイページログイン中はログイン画面へ移行 
    222             SC_Response_Ex::sendRedirectFromUrlPath('mypage/login.php'); 
    223         } else { 
    224             // 上記以外の場合、トップへ遷移 
    225             SC_Response_Ex::sendRedirect(HTTP_URL); 
    226         } 
    227          
    228         exit; 
    229     } 
    230  
    231200} 
    232201?> 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Cart.php

    r20076 r20108  
    8585     * @return array $arrCartList カートデータ配列 
    8686     */ 
    87     function lfGetCartData($objCart, $objSiteInfo) { 
     87    function lfGetCartData(&$objCart, &$objSiteInfo) { 
    8888        $arrCartKeys = $objCart->getKeys(); 
    8989        foreach ($arrCartKeys as $cart_key) { 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php

    r20086 r20108  
    6464    function action() { 
    6565        // モバイル判定 
    66         if (SC_Display::detectDevice() === true) { 
    67             // --- モバイルの場合 
    68             // メインカテゴリーの取得 
    69             $this->arrCat = $this->lfGetMainCat(true); 
    70         } else { 
    71             // --- PCの場合 
    72             // 選択中のカテゴリID 
    73             $this->tpl_category_id = $this->lfGetSelectedCategoryId(); 
    74             // カテゴリツリーの取得 
    75             $this->arrTree = $this->lfGetCatTree($this->tpl_category_id, true); 
     66        switch ( SC_Display::detectDevice() ) { 
     67            case DEVICE_TYPE_MOBILE: 
     68                // メインカテゴリーの取得 
     69                $this->arrCat = $this->lfGetMainCat(true); 
     70                break; 
     71            default: 
     72                // 選択中のカテゴリID 
     73                $this->tpl_category_id = $this->lfGetSelectedCategoryId($_GET); 
     74                // カテゴリツリーの取得 
     75                $this->arrTree = $this->lfGetCatTree($this->tpl_category_id, true); 
     76                break; 
    7677        } 
    7778    } 
     
    8990     * 選択中のカテゴリIDを取得する. 
    9091     * 
     92     * @param array $arrRequest リクエスト配列 
    9193     * @return array $arrCategoryId 選択中のカテゴリID 
    9294     */ 
    93     function lfGetSelectedCategoryId() { 
     95    function lfGetSelectedCategoryId($arrRequest) { 
    9496            // 商品ID取得 
    9597        $product_id = ''; 
    96         if ( isset($_GET['product_id']) && $_GET['product_id'] != '' && is_numeric($_GET['product_id']) ) { 
    97             $product_id = $_GET['product_id']; 
     98        if ( isset($arrRequest['product_id']) && $arrRequest['product_id'] != '' && is_numeric($arrRequest['product_id']) ) { 
     99            $product_id = $arrRequest['product_id']; 
    98100        } 
    99101        // カテゴリID取得 
    100102        $category_id = ''; 
    101         if ( isset($_GET['category_id']) && $_GET['category_id'] != '' && is_numeric($_GET['category_id']) ) { 
    102             $category_id = $_GET['category_id']; 
     103        if ( isset($arrRequest['category_id']) && $arrRequest['category_id'] != '' && is_numeric($arrRequest['category_id']) ) { 
     104            $category_id = $arrRequest['category_id']; 
    103105        } 
    104106        // 選択中のカテゴリIDを判定する 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_News.php

    r20076 r20108  
    8181     */ 
    8282    function lfGetNews(){ 
    83         $objQuery = new SC_Query(); 
     83        $objQuery = SC_Query::getSingletonInstance(); 
    8484        $sql = ''; 
    8585        $sql .= " SELECT "; 
  • branches/version-2_5-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_SearchProducts.php

    r20076 r20108  
    6363     */ 
    6464    function action() { 
     65        // 商品ID取得 
     66        $product_id = $this -> lfGetProductId(); 
     67        // カテゴリID取得 
     68        $category_id = $this -> lfGetCategoryId(); 
     69        // メーカーID取得 
     70        $maker_id = $this -> lfGetMakerId(); 
    6571        // 選択中のカテゴリIDを判定する 
    66         $this->category_id = $this->lfGetSelectedCategoryId(); 
     72        $this->category_id = $this->lfGetSelectedCategoryId($product_id, $category_id); 
    6773        // カテゴリ検索用選択リスト 
    6874        $this->arrCatList = $this->lfGetCategoryList(); 
    6975        // 選択中のメーカーIDを判定する 
    70         $this->maker_id = $this->lfGetSelectedMakerId(); 
     76        $this->maker_id = $this->lfGetSelectedMakerId($product_id, $maker_id); 
    7177        // メーカー検索用選択リスト 
    7278        $this->arrMakerList = $this->lfGetMakerList(); 
     
    8187        parent::destroy(); 
    8288    } 
    83  
     89     
     90    /** 
     91     * 商品IDを取得する. 
     92     *  
     93     * @return string $product_id 商品ID 
     94     */ 
     95    function lfGetProductId() { 
     96        $product_id = ''; 
     97        if ( isset($_GET['product_id']) && $_GET['product_id'] != '' && is_numeric($_GET['product_id']) ) { 
     98            $product_id = $_GET['product_id']; 
     99        } 
     100        return $product_id; 
     101    } 
     102     
     103    /** 
     104     * カテゴリIDを取得する. 
     105     *  
     106     * @return string $category_id カテゴリID 
     107     */ 
     108    function lfGetCategoryId() { 
     109        $category_id = ''; 
     110        if ( isset($_GET['category_id']) && $_GET['category_id'] != '' && is_numeric($_GET['category_id']) ) { 
     111            $category_id = $_GET['category_id']; 
     112        } 
     113        return $category_id; 
     114    } 
     115     
     116    /** 
     117     * メーカーIDを取得する. 
     118     *  
     119     * @return string $maker_id メーカーID 
     120     */ 
     121    function lfGetCategoryId() { 
     122        $maker_id = ''; 
     123        if ( isset($_GET['maker_id']) && $_GET['maker_id'] != '' && is_numeric($_GET['maker_id']) ) { 
     124            $maker_id = $_GET['maker_id']; 
     125        } 
     126        return $maker_id; 
     127    } 
     128     
    84129    /** 
    85130     * 選択中のカテゴリIDを取得する 
     
    87132     * @return array $arrCategoryId 選択中のカテゴリID 
    88133     */ 
    89     function lfGetSelectedCategoryId() { 
    90         // 商品ID取得 
    91         if ( !isset($_GET['product_id']) || $_GET['product_id'] == '' || !is_numeric($_GET['product_id']) ) { 
    92             return array(); 
    93         } 
    94         $product_id = $_GET['product_id']; 
    95         // カテゴリID取得 
    96         if ( !isset($_GET['category_id']) || $_GET['category_id'] == '' || !is_numeric($_GET['category_id']) ) { 
    97             return array(); 
    98         } 
    99         $category_id = $_GET['category_id']; 
     134    function lfGetSelectedCategoryId($product_id, $category_id) { 
    100135        // 選択中のカテゴリIDを判定する 
    101136        $objDb = new SC_Helper_DB_Ex(); 
     
    109144     * @return array $arrMakerId 選択中のメーカーID 
    110145     */ 
    111     function lfGetSelectedMakerId() { 
    112         // 商品ID取得 
    113         if ( !isset($_GET['product_id']) || $_GET['product_id'] == '' || !is_numeric($_GET['product_id']) ) { 
    114             return array(); 
    115         } 
    116         $product_id = $_GET['product_id']; 
    117         // メーカーID取得 
    118         if ( !isset($_GET['maker_id']) || $_GET['maker_id'] == '' || !is_numeric($_GET['maker_id']) ) { 
    119             return array(); 
    120         } 
    121         $maker_id = $_GET['maker_id']; 
     146    function lfGetSelectedMakerId($product_id, $maker_id) { 
    122147        // 選択中のメーカーIDを判定する 
    123148        $objDb = new SC_Helper_DB_Ex(); 
Note: See TracChangeset for help on using the changeset viewer.