source: branches/version-2_13-dev/data/class/pages/LC_Page_ResizeImage.php @ 22856

Revision 22856, 3.7 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。もう少し整えたいが、一旦現状コミット。
  • 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/LC_Page_Ex.php';
25
26/**
27 * リサイズイメージ のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_ResizeImage extends LC_Page_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    function init()
41    {
42        parent::init();
43    }
44
45    /**
46     * Page のプロセス.
47     *
48     * @return void
49     */
50    function process()
51    {
52        parent::process();
53        $this->action();
54    }
55
56    /**
57     * Page のAction.
58     *
59     * @return void
60     */
61    function action()
62    {
63        $objFormParam = new SC_FormParam_Ex();
64        $this->lfInitParam($objFormParam);
65        $objFormParam->setParam($_GET);
66        $arrForm  = $objFormParam->getHashArray();
67
68        $file = NO_IMAGE_REALFILE;
69
70        // NO_IMAGE_REALFILE以外のファイル名が渡された場合、ファイル名のチェックを行う
71        if (strlen($arrForm['image']) >= 1
72            && $arrForm['image'] !== NO_IMAGE_REALFILE) {
73            // ファイル名が正しく、ファイルが存在する場合だけ、$fileを設定
74            if (!$this->lfCheckFileName()) {
75                GC_Utils_Ex::gfPrintLog('invalid access :resize_image.php image=' . $arrForm['image']);
76            } elseif (file_exists(IMAGE_SAVE_REALDIR . $arrForm['image'])) {
77                $file = IMAGE_SAVE_REALDIR . $arrForm['image'];
78            }
79        }
80
81        // リサイズ画像の出力
82        $this->lfOutputImage($file, $arrForm['width'], $arrForm['height']);
83    }
84
85    /**
86     * デストラクタ.
87     *
88     * @return void
89     */
90    function destroy()
91    {
92        parent::destroy();
93    }
94
95    function lfInitParam(&$objFormParam)
96    {
97        $objFormParam->addParam('画像ファイル名', 'image', STEXT_LEN, 'a',  array('MAX_LENGTH_CHECK'));
98        $objFormParam->addParam('画像の幅', 'width', STEXT_LEN, 'n',  array('NUM_CHECK'));
99        $objFormParam->addParam('画像の高さ', 'height', STEXT_LEN, 'n',  array('NUM_CHECK'));
100    }
101
102    /**
103     * ファイル名の形式をチェック.
104     *
105     * @return boolean 正常な形式:true 不正な形式:false
106     */
107    function lfCheckFileName()
108    {
109        //$pattern = '|^[0-9]+_[0-9a-z]+\.[a-z]{3}$|';
110        $pattern = '|\./|';
111        $file    = trim($_GET['image']);
112        if (preg_match_all($pattern, $file, $matches)) {
113            return false;
114        } else {
115            return true;
116        }
117    }
118
119    /**
120     * 画像の出力
121     *
122     * @param string $file 画像ファイル名
123     * @param integer $width 画像の幅
124     * @param integer $height 画像の高さ
125     *
126     * @return void
127     */
128    function lfOutputImage($file, $width, $height)
129    {
130        $objThumb = new gdthumb();
131        $objThumb->Main($file, $width, $height, '', true);
132    }
133}
Note: See TracBrowser for help on using the repository browser.