[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 | |
---|
[20534] | 24 | require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; |
---|
[16394] | 25 | |
---|
| 26 | /** |
---|
| 27 | * リサイズイメージ のページクラス. |
---|
| 28 | * |
---|
| 29 | * @package Page |
---|
| 30 | * @author LOCKON CO.,LTD. |
---|
| 31 | * @version $Id$ |
---|
| 32 | */ |
---|
[22856] | 33 | class LC_Page_ResizeImage extends LC_Page_Ex |
---|
[22567] | 34 | { |
---|
[16394] | 35 | /** |
---|
| 36 | * Page を初期化する. |
---|
| 37 | * |
---|
| 38 | * @return void |
---|
| 39 | */ |
---|
[22567] | 40 | function init() |
---|
| 41 | { |
---|
[16394] | 42 | parent::init(); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | /** |
---|
| 46 | * Page のプロセス. |
---|
| 47 | * |
---|
| 48 | * @return void |
---|
| 49 | */ |
---|
[22567] | 50 | function process() |
---|
| 51 | { |
---|
[21764] | 52 | parent::process(); |
---|
| 53 | $this->action(); |
---|
| 54 | } |
---|
[16394] | 55 | |
---|
[21764] | 56 | /** |
---|
| 57 | * Page のAction. |
---|
| 58 | * |
---|
| 59 | * @return void |
---|
| 60 | */ |
---|
[22567] | 61 | function action() |
---|
| 62 | { |
---|
[21764] | 63 | $objFormParam = new SC_FormParam_Ex(); |
---|
| 64 | $this->lfInitParam($objFormParam); |
---|
| 65 | $objFormParam->setParam($_GET); |
---|
| 66 | $arrForm = $objFormParam->getHashArray(); |
---|
| 67 | |
---|
[21456] | 68 | $file = NO_IMAGE_REALFILE; |
---|
[16394] | 69 | |
---|
[21456] | 70 | // NO_IMAGE_REALFILE以外のファイル名が渡された場合、ファイル名のチェックを行う |
---|
[21764] | 71 | if (strlen($arrForm['image']) >= 1 |
---|
| 72 | && $arrForm['image'] !== NO_IMAGE_REALFILE) { |
---|
[17967] | 73 | // ファイル名が正しく、ファイルが存在する場合だけ、$fileを設定 |
---|
| 74 | if (!$this->lfCheckFileName()) { |
---|
[21764] | 75 | GC_Utils_Ex::gfPrintLog('invalid access :resize_image.php image=' . $arrForm['image']); |
---|
| 76 | } elseif (file_exists(IMAGE_SAVE_REALDIR . $arrForm['image'])) { |
---|
| 77 | $file = IMAGE_SAVE_REALDIR . $arrForm['image']; |
---|
[16394] | 78 | } |
---|
| 79 | } |
---|
| 80 | |
---|
[21764] | 81 | // リサイズ画像の出力 |
---|
| 82 | $this->lfOutputImage($file, $arrForm['width'], $arrForm['height']); |
---|
[16394] | 83 | } |
---|
| 84 | |
---|
| 85 | /** |
---|
| 86 | * デストラクタ. |
---|
| 87 | * |
---|
| 88 | * @return void |
---|
| 89 | */ |
---|
[22567] | 90 | function destroy() |
---|
| 91 | { |
---|
[16394] | 92 | parent::destroy(); |
---|
| 93 | } |
---|
| 94 | |
---|
[22567] | 95 | function lfInitParam(&$objFormParam) |
---|
| 96 | { |
---|
[21764] | 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 | */ |
---|
[22567] | 107 | function lfCheckFileName() |
---|
| 108 | { |
---|
[20538] | 109 | $file = trim($_GET['image']); |
---|
[22917] | 110 | if (!preg_match("/^[[:alnum:]_\.-]+$/i", $file)) { |
---|
[16394] | 111 | return false; |
---|
| 112 | } else { |
---|
| 113 | return true; |
---|
| 114 | } |
---|
| 115 | } |
---|
[21764] | 116 | |
---|
| 117 | /** |
---|
| 118 | * 画像の出力 |
---|
| 119 | * |
---|
| 120 | * @param string $file 画像ファイル名 |
---|
| 121 | * @param integer $width 画像の幅 |
---|
| 122 | * @param integer $height 画像の高さ |
---|
[22856] | 123 | * |
---|
[21764] | 124 | * @return void |
---|
| 125 | */ |
---|
[22567] | 126 | function lfOutputImage($file, $width, $height) |
---|
| 127 | { |
---|
[21764] | 128 | $objThumb = new gdthumb(); |
---|
| 129 | $objThumb->Main($file, $width, $height, '', true); |
---|
| 130 | } |
---|
[16394] | 131 | } |
---|