1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | // {{{ requires |
---|
25 | require_once(CLASS_REALDIR . "pages/admin/LC_Page_Admin.php"); |
---|
26 | require_once(CLASS_EX_REALDIR . "helper_extends/SC_Helper_FileManager_Ex.php"); |
---|
27 | |
---|
28 | /** |
---|
29 | * ファイル表示 のページクラス. |
---|
30 | * |
---|
31 | * @package Page |
---|
32 | * @author LOCKON CO.,LTD. |
---|
33 | * @version $Id$ |
---|
34 | */ |
---|
35 | class LC_Page_Admin_Contents_FileView extends LC_Page_Admin { |
---|
36 | |
---|
37 | // }}} |
---|
38 | // {{{ functions |
---|
39 | |
---|
40 | /** |
---|
41 | * Page を初期化する. |
---|
42 | * |
---|
43 | * @return void |
---|
44 | */ |
---|
45 | function init() { |
---|
46 | parent::init(); |
---|
47 | } |
---|
48 | |
---|
49 | /** |
---|
50 | * Page のプロセス. |
---|
51 | * |
---|
52 | * @return void |
---|
53 | */ |
---|
54 | function process() { |
---|
55 | $this->action(); |
---|
56 | $this->sendResponse(); |
---|
57 | } |
---|
58 | |
---|
59 | /** |
---|
60 | * Page のアクション. |
---|
61 | * |
---|
62 | * @return void |
---|
63 | */ |
---|
64 | function action() { |
---|
65 | // ユーザー認証 |
---|
66 | SC_Utils_Ex::sfIsSuccess(new SC_Session()); |
---|
67 | |
---|
68 | switch($this->getMode()){ |
---|
69 | default: |
---|
70 | // フォーム操作クラス |
---|
71 | $objFormParam = new SC_FormParam(); |
---|
72 | // パラメータ情報の初期化 |
---|
73 | $this->lfInitParam($objFormParam); |
---|
74 | $objFormParam->setParam($_GET); |
---|
75 | $objFormParam->convParam(); |
---|
76 | |
---|
77 | // 表示するファイルにエラーチェックを行う |
---|
78 | if ($this->checkErrorDispFile($objFormParam)) { |
---|
79 | $this->execFileView($objFormParam); |
---|
80 | } else { |
---|
81 | SC_Utils_Ex::sfDispError(''); |
---|
82 | } |
---|
83 | exit; |
---|
84 | break; |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | /** |
---|
89 | * デストラクタ. |
---|
90 | * |
---|
91 | * @return void |
---|
92 | */ |
---|
93 | function destroy() { |
---|
94 | parent::destroy(); |
---|
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 | } |
---|
151 | } |
---|
152 | ?> |
---|