source: branches/version-2_13_0/data/class/pages/admin/contents/LC_Page_Admin_Contents_FileView.php @ 23126

Revision 23126, 3.9 KB checked in by m_uehara, 11 years ago (diff)

#2348 r23116 - r23125 をマージ

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