Changeset 16764


Ignore:
Timestamp:
2007/11/08 23:02:23 (19 years ago)
Author:
adachi
Message:

sfFlush()でniticeが出るのを修正

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/util/SC_Utils.php

    r16710 r16764  
    2121 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
    2222 */ 
    23   
     23 
    2424/** 
    2525 * 各種ユーティリティクラス. 
     
    13851385        } 
    13861386    } 
    1387      
     1387 
    13881388    // ディレクトリを再帰的に生成する 
    13891389    function sfMakeDir($path) { 
     
    14071407                        GC_Utils::gfPrintLog("mkdir $dir"); 
    14081408                    } 
    1409                 }         
     1409                } 
    14101410           } 
    14111411        } 
    14121412        return; 
    14131413    } 
    1414          
     1414 
    14151415    // ディレクトリ以下のファイルを再帰的にコピー 
    14161416    function sfCopyDir($src, $des, $mess = "", $override = false){ 
     
    14761476                    $ret = SC_Utils::sfDelFile($del_file); 
    14771477                } 
    1478      
     1478 
    14791479                if(!$ret){ 
    14801480                    return $ret; 
    14811481                } 
    14821482            } 
    1483      
     1483 
    14841484            // 閉じる 
    14851485            closedir($dh); 
    1486      
     1486 
    14871487            // フォルダを削除 
    14881488            return rmdir($dir); 
     
    15351535        flush(); 
    15361536 
    1537         ob_end_flush(); 
     1537        ob_flush(); 
    15381538        ob_start(); 
    15391539 
     
    16391639        } 
    16401640    } 
    1641      
    1642     /*  
     1641 
     1642    /* 
    16431643     * 関数名:sfGetFileList() 
    16441644     * 説明 :指定パス配下のディレクトリ取得 
     
    16481648        $arrFileList = array(); 
    16491649        $arrDirList = array(); 
    1650          
     1650 
    16511651        if (is_dir($dir)) { 
    1652             if ($dh = opendir($dir)) {  
     1652            if ($dh = opendir($dir)) { 
    16531653                $cnt = 0; 
    16541654                // 行末の/を取り除く 
     
    16571657                // アルファベットと数字でソート 
    16581658                natcasesort($arrDir); 
    1659                 foreach($arrDir as $file) {              
     1659                foreach($arrDir as $file) { 
    16601660                    // ./ と ../を除くファイルのみを取得 
    16611661                    if($file != "." && $file != "..") { 
    1662      
     1662 
    16631663                        $path = $dir."/".$file; 
    16641664                        // SELECT内の見た目を整えるため指定文字数で切る 
    1665                         $file_name = SC_Utils::sfCutString($file, FILE_NAME_LEN);                        
     1665                        $file_name = SC_Utils::sfCutString($file, FILE_NAME_LEN); 
    16661666                        $file_size = SC_Utils::sfCutString(SC_Utils::sfGetDirSize($path), FILE_NAME_LEN); 
    16671667                        $file_time = date("Y/m/d", filemtime($path)); 
    1668                          
     1668 
    16691669                        // ディレクトリとファイルで格納配列を変える 
    16701670                        if(is_dir($path)) { 
     
    16721672                            $arrDirList[$cnt]['file_path'] = $path; 
    16731673                            $arrDirList[$cnt]['file_size'] = $file_size; 
    1674                             $arrDirList[$cnt]['file_time'] = $file_time;  
     1674                            $arrDirList[$cnt]['file_time'] = $file_time; 
    16751675                            $arrDirList[$cnt]['is_dir'] = true; 
    16761676                        } else { 
     
    16781678                            $arrFileList[$cnt]['file_path'] = $path; 
    16791679                            $arrFileList[$cnt]['file_size'] = $file_size; 
    1680                             $arrFileList[$cnt]['file_time'] = $file_time;  
     1680                            $arrFileList[$cnt]['file_time'] = $file_time; 
    16811681                            $arrFileList[$cnt]['is_dir'] = false; 
    16821682                        } 
     
    16841684                    } 
    16851685                } 
    1686                 closedir($dh);  
     1686                closedir($dh); 
    16871687            } 
    16881688        } 
    1689      
     1689 
    16901690        // フォルダを先頭にしてマージ 
    16911691        return array_merge($arrDirList, $arrFileList); 
    16921692    } 
    1693      
    1694     /*  
     1693 
     1694    /* 
    16951695     * 関数名:sfGetDirSize() 
    16961696     * 説明 :指定したディレクトリのバイト数を取得 
     
    17011701            // ディレクトリの場合下層ファイルの総量を取得 
    17021702            if (is_dir($dir)) { 
    1703                 $handle = opendir($dir);  
     1703                $handle = opendir($dir); 
    17041704                while ($file = readdir($handle)) { 
    17051705                    // 行末の/を取り除く 
    17061706                    $dir = ereg_replace("/$", "", $dir); 
    17071707                    $path = $dir."/".$file; 
    1708                     if ($file != '..' && $file != '.' && !is_dir($path)) {  
    1709                         $bytes += filesize($path);  
     1708                    if ($file != '..' && $file != '.' && !is_dir($path)) { 
     1709                        $bytes += filesize($path); 
    17101710                    } else if (is_dir($path) && $file != '..' && $file != '.') { 
    17111711                        // 下層ファイルのバイト数を取得する為、再帰的に呼び出す。 
    1712                         $bytes += SC_Utils::sfGetDirSize($path);  
    1713                     }  
    1714                 }  
     1712                        $bytes += SC_Utils::sfGetDirSize($path); 
     1713                    } 
     1714                } 
    17151715            } else { 
    17161716                // ファイルの場合 
     
    17201720        // ディレクトリ(ファイル)が存在しない場合は0byteを返す 
    17211721        if($bytes == "") $bytes = 0; 
    1722          
     1722 
    17231723        return $bytes; 
    17241724    } 
    1725      
    1726     /*  
     1725 
     1726    /* 
    17271727     * 関数名:sfDeleteDir() 
    17281728     * 説明 :指定したディレクトリを削除 
     
    17541754                // ファイル削除 
    17551755                $arrResult[0]['result'] = @unlink("$dir"); 
    1756                 $arrResult[0]['file_name'] = "$dir";             
     1756                $arrResult[0]['file_name'] = "$dir"; 
    17571757            } 
    17581758        } 
    1759          
     1759 
    17601760        return $arrResult; 
    17611761    } 
    1762      
    1763     /*  
     1762 
     1763    /* 
    17641764     * 関数名:sfGetFileTree() 
    17651765     * 説明 :ツリー生成用配列取得(javascriptに渡す用) 
     
    17681768     */ 
    17691769    function sfGetFileTree($dir, $tree_status) { 
    1770          
     1770 
    17711771        $cnt = 0; 
    17721772        $arrTree = array(); 
    17731773        $default_rank = count(split('/', $dir)); 
    1774      
     1774 
    17751775        // 文末の/を取り除く 
    1776         $dir = ereg_replace("/$", "", $dir);     
     1776        $dir = ereg_replace("/$", "", $dir); 
    17771777        // 最上位層を格納(user_data/) 
    17781778        if(sfDirChildExists($dir)) { 
    17791779            $arrTree[$cnt]['type'] = "_parent"; 
    17801780        } else { 
    1781             $arrTree[$cnt]['type'] = "_child";   
     1781            $arrTree[$cnt]['type'] = "_child"; 
    17821782        } 
    17831783        $arrTree[$cnt]['path'] = $dir; 
     
    17901790            $arrTree[$cnt]['open'] = true; 
    17911791        } 
    1792         $cnt++;  
    1793      
     1792        $cnt++; 
     1793 
    17941794        sfGetFileTreeSub($dir, $default_rank, $cnt, $arrTree, $tree_status); 
    1795      
     1795 
    17961796        return $arrTree; 
    17971797    } 
    1798      
    1799     /*  
     1798 
     1799    /* 
    18001800     * 関数名:sfGetFileTree() 
    18011801     * 説明 :ツリー生成用配列取得(javascriptに渡す用) 
     
    18061806     */ 
    18071807    function sfGetFileTreeSub($dir, $default_rank, &$cnt, &$arrTree, $tree_status) { 
    1808          
     1808 
    18091809        if(file_exists($dir)) { 
    18101810            if ($handle = opendir("$dir")) { 
    1811                 while (false !== ($item = readdir($handle))) $arrDir[] = $item;  
     1811                while (false !== ($item = readdir($handle))) $arrDir[] = $item; 
    18121812                // アルファベットと数字でソート 
    18131813                natcasesort($arrDir); 
     
    18231823                                $arrTree[$cnt]['type'] = "_parent"; 
    18241824                            } else { 
    1825                                 $arrTree[$cnt]['type'] = "_child";   
     1825                                $arrTree[$cnt]['type'] = "_child"; 
    18261826                            } 
    1827                              
     1827 
    18281828                            // 階層を割り出す 
    18291829                            $arrCnt = split('/', $path); 
     
    18431843        } 
    18441844    } 
    1845      
    1846     /*  
     1845 
     1846    /* 
    18471847     * 関数名:sfDirChildExists() 
    18481848     * 説明 :指定したディレクトリ配下にファイルがあるか 
     
    18521852        if(file_exists($dir)) { 
    18531853            if (is_dir($dir)) { 
    1854                 $handle = opendir($dir);  
     1854                $handle = opendir($dir); 
    18551855                while ($file = readdir($handle)) { 
    18561856                    // 行末の/を取り除く 
    18571857                    $dir = ereg_replace("/$", "", $dir); 
    18581858                    $path = $dir."/".$file; 
    1859                     if ($file != '..' && $file != '.' && is_dir($path)) {  
     1859                    if ($file != '..' && $file != '.' && is_dir($path)) { 
    18601860                        return true; 
    1861                     }  
    1862                 }  
     1861                    } 
     1862                } 
    18631863            } 
    18641864        } 
    1865          
     1865 
    18661866        return false; 
    18671867    } 
    1868      
    1869     /*  
     1868 
     1869    /* 
    18701870     * 関数名:lfIsFileOpen() 
    18711871     * 説明 :指定したファイルが前回開かれた状態にあったかチェック 
     
    18781878            return true; 
    18791879        } 
    1880          
     1880 
    18811881        return false; 
    18821882    } 
    1883      
    1884     /*  
     1883 
     1884    /* 
    18851885     * 関数名:sfDownloadFile() 
    18861886     * 引数1 :ファイルパス 
     
    18951895        echo (sfReadFile($file)); 
    18961896    } 
    1897      
    1898     /*  
     1897 
     1898    /* 
    18991899     * 関数名:sfCreateFile() 
    19001900     * 引数1 :ファイルパス 
     
    19091909            $ret = @mkdir($file); 
    19101910        } 
    1911          
     1911 
    19121912        return $ret; 
    19131913    } 
    1914      
    1915     /*  
     1914 
     1915    /* 
    19161916     * 関数名:sfReadFile() 
    19171917     * 引数1 :ファイルパス 
    19181918     * 説明 :ファイル読込 
    19191919     */ 
    1920     function sfReadFile($filename) {  
    1921         $str = "";  
    1922         // バイナリモードでオープン  
    1923         $fp = @fopen($filename, "rb" );  
    1924         //ファイル内容を全て変数に読み込む  
    1925         if($fp) {  
    1926             $str = @fread($fp, filesize($filename)+1);  
    1927         }  
     1920    function sfReadFile($filename) { 
     1921        $str = ""; 
     1922        // バイナリモードでオープン 
     1923        $fp = @fopen($filename, "rb" ); 
     1924        //ファイル内容を全て変数に読み込む 
     1925        if($fp) { 
     1926            $str = @fread($fp, filesize($filename)+1); 
     1927        } 
    19281928        @fclose($fp); 
    1929      
    1930         return $str;  
     1929 
     1930        return $str; 
    19311931    } 
    1932      
     1932 
    19331933    /** 
    19341934     * 出力バッファをフラッシュし, バッファリングを開始する. 
     
    19411941        ob_start(); 
    19421942    } 
    1943      
     1943 
    19441944    /* デバッグ用 ------------------------------------------------------------------------------------------------*/ 
    19451945    function sfPrintR($obj) { 
Note: See TracChangeset for help on using the changeset viewer.