source: branches/version-2_12-multilang/data/class/pages/admin/contents/LC_Page_Admin_Contents_FileView.php @ 22492

Revision 22492, 4.0 KB checked in by m_uehara, 11 years ago (diff)

#2084 メッセージIDの振り直し

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2012 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
25require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
26
27/**
28 * ファイル表示 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Contents_FileView extends LC_Page_Admin_Ex {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46    }
47
48    /**
49     * Page のプロセス.
50     *
51     * @return void
52     */
53    function process() {
54        $this->action();
55        $this->sendResponse();
56    }
57
58    /**
59     * Page のアクション.
60     *
61     * @return void
62     */
63    function action() {
64
65        switch ($this->getMode()) {
66            default:
67                // フォーム操作クラス
68                $objFormParam = new SC_FormParam_Ex();
69                // パラメーター情報の初期化
70                $this->lfInitParam($objFormParam);
71                $objFormParam->setParam($_GET);
72                $objFormParam->convParam();
73
74                // 表示するファイルにエラーチェックを行う
75                if ($this->checkErrorDispFile($objFormParam)) {
76                    $this->execFileView($objFormParam);
77                } else {
78                    SC_Utils_Ex::sfDispError('');
79                }
80
81                SC_Response_Ex::actionExit();
82            break;
83        }
84    }
85
86    /**
87     * デストラクタ.
88     *
89     * @return void
90     */
91    function destroy() {
92        parent::destroy();
93    }
94
95    /**
96     * 初期化を行う.
97     *
98     * @param SC_FormParam $objFormParam SC_FormParamインスタンス
99     * @return void
100     */
101    function lfInitParam(&$objFormParam) {
102        $objFormParam->addParam(t('c_File name_01'), 'file', MTEXT_LEN, 'a', array('EXIST_CHECK'));
103    }
104
105    /**
106     * 表示するファイルにエラーチェックを行う
107     *
108     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
109     * @return boolen $file_check_flg エラーチェックの結果
110     */
111    function checkErrorDispFile($objFormParam) {
112        $file_check_flg = false;
113
114        // FIXME パスのチェック関数が必要
115        $file = $objFormParam->getValue('file');
116
117        if (!preg_match('|\./|', $file)) {
118            $file_check_flg = true;
119        }
120
121        return $file_check_flg;
122    }
123
124    /**
125     * ファイル内容を表示する
126     *
127     * @return void
128     */
129    function execFileView($objFormParam) {
130        $file = $objFormParam->getValue('file');
131
132        // ソースとして表示するファイルを定義(直接実行しないファイル)
133        $arrViewFile = array(
134            'html',
135            'htm',
136            'tpl',
137            'php',
138            'css',
139            'js',
140        );
141
142        $extension = pathinfo($file, PATHINFO_EXTENSION);
143
144        if (in_array($extension, $arrViewFile)) {
145            $objFileManager = new SC_Helper_FileManager_Ex();
146            // ファイルを読み込んで表示
147            header("Content-type: text/plain\n\n");
148            echo $objFileManager->sfReadFile(USER_REALDIR . $file);
149        } else {
150            SC_Response_Ex::sendRedirect(USER_URL . $file);
151        }
152    }
153}
Note: See TracBrowser for help on using the repository browser.