source: branches/feature-module-update/data/class/pages/upgrade/LC_Page_Upgrade_ProductsList.php @ 16839

Revision 16839, 4.5 KB checked in by adachi, 15 years ago (diff)

認証処理修正

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php
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 'LC_Page_Upgrade_Base.php';
26
27/**
28 * オーナーズストア購入商品一覧を返すページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Upgrade_ProductsList extends LC_Page_Upgrade_Base {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46    }
47
48    /**
49     * Page のプロセス.
50     *
51     * @return void
52     */
53    function process($mode) {
54        $objLog  = new LC_Upgrade_Helper_Log;
55        $objJson = new LC_Upgrade_Helper_Json;
56
57        $objLog->start($mode);
58
59        // 管理画面ログインチェック
60        $objLog->log('* admin auth start');
61        if ($this->isLoggedInAdminPage() !== true) {
62            $objJson->setError(OSTORE_E_C_ADMIN_AUTH);
63            $objJson->display();
64            $objLog->error(OSTORE_E_C_ADMIN_AUTH);
65            return;
66        }
67
68        // 認証キーの取得
69        $public_key = $this->getPublicKey();
70        $sha1_key = $this->createSeed();
71
72        $objLog->log('* public key check start');
73        if (empty($public_key)) {
74            $objJson->setError(OSTORE_E_C_NO_KEY);
75            $objJson->display();
76            $objLog->error(OSTORE_E_C_NO_KEY);
77            return;
78        }
79
80        // リクエストを開始
81        $objLog->log('* http request start');
82        $arrPostData = array(
83            'eccube_url' => SITE_URL,
84            'public_key' => sha1($public_key . $sha1_key),
85            'sha1_key'   => $sha1_key
86        );
87        $objReq = $this->request('products_list', $arrPostData);
88
89        // リクエストチェック
90        $objLog->log('* http request check start');
91        if (PEAR::isError($objReq)) {
92            $objJson->setError(OSTORE_E_C_HTTP_REQ);
93            $objJson->display();
94            $objLogerr(OSTORE_E_C_HTTP_REQ, $objReq);
95            return;
96        }
97
98        // レスポンスチェック
99        $objLog->log('* http response check start');
100        if ($objReq->getResponseCode() !== 200) {
101            $objJson->setError(OSTORE_E_C_HTTP_RESP);
102            $objJson->display();
103            $objLog->error(OSTORE_E_C_HTTP_RESP, $objReq);
104            return;
105        }
106
107        $body = $objReq->getResponseBody();
108        $objRet = $objJson->decode($body);
109
110        // JSONデータのチェック
111        $objLog->log('* json deta check start');
112        if (empty($objRet)) {
113            $objJson->setError(OSTORE_E_C_FAILED_JSON_PARSE);
114            $objJson->display();
115            $objLog->error(OSTORE_E_C_FAILED_JSON_PARSE, $objReq);
116            return;
117        }
118
119        // ステータスチェック
120        $objLog->log('* json status check start');
121        if ($objRet->status === OSTORE_STATUS_SUCCESS) {
122            $objLog->log('* get products list ok');
123
124            $arrProducts = array();
125
126            foreach ($objRet->data as $product) {
127                $arrProducts[] = get_object_vars($product);
128            }
129            $objView = new SC_AdminView();
130            $objView->assign('arrProducts', $arrProducts);
131            //print_r($arrProducts);
132            $html = $objView->fetch('ownersstore/products_list.tpl');
133
134            $objJson->setSuccess(array(), $html);
135            $objJson->display();
136            $objLog->end();
137            return;
138        } else {
139            // 配信サーバ側でエラーを補足
140            echo $body;
141            $objLog->error($objRet->errcode, $objReq);
142            return;
143        }
144    }
145
146    /**
147     * デストラクタ.
148     *
149     * @return void
150     */
151    function destroy() {
152        parent::destroy();
153    }
154}
155?>
Note: See TracBrowser for help on using the repository browser.