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$ |
---|
33 | */ |
---|
34 | class LC_Page_Upgrade_ProductsList extends LC_Page { |
---|
35 | |
---|
36 | // }}} |
---|
37 | // {{{ functions |
---|
38 | |
---|
39 | /** |
---|
40 | * Page を初期化する. |
---|
41 | * |
---|
42 | * @return void |
---|
43 | */ |
---|
44 | function init() { |
---|
45 | $this->objJson = new Services_Json(); |
---|
46 | $this->objSess = new SC_Session(); |
---|
47 | } |
---|
48 | |
---|
49 | /** |
---|
50 | * Page のプロセス. |
---|
51 | * |
---|
52 | * @return void |
---|
53 | */ |
---|
54 | function process() { |
---|
55 | $errFormat = '* error! code:%s / debug:%s'; |
---|
56 | |
---|
57 | GC_Utils::gfPrintLog('###ProductsList Start###'); |
---|
58 | |
---|
59 | // 管理画面ログインチェック |
---|
60 | GC_Utils::gfPrintLog('* admin auth start'); |
---|
61 | if ($this->objSess->isSuccess() !== SUCCESS) { |
---|
62 | $arrErr = array( |
---|
63 | 'status' => OWNERSSTORE_STATUS_ERROR, |
---|
64 | 'errcode' => OWNERSSTORE_ERR_PL_ADMIN_AUTH, |
---|
65 | 'body' => '配信サーバとの通信中にエラーが発生しました。エラーコード:' . OWNERSSTORE_ERR_PL_ADMIN_AUTH |
---|
66 | ); |
---|
67 | echo $this->objJson->encode($arrErr); |
---|
68 | GC_Utils::gfPrintLog( |
---|
69 | sprintf($errFormat, $arrErr['errcode'], serialize($this->objSess)) |
---|
70 | ); |
---|
71 | exit; |
---|
72 | } |
---|
73 | |
---|
74 | // TODO CSRF対策が必須 |
---|
75 | |
---|
76 | $objReq = new HTTP_Request(); |
---|
77 | $objReq->setUrl('http://cube-shopaccount/upgrade/index.php'); // TODO URL定数化 |
---|
78 | $objReq->setMethod('POST'); |
---|
79 | $objReq->addPostData('mode', 'products_list'); |
---|
80 | $objReq->addPostData('site_url', SITE_URL); |
---|
81 | $objReq->addPostData('ssl_url', SSL_URL); |
---|
82 | |
---|
83 | // リクエストを開始 |
---|
84 | GC_Utils::gfPrintLog('* http request start'); |
---|
85 | if (PEAR::isError($e = $objReq->sendRequest())) { |
---|
86 | $arrErr = array( |
---|
87 | 'status' => OWNERSSTORE_STATUS_ERROR, |
---|
88 | 'errcode' => OWNERSSTORE_ERR_DL_HTTP_REQ, |
---|
89 | 'body' => '配信サーバとの通信中にエラーが発生しました。エラーコード:' . OWNERSSTORE_ERR_DL_HTTP_REQ |
---|
90 | ); |
---|
91 | echo $this->objJson->encode($arrErr); |
---|
92 | GC_Utils::gfPrintLog( |
---|
93 | sprintf($errFormat, $arrErr['errcode'], serialize($e)) |
---|
94 | ); |
---|
95 | exit; |
---|
96 | } |
---|
97 | |
---|
98 | GC_Utils::gfPrintLog('* http response check start'); |
---|
99 | if ($objReq->getResponseCode() !== 200) { |
---|
100 | $arrErr = array( |
---|
101 | 'status' => OWNERSSTORE_STATUS_ERROR, |
---|
102 | 'errcode' => OWNERSSTORE_ERR_DL_HTTP_RESP_CODE, |
---|
103 | 'body' => '配信サーバとの通信中にエラーが発生しました。エラーコード:' . OWNERSSTORE_ERR_DL_HTTP_RESP_CODE |
---|
104 | ); |
---|
105 | echo $this->objJson->encode($arrErr); |
---|
106 | GC_Utils::gfPrintLog( |
---|
107 | sprintf($errFormat, $arrErr['errcode'], serialize($objReq)) |
---|
108 | ); |
---|
109 | exit; |
---|
110 | } |
---|
111 | |
---|
112 | $body = $objReq->getResponseBody(); |
---|
113 | $jsonData = $this->objJson->decode($body); |
---|
114 | GC_Utils::gfPrintLog('* json deta check start'); |
---|
115 | if (empty($jsonData)) { |
---|
116 | $arrErr = array( |
---|
117 | 'status' => OWNERSSTORE_STATUS_ERROR, |
---|
118 | 'errcode' => OWNERSSTORE_ERR_PL_INVALID_JSON_DATA, |
---|
119 | 'body' => '配信サーバとの通信中にエラーが発生しました。エラーコード:' . OWNERSSTORE_ERR_PL_INVALID_JSON_DATA |
---|
120 | ); |
---|
121 | echo $this->objJson->encode($arrErr); |
---|
122 | GC_Utils::gfPrintLog( |
---|
123 | sprintf($errFormat, $arrErr['errcode'], serialize($body)) |
---|
124 | ); |
---|
125 | exit; |
---|
126 | } |
---|
127 | GC_Utils::gfPrintLog('* json status check start'); |
---|
128 | if ($jsonData->status === OWNERSSTORE_STATUS_SUCCESS) { |
---|
129 | GC_Utils::gfPrintLog('* get products list ok'); |
---|
130 | echo $body; |
---|
131 | exit; |
---|
132 | } else { |
---|
133 | echo $body; |
---|
134 | GC_Utils::gfPrintLog( |
---|
135 | sprintf($errFormat, $jsonData->errcode, serialize($objReq)) |
---|
136 | ); |
---|
137 | exit; |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | /** |
---|
142 | * デストラクタ. |
---|
143 | * |
---|
144 | * @return void |
---|
145 | */ |
---|
146 | function destroy() { |
---|
147 | GC_Utils::gfPrintLog('###ProductsList END###'); |
---|
148 | } |
---|
149 | } |
---|
150 | ?> |
---|