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 |
---|
25 | require_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 | */ |
---|
34 | class LC_Page_ResizeImage extends LC_Page_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 | parent::process(); |
---|
55 | $this->action(); |
---|
56 | } |
---|
57 | |
---|
58 | /** |
---|
59 | * Page のAction. |
---|
60 | * |
---|
61 | * @return void |
---|
62 | */ |
---|
63 | function action() { |
---|
64 | $objFormParam = new SC_FormParam_Ex(); |
---|
65 | $this->lfInitParam($objFormParam); |
---|
66 | $objFormParam->setParam($_GET); |
---|
67 | $arrForm = $objFormParam->getHashArray(); |
---|
68 | |
---|
69 | $file = NO_IMAGE_REALFILE; |
---|
70 | |
---|
71 | // NO_IMAGE_REALFILE以外のファイル名が渡された場合、ファイル名のチェックを行う |
---|
72 | if (strlen($arrForm['image']) >= 1 |
---|
73 | && $arrForm['image'] !== NO_IMAGE_REALFILE) { |
---|
74 | |
---|
75 | // ファイル名が正しく、ファイルが存在する場合だけ、$fileを設定 |
---|
76 | if (!$this->lfCheckFileName()) { |
---|
77 | GC_Utils_Ex::gfPrintLog('invalid access :resize_image.php image=' . $arrForm['image']); |
---|
78 | } elseif (file_exists(IMAGE_SAVE_REALDIR . $arrForm['image'])) { |
---|
79 | $file = IMAGE_SAVE_REALDIR . $arrForm['image']; |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | // リサイズ画像の出力 |
---|
84 | $this->lfOutputImage($file, $arrForm['width'], $arrForm['height']); |
---|
85 | } |
---|
86 | |
---|
87 | /** |
---|
88 | * デストラクタ. |
---|
89 | * |
---|
90 | * @return void |
---|
91 | */ |
---|
92 | function destroy() { |
---|
93 | parent::destroy(); |
---|
94 | } |
---|
95 | |
---|
96 | function lfInitParam(&$objFormParam) { |
---|
97 | $objFormParam->addParam('画像ファイル名', 'image', STEXT_LEN, 'a', array('MAX_LENGTH_CHECK')); |
---|
98 | $objFormParam->addParam('画像の幅', 'width', STEXT_LEN, 'n', array('NUM_CHECK')); |
---|
99 | $objFormParam->addParam('画像の高さ', 'width', STEXT_LEN, 'n', array('NUM_CHECK')); |
---|
100 | } |
---|
101 | |
---|
102 | /** |
---|
103 | * ファイル名の形式をチェック. |
---|
104 | * |
---|
105 | * @return boolean 正常な形式:true 不正な形式:false |
---|
106 | */ |
---|
107 | function lfCheckFileName() { |
---|
108 | //$pattern = '|^[0-9]+_[0-9a-z]+\.[a-z]{3}$|'; |
---|
109 | $pattern = '|\./|'; |
---|
110 | $file = trim($_GET['image']); |
---|
111 | if (preg_match_all($pattern, $file, $matches)) { |
---|
112 | return false; |
---|
113 | } else { |
---|
114 | return true; |
---|
115 | } |
---|
116 | } |
---|
117 | |
---|
118 | /** |
---|
119 | * 画像の出力 |
---|
120 | * |
---|
121 | * @param string $file 画像ファイル名 |
---|
122 | * @param integer $width 画像の幅 |
---|
123 | * @param integer $height 画像の高さ |
---|
124 | * |
---|
125 | * @return void |
---|
126 | */ |
---|
127 | function lfOutputImage($file, $width, $height) { |
---|
128 | $objThumb = new gdthumb(); |
---|
129 | $objThumb->Main($file, $width, $height, '', true); |
---|
130 | } |
---|
131 | } |
---|