[16394] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[22206] | 5 | * Copyright(c) 2000-2013 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() { |
---|
[21764] | 54 | parent::process(); |
---|
| 55 | $this->action(); |
---|
| 56 | } |
---|
[16394] | 57 | |
---|
[21764] | 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 | |
---|
[21456] | 69 | $file = NO_IMAGE_REALFILE; |
---|
[16394] | 70 | |
---|
[21456] | 71 | // NO_IMAGE_REALFILE以外のファイル名が渡された場合、ファイル名のチェックを行う |
---|
[21764] | 72 | if (strlen($arrForm['image']) >= 1 |
---|
| 73 | && $arrForm['image'] !== NO_IMAGE_REALFILE) { |
---|
[16394] | 74 | |
---|
[17967] | 75 | // ファイル名が正しく、ファイルが存在する場合だけ、$fileを設定 |
---|
| 76 | if (!$this->lfCheckFileName()) { |
---|
[21764] | 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']; |
---|
[16394] | 80 | } |
---|
| 81 | } |
---|
| 82 | |
---|
[21764] | 83 | // リサイズ画像の出力 |
---|
| 84 | $this->lfOutputImage($file, $arrForm['width'], $arrForm['height']); |
---|
[16394] | 85 | } |
---|
| 86 | |
---|
| 87 | /** |
---|
| 88 | * デストラクタ. |
---|
| 89 | * |
---|
| 90 | * @return void |
---|
| 91 | */ |
---|
| 92 | function destroy() { |
---|
| 93 | parent::destroy(); |
---|
| 94 | } |
---|
| 95 | |
---|
[21764] | 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')); |
---|
[21880] | 99 | $objFormParam->addParam('画像の高さ', 'height', STEXT_LEN, 'n', array('NUM_CHECK')); |
---|
[21764] | 100 | } |
---|
| 101 | |
---|
[20098] | 102 | /** |
---|
| 103 | * ファイル名の形式をチェック. |
---|
| 104 | * |
---|
| 105 | * @return boolean 正常な形式:true 不正な形式:false |
---|
| 106 | */ |
---|
[16394] | 107 | function lfCheckFileName() { |
---|
| 108 | //$pattern = '|^[0-9]+_[0-9a-z]+\.[a-z]{3}$|'; |
---|
| 109 | $pattern = '|\./|'; |
---|
[20538] | 110 | $file = trim($_GET['image']); |
---|
[21442] | 111 | if (preg_match_all($pattern, $file, $matches)) { |
---|
[16394] | 112 | return false; |
---|
| 113 | } else { |
---|
| 114 | return true; |
---|
| 115 | } |
---|
| 116 | } |
---|
[21764] | 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 | } |
---|
[16394] | 131 | } |
---|