Example #1
0
 function getFormFileList($temp_url, $save_url, $real_size = false)
 {
     $objBlob = new SC_Helper_Blob_Ex();
     $containerName = "saveimage";
     $arrRet = array();
     $cnt = 0;
     foreach ($this->keyname as $val) {
         if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") {
             // ファイルパスチェック(パスのスラッシュ/が連続しないようにする。)
             if (ereg("/\$", $temp_url)) {
                 $arrRet[$val]['filepath'] = $temp_url . $this->temp_file[$cnt];
             } else {
                 $arrRet[$val]['filepath'] = $temp_url . "/" . $this->temp_file[$cnt];
             }
             $arrRet[$val]['real_filepath'] = $this->temp_dir . $this->temp_file[$cnt];
         } elseif (isset($this->save_file[$cnt]) && $this->save_file[$cnt] != "") {
             // ファイルパスチェック(パスのスラッシュ/が連続しないようにする。)
             if (ereg("/\$", $save_url)) {
                 $arrRet[$val]['filepath'] = $save_url . $this->save_file[$cnt];
             } else {
                 $arrRet[$val]['filepath'] = $save_url . "/" . $this->save_file[$cnt];
             }
             //$arrRet[$val]['real_filepath'] = $this->save_dir . $this->save_file[$cnt];
             $arrRet[$val]['real_filepath'] = IMAGE_SAVE_URLPATH . $this->save_file[$cnt];
         }
         if (isset($arrRet[$val]['filepath']) && !empty($arrRet[$val]['filepath'])) {
             if ($real_size) {
                 //                    if(is_file($arrRet[$val]['real_filepath'])) {
                 if ($objBlob->blobExists($containerName, $this->save_file[$cnt])) {
                     //is_file($arrRet[$val]['real_filepath'])) {
                     list($width, $height) = getimagesize($arrRet[$val]['real_filepath']);
                 }
                 // ファイル横幅
                 $arrRet[$val]['width'] = $width;
                 // ファイル縦幅
                 $arrRet[$val]['height'] = $height;
             } else {
                 // ファイル横幅
                 $arrRet[$val]['width'] = $this->width[$cnt];
                 // ファイル縦幅
                 $arrRet[$val]['height'] = $this->height[$cnt];
             }
             // 表示名
             $arrRet[$val]['disp_name'] = $this->disp_name[$cnt];
         }
         $cnt++;
     }
     return $arrRet;
 }
 /**
  * ページのレイアウト情報を取得し, 設定する.
  *
  * 現在の 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);
 }
 /**
  * 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);
 }
 /**
  * アップロードファイルをBlobに保存する
  *
  * @param object $objUpFile SC_UploadFileインスタンス
  * @param object $objDownFile SC_UploadFileインスタンス
  * @param integer $product_id 商品ID
  * @return void
  */
 function lfSaveUploadFiles(&$objUpFile, &$objDownFile, $product_id)
 {
     // TODO: SC_UploadFile::moveTempFileの画像削除条件見直し要
     $objImage = new SC_Image_Ex($objUpFile->temp_dir);
     $objBlob = new SC_Helper_Blob_Ex();
     $arrKeyName = $objUpFile->keyname;
     $arrTempFile = $objUpFile->temp_file;
     $arrSaveFile = $objUpFile->save_file;
     $containerName = "saveimage";
     $arrImageKey = array();
     foreach ($arrTempFile as $key => $temp_file) {
         if ($temp_file) {
             $objBlob->saveBlob($containerName, $temp_file, $objImage->tmp_dir . $temp_file);
             unlink($objImage->tmp_dir . $temp_file);
             $arrImageKey[] = $arrKeyName[$key];
             if (!empty($arrSaveFile[$key]) && !$this->lfHasSameProductImage($product_id, $arrImageKey, $arrSaveFile[$key]) && !in_array($temp_file, $arrSaveFile)) {
                 $objBlob->deleteBlob($containerName, $arrSaveFile[$key]);
             }
         }
     }
     $objDownFile->moveTempDownFile();
 }
 /**
  * 登録を実行する.
  *
  * ファイルの作成に失敗した場合は, エラーメッセージを出力し,
  * データベースをロールバックする.
  *
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス
  * @return integer|boolean 登録が成功した場合, 登録したページID;
  *                         失敗した場合 false
  */
 function doRegister(&$objFormParam, &$objLayout)
 {
     $filename = $objFormParam->getValue('filename');
     $arrParams['device_type_id'] = $objFormParam->getValue('device_type_id');
     $arrParams['page_id'] = $objFormParam->getValue('page_id');
     $arrParams['header_chk'] = intval($objFormParam->getValue('header_chk')) === 1 ? 1 : 2;
     $arrParams['footer_chk'] = intval($objFormParam->getValue('footer_chk')) === 1 ? 1 : 2;
     $arrParams['tpl_data'] = $objFormParam->getValue('tpl_data');
     $arrParams['page_name'] = $objFormParam->getValue('page_name');
     $arrParams['url'] = USER_DIR . $filename . '.php';
     $arrParams['filename'] = USER_DIR . $filename;
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->begin();
     $page_id = $this->registerPage($arrParams, $objLayout);
     $objBlob = new SC_Helper_Blob_Ex();
     $containerName = $objBlob->getTemplateContainerName($arrParams['device_type_id']);
     /*
      * 新規登録時
      * or 編集可能な既存ページ編集時かつ, PHP ファイルが存在しない場合に,
      * PHP ファイルを作成する.
      */
     if (SC_Utils_Ex::isBlank($arrParams['page_id']) || $objLayout->isEditablePage($arrParams['device_type_id'], $arrParams['page_id'])) {
         if (!$this->createPHPFile($filename)) {
             $this->arrErr['err'] = '※ PHPファイルの作成に失敗しました<br />';
             $objQuery->rollback();
             return false;
         }
         // 新規登録時のみ $page_id を代入
         $arrParams['page_id'] = $page_id;
     }
     if ($objLayout->isEditablePage($arrParams['device_type_id'], $page_id)) {
         $tpl_path = $objLayout->getTemplatePath($arrParams['device_type_id']) . $arrParams['filename'] . '.tpl';
     } else {
         $tpl_path = $objLayout->getTemplatePath($arrParams['device_type_id']) . $filename . '.tpl';
     }
     if (!$objBlob->putBlobData($containerName, $arrParams['filename'] . '.tpl', $arrParams['tpl_data'])) {
         $this->arrErr['err'] = '※ TPLファイルの書き込みに失敗しました<br />';
         $objQuery->rollback();
         return false;
     }
     //既存のTPLが存在する場合は削除しておく
     if (file_exists($tpl_path)) {
         unlink($tpl_path);
     }
     $objQuery->commit();
     return $arrParams['page_id'];
 }
 /**
  * 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);
 }
 /**
  * 登録を実行する.
  *
  * ファイルの作成に失敗した場合は, エラーメッセージを出力し,
  * データベースをロールバックする.
  *
  * @param SC_FormParam $objFormParam SC_FormParam インスタンス
  * @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス
  * @return integer|boolean 登録が成功した場合, 登録したブロックID;
  *                         失敗した場合 false
  */
 function doRegister(&$objFormParam, &$objLayout)
 {
     $arrParams = $objFormParam->getHashArray();
     $objQuery =& SC_Query_Ex::getSingletonInstance();
     $objQuery->begin();
     // blod_id が空の場合は新規登録
     $is_new = SC_Utils_Ex::isBlank($arrParams['bloc_id']);
     $bloc_dir = $objLayout->getTemplatePath($arrParams['device_type_id']) . BLOC_DIR;
     // 既存データの重複チェック
     if (!$is_new) {
         $arrExists = $objLayout->getBlocs($arrParams['device_type_id'], 'bloc_id = ?', array($arrParams['bloc_id']));
         // 既存のファイルが存在する場合は削除しておく
         $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl';
         if (file_exists($exists_file)) {
             unlink($exists_file);
         }
     }
     $table = 'dtb_bloc';
     $arrValues = $objQuery->extractOnlyColsOf($table, $arrParams);
     $arrValues['tpl_path'] = $arrParams['filename'] . '.tpl';
     $arrValues['update_date'] = 'CURRENT_TIMESTAMP';
     $objBlob = new SC_Helper_Blob_Ex();
     $containerName = $objBlob->getTemplateContainerName($arrParams['device_type_id']);
     // 新規登録
     if ($is_new || SC_Utils_Ex::isBlank($arrExists)) {
         $objQuery->setOrder('');
         $arrValues['bloc_id'] = 1 + $objQuery->max('bloc_id', $table, 'device_type_id = ?', array($arrValues['device_type_id']));
         $arrValues['create_date'] = 'CURRENT_TIMESTAMP';
         $objQuery->insert($table, $arrValues);
     } else {
         $objQuery->update($table, $arrValues, 'bloc_id = ? AND device_type_id = ?', array($arrValues['bloc_id'], $arrValues['device_type_id']));
     }
     $bloc_path = $bloc_dir . $arrValues['tpl_path'];
     if (!$objBlob->putBlobData($containerName, BLOC_DIR . $arrValues['tpl_path'], $arrParams['bloc_html'])) {
         $this->arrErr['err'] = '※ ブロックの書き込みに失敗しました<br />';
         $objQuery->rollback();
         return false;
     }
     $objQuery->commit();
     return $arrValues['bloc_id'];
 }
Example #8
0
function lfDispStep0_1($objPage)
{
    global $objWebParam;
    global $objDBParam;
    $objBlob = new SC_Helper_Blob_Ex();
    //Azureで永続化する必要のあるコンテンツのディレクトリをコンテナとして作成
    $imageDir = "saveimage";
    $objBlob->createContainer($imageDir);
    $templateDir = "template" . TEMPLATE_NAME;
    $objBlob->createContainer($templateDir);
    $mobileTemplateDir = "template" . MOBILE_TEMPLATE_NAME;
    $objBlob->createContainer($mobileTemplateDir);
    $smartphoneTemplateDir = "template" . SMARTPHONE_TEMPLATE_NAME;
    $objBlob->createContainer($smartphoneTemplateDir);
    $downloadFileDir = "downsave";
    $objBlob->createContainer($downloadFileDir, false);
    // hiddenに入力値を保持
    $objPage->arrHidden = $objWebParam->getHashArray();
    // hiddenに入力値を保持
    $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray());
    $objPage->arrHidden['db_skip'] = $_POST['db_skip'];
    $objPage->arrHidden['agreement'] = $_POST['agreement'];
    $objPage->tpl_mainpage = 'step0_1.tpl';
    $objPage->tpl_mode = 'step0_1';
    // ファイルコピー
    //$objPage->copy_mess = SC_Utils_Ex::sfCopyDir("./save_image/", HTML_REALDIR . "upload/save_image/", $objPage->copy_mess);
    $objPage->copy_mess .= $objBlob->putBlobDir($imageDir, "./save_image/");
    $objPage->copy_mess .= $objBlob->putBlobDir($templateDir, TEMPLATE_REALDIR . BLOC_DIR, BLOC_DIR);
    $objPage->copy_mess .= $objBlob->putBlobDir($mobileTemplateDir, TEMPLATE_REALDIR . BLOC_DIR, BLOC_DIR);
    $objPage->copy_mess .= $objBlob->putBlobDir($smartphoneTemplateDir, TEMPLATE_REALDIR . BLOC_DIR, BLOC_DIR);
    $objPage->copy_mess .= $objBlob->putBlobDir($downloadFileDir, DOWN_SAVE_REALDIR);
    return $objPage;
}