Ignore:
Timestamp:
2012/04/17 15:53:10 (12 years ago)
Author:
shutta
Message:

#515 PHP 5.3.0対応
PHP5.3以降で、非推奨関数となるereg系関数を書き換えた。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/SC_UploadFile.php

    r21684 r21755  
    5959    // ファイル管理クラス 
    6060    function SC_UploadFile($temp_dir, $save_dir) { 
    61         $this->temp_dir = (preg_match("|/$|", $temp_dir) == 0) ? $temp_dir. '/' : $temp_dir; 
    62         $this->save_dir = (preg_match("|/$|", $save_dir) == 0) ? $save_dir. '/' : $save_dir; 
     61        $this->temp_dir = rtrim($temp_dir, '/') . '/'; 
     62        $this->save_dir = rtrim($save_dir, '/') . '/'; 
    6363        $this->file_max = 0; 
    6464    } 
     
    117117                            if ($rename) { 
    118118                                $uniqname = date('mdHi') . '_' . uniqid('').'.'; 
    119                                 $this->temp_file[$cnt] = ereg_replace("^.*\.",$uniqname, $_FILES[$keyname]['name']); 
     119                                $this->temp_file[$cnt] = preg_replace("/^.*\./", $uniqname, $_FILES[$keyname]['name']); 
    120120                            } else { 
    121121                                $this->temp_file[$cnt] = $_FILES[$keyname]['name']; 
     
    155155                        // 一意なファイル名を作成する。 
    156156                        $uniqname = date('mdHi') . '_' . uniqid('').'.'; 
    157                         $this->temp_file[$cnt] = ereg_replace("^.*\.",$uniqname, $_FILES[$keyname]['name']); 
     157                        $this->temp_file[$cnt] = preg_replace("/^.*\./", $uniqname, $_FILES[$keyname]['name']); 
    158158                        set_time_limit(0); 
    159159                        $result  = copy($_FILES[$keyname]['tmp_name'], $this->temp_dir . $this->temp_file[$cnt]); 
     
    229229                if (isset($this->save_file[$cnt]) 
    230230                    && $this->save_file[$cnt] != '' 
    231                     && !ereg('^sub/', $this->save_file[$cnt]) 
     231                    && !preg_match('|^sub/|', $this->save_file[$cnt]) 
    232232                ) { 
    233233 
     
    249249                if (isset($this->save_file[$cnt]) 
    250250                    && $this->save_file[$cnt] != '' 
    251                     && !ereg('^sub/', $this->save_file[$cnt]) 
     251                    && !preg_match('|^sub/|', $this->save_file[$cnt]) 
    252252                ) { 
    253253                    $objImage->deleteImage($this->save_file[$cnt], $this->save_dir); 
     
    311311        foreach ($this->keyname as $val) { 
    312312            if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != '') { 
    313                 // ファイルパスチェック(パスのスラッシュ/が連続しないようにする。) 
    314                 if (ereg("/$", $temp_url)) { 
    315                     $arrRet[$val]['filepath'] = $temp_url . $this->temp_file[$cnt]; 
    316                 } else { 
    317                     $arrRet[$val]['filepath'] = $temp_url . '/' . $this->temp_file[$cnt]; 
    318                 } 
     313                // パスのスラッシュ/が連続しないようにする。 
     314                $arrRet[$val]['filepath'] = rtrim($temp_url, '/') . '/' . $this->temp_file[$cnt]; 
     315 
    319316                $arrRet[$val]['real_filepath'] = $this->temp_dir . $this->temp_file[$cnt]; 
    320317            } elseif (isset($this->save_file[$cnt]) && $this->save_file[$cnt] != '') { 
    321                 // ファイルパスチェック(パスのスラッシュ/が連続しないようにする。) 
    322                 if (ereg("/$", $save_url)) { 
    323                     $arrRet[$val]['filepath'] = $save_url . $this->save_file[$cnt]; 
    324                 } else { 
    325                     $arrRet[$val]['filepath'] = $save_url . '/' . $this->save_file[$cnt]; 
    326                 } 
     318                // パスのスラッシュ/が連続しないようにする。 
     319                $arrRet[$val]['filepath'] = rtrim($save_url, '/') . '/' . $this->save_file[$cnt]; 
     320 
    327321                $arrRet[$val]['real_filepath'] = $this->save_dir . $this->save_file[$cnt]; 
    328322            } 
     
    438432        foreach ($this->keyname as $val) { 
    439433            if ($arrVal[$val] != '') { 
    440                 if ($this->save_file[$cnt] == '' && !ereg('^sub/', $arrVal[$val])) { 
     434                if ($this->save_file[$cnt] == '' && !preg_match('|^sub/|', $arrVal[$val])) { 
    441435                    $objImage->deleteImage($arrVal[$val], $this->save_dir); 
    442436                } 
     
    451445        $cnt = 0; 
    452446        if ($arrVal['down_realfilename'] != '') { 
    453             if ($this->save_file[$cnt] == '' && !ereg('^sub/', $arrVal['down_realfilename'])) { 
     447            if ($this->save_file[$cnt] == '' && !preg_match('|^sub/|', $arrVal['down_realfilename'])) { 
    454448                $objImage->deleteImage($arrVal['down_realfilename'], $this->save_dir); 
    455449            } 
Note: See TracChangeset for help on using the changeset viewer.