[16394] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[20764] | 5 | * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved. |
---|
[16394] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 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. |
---|
[16394] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
[20534] | 25 | require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; |
---|
[16394] | 26 | |
---|
| 27 | /** |
---|
| 28 | * リサイズイメージ のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[20344] | 34 | class LC_Page_ResizeImage extends LC_Page_Ex { |
---|
[16394] | 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 | $objThumb = new gdthumb(); |
---|
| 55 | |
---|
[21456] | 56 | $file = NO_IMAGE_REALFILE; |
---|
[16394] | 57 | |
---|
[21456] | 58 | // NO_IMAGE_REALFILE以外のファイル名が渡された場合、ファイル名のチェックを行う |
---|
| 59 | if (strlen($_GET['image']) >= 1 && $_GET['image'] !== NO_IMAGE_REALFILE) { |
---|
[16394] | 60 | |
---|
[17967] | 61 | // ファイル名が正しく、ファイルが存在する場合だけ、$fileを設定 |
---|
| 62 | if (!$this->lfCheckFileName()) { |
---|
[20538] | 63 | GC_Utils_Ex::gfPrintLog('invalid access :resize_image.php $_GET[\'image\']=' . $_GET['image']); |
---|
[16394] | 64 | } |
---|
[19805] | 65 | else if (file_exists(IMAGE_SAVE_REALDIR . $_GET['image'])) { |
---|
| 66 | $file = IMAGE_SAVE_REALDIR . $_GET['image']; |
---|
[17967] | 67 | } |
---|
[16394] | 68 | } |
---|
| 69 | |
---|
[21515] | 70 | $objThumb->Main($file, $_GET['width'], $_GET['height'], '', true); |
---|
[16394] | 71 | } |
---|
| 72 | |
---|
| 73 | /** |
---|
| 74 | * デストラクタ. |
---|
| 75 | * |
---|
| 76 | * @return void |
---|
| 77 | */ |
---|
| 78 | function destroy() { |
---|
| 79 | parent::destroy(); |
---|
| 80 | } |
---|
| 81 | |
---|
[20098] | 82 | /** |
---|
| 83 | * ファイル名の形式をチェック. |
---|
| 84 | * |
---|
| 85 | * @return boolean 正常な形式:true 不正な形式:false |
---|
| 86 | */ |
---|
[16394] | 87 | function lfCheckFileName() { |
---|
| 88 | //$pattern = '|^[0-9]+_[0-9a-z]+\.[a-z]{3}$|'; |
---|
| 89 | $pattern = '|\./|'; |
---|
[20538] | 90 | $file = trim($_GET['image']); |
---|
[21442] | 91 | if (preg_match_all($pattern, $file, $matches)) { |
---|
[16394] | 92 | return false; |
---|
| 93 | } else { |
---|
| 94 | return true; |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | } |
---|