source: branches/version-2_5-dev/data/class/pages/mypage/LC_Page_Mypage_DownLoad.php @ 18793

Revision 18793, 4.9 KB checked in by nanasess, 14 years ago (diff)
  • DB_TYPE で分岐している箇所の修正(#801)
  • プリペアドステートメントを使用するよう修正(#792)
Line 
1<?php
2/*
3 * This file is part of EC CUORE
4 *
5 * Copyright(c) 2009 CUORE CO.,LTD. All Rights Reserved.
6 *
7 * http://ec.cuore.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 */
23ini_set("memory_limit","100M");
24// {{{ requires
25require_once(CLASS_PATH . "pages/LC_Page.php");
26
27/**
28 * ダウンロード商品ダウンロード のページクラス.
29 *
30 * @package Page
31 * @author CUORE CO.,LTD.
32 * @version $Id: LC_Page_Mypage_DownLoad.php 1 2009-08-04 00:00:00Z $
33 */
34class LC_Page_Mypage_DownLoad extends LC_Page {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->allowClientCache();
47    }
48
49    /**
50     * Page のプロセス.
51     *
52     * @return void
53     */
54    function process() {
55        ob_end_clean();
56
57        $customer_id = $_SESSION['customer']['customer_id'];
58        $order_id = $_GET['order_id'];
59        $product_id = $_GET['product_id'];
60
61        // ID の数値チェック
62        // TODO SC_FormParam でチェックした方が良い?
63        if (!is_numeric($customer_id)
64            || !is_numeric($order_id)
65            || !is_numeric($product_id)) {
66            SC_Utils_Ex::sfDispSiteError("");
67        }
68
69
70        $objCustomer = new SC_Customer();
71        //ログインしていない場合
72        if (!$objCustomer->isLoginSuccess()){
73            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
74        } else {
75        //ログインしている場合
76            //DBから商品情報の読込
77
78            $arrForm = $this->lfGetRealFileName($customer_id, $order_id, $product_id);
79
80            //ステータスが支払済み以上である事
81            if ($arrForm["status"] < ORDER_DELIV){
82                SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND,"",true);
83            }
84            //ファイル情報が無い場合はNG
85            if ($arrForm["down_realfilename"] == "" ){
86                SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND,"",true);
87            }
88            //ファイルそのものが無い場合もとりあえずNG
89            $realpath = DOWN_SAVE_DIR . $arrForm["down_realfilename"];
90            if (!file_exists($realpath)){
91                SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND,"",true);
92            }
93            //ファイル名をエンコードする
94            $sdown_filename = mb_convert_encoding($arrForm["down_filename"], "Shift_JIS", "auto");
95            //タイプ指定
96            header("Content-Type: Application/octet-stream");
97            //ファイル名指定
98            header("Content-Disposition: attachment; filename=" . $sdown_filename);
99            header("Content-Transfer-Encoding: binary");
100            //キャッシュ無効化
101            header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
102            header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
103            //IE6+SSL環境下は、キャッシュ無しでダウンロードできない
104            header("Cache-Control: private");
105            header("Pragma: private");
106            //ファイルサイズ指定
107            $zv_filesize = filesize($realpath);
108            header("Content-Length: " . $zv_filesize);
109            set_time_limit(0);
110            ob_end_flush();
111            flush();
112
113            //ファイル読み込み
114            readfile($realpath);
115        }
116    }
117
118    /**
119     * 商品情報の読み込みを行う.
120     *
121     * @param integer $customer_id 顧客ID
122     * @param integer $order_id 受注ID
123     * @param integer $product_id 商品ID
124     * @return array 商品情報の配列
125     */
126    function lfGetRealFileName($customer_id, $order_id, $product_id) {
127        $objQuery = new SC_Query();
128        $col = "*";
129        $table = "vw_download_class AS T1";
130        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
131        $where = "T1.customer_id = ? AND T1.order_id = ? AND T1.product_id = ?";
132        $where .= " AND " . $dbFactory->getDownloadableDaysWhereSql("T1");
133        $where .= " = 1";
134        $arrRet = $objQuery->select($col, $table, $where,
135                                    array($customer_id, $order_id, $product_id));
136        return $arrRet[0];
137    }
138
139    /**
140     * デストラクタ.
141     *
142     * @return void
143     */
144    function destroy() {
145        parent::destroy();
146    }
147}
148?>
Note: See TracBrowser for help on using the repository browser.