ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 2340


Ignore:
Timestamp:
Mar 30, 2007, 1:12:48 AM (13 years ago)
Author:
ebihara
Message:

#430 biz_saveImageを使用しないようにした

Location:
OpenPNE/branches/ebihara/prj_dev28_bizfix/webapp_biz/modules
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/ebihara/prj_dev28_bizfix/webapp_biz/modules/admin_biz/do/biz_admin_add_shisetsu.php

    r2312 r2340  
    1010    function execute($requests)
    1111    {
    12         if (!$requests['name']) {
     12        $shisetsu_name = $requests['name'];
     13
     14        if (!$shisetsu_name) {
    1315            admin_biz_client_redirect('biz_shisetsu_list', '施設名を入力してください。');
    1416            exit();
    1517        }
    16         $sessid = session_id();
    17         $filename = '';
    18         if ($_FILES['image_filename']['name']) {
    19             $filename = biz_saveImage($_FILES['image_filename'], "s_".$sessid);
    20             if (!$filename) {
     18
     19        $biz_shisetsu_id = db_shisetsu_insert_biz_shisetsu($shisetsu_name);
     20
     21        if ($_FILES['image_filename']['size']) {
     22                $ext = t_check_image_format($_FILES['image_filename']);
     23                $image_filename = "s_{$biz_shisetsu_id}_".time().".{$ext}";
     24            if (!db_image_insert_c_image2($image_filename, $_FILES['image_filename']['tmp_name'])) {
    2125                admin_biz_client_redirect('biz_shisetsu_list', '画像は300KB以内のGIF・JPEG・PNGにしてください。');
    2226                exit();
    2327            }
     28            db_shisetsu_edit_biz_shisetsu($biz_shisetsu_id, $shisetsu_name, $image_filename);
    2429        }
    2530        t_image_clear_tmp(session_id());
    26 
    27         db_shisetsu_insert_biz_shisetsu($requests['name'], $filename);
    2831
    2932        admin_biz_client_redirect('biz_shisetsu_list', "施設を追加しました。");
  • OpenPNE/branches/ebihara/prj_dev28_bizfix/webapp_biz/modules/admin_biz/do/biz_admin_edit_shisetsu.php

    r2314 r2340  
    1616        }
    1717
    18         if ($requests['image_filename']) {
    19             $filename = $requests['image_filename'];
    20         } else {
    21             $filename = '';
    22         }
     18        $biz_shisetsu_id = $requests['biz_shisetsu_id'];
     19        $shisetsu = db_shisetsu_biz_shisetsu4biz_shisetsu_id($biz_shisetsu_id);
    2320
    2421        if ($_FILES['image_filename']['size']) {
    25             $filename = biz_saveImage($_FILES['image_filename'], "s_".$sessid);
    26             if (!$filename) {
    27                 $filename = $requests['image_filename'];
     22                $ext = t_check_image_format($_FILES['image_filename']);
     23                $image_filename = "s_{$biz_shisetsu_id}_".time().".{$ext}";
     24            if (!db_image_insert_c_image2($image_filename, $_FILES['image_filename']['tmp_name'])) {
    2825                admin_biz_client_redirect('biz_shisetsu_list', '画像は300KB以内のGIF・JPEG・PNGにしてください。');
    2926                exit();
    3027            }
    31 
    32             //変更前の画像を削除
    33             $shisetsu = db_shisetsu_biz_shisetsu4biz_shisetsu_id($requests['biz_shisetsu_id']);
    34             db_image_delete_c_image($shisetsu['image_filename']);
     28             db_image_delete_c_image($shisetsu['image_filename']);
     29        } else {
     30            $image_filename = $shisetsu['image_filename'];
    3531        }
    3632        t_image_clear_tmp(session_id());
    37 
    38 
    39         db_shisetsu_edit_biz_shisetsu($requests['biz_shisetsu_id'], $requests['name'], $filename);
     33       
     34        db_shisetsu_edit_biz_shisetsu($requests['biz_shisetsu_id'], $requests['name'], $image_filename);
    4035
    4136        admin_biz_client_redirect('biz_shisetsu_list', "施設を編集しました。");
  • OpenPNE/branches/ebihara/prj_dev28_bizfix/webapp_biz/modules/biz/do/h_biz_group_edit.php

    r2339 r2340  
    2323        $group = db_group_biz_group4biz_group_id($biz_group_id);
    2424
    25         if (!empty($_FILES['image_filename'])) {
     25        if ($_FILES['image_filename']['size']) {
    2626            $ext = t_check_image_format($_FILES['image_filename']);
    2727            $image_filename = "g_{$biz_group_id}_".time().".{$ext}";
  • OpenPNE/branches/ebihara/prj_dev28_bizfix/webapp_biz/modules/biz/do/s_add_shisetsu.php

    r2312 r2340  
    1010    function execute($requests)
    1111    {
     12        $shisetsu_name = $requests['name'];
     13
    1214        if (!$requests['name']) {
    1315            $p = array('msg' => '施設名を入力してください');
     
    1517        }
    1618
    17         $sessid = session_id();
    18         $filename = '';
     19        $biz_shisetsu_id = db_shisetsu_insert_biz_shisetsu($shisetsu_name);
    1920
    2021        if ($_FILES['image_filename']['name']) {
    21             $filename = biz_saveImage($_FILES['image_filename'], "s_".$sessid);
    22 
    23             if (!$filename) {
     22            $ext = t_check_image_format($_FILES['image_filename']);
     23            $image_filename = "s_{$biz_shisetsu_id}_".time().".{$ext}";
     24            if (!db_image_insert_c_image2($image_filename, $_FILES['image_filename']['tmp_name'])) {
    2425                $p = array('msg' => '画像は300KB以内のGIF・JPEG・PNGにしてください。');
    2526                openpne_redirect('biz', 'page_s_add_shisetsu', $p);
     27                exit();
    2628            }
     29            db_shisetsu_edit_biz_shisetsu($biz_shisetsu_id, $shisetsu_name, $image_filename);
    2730        }
    28 
    2931        t_image_clear_tmp(session_id());
    30 
    31         db_shisetsu_insert_biz_shisetsu($requests['name'], $filename, $requests['info']);
    3232
    3333        $p = array('msg' => '施設を追加しました');
  • OpenPNE/branches/ebihara/prj_dev28_bizfix/webapp_biz/modules/biz/do/s_edit_shisetsu.php

    r2314 r2340  
    1717
    1818        $u = $GLOBALS['AUTH']->uid();
    19         $sessid = session_id();
    2019
    21         $id = $requests['target_id'];
     20        $biz_shisetsu_id = $requests['target_id'];
     21        $shisetsu = db_shisetsu_biz_shisetsu4biz_shisetsu_id($biz_shisetsu_id);
    2222
    23         $filename = $requests['image_filename'];
    24 
    25 
    26         if ($_FILES['image_filename']['name']) {
    27             $filename = biz_saveImage($_FILES['image_filename'], "s_".$sessid);
    28 
    29             if (!$filename) {
     23        if ($_FILES['image_filename']['size']) {
     24                $ext = t_check_image_format($_FILES['image_filename']);
     25                $image_filename = "s_{$biz_shisetsu_id}_".time().".{$ext}";
     26            if (!db_image_insert_c_image2($image_filename, $_FILES['image_filename']['tmp_name'])) {
    3027                $p = array('msg' => '画像は300KB以内のGIF・JPEG・PNGにしてください。',
    31                        'id'  => $id);
     28                       'id'  => $biz_shisetsu_id);
    3229                openpne_redirect('biz', 'page_s_edit_shisetsu', $p);
    33             } else {
    34                 db_image_delete_c_image($requests['image_filename']);
     30                exit();
    3531            }
     32             db_image_delete_c_image($shisetsu['image_filename']);
     33        } else {
     34            $image_filename = $shisetsu['image_filename'];
    3635        }
    37 
    3836        t_image_clear_tmp(session_id());
    3937
    40         db_shisetsu_edit_biz_shisetsu($id, $requests['name'], $filename, $requests['info']);
     38        db_shisetsu_edit_biz_shisetsu($biz_shisetsu_id, $requests['name'], $image_filename, $requests['info']);
    4139
    4240        $p = array('msg' => '施設を編集しました');
  • OpenPNE/branches/ebihara/prj_dev28_bizfix/webapp_biz/modules/biz/lib/mysql_functions.php

    r2326 r2340  
    44 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
    55 */
    6 
    7 //bizモジュール用 MySQL接続、操作用ライブラリ
    8 
    9 //予期しない多重定義を避けるため、必ず関数名にはbiz_というprefixをつける
    10 
    11 //GET---------------------------------------------
    12 
    13 //画像をDBに格納する
    14 function biz_saveImage($upfile, $filename)
    15 {
    16     if (!$upfile) {
    17         return false;
    18     }
    19     if (!$filename) {
    20         return false;
    21     }
    22 
    23     if (!t_check_image($upfile)) {
    24         return false;
    25     }
    26 
    27     $image = t_check_image($upfile);
    28     $filepath = $upfile["tmp_name"];
    29 
    30     $path_parts = pathinfo($upfile["name"]);
    31     $ext = $path_parts["extension"];
    32     $ext = strtolower($ext);
    33     $filename = $filename."_".time().".".$ext;
    34 
    35     $fp = fopen($filepath, "rb");
    36     $image_data = fread($fp, filesize($filepath));
    37     fclose($fp);
    38 
    39     // 画像かどうかのチェック
    40     if (!@imagecreatefromstring($image_data)) return false;
    41 
    42     $image_data = base64_encode($image_data);
    43     $sql = "INSERT INTO c_image (filename, bin, r_datetime, type)" .
    44         " VALUES (?, ?, NOW(), ?)";
    45 
    46     $params = array(
    47         $filename,
    48         $image_data,
    49         $image['format'],
    50     );
    51     $result = db_query($sql, $params);;
    52 
    53     return $filename;
    54 }
    556?>
Note: See TracChangeset for help on using the changeset viewer.