Пример #1
0
 /**
  * ページのレイアウト情報を取得し, 設定する.
  *
  * 現在の URL に応じたページのレイアウト情報を取得し, LC_Page インスタンスに
  * 設定する.
  *
  * @access public
  * @param LC_Page $objPage LC_Page インスタンス
  * @param boolean $preview プレビュー表示の場合 true
  * @param string $url ページのURL($_SERVER['PHP_SELF'] の情報)
  * @param integer $device_type_id 端末種別ID
  * @return void
  */
 function sfGetPageLayout(&$objPage, $preview = false, $url = "", $device_type_id = DEVICE_TYPE_PC)
 {
     // URLを元にページ情報を取得
     if ($preview === false) {
         $url = preg_replace('|^' . preg_quote(ROOT_URLPATH) . '|', '', $url);
         $arrPageData = $this->getPageProperties($device_type_id, null, 'url = ?', array($url));
     } else {
         $arrPageData = $this->getPageProperties($device_type_id, 0);
     }
     $objPage->tpl_mainpage = $this->getTemplatePath($device_type_id) . $arrPageData[0]['filename'] . ".tpl";
     $objPage->arrPageLayout =& $arrPageData[0];
     $objBlob = new SC_Helper_Blob_Ex();
     $containerName = $objBlob->getTemplateContainerName($device_type_id);
     /** pageのテンプレートがなければBlobから取得する */
     if (!is_file($objPage->tpl_mainpage)) {
         $objBlob->getBlob($containerName, $arrPageData[0]['filename'] . ".tpl", $objPage->tpl_mainpage);
     }
     // ページタイトルを設定
     if (SC_Utils_Ex::isBlank($objPage->tpl_title)) {
         $objPage->tpl_title = $objPage->arrPageLayout['page_name'];
     }
     // 該当ページのブロックを取得し, 配置する
     $masterData = new SC_DB_MasterData();
     $arrTarget = $masterData->getMasterData("mtb_target");
     $arrBlocs = $this->getBlocPositions($device_type_id, $objPage->arrPageLayout['page_id']);
     // php_path, tpl_path が存在するものを, 各ターゲットに配置
     foreach (array_keys($arrTarget) as $target_id) {
         foreach ($arrBlocs as $arrBloc) {
             if ($arrBloc['target_id'] != $target_id) {
                 continue;
             }
             /* Blobからすでにファイルを取得している場合*/
             if (is_file($arrBloc['tpl_path'])) {
                 $objPage->arrPageLayout[$arrTarget[$target_id]][] = $arrBloc;
             } else {
                 if ($objBlob->blobExists($containerName, $arrBloc['filename'] . ".tpl")) {
                     $localFilename = $arrBloc['tpl_path'];
                     $objBlob->getBlob($containerName, $arrBloc['filename'] . ".tpl", $localFilename);
                     $objPage->arrPageLayout[$arrTarget[$target_id]][] = $arrBloc;
                 } else {
                     $error = "ブロックが見つかりません\n" . "tpl_path: " . $arrBloc['tpl_path'] . "\n" . "php_path: " . $arrBloc['php_path'];
                     GC_Utils_Ex::gfPrintLog($error);
                 }
             }
         }
     }
     // カラム数を取得する
     $objPage->tpl_column_num = $this->getColumnNum($objPage->arrPageLayout);
 }
Пример #2
0
 /**
  * Page のプロセス.
  *
  * @return void
  */
 function process()
 {
     $objThumb = new gdthumb();
     $objBlob = new SC_Helper_Blob_Ex();
     $file = NO_IMAGE_REALDIR;
     // NO_IMAGE_REALDIR以外のファイル名が渡された場合、ファイル名のチェックを行う
     if (strlen($_GET['image']) >= 1 && $_GET['image'] !== NO_IMAGE_REALDIR) {
         // ファイル名が正しく、ファイルが存在する場合だけ、$fileを設定
         if (!$this->lfCheckFileName()) {
             GC_Utils_Ex::gfPrintLog('invalid access :resize_image.php $_GET[\'image\']=' . $_GET['image']);
         } else {
             $objBlob->getBlob("saveimage", $_GET['image'], IMAGE_TEMP_REALDIR . $_GET['image']);
             $file = IMAGE_TEMP_REALDIR . $_GET['image'];
         }
     }
     $ret = $objThumb->Main($file, $_GET['width'], $_GET['height'], "", true);
 }
Пример #3
0
 /**
  * Page のResponse.
  *
  * todo たいした処理でないのに異常に処理が重い
  * @return void
  */
 function sendResponse()
 {
     $this->objDisplay->noAction();
     // パラメーター取得
     $customer_id = $_SESSION['customer']['customer_id'];
     $order_id = $_GET['order_id'];
     $product_id = $_GET['product_id'];
     $product_class_id = $_GET['product_class_id'];
     //DBから商品情報の読込
     $arrForm = $this->lfGetRealFileName($customer_id, $order_id, $product_id, $product_class_id);
     //ファイル情報が無い場合はNG
     if ($arrForm["down_realfilename"] == "") {
         SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND, "", true);
     }
     //ファイルそのものが無い場合もとりあえずNG
     $realpath = DOWN_SAVE_REALDIR . $arrForm["down_realfilename"];
     $objBlob = new SC_Helper_Blob_Ex();
     $objBlob->getBlob("downsave", $arrForm['down_realfilename'], $realpath);
     if (!file_exists($realpath)) {
         SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND, "", true);
     }
     //ファイル名をエンコードする Safariの対策はUTF-8で様子を見る
     $encoding = "Shift_JIS";
     if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari')) {
         $encoding = "UTF-8";
     }
     $sdown_filename = mb_convert_encoding($arrForm["down_filename"], $encoding, 'auto');
     // flushなどを利用しているので、現行のSC_Displayは利用できません。
     // SC_DisplayやSC_Responseに大容量ファイルレスポンスが実装されたら移行可能だと思います。
     // 拡張子を取得
     $extension = pathinfo($realpath, PATHINFO_EXTENSION);
     $contentType = $this->defaultContentType;
     // 拡張ContentType判定(拡張子をキーに拡張ContentType対象か判断)
     if (isset($this->arrContentType[$extension])) {
         // 拡張ContentType対象の場合は、ContentTypeを変更
         $contentType = $this->arrContentType[$extension];
     }
     header("Content-Type: " . $contentType);
     //ファイル名指定
     header('Content-Disposition: attachment; filename="' . $sdown_filename . '"');
     header("Content-Transfer-Encoding: binary");
     //キャッシュ無効化
     header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
     header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
     //IE6+SSL環境下は、キャッシュ無しでダウンロードできない
     header("Cache-Control: private");
     header("Pragma: private");
     //ファイルサイズ指定
     $zv_filesize = filesize($realpath);
     header("Content-Length: " . $zv_filesize);
     set_time_limit(0);
     ob_end_flush();
     flush();
     //ファイル読み込み
     $handle = fopen($realpath, 'rb');
     if ($handle === false) {
         SC_Utils_Ex::sfDispSiteError(DOWNFILE_NOT_FOUND, "", true);
         exit;
     }
     while (!feof($handle)) {
         echo fread($handle, DOWNLOAD_BLOCK * 1024);
         ob_flush();
         flush();
     }
     fclose($handle);
 }