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 | |
---|
57 | $customer_id = $_SESSION['customer']['customer_id']; |
---|
58 | $order_id = $_GET['order_id']; |
---|
59 | $product_id = $_GET['product_id']; |
---|
60 | $classcategory_id1 = $_GET['classcategory_id1']; |
---|
61 | $classcategory_id2 = $_GET['classcategory_id2']; |
---|
62 | |
---|
63 | // ID の数値チェック |
---|
64 | // TODO SC_FormParam でチェックした方が良い? |
---|
65 | if (!is_numeric($customer_id) |
---|
66 | || !is_numeric($order_id) |
---|
67 | || !is_numeric($product_id) |
---|
68 | || !is_numeric($classcategory_id1) |
---|
69 | || !is_numeric($classcategory_id2)) { |
---|
70 | SC_Utils_Ex::sfDispSiteError(""); |
---|
71 | } |
---|
72 | |
---|
73 | $objCustomer = new SC_Customer(); |
---|
74 | //ログインしていない場合 |
---|
75 | if (!$objCustomer->isLoginSuccess()){ |
---|
76 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
77 | } else { |
---|
78 | //ログインしている場合 |
---|
79 | //DBから商品情報の読込 |
---|
80 | |
---|
81 | $arrForm = $this->lfGetRealFileName($customer_id, $order_id, $product_id, $classcategory_id1, $classcategory_id2); |
---|
82 | |
---|
83 | //ステータスが支払済み以上である事 |
---|
84 | if ($arrForm["status"] < ORDER_DELIV){ |
---|
85 | SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND,"",true); |
---|
86 | } |
---|
87 | //ファイル情報が無い場合はNG |
---|
88 | if ($arrForm["down_realfilename"] == "" ){ |
---|
89 | SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND,"",true); |
---|
90 | } |
---|
91 | //ファイルそのものが無い場合もとりあえずNG |
---|
92 | $realpath = DOWN_SAVE_DIR . $arrForm["down_realfilename"]; |
---|
93 | if (!file_exists($realpath)){ |
---|
94 | SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND,"",true); |
---|
95 | } |
---|
96 | //ファイル名をエンコードする |
---|
97 | $sdown_filename = mb_convert_encoding($arrForm["down_filename"], "Shift_JIS", "auto"); |
---|
98 | //タイプ指定 |
---|
99 | header("Content-Type: Application/octet-stream"); |
---|
100 | //ファイル名指定 |
---|
101 | header("Content-Disposition: attachment; filename=" . $sdown_filename); |
---|
102 | header("Content-Transfer-Encoding: binary"); |
---|
103 | //キャッシュ無効化 |
---|
104 | header("Expires: Mon, 26 Nov 1962 00:00:00 GMT"); |
---|
105 | header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT"); |
---|
106 | //IE6+SSL環境下は、キャッシュ無しでダウンロードできない |
---|
107 | header("Cache-Control: private"); |
---|
108 | header("Pragma: private"); |
---|
109 | //ファイルサイズ指定 |
---|
110 | $zv_filesize = filesize($realpath); |
---|
111 | header("Content-Length: " . $zv_filesize); |
---|
112 | set_time_limit(0); |
---|
113 | ob_end_flush(); |
---|
114 | flush(); |
---|
115 | |
---|
116 | //ファイル読み込み |
---|
117 | readfile($realpath); |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * 商品情報の読み込みを行う. |
---|
123 | * |
---|
124 | * @param integer $customer_id 顧客ID |
---|
125 | * @param integer $order_id 受注ID |
---|
126 | * @param integer $product_id 商品ID |
---|
127 | * @return array 商品情報の配列 |
---|
128 | */ |
---|
129 | function lfGetRealFileName($customer_id, $order_id, $product_id, $classcategory_id1, $classcategory_id2) { |
---|
130 | $objQuery = new SC_Query(); |
---|
131 | $col = "*"; |
---|
132 | $table = "vw_download_class AS T1"; |
---|
133 | $dbFactory = SC_DB_DBFactory_Ex::getInstance(); |
---|
134 | $where = "T1.customer_id = ? AND T1.order_id = ? AND T1.product_id = ? AND T1.classcategory_id1 = ? AND T1.classcategory_id2 = ?"; |
---|
135 | $where .= " AND " . $dbFactory->getDownloadableDaysWhereSql("T1"); |
---|
136 | $where .= " = 1"; |
---|
137 | $arrRet = $objQuery->select($col, $table, $where, |
---|
138 | array($customer_id, $order_id, $product_id, $classcategory_id1, $classcategory_id2)); |
---|
139 | return $arrRet[0]; |
---|
140 | } |
---|
141 | |
---|
142 | /** |
---|
143 | * デストラクタ. |
---|
144 | * |
---|
145 | * @return void |
---|
146 | */ |
---|
147 | function destroy() { |
---|
148 | parent::destroy(); |
---|
149 | } |
---|
150 | } |
---|
151 | ?> |
---|