• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    一個目錄類

    發布: 2007-7-14 19:53 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 8次 | 進入軟件測試論壇討論

    領測軟件測試網 <?
    //目錄操作基類
    class FileDirectory {
      var $servermode;
      var $serverpath;    //web服務器目錄
      var $pagepath;    //當前頁目錄
      var $path;        //當前目錄
      var $ffblk;        //用于存儲有關文件的信息
      function FileDirectory() {
        set_time_limit(0);    //設置網頁運行時間,0不限
        $this->serverpath = $GLOBALS[DOCUMENT_ROOT]."/";
        $this->path = $this->pagepath = dirname(eregi_replace("//","/",$GLOBALS[SCRIPT_FILENAME]))."/";
        if(eregi("Win32",getenv("SERVER_SOFTWARE")))
          $this->servermode = "WIN32";
      }
      function first_dir() {
        return dirname(eregi_replace("//","/",$GLOBALS[SCRIPT_FILENAME]));
      }
      //獲取文件信息
      function file_info($filename) {
        $ar[name] = $filename;
        $ar[type] = filetype($filename);
        $ar[read] = is_readable($filename);
        $ar[write] = is_writeable($filename);
        $ar[exec] = is_executable($filename);
        $ar[time] = date("Y-m-d H:i:s",filemtime($filename));
        $ar[size] = filesize($filename);
        $ar[style] = ($ar[type]=="dir"?"d":"-")
                  .($ar[read]?"r":"-")
                  .($ar[write]?"w":"-")
                  .($ar[exec]?"x":"-");
        return $ar;
      }

      function format_path($path){
        $tar = split("/",$path);
        $sar = split("/",$this->path);
        $t = count($tar);
        $s = count($sar);
        if($tar[$t-1] == "") $t--;
        if($sar[$s-1] == "") $s--;
        $j = 0;
        while($tar[$j] == "..") {
          $j++;
          $s--;
        }
        $p = "";
        for($i=0;$i<$s;$i++)
          $p .= $sar[$i]."/";
        for($i=$j;$i<$t;$i++)
          if($tar[$i] != ".")
            $p .= $tar[$i]."/";
        $this->path = $p;
      }
      //獲取目錄信息到數組,成功返回時$this->path為目錄的全路徑
      function array_dir($pathname=".") {
        $old = $this->path;
        if($this->servermode == "WIN32")
          $path = str_replace("\\","/",$pathname);
        else
          $path = $pathname;
        $this->format_path($path);
        if(! ($handle = @opendir($path))) {
          $path = dirname($pathname);
          $handle = opendir($path);
        }
        if(@chdir($this->path)) {
          while ($file = readdir($handle)) {
            $ar[] = $this->file_info($file);
          }
        }else
          $this->path = $old;
        closedir($handle);
        return $ar;
      }
    }    //FileDirectory定義結束

    ?>

    <?
    //目錄對話框
    class OpenFileDialog extends FileDirectory {
      var $filter = array("*.*");
      function Execute($path,$statpath) {
        if($path != "") {
          chdir($statpath);
          $this->path = $statpath;
          $ar = $this->array_dir($path);
        }else
          $ar = $this->array_dir(".");
        array_multisort($ar);
    echo "
    <style>
    td{font-size:9pt;}
    select{font-size:9pt;}
    #box{border:3px outset #ffffff}
    </style>
    <form action=";
    echo $GLOBALS[PHP_SELF];
    echo " method=POST>
    <table bgcolor=#cccccc cellspacing=0 cellpadding=0>
    <tr><td>
    <table border=0 id=box>
    <tr><td>
    ";
    echo "當前路徑 ".$this->path."<br>\n";
    echo "<input type=hidden name=statpath value=\"".$this->path."\">\n";

    echo "<select name=dirlist size=6 style=\"width:100px\" onChange=\"this.form.submit()\">\n";
    for($i=0;$i<count($ar);$i++)
      if($ar[$i][type] == "dir")
        if($ar[$i][name] == ".")
          echo "<option selected>".$ar[$i][name]."\n";
        else
          echo "<option>".$ar[$i][name]."\n";
    echo "</select>  \n";
    echo "<select size=6 style=\"width:100px\">\n";
    for($i=0;$i<count($ar);$i++)
      if($ar[$i][type] == "file")
        echo "<option>".$ar[$i][name]."\n";
    echo "
    </select>
    </td></tr>
    </table>
    </td></tr>
    </table>
    </form>
    ";
      }
    }    //OpenFileDialog
    ?>

    <?
    //測試

    $dir = new OpenFileDialog();
    echo "服務器類型 ".$dir->servermode."<br>";
    echo "服務器路徑 ".$dir->serverpath."<br>";
    echo "當前頁路徑 ".$dir->pagepath."<br>";
    echo "當前路徑 ".$dir->path."<br>";
    $dir->Execute($dirlist,$statpath);
    ?>

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>