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

Revision 20562, 3.1 KB checked in by Seasoft, 13 years ago (diff)

#627(ソース整形・ソースコメントの改善)

  • TAB
  • 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        {
24            $objLog->log('* ip ok ' . $_SERVER['REMOTE_ADDR']);
25            return true;
26        }
27        $objLog->log('* refused ip ' . $_SERVER['REMOTE_ADDR']);
28        return false;
29    }
30
31    /**
32     * 自動アップデートが有効かどうかを判定する.
33     *
34     * @param integer $product_id
35     * @return boolean
36     */
37    function autoUpdateEnable($product_id) {
38        $where = 'module_id = ?';
39        $objQuery = new SC_Query_Ex();
40        $arrRet = $objQuery->select('auto_update_flg', 'dtb_module', $where, array($product_id));
41
42        if (isset($arrRet[0]['auto_update_flg'])
43        && $arrRet[0]['auto_update_flg'] === '1') {
44
45            return true;
46        }
47
48        return false;
49    }
50
51    /**
52     * 配信サーバへリクエストを送信する.
53     *
54     * @param string $mode
55     * @param array $arrParams 追加パラメータ.連想配列で渡す.
56     * @return string|object レスポンスボディ|エラー時にはPEAR::Errorオブジェクトを返す.
57     */
58    function request($mode, $arrParams = array(), $arrCookies = array()) {
59        $objReq = new HTTP_Request();
60        $objReq->setUrl(OSTORE_URL . 'upgrade/index.php');
61        $objReq->setMethod('POST');
62        $objReq->addPostData('mode', $mode);
63        $objReq->addPostDataArray($arrParams);
64
65        foreach ($arrCookies as $cookie) {
66            $objReq->addCookie($cookie['name'], $cookie['value']);
67        }
68
69        $e = $objReq->sendRequest();
70        if (PEAR::isError($e)) {
71            return $e;
72        } else {
73            return $objReq;
74        }
75    }
76
77    function isLoggedInAdminPage() {
78        $objSess = new SC_Session_Ex();
79
80        if ($objSess->isSuccess() === SUCCESS) {
81            return true;
82        }
83        return false;
84    }
85
86    /**
87     * 予測されにくいランダム値を生成する.
88     *
89     * @return string
90     */
91    function createSeed() {
92        return sha1(uniqid(rand(), true) . time());
93    }
94
95    function getPublicKey() {
96        $objQuery = new SC_Query_Ex();
97        $arrRet = $objQuery->select('*', 'dtb_ownersstore_settings');
98        return isset($arrRet[0]['public_key'])
99            ? $arrRet[0]['public_key']
100            : null;
101    }
102
103    /**
104     * オーナーズストアからの POST のため, トークンチェックしない.
105     */
106    function doValidToken() {
107        // nothing.
108    }
109}
110?>
Note: See TracBrowser for help on using the repository browser.