source: branches/feature-module-update/data/class/SC_Image.php @ 15080

Revision 15080, 1.6 KB checked in by nanasess, 17 years ago (diff)

svn properties 設定

  • svn:mime-type - application/x-httpd-php; charset=UTF-8
  • svn:keywords - Id
  • Property svn:keywords set to Id
  • Property svn:mime-type set to application/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8//---- アップロードファイル加工クラス(thumb.phpとセットで使用する)
9class SC_Image {
10   
11    var $tmp_dir;
12       
13    function SC_Image($tmp_dir) {
14        // ヘッダファイル読込
15        $include_dir = realpath(dirname( __FILE__));
16        require_once($include_dir . "/../lib/thumb.php");
17        if(!ereg("/$", $tmp_dir)) {
18            $this->tmp_dir = $tmp_dir . "/";
19        } else {
20            $this->tmp_dir = $tmp_dir;
21        }
22    }
23   
24    //--- 一時ファイル生成(サムネイル画像生成用)
25    function makeTempImage($keyname, $max_width, $max_height) {
26        // 一意なIDを取得する。
27        $mainname = uniqid("").".";
28        // 拡張子以外を置き換える。
29        $newFileName = ereg_replace("^.*\.",$mainname, $_FILES[$keyname]['name']);
30        $result  = MakeThumb($_FILES[$keyname]['tmp_name'], $this->tmp_dir , $max_width, $max_height, $newFileName);
31        gfDebugLog($result);
32        return $newFileName;
33    }
34
35    //--- ファイルを指定保存DIRへ移動
36    function moveTempImage($filename, $save_dir) {
37        // コピー元ファイル、コピー先ディレクトリが存在する場合にのみ実行する
38        if(file_exists($this->tmp_dir.$filename) && file_exists($save_dir)) {
39            if(copy($this->tmp_dir . $filename , $save_dir."/".$filename)) {
40                unlink( $this->tmp_dir . $filename );
41            }
42        } else {
43            gfDebugLog($this->tmp_dir.$filename."の移動に失敗しました。");
44        }
45    }
46
47    //---- 指定ファイルを削除   
48    function deleteImage($filename, $dir) {
49        if(file_exists($dir."/".$filename)) {
50            unlink($dir."/".$filename);
51        }
52    }
53
54}
55?>
Note: See TracBrowser for help on using the repository browser.