Changeset 21354
- Timestamp:
- 2011/11/24 15:15:19 (12 years ago)
- Location:
- branches/version-2_11-dev/data
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_11-dev/data/Smarty/templates/mobile/mypage/history.tpl
r21000 r21354 46 46 <!--{if $orderDetail.product_type_id == $smarty.const.PRODUCT_TYPE_DOWNLOAD}--> 47 47 <!--{if $orderDetail.is_downloadable}--> 48 <!--{if $isAU == false}--> 48 49 <a target="_self" href="<!--{$smarty.const.ROOT_URLPATH}-->mypage/download.php?order_id=<!--{$tpl_arrOrderData.order_id}-->&product_id=<!--{$orderDetail.product_id}-->&product_class_id=<!--{$orderDetail.product_class_id}-->">ダウンロード</a><br> 50 <!--{else}--> 51 <object data="<!--{$smarty.const.ROOT_URLPATH}-->mypage/download.php?order_id=<!--{$tpl_arrOrderData.order_id}-->&product_id=<!--{$orderDetail.product_id}-->&product_class_id=<!--{$orderDetail.product_class_id}-->&PHPSESSID=<!--{$phpsessid}-->" copyright="no" standby="ダウンロード" type="<!--{$orderDetail.mime_type}-->"> 52 <param name="title" value="<!--{$orderDetail.down_filename}-->" valuetype="data"> 53 </object><br> 54 <!--{/if}--> 49 55 <!--{else}--> 50 56 <!--{if $orderDetail.payment_date == "" && $orderDetail.effective == "0"}--> -
branches/version-2_11-dev/data/class/helper/SC_Helper_Mobile.php
r21185 r21354 35 35 class SC_Helper_Mobile { 36 36 37 /** 基本MimeType */ 38 var $defaultMimeType = 'application/force-download'; 39 40 /** 拡張MimeType配列 41 * Application/octet-streamで対応出来ないファイルタイプのみ拡張子をキーに記述する 42 * 拡張子が本配列に存在しない場合は application/force-download を利用する */ 43 var $arrMimetypes = array( 44 'html'=> 'text/html', 45 'css' => 'text/css', 46 'hdml'=> 'text/x-hdml', 47 'mmf' => 'application/x-smaf', 48 'jpeg'=> 'image/jpeg', 49 'jpg' => 'image/jpeg', 50 'gif' => 'image/gif', 51 'png' => 'image/png', 52 'bmp' => 'image/x-ms-bmp', 53 'amc' => 'application/x-mpeg', 54 '3g2' => 'video/3gpp2', 55 '3gp' => 'video/3gpp', 56 'jam' => 'application/x-jam', 57 'kjx' => 'application/x-kjx', 58 'jar' => 'application/java-archive', 59 'jad' => 'text/vnd.sun.j2me.app-descriptor', 60 'swf' => 'application/x-shockwave-flash', 61 'dmt' => 'application/x-decomail-template', 62 'khm' => 'application/x-kddi-htmlmail', 63 'hmt' => 'application/x-htmlmail-template', 64 'ucm' => 'application/x-ucf-package', 65 'ucp' => 'application/x-ucf-package', 66 'pdf' => 'application/pdf', 67 'wma' => 'audio/x-ms-wma', 68 'asf' => 'video/x-ms-asf', 69 'wax' => 'audio/x-ms-wax', 70 'wvx' => 'video/x-ms-wvx', 71 'wmv' => 'video/x-ms-wmv', 72 'asx' => 'video/asx', 73 'txt' => 'text/plain', 74 'exe' => 'application/octet-stream', 75 'zip' => 'application/zip', 76 'doc' => 'application/msword', 77 'xls' => 'application/vnd.ms-excel', 78 'ppt' => 'application/vnd.ms-powerpoint' 79 ); 80 37 81 /** 38 82 * EC-CUBE がサポートする携帯端末かどうかをチェックする。 … … 238 282 ob_start(array('SC_MobileImage_Ex', 'handler')); 239 283 240 // 全角カタカナを半角カタカナに変換する。 241 ob_start(create_function('$buffer', 'return mb_convert_kana($buffer, "k", "SJIS-win");')); 284 //download.phpに対してカタカナ変換をするとファイルが壊れてしまうため回避する 285 if ($_SERVER['SCRIPT_FILENAME'] != HTML_REALDIR . "mypage/download.php") { 286 // 全角カタカナを半角カタカナに変換する。 287 ob_start(create_function('$buffer', 'return mb_convert_kana($buffer, "k", "SJIS-win");')); 288 } 242 289 243 290 // 内部エンコーディングから Shift JIS に変換する。 … … 460 507 return false; 461 508 } 509 510 /** 511 * ファイルのMIMEタイプを判別する 512 * 513 * @param string $filename ファイル名 514 * @return string MIMEタイプ 515 */ 516 function getMimeType($filename) { 517 //ファイルの拡張子からコンテンツタイプを決定する 518 $file_extension = strtolower(substr(strrchr($filename,"."),1)); 519 $mime_type = $this->defaultMimeType; 520 if(array_key_exists($file_extension, $this->arrMimetypes)){ 521 $mime_type = $this->arrMimetypes[$file_extension]; 522 } 523 return $mime_type; 524 } 462 525 } 463 526 ?> -
branches/version-2_11-dev/data/class/pages/mypage/LC_Page_Mypage_DownLoad.php
r21335 r21354 44 44 * Application/octet-streamで対応出来ないファイルタイプのみ拡張子をキーに記述する 45 45 * 拡張子が本配列に存在しない場合は $defaultContentTypeを利用する */ 46 var $arrContentType = array('apk' => 'application/vnd.android.package-archive'); 46 var $arrContentType = array('apk' => 'application/vnd.android.package-archive', 47 'pdf' => 'application/pdf' 48 ); 47 49 48 50 // }}} … … 132 134 // SC_DisplayやSC_Responseに大容量ファイルレスポンスが実装されたら移行可能だと思います。 133 135 136 // ダウンロード実行 モバイル端末はダウンロード方法が異なる 137 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE){ 138 // キャリアがAUのモバイル端末はさらにダウンロード方法が異なる 139 if (SC_MobileUserAgent::getCarrier() == 'ezweb'){ 140 // AUモバイル 141 $this->lfMobileAuDownload($realpath,$sdown_filename); 142 }else{ 143 // AU以外のモバイル 144 $this->lfMobileDownload($realpath,$sdown_filename); 145 } 146 }else{ 147 // PC、スマフォ 148 $this->lfDownload($realpath,$sdown_filename); 149 } 150 } 151 152 /** 153 * 商品情報の読み込みを行う. 154 * 155 * @param integer $customer_id 会員ID 156 * @param integer $order_id 受注ID 157 * @param integer $product_id 商品ID 158 * @param integer $product_class_id 商品規格ID 159 * @return array 商品情報の配列 160 */ 161 function lfGetRealFileName($customer_id, $order_id, $product_id, $product_class_id) { 162 $objQuery = new SC_Query_Ex(); 163 $col = <<< __EOS__ 164 pc.product_id AS product_id, 165 pc.product_class_id AS product_class_id, 166 pc.down_realfilename AS down_realfilename, 167 pc.down_filename AS down_filename, 168 o.order_id AS order_id, 169 o.customer_id AS customer_id, 170 o.payment_date AS payment_date, 171 o.status AS status 172 __EOS__; 173 174 $table = <<< __EOS__ 175 dtb_products_class pc, 176 dtb_order_detail od, 177 dtb_order o 178 __EOS__; 179 180 $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 181 $where = "o.customer_id = ? AND o.order_id = ? AND pc.product_id = ? AND pc.product_class_id = ?"; 182 $where .= " AND " . $dbFactory->getDownloadableDaysWhereSql('o'); 183 $where .= " = 1"; 184 $arrRet = $objQuery->select($col, $table, $where, 185 array($customer_id, $order_id, $product_id, $product_class_id)); 186 return $arrRet[0]; 187 } 188 189 /* パラメーター情報の初期化 */ 190 function lfInitParam(&$objFormParam) { 191 $objFormParam->addParam("customer_id", "customer_id", INT_LEN, 'n', array("EXIST_CHECK","NUM_CHECK")); 192 $objFormParam->addParam("order_id", "order_id", INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK")); 193 $objFormParam->addParam("product_id", "product_id", INT_LEN, 'n', array("EXIST_CHECK","NUM_CHECK")); 194 $objFormParam->addParam("product_class_id", "product_class_id", INT_LEN, 'n', array("EXIST_CHECK","NUM_CHECK")); 195 } 196 197 /* 入力内容のチェック */ 198 function lfCheckError(&$objFormParam) { 199 $objErr = new SC_CheckError_Ex($objFormParam->getHashArray()); 200 $objErr->arrErr = $objFormParam->checkError(); 201 return $objErr->arrErr; 202 } 203 204 /** 205 * モバイル端末用ヘッダー出力処理 206 * 207 * @param string $realpath ダウンロードファイルパス 208 * @param string $sdown_filename ダウンロード時の指定ファイル名 209 */ 210 function lfMobileHeader($realpath,$sdown_filename){ 211 $objHelperMobile = new SC_Helper_Mobile_Ex(); 212 //ファイルの拡張子からコンテンツタイプを取得する 213 $mime_type = $objHelperMobile->getMIMEType($realpath); 214 header('Content-Type: ' . $mime_type); 215 header("Content-Disposition: attachment; filename=" . $sdown_filename); 216 header('Accept-Ranges: bytes'); 217 header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT"); 218 header("Cache-Control: public"); 219 } 220 221 /** 222 * モバイル端末(AU)ダウンロード処理 223 * 224 * @param string $realpath ダウンロードファイルパス 225 * @param string $sdown_filename ダウンロード時の指定ファイル名 226 */ 227 function lfMobileAuDownload($realpath,$sdown_filename){ 228 //モバイル用ヘッダー出力 229 $this->lfMobileHeader($realpath,$sdown_filename); 230 //ファイルサイズを取得する 231 $file_size = filesize($realpath); 232 //読み込み 233 $fp = fopen( $realpath, "rb" ); 234 if (isset($_SERVER['HTTP_RANGE'])) { 235 // 二回目以降のリクエスト 236 list($range_offset, $range_limit) = sscanf($_SERVER['HTTP_RANGE'], "bytes=%d-%d"); 237 $content_range = sprintf("bytes %d-%d/%d", $range_offset, $range_limit, $file_size); 238 $content_length = $range_limit - $range_offset + 1; 239 fseek( $fp, $range_offset, SEEK_SET ); 240 header("HTTP/1.1 206 Partial Content" ); 241 header("Content-Lenth: " . $content_length); 242 header("Content-Range: " . $content_range); 243 } else { 244 // 一回目のリクエスト 245 $content_length = $file_size; 246 header("Content-Length: " . $content_length); 247 } 248 echo fread( $fp, $content_length ) ; 249 ob_flush(); 250 flush(); 251 } 252 253 /** 254 * モバイル端末(AU以外)ダウンロード処理 255 * 256 * @param string $realpath ダウンロードファイルパス 257 * @param string $sdown_filename ダウンロード時の指定ファイル名 258 */ 259 function lfMobileDownload($realpath,$sdown_filename){ 260 //モバイル用ヘッダー出力 261 $this->lfMobileHeader($realpath,$sdown_filename); 262 //ファイルサイズを取得する 263 $file_size = filesize($realpath); 264 265 //出力用バッファをクリアする 266 @ob_end_clean(); 267 268 //HTTP_RANGEがセットされていた場合 269 if (isset($_SERVER['HTTP_RANGE'])) { 270 // 二回目以降のリクエスト 271 list($a, $range) = explode("=",$_SERVER['HTTP_RANGE'],2); 272 list($range) = explode(",",$range,2); 273 list($range, $range_end) = explode("-", $range); 274 $range=intval($range); 275 276 if (!$range_end) { 277 $range_end=$file_size-1; 278 } else { 279 $range_end=intval($range_end); 280 } 281 282 $new_length = $range_end-$range+1; 283 header("HTTP/1.1 206 Partial Content"); 284 header("Content-Length: $new_length"); 285 header("Content-Range: bytes $range-$range_end/$file_size"); 286 } else { 287 // 一回目のリクエスト 288 $new_length=$file_size; 289 header("Content-Length: ".$file_size); 290 } 291 292 //ファイル読み込み 293 $chunksize = 1*(DOWNLOAD_BLOCK*1024); 294 $bytes_send = 0; 295 if ($realpath = fopen($realpath, 'r')) { 296 // 二回目以降のリクエスト 297 if (isset($_SERVER['HTTP_RANGE'])) fseek($realpath, $range); 298 299 while (!feof($realpath) && (!connection_aborted()) && ($bytes_send<$new_length)) { 300 $buffer = fread($realpath, $chunksize); 301 print($buffer); 302 ob_flush(); 303 flush(); 304 $bytes_send += strlen($buffer); 305 } 306 fclose($realpath); 307 } 308 die(); 309 } 310 311 /** 312 * モバイル端末以外ダウンロード処理 313 * 314 * @param string $realpath ダウンロードファイルパス 315 * @param string $sdown_filename ダウンロード時の指定ファイル名 316 */ 317 function lfDownload($realpath,$sdown_filename){ 134 318 // 拡張子を取得 135 319 $extension = pathinfo($realpath, PATHINFO_EXTENSION); … … 162 346 exit; 163 347 } 164 165 348 while (!feof($handle)) { 166 349 echo(fread($handle, DOWNLOAD_BLOCK*1024)); … … 172 355 173 356 /** 174 * 商品情報の読み込みを行う.175 *176 * @param integer $customer_id 会員ID177 * @param integer $order_id 受注ID178 * @param integer $product_id 商品ID179 * @param integer $product_class_id 商品規格ID180 * @return array 商品情報の配列181 */182 function lfGetRealFileName($customer_id, $order_id, $product_id, $product_class_id) {183 $objQuery = new SC_Query_Ex();184 $col = <<< __EOS__185 pc.product_id AS product_id,186 pc.product_class_id AS product_class_id,187 pc.down_realfilename AS down_realfilename,188 pc.down_filename AS down_filename,189 o.order_id AS order_id,190 o.customer_id AS customer_id,191 o.payment_date AS payment_date,192 o.status AS status193 __EOS__;194 195 $table = <<< __EOS__196 dtb_products_class pc,197 dtb_order_detail od,198 dtb_order o199 __EOS__;200 201 $dbFactory = SC_DB_DBFactory_Ex::getInstance();202 $where = "o.customer_id = ? AND o.order_id = ? AND pc.product_id = ? AND pc.product_class_id = ?";203 $where .= " AND " . $dbFactory->getDownloadableDaysWhereSql('o');204 $where .= " = 1";205 $arrRet = $objQuery->select($col, $table, $where,206 array($customer_id, $order_id, $product_id, $product_class_id));207 return $arrRet[0];208 }209 210 /* パラメーター情報の初期化 */211 function lfInitParam(&$objFormParam) {212 $objFormParam->addParam("customer_id", "customer_id", INT_LEN, 'n', array("EXIST_CHECK","NUM_CHECK"));213 $objFormParam->addParam("order_id", "order_id", INT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK"));214 $objFormParam->addParam("product_id", "product_id", INT_LEN, 'n', array("EXIST_CHECK","NUM_CHECK"));215 $objFormParam->addParam("product_class_id", "product_class_id", INT_LEN, 'n', array("EXIST_CHECK","NUM_CHECK"));216 }217 218 /* 入力内容のチェック */219 function lfCheckError(&$objFormParam) {220 $objErr = new SC_CheckError_Ex($objFormParam->getHashArray());221 $objErr->arrErr = $objFormParam->checkError();222 return $objErr->arrErr;223 }224 225 /**226 357 * デストラクタ. 227 358 * -
branches/version-2_11-dev/data/class/pages/mypage/LC_Page_Mypage_History.php
r21071 r21354 96 96 $this->tpl_arrOrderDetail = $this->setMainListImage($this->tpl_arrOrderDetail); 97 97 $objPurchase->setDownloadableFlgTo($this->tpl_arrOrderDetail); 98 // モバイルダウンロード対応処理 99 $this->lfSetAU($this->tpl_arrOrderDetail); 98 100 // 受注メール送信履歴の取得 99 101 $this->tpl_arrMailHistory = $this->lfGetMailHistory($order_id); … … 164 166 return $arrOrderDetails; 165 167 } 168 169 /** 170 * 購入履歴商品にMIMETYPE、ファイル名をセット 171 * 172 * @param $arrOrderDetail 購入履歴の配列 173 * @return array MIMETYPE、ファイル名をセットした購入履歴の配列 174 */ 175 function lfSetMimetype($arrOrderDetails) { 176 $objHelperMobile = new SC_Helper_Mobile_Ex(); 177 $i = 0; 178 foreach ($arrOrderDetails as $arrOrderDetail) { 179 $objQuery =& SC_Query_Ex::getSingletonInstance(); 180 $arrProduct = $objQuery->select('down_realfilename,down_filename', 'dtb_products_class', 'product_id = ? AND product_class_id = ?', array($arrOrderDetail['product_id'],$arrOrderDetail['product_class_id'])); 181 $arrOrderDetails[$i]['mime_type'] = $objHelperMobile->getMimeType($arrProduct[0]['down_realfilename']); 182 $arrOrderDetails[$i]['down_filename'] = $arrProduct[0]['down_filename']; 183 $i++; 184 } 185 return $arrOrderDetails; 186 } 187 188 /** 189 * 特定キャリア(AU)モバイルダウンロード処理 190 * キャリアがAUのモバイル端末からダウンロードする場合は単純に 191 * Aタグでダウンロードできないケースがある為、対応する。 192 * 193 * @param integer $order_id 注文番号 194 * @param $arrOrderDetail 購入履歴の配列 195 */ 196 function lfSetAU($arrOrderDetails) { 197 $this->isAU = false; 198 // モバイル端末かつ、キャリアがAUの場合に処理を行う 199 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE && SC_MobileUserAgent::getCarrier() == 'ezweb'){ 200 // MIMETYPE、ファイル名のセット 201 $this->tpl_arrOrderDetail = $this->lfSetMimetype($arrOrderDetails); 202 $this->phpsessid = $_GET['PHPSESSID']; 203 $this->isAU = true; 204 } 205 } 166 206 } -
branches/version-2_11-dev/data/class/session/sessionfactory/SC_SessionFactory_UseRequest.php
r20970 r21354 158 158 if (!isset($sessionId)) { 159 159 $sessionId = @$_GET[session_name()]; 160 // AU動画音声ファイルダウンロード対策 161 // キャリアがAUで、動画、音声ファイルをダウンロードする際に 162 // SESSIONIDの後に余計なパラメータが付与され、セッションが無効になるケースがある 163 if (SC_MobileUserAgent::getCarrier() == "ezweb") { 164 $idArray = split("\?", $sessionId); 165 $sessionId = $idArray[0]; 166 } 160 167 } 161 168 if (!isset($sessionId)) {
Note: See TracChangeset
for help on using the changeset viewer.