/** * 表示するファイルにエラーチェックを行う * * @param FormParam $objFormParam FormParam インスタンス * @return boolean $file_check_flg エラーチェックの結果 */ public function checkErrorDispFile($objFormParam) { $file_check_flg = false; // FIXME パスのチェック関数が必要 $file = $objFormParam->getValue('file'); $path_exists = Utils::checkFileExistsWithInBasePath($file, USER_REALDIR); if ($path_exists) { $file_check_flg = true; } return $file_check_flg; }
/** * Page のアクション. * * @return void */ public function action() { // フォーム操作クラス $objFormParam = Application::alias('eccube.form_param'); // パラメーター情報の初期化 $this->lfInitParam($objFormParam); $objFormParam->setParam($this->createSetParam($_POST)); $objFormParam->convParam(); // ファイル管理クラス $objUpFile = new UploadFile($objFormParam->getValue('now_dir'), $objFormParam->getValue('now_dir')); // ファイル情報の初期化 $this->lfInitFile($objUpFile); // ファイル操作クラス /* @var $objFileManager FileManagerHelper */ $objFileManager = Application::alias('eccube.helper.file_manager'); switch ($this->getMode()) { // フォルダ移動 case 'move': $objFormParam = Application::alias('eccube.form_param'); $this->lfInitParamModeMove($objFormParam); $objFormParam->setParam($this->createSetParam($_POST)); $objFormParam->convParam(); $this->arrErr = $objFormParam->checkError(); if (Utils::isBlank($this->arrErr)) { $now_dir = $this->lfCheckSelectDir($objFormParam, $objFormParam->getValue('tree_select_file')); $objFormParam->setValue('now_dir', $now_dir); } break; // ファイル表示 // ファイル表示 case 'view': $objFormParam = Application::alias('eccube.form_param'); $this->lfInitParamModeView($objFormParam); $objFormParam->setParam($this->createSetParam($_POST)); $objFormParam->convParam(); $this->arrErr = $objFormParam->checkError(); if (Utils::isBlank($this->arrErr)) { if ($this->tryView($objFormParam)) { $pattern = '/' . preg_quote($objFormParam->getValue('top_dir'), '/') . '/'; $file_url = htmlspecialchars(preg_replace($pattern, '', $objFormParam->getValue('select_file'))); $tpl_onload = "eccube.openWindow('./file_view.php?file=" . $file_url . "', 'user_data', '600', '400');"; $this->setTplOnLoad($tpl_onload); } } break; // ファイルダウンロード // ファイルダウンロード case 'download': $objFormParam = Application::alias('eccube.form_param'); $this->lfInitParamModeView($objFormParam); $objFormParam->setParam($this->createSetParam($_POST)); $objFormParam->convParam(); $this->arrErr = $objFormParam->checkError(); if (Utils::isBlank($this->arrErr)) { if (is_dir($objFormParam->getValue('select_file'))) { $disp_error = '※ ディレクトリをダウンロードすることは出来ません。<br/>'; $this->setDispError('select_file', $disp_error); } else { $path_exists = Utils::checkFileExistsWithInBasePath($objFormParam->getValue('select_file'), USER_REALDIR); if ($path_exists) { // ファイルダウンロード $objFileManager->sfDownloadFile($objFormParam->getValue('select_file')); Application::alias('eccube.response')->actionExit(); } } } break; // ファイル削除 // ファイル削除 case 'delete': $objFormParam = Application::alias('eccube.form_param'); $this->lfInitParamModeView($objFormParam); $objFormParam->setParam($this->createSetParam($_POST)); $objFormParam->convParam(); $this->arrErr = $objFormParam->checkError(); $path_exists = Utils::checkFileExistsWithInBasePath($objFormParam->getValue('select_file'), USER_REALDIR); if (Utils::isBlank($this->arrErr) && $path_exists) { Application::alias('eccube.helper.file_manager')->deleteFile($objFormParam->getValue('select_file')); } break; // ファイル作成 // ファイル作成 case 'create': $objFormParam = Application::alias('eccube.form_param'); $this->lfInitParamModeCreate($objFormParam); $objFormParam->setParam($this->createSetParam($_POST)); $objFormParam->convParam(); $this->arrErr = $objFormParam->checkError(); if (Utils::isBlank($this->arrErr)) { if (!$this->tryCreateDir($objFileManager, $objFormParam)) { $disp_error = '※ ' . htmlspecialchars($objFormParam->getValue('create_file'), ENT_QUOTES) . 'の作成に失敗しました。<br/>'; $this->setDispError('create_file', $disp_error); } else { $tpl_onload = "alert('フォルダを作成しました。');"; $this->setTplOnLoad($tpl_onload); } } break; // ファイルアップロード // ファイルアップロード case 'upload': // 画像保存処理 $ret = $objUpFile->makeTempFile('upload_file', false); if (Utils::isBlank($ret)) { $tpl_onload = "alert('ファイルをアップロードしました。');"; $this->setTplOnLoad($tpl_onload); } else { $this->setDispError('upload_file', $ret); } break; // 初期表示 // 初期表示 default: break; } // 値をテンプレートに渡す $this->arrParam = $objFormParam->getHashArray(); // 現在の階層がルートディレクトリかどうかテンプレートに渡す $this->setIsTopDir($objFormParam); // 現在の階層より一つ上の階層をテンプレートに渡す $this->setParentDir($objFormParam); // 現在いる階層(表示用)をテンプレートに渡す $this->setDispPath($objFormParam); // 現在のディレクトリ配下のファイル一覧を取得 $this->arrFileList = $objFileManager->sfGetFileList($objFormParam->getValue('now_dir')); // 現在の階層のディレクトリをテンプレートに渡す $this->setDispParam('tpl_now_file', $objFormParam->getValue('now_dir')); // ディレクトリツリー表示 $this->setDispTree($objFileManager, $objFormParam); }