source: branches/version-2_13_0/data/class/pages/shopping/LC_Page_Shopping_LoadPaymentModule.php @ 23126

Revision 23126, 5.0 KB checked in by m_uehara, 11 years ago (diff)

#2348 r23116 - r23125 をマージ

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