source: branches/feature-module-update/data/class/pages/upgrade/LC_Page_Upgrade_EchoKey.php @ 16582

Revision 16582, 4.0 KB checked in by nanasess, 17 years ago (diff)

ライセンス表記変更

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once CLASS_PATH . 'pages/LC_Page.php';
26
27/**
28 * オーナーズストア認証キーを返すページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Upgrade_EchoKey extends LC_Page {
35
36    /** Services_Jsonオブジェクト */
37    var $objJson = null;
38    /** SC_FromParamオブジェクト */
39    var $objForm = null;
40
41    // }}}
42    // {{{ functions
43
44    /**
45     * Page を初期化する.
46     *
47     * @return void
48     */
49    function init() {
50        $this->objJson = new Services_JSON();
51
52        $this->objForm = new SC_FormParam();
53        $this->objForm->addParam('seed', 'seed', MLTEXT_LEN, '', array('EXIST_CHECK', 'ALNUM_CHECK', 'MAX_LENGTH_CHECK'));
54        $this->objForm->setParam($_POST);
55    }
56
57    /**
58     * Page のプロセス.
59     *
60     * @return void
61     */
62    function process() {
63        $errFormat = '* error! code:%s / debug:%s';
64
65        GC_Utils::gfPrintLog('###Echo Key Start###');
66
67        // リクエストの検証
68        if ($this->objForm->checkError()) {
69            $arrErr = array(
70                'status'  => OWNERSSTORE_STATUS_ERROR,
71                'errcode' => OWNERSSTORE_ERR_EK_POST_PARAM,
72                'body' => '配信サーバとの通信中にエラーが発生しました。エラーコード:' . OWNERSSTORE_ERR_EK_POST_PARAM
73            );
74            echo $this->objJson->encode($arrErr);
75            GC_Utils::gfPrintLog(
76                sprintf($errFormat, $arrErr['errcode'], serialize($_POST))
77            );
78            exit;
79        }
80
81        $public_key = $this->getPublicKey();
82
83        // 認証キーが設定されていない場合
84        if (empty($public_key)) {
85            $arrErr = array(
86                'status'  => OWNERSSTORE_STATUS_ERROR,
87                'errcode' => OWNERSSTORE_ERR_EK_KEY_MISSING,
88                'body' => '配信サーバとの通信中にエラーが発生しました。エラーコード:' . OWNERSSTORE_ERR_EK_KEY_MISSING
89            );
90            echo $this->objJson->encode($arrErr);
91            GC_Utils::gfPrintLog(
92                sprintf($errFormat, $arrErr['errcode'], serialize($_POST))
93            );
94            exit;
95        }
96
97        // 認証キー + 配信サーバから送られるランダムな値をsha1()にかけechoする
98        $arrParams = array(
99            'status' => OWNERSSTORE_STATUS_SUCCESS,
100            'body'   => sha1($public_key . $this->objForm->getValue('seed'))
101        );
102
103        echo $this->objJson->encode($arrParams);
104        GC_Utils::gfPrintLog('* echo key ok');
105        exit;
106    }
107
108    /**
109     * デストラクタ.
110     *
111     * @return void
112     */
113    function destroy() {
114        GC_Utils::gfPrintLog('###Echo Key End###');
115    }
116
117     /**
118     * DBから認証キーを取得する
119     * 無い場合はnullを返す
120     *
121     * @param void
122     * @return string|null 認証キー
123     */
124    function getPublicKey() {
125        $table  = 'dtb_ownersstore_settings';
126        $col    = 'public_key';
127
128        $objQuery = new SC_Query();
129
130        $arrRet = $objQuery->select($col, $table, $where);
131
132        if (isset($arrRet[0]['public_key'])) {
133            return $arrRet[0]['public_key'];
134        }
135
136        return null;
137    }
138}
139?>
Note: See TracBrowser for help on using the repository browser.