source: branches/version-2_5-dev/data/class/pages/upgrade/LC_Page_Upgrade_Base.php @ 20449

Revision 20449, 3.1 KB checked in by shutta, 13 years ago (diff)

SC_Sessionクラスのclass_extends対応。

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2// {{{ requires
3require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
4require_once CLASS_REALDIR . 'pages/upgrade/helper/LC_Upgrade_Helper_Log.php';
5require_once CLASS_REALDIR . 'pages/upgrade/helper/LC_Upgrade_Helper_Json.php';
6require_once DATA_REALDIR . 'module/Request.php';
7
8/**
9 * オーナーズストアページクラスの基底クラス.
10 *
11 * @package Page
12 * @author LOCKON CO.,LTD.
13 * @version $Id$
14 */
15class LC_Page_Upgrade_Base extends LC_Page_Ex {
16    function isValidIP() {
17        $objLog  = new LC_Upgrade_Helper_Log;
18        $masterData = new SC_DB_MasterData();
19        $arrOstoreIPs = $masterData->getMasterData("mtb_ownersstore_ips");
20
21        if (isset($_SERVER['REMOTE_ADDR'])
22        && in_array($_SERVER['REMOTE_ADDR'], $arrOstoreIPs)) {
23            $objLog->log('* ip ok ' . $_SERVER['REMOTE_ADDR']);
24            return true;
25        }
26        $objLog->log('* refused ip ' . $_SERVER['REMOTE_ADDR']);
27        return false;
28    }
29
30    /**
31     * 自動アップデートが有効かどうかを判定する.
32     *
33     * @param integer $product_id
34     * @return boolean
35     */
36    function autoUpdateEnable($product_id) {
37        $where = 'module_id = ?';
38        $objQuery = new SC_Query();
39        $arrRet = $objQuery->select('auto_update_flg', 'dtb_module', $where, array($product_id));
40
41        if (isset($arrRet[0]['auto_update_flg'])
42        && $arrRet[0]['auto_update_flg'] === '1') {
43
44            return true;
45        }
46
47        return false;
48    }
49
50    /**
51     * 配信サーバへリクエストを送信する.
52     *
53     * @param string $mode
54     * @param array $arrParams 追加パラメータ.連想配列で渡す.
55     * @return string|object レスポンスボディ|エラー時にはPEAR::Errorオブジェクトを返す.
56     */
57    function request($mode, $arrParams = array(), $arrCookies = array()) {
58        $objReq = new HTTP_Request();
59        $objReq->setUrl(OSTORE_URL . 'upgrade/index.php');
60        $objReq->setMethod('POST');
61        $objReq->addPostData('mode', $mode);
62        $objReq->addPostDataArray($arrParams);
63
64        foreach ($arrCookies as $cookie) {
65            $objReq->addCookie($cookie['name'], $cookie['value']);
66        }
67
68        $e = $objReq->sendRequest();
69        if (PEAR::isError($e)) {
70            return $e;
71        } else {
72            return $objReq;
73        }
74    }
75
76    function isLoggedInAdminPage() {
77        $objSess = new SC_Session_Ex();
78
79        if ($objSess->isSuccess() === SUCCESS) {
80            return true;
81        }
82        return false;
83    }
84
85    /**
86     * 予測されにくいランダム値を生成する.
87     *
88     * @return string
89     */
90    function createSeed() {
91        return sha1(uniqid(rand(), true) . time());
92    }
93
94    function getPublicKey() {
95        $objQuery = new SC_Query;
96        $arrRet = $objQuery->select('*', 'dtb_ownersstore_settings');
97        return isset($arrRet[0]['public_key'])
98            ? $arrRet[0]['public_key']
99            : null;
100    }
101
102    /**
103     * オーナーズストアからの POST のため, トークンチェックしない.
104     */
105    function doValidToken() {
106        // nothing.
107    }
108}
109?>
Note: See TracBrowser for help on using the repository browser.