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

Revision 22856, 3.2 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

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