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 | */ |
---|
23 | ini_set("memory_limit","100M"); |
---|
24 | // {{{ requires |
---|
25 | require_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 | */ |
---|
34 | class 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 | $objCustomer = new SC_Customer(); |
---|
57 | //ログインしていない場合 |
---|
58 | if (!$objCustomer->isLoginSuccess()){ |
---|
59 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
60 | } else { |
---|
61 | //ログインしている場合 |
---|
62 | //DBから商品情報の読込 |
---|
63 | $arrForm = $this->lfGetRealFileName($_GET['product_id']); |
---|
64 | |
---|
65 | //ステータスが支払済み以上である事 |
---|
66 | if ($arrForm["status"] < ORDER_DELIV){ |
---|
67 | SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND,"",true); |
---|
68 | } |
---|
69 | //ファイル情報が無い場合はNG |
---|
70 | if ($arrForm["down_realfilename"] == "" ){ |
---|
71 | SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND,"",true); |
---|
72 | } |
---|
73 | //ファイルそのものが無い場合もとりあえずNG |
---|
74 | $realpath = DOWN_SAVE_DIR . $arrForm["down_realfilename"]; |
---|
75 | if (!file_exists($realpath)){ |
---|
76 | SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND,"",true); |
---|
77 | } |
---|
78 | //ファイル名をエンコードする |
---|
79 | $sdown_filename = mb_convert_encoding($arrForm["down_filename"], "Shift_JIS", "auto"); |
---|
80 | //タイプ指定 |
---|
81 | header("Content-Type: Application/octet-stream"); |
---|
82 | //ファイル名指定 |
---|
83 | header("Content-Disposition: attachment; filename=" . $sdown_filename); |
---|
84 | header("Content-Transfer-Encoding: binary"); |
---|
85 | //キャッシュ無効化 |
---|
86 | header("Expires: Mon, 26 Nov 1962 00:00:00 GMT"); |
---|
87 | header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT"); |
---|
88 | //IE6+SSL環境下は、キャッシュ無しでダウンロードできない |
---|
89 | header("Cache-Control: private"); |
---|
90 | header("Pragma: private"); |
---|
91 | //ファイルサイズ指定 |
---|
92 | $zv_filesize = filesize($realpath); |
---|
93 | header("Content-Length: " . $zv_filesize); |
---|
94 | set_time_limit(0); |
---|
95 | ob_end_flush(); |
---|
96 | flush(); |
---|
97 | |
---|
98 | //ファイル読み込み |
---|
99 | readfile($realpath); |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | /* 商品情報の読み込み */ |
---|
104 | function lfGetRealFileName($product_id) { |
---|
105 | $objQuery = new SC_Query(); |
---|
106 | $col = "*"; |
---|
107 | $table = "vw_download_class AS T1"; |
---|
108 | if (DB_TYPE == "mysql"){ |
---|
109 | $where = "T1.customer_id = " . (int)$_SESSION['customer']['customer_id'] . " AND T1.order_id = " . (int)$_GET['order_id'] . " AND T1.product_id = " . (int)$_GET['product_id'] . |
---|
110 | " AND (SELECT IF((SELECT d1.downloadable_days_unlimited FROM dtb_baseinfo d1)=1, 1, DATE(NOW()) <= DATE(DATE_ADD(T1.commit_date, INTERVAL (SELECT downloadable_days FROM dtb_baseinfo) DAY)))) = 1;"; |
---|
111 | }else{ |
---|
112 | $baseinfo = SC_Helper_DB_Ex::sf_getBasisData(); |
---|
113 | $where = "T1.customer_id = " . (int)$_SESSION['customer']['customer_id'] . " AND T1.order_id = " . (int)$_GET['order_id'] . " AND T1.product_id = " . (int)$_GET['product_id'] . |
---|
114 | " AND (SELECT CASE WHEN (SELECT d1.downloadable_days_unlimited FROM dtb_baseinfo d1) = 1 THEN 1 WHEN DATE(NOW()) <= DATE(T1.commit_date + '". $baseinfo['downloadable_days'] ." days') THEN 1 ELSE 0 END) = 1;"; |
---|
115 | } |
---|
116 | $arrRet = $objQuery->select($col, $table, $where); |
---|
117 | return $arrRet[0]; |
---|
118 | } |
---|
119 | |
---|
120 | /** |
---|
121 | * デストラクタ. |
---|
122 | * |
---|
123 | * @return void |
---|
124 | */ |
---|
125 | function destroy() { |
---|
126 | parent::destroy(); |
---|
127 | } |
---|
128 | } |
---|
129 | ?> |
---|