| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 4 | * |
|---|
| 5 | * http://www.lockon.co.jp/ |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | require_once("../lib/thumb.php"); |
|---|
| 9 | |
|---|
| 10 | /*---------------------------------------------------------------------- |
|---|
| 11 | * [名称] GC_Thumb |
|---|
| 12 | * [概要] アップロードファイル加工クラス(thumb.phpとセットで使用する) |
|---|
| 13 | * [引数] - |
|---|
| 14 | * [戻値] - |
|---|
| 15 | * [依存] thumb.php |
|---|
| 16 | * [注釈] - |
|---|
| 17 | *----------------------------------------------------------------------*/ |
|---|
| 18 | |
|---|
| 19 | Class GC_Thumb { |
|---|
| 20 | |
|---|
| 21 | var $tempPath; |
|---|
| 22 | |
|---|
| 23 | function GC_Thumb($tempFilePath = "") { |
|---|
| 24 | $this->tempPath = $_SERVER['DOCUMENT_ROOT'] . $tempFilePath; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | //--- 一時ファイル生成(サムネイル画像生成用) |
|---|
| 28 | function makeImageTempFile($fileName, $phpFileName, $max_width,$max_height) { |
|---|
| 29 | // 一意なIDを取得する。 |
|---|
| 30 | $mainname = uniqid("")."."; |
|---|
| 31 | // 拡張子以外を置き換える。 |
|---|
| 32 | $newFileName = ereg_replace("^.*\.",$mainname,$fileName); |
|---|
| 33 | $result = MakeThumb( $phpFileName, $this->tempPath, $max_width, $max_height, $newFileName ); |
|---|
| 34 | return $newFileName; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | //--- 一時ファイル生成 |
|---|
| 38 | function makeTempFile($fileName, $phpFileName) { |
|---|
| 39 | $newFileNname = str_replace("'", "’", $fileName ); |
|---|
| 40 | $newFileNname = date("siU") . $newFileNname; |
|---|
| 41 | copy( $phpFileName, $this->tempPath . $newFileNname ); |
|---|
| 42 | return $newFileNname; |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | //--- ファイルを指定保存DIRへ移動 |
|---|
| 46 | function fileMove($fileName, $dirName) { |
|---|
| 47 | if(copy( $this->tempPath . $fileName , $_SERVER['DOCUMENT_ROOT'] . $dirName . $fileName)) { |
|---|
| 48 | unlink( $this->tempPath . $fileName ); |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | //---- 一時DIRのファイルを一括削除 |
|---|
| 53 | function execDeleteTempFile() { |
|---|
| 54 | chdir( $this->tempPath ); |
|---|
| 55 | $delFile = glob( "*.*" ); |
|---|
| 56 | if( is_array($delFile) ) foreach( $delFile as $val ) @unlink( $val ); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | //---- 指定ファイルを削除 |
|---|
| 60 | function fileDelete($fileName, $dirName) { |
|---|
| 61 | unlink( $_SERVER['DOCUMENT_ROOT'] . $dirName . $fileName ); |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | ?> |
|---|