| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * This file is part of EC-CUBE |
|---|
| 4 | * |
|---|
| 5 | * Copyright(c) 2000-2010 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_PATH . "pages/LC_Page.php"); |
|---|
| 26 | require_once(DATA_PATH . "module/gdthumb.php"); |
|---|
| 27 | |
|---|
| 28 | /** |
|---|
| 29 | * リサイズイメージ のページクラス. |
|---|
| 30 | * |
|---|
| 31 | * @package Page |
|---|
| 32 | * @author LOCKON CO.,LTD. |
|---|
| 33 | * @version $Id$ |
|---|
| 34 | */ |
|---|
| 35 | class LC_Page_ResizeImage extends LC_Page { |
|---|
| 36 | |
|---|
| 37 | // }}} |
|---|
| 38 | // {{{ functions |
|---|
| 39 | |
|---|
| 40 | /** |
|---|
| 41 | * Page を初期化する. |
|---|
| 42 | * |
|---|
| 43 | * @return void |
|---|
| 44 | */ |
|---|
| 45 | function init() { |
|---|
| 46 | parent::init(); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | /** |
|---|
| 50 | * Page のプロセス. |
|---|
| 51 | * |
|---|
| 52 | * @return void |
|---|
| 53 | */ |
|---|
| 54 | function process() { |
|---|
| 55 | $objThumb = new gdthumb(); |
|---|
| 56 | |
|---|
| 57 | $file = NO_IMAGE_DIR; |
|---|
| 58 | |
|---|
| 59 | // NO_IMAGE_DIR以外のファイル名が渡された場合、ファイル名のチェックを行う |
|---|
| 60 | if ( isset($_GET['image']) && $_GET['image'] !== NO_IMAGE_DIR) { |
|---|
| 61 | |
|---|
| 62 | // ファイル名が正しい場合だけ、$fileを設定 |
|---|
| 63 | if ( $this->lfCheckFileName() === true ) { |
|---|
| 64 | $file = IMAGE_SAVE_DIR . $_GET['image']; |
|---|
| 65 | } else { |
|---|
| 66 | GC_Utils_Ex::gfPrintLog('invalid access :resize_image.php $_GET["image"]=' . $_GET['image']); |
|---|
| 67 | } |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | if(file_exists($file)){ |
|---|
| 71 | $objThumb->Main($file, $_GET["width"], $_GET["height"], "", true); |
|---|
| 72 | }else{ |
|---|
| 73 | $objThumb->Main(NO_IMAGE_DIR, $_GET["width"], $_GET["height"], "", true); |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | /** |
|---|
| 78 | * デストラクタ. |
|---|
| 79 | * |
|---|
| 80 | * @return void |
|---|
| 81 | */ |
|---|
| 82 | function destroy() { |
|---|
| 83 | parent::destroy(); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | // ファイル名の形式をチェック |
|---|
| 87 | function lfCheckFileName() { |
|---|
| 88 | //$pattern = '|^[0-9]+_[0-9a-z]+\.[a-z]{3}$|'; |
|---|
| 89 | $pattern = '|\./|'; |
|---|
| 90 | $file = trim($_GET["image"]); |
|---|
| 91 | if ( preg_match_all($pattern, $file, $matches) ) { |
|---|
| 92 | return false; |
|---|
| 93 | } else { |
|---|
| 94 | return true; |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | } |
|---|
| 98 | ?> |
|---|