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

Revision 22567, 3.2 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • 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';
6
7/**
8 * オーナーズストアページクラスの基底クラス.
9 *
10 * @package Page
11 * @author LOCKON CO.,LTD.
12 * @version $Id$
13 */
14class LC_Page_Upgrade_Base extends LC_Page_Ex
15{
16    function isValidIP()
17    {
18        $objLog  = new LC_Upgrade_Helper_Log;
19        $masterData = new SC_DB_MasterData_Ex();
20        $arrOstoreIPs = $masterData->getMasterData('mtb_ownersstore_ips');
21
22        if (isset($_SERVER['REMOTE_ADDR'])
23            && in_array($_SERVER['REMOTE_ADDR'], $arrOstoreIPs))
24        {
25            $objLog->log('* ip ok ' . $_SERVER['REMOTE_ADDR']);
26            return true;
27        }
28        $objLog->log('* refused ip ' . $_SERVER['REMOTE_ADDR']);
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
47            return true;
48        }
49
50        return false;
51    }
52
53    /**
54     * 配信サーバーへリクエストを送信する.
55     *
56     * @param string $mode
57     * @param array $arrParams 追加パラメーター.連想配列で渡す.
58     * @return string|object レスポンスボディ|エラー時にはPEAR::Errorオブジェクトを返す.
59     */
60    function request($mode, $arrParams = array(), $arrCookies = array())
61    {
62        $objReq = new HTTP_Request();
63        $objReq->setUrl(OSTORE_URL . 'upgrade/index.php');
64        $objReq->setMethod('POST');
65        $objReq->addPostData('mode', $mode);
66        foreach ($arrParams as $key => $val) {
67            $objReq->addPostData($key, $val);
68        }
69
70        foreach ($arrCookies as $cookie) {
71            $objReq->addCookie($cookie['name'], $cookie['value']);
72        }
73
74        $e = $objReq->sendRequest();
75        if (PEAR::isError($e)) {
76            return $e;
77        } else {
78            return $objReq;
79        }
80    }
81
82    function isLoggedInAdminPage()
83    {
84        $objSess = new SC_Session_Ex();
85
86        if ($objSess->isSuccess() === SUCCESS) {
87            return true;
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        return isset($arrRet[0]['public_key'])
107            ? $arrRet[0]['public_key']
108            : null;
109    }
110
111    /**
112     * オーナーズストアからの POST のため, トークンチェックしない.
113     */
114    function doValidToken()
115    {
116        // nothing.
117    }
118}
Note: See TracBrowser for help on using the repository browser.