source: branches/version-2_13_0/data/class/pages/upgrade/LC_Page_Upgrade_Base.php @ 23143

Revision 23143, 3.4 KB checked in by m_uehara, 11 years ago (diff)

#2348 r23140 をマージ

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