source: branches/version-2_12-dev/data/class/pages/LC_Page_ResizeImage.php @ 22567

Revision 22567, 3.7 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

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