Changeset 20209
- Timestamp:
- 2011/02/19 21:39:14 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_FileView.php
r20116 r20209 63 63 */ 64 64 function action() { 65 // FIXME パスのチェック関数が必要66 if (preg_match('|\./|', $_GET['file'])) {67 SC_Utils_Ex::sfDispError('');68 }69 65 // ユーザー認証 70 66 SC_Utils_Ex::sfIsSuccess(new SC_Session()); 71 67 72 // ソースとして表示するファイルを定義(直接実行しないファイル) 73 $arrViewFile = array( 74 'html', 75 'htm', 76 'tpl', 77 'php', 78 'css', 79 'js', 80 ); 68 switch($this->getMode()){ 69 default: 70 // フォーム操作クラス 71 $objFormParam = new SC_FormParam(); 72 // パラメータ情報の初期化 73 $this->lfInitParam($objFormParam); 74 $objFormParam->setParam($_GET); 75 $objFormParam->convParam(); 81 76 82 // 拡張子取得 83 $arrResult = split('\.', $_GET['file']); 84 $ext = $arrResult[count($arrResult)-1]; 85 86 // ファイル内容表示 87 if(in_array($ext, $arrViewFile)) { 88 $objFileManager = new SC_Helper_FileManager_Ex(); 89 // ファイルを読み込んで表示 90 header("Content-type: text/plain\n\n"); 91 print($objFileManager->sfReadFile(USER_REALDIR . $_GET['file'])); 92 } else { 93 SC_Response_Ex::sendRedirect(USER_URL . $_GET['file']); 77 // 表示するファイルにエラーチェックを行う 78 if ($this->checkErrorDispFile($objFormParam)) { 79 $this->execFileView($objFormParam); 80 } else { 81 SC_Utils_Ex::sfDispError(''); 82 } 83 exit; 84 break; 94 85 } 95 exit;96 86 } 97 87 … … 104 94 parent::destroy(); 105 95 } 96 97 /** 98 * 初期化を行う. 99 * 100 * @param SC_FormParam $objFormParam SC_FormParamインスタンス 101 * @return void 102 */ 103 function lfInitParam(&$objFormParam) { 104 $objFormParam->addParam("ファイル名", "file", MTEXT_LEN, "a", array("EXIST_CHECK")); 105 } 106 107 /** 108 * 表示するファイルにエラーチェックを行う 109 * 110 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 111 * @return boolen $file_check_flg エラーチェックの結果 112 */ 113 function checkErrorDispFile($objFormParam) { 114 $file_check_flg = false; 115 116 // FIXME パスのチェック関数が必要 117 $file = $objFormParam->getValue('file'); 118 119 // ソースとして表示するファイルを定義(直接実行しないファイル) 120 $arrViewFile = array( 121 'html', 122 'htm', 123 'tpl', 124 'php', 125 'css', 126 'js', 127 ); 128 129 // 拡張子取得 130 $arrResult = split('\.', $objFormParam->getValue('file')); 131 $ext = $arrResult[count($arrResult)-1]; 132 133 if (!preg_match('|\./|', $file) && in_array($ext, $arrViewFile)) { 134 $file_check_flg = true; 135 } 136 137 return $file_check_flg; 138 } 139 140 /** 141 * ファイル内容を表示する 142 * 143 * @return void 144 */ 145 function execFileView($objFormParam) { 146 $objFileManager = new SC_Helper_FileManager_Ex(); 147 // ファイルを読み込んで表示 148 header("Content-type: text/plain\n\n"); 149 print($objFileManager->sfReadFile(USER_REALDIR . $objFormParam->getValue('file'))); 150 } 106 151 } 107 152 ?>
Note: See TracChangeset
for help on using the changeset viewer.