source: branches/version-2_13-dev/data/class/pages/shopping/LC_Page_Shopping_LoadPaymentModule.php @ 23057

Revision 23057, 5.0 KB checked in by Seasoft, 11 years ago (diff)

#2327 (SC_Helper_PageLayout#sfGetPageLayout ページ情報が取得できない場合の動作が不定)

  • 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/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26/**
27 * 決済モジュールの呼び出しを行うクラス.
28 *
29 * 決済フローの妥当性検証は, トランザクションID等を使用して, 決済モジュール側で
30 * 行う必要がある.
31 *
32 * @package Page
33 * @author Kentaro Ohkouchi
34 * @version $Id$
35 */
36class LC_Page_Shopping_LoadPaymentModule extends LC_Page_Ex
37{
38    /**
39     * Page を初期化する.
40     *
41     * @return void
42     */
43    function init()
44    {
45        $this->skip_load_page_layout = true;
46        parent::init();
47    }
48
49    /**
50     * Page のプロセス.
51     *
52     * @return void
53     */
54    function process()
55    {
56        $order_id = $this->getOrderId();
57        if ($order_id === false) {
58            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
59            return;
60        }
61
62        $module_path = $this->getModulePath($order_id);
63        if ($module_path === false) {
64            $msg = 'モジュールファイルの取得に失敗しました。<br />この手続きは無効となりました。';
65            SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', true, $msg);
66            return;
67        }
68        require_once $module_path;
69    }
70
71    /**
72     * 受注IDをキーにして, 決済モジュールのパスを取得する.
73     *
74     * 決済モジュールが取得できた場合は, require 可能な決済モジュールのパスを返す.
75     * 受注IDが無効な場合, 取得したパスにファイルが存在しない場合は false
76     *
77     * @param integer $order_id 受注ID
78     * @return string|boolean 成功した場合は決済モジュールのパス;
79     *                        失敗した場合 false
80     */
81    function getModulePath($order_id)
82    {
83        $objPurchase = new SC_Helper_Purchase_Ex();
84        $objPayment = new SC_Helper_Payment_Ex();
85
86        $order = $objPurchase->getOrder($order_id);
87        $payment = $objPayment->get($order['payment_id']);
88        $module_path = $payment['module_path'];
89
90        /*
91         * 2.12.x までは dtb_payment.module_path がフルパスとなっていた.
92         * 2.13.x より, MODULE_REALDIR からのパスでも対応できるよう修正
93         * http://svn.ec-cube.net/open_trac/ticket/2292
94         */
95        if (realpath($module_path) !== false) {
96            $module_path = str_replace('\\', '/', realpath($module_path));
97        } else {
98            $module_path = str_replace('\\', '/', $module_path);
99        }
100        $module_realdir = str_replace('\\', '/', realpath(MODULE_REALDIR) . '/');
101        if (strpos($module_path, $module_realdir) !== false) {
102            $module_path = str_replace($module_realdir, '', $module_path);
103        }
104        $module_path = $module_realdir . $module_path;
105        if (file_exists($module_path)) {
106            return $module_path;
107        }
108
109        return false;
110    }
111
112    /**
113     * 受注ID を取得する.
114     *
115     * 以下の順序で受注IDを取得する.
116     *
117     * 1. $_SESSION['order_id']
118     * 2. $_POST['order_id']
119     * 3. $_GET['order_id']
120     *
121     * 受注IDが取得できない場合は false を返す.
122     *
123     * @access private
124     * @return integer|boolean 受注IDの取得に成功した場合は受注IDを返す;
125     *                         失敗した場合は, false を返す.
126     */
127    function getOrderId()
128    {
129        if (isset($_SESSION['order_id'])
130            && !SC_Utils_Ex::isBlank($_SESSION['order_id'])
131            && SC_Utils_Ex::sfIsInt($_SESSION['order_id'])) {
132            return $_SESSION['order_id'];
133        }
134
135        if (isset($_POST['order_id'])
136            && !SC_Utils_Ex::isBlank($_POST['order_id'])
137            && SC_Utils_Ex::sfIsInt($_POST['order_id'])) {
138            return $_POST['order_id'];
139        }
140
141        if (isset($_GET['order_id'])
142            && !SC_Utils_Ex::isBlank($_GET['order_id'])
143            && SC_Utils_Ex::sfIsInt($_GET['order_id'])) {
144            return $_GET['order_id'];
145        }
146
147        return false;
148    }
149
150    /**
151     * 決済モジュールから遷移する場合があるため, トークンチェックしない.
152     */
153    function doValidToken()
154    {
155        // nothing.
156    }
157}
Note: See TracBrowser for help on using the repository browser.