示例#1
0
 function choosedirlist()
 {
     global $bhcurrent;
     $dirsarray = bh_foldersarray("/", 0, $this->filepath . "/", $bhcurrent['userobj']->username, 1, 2);
     $str = "<table>";
     foreach ($dirsarray as $dirrow) {
         $patharray = explode("/", $dirrow['path']);
         $title = $patharray[count($patharray) - 2];
         if ($dirrow['path'] == "/") {
             $title = "/";
         }
         $str .= "<tr><td>" . str_repeat("&nbsp;", 4 * $dirrow['level']) . " <a href='" . $this->returnto . "&infolder=" . $dirrow['path'] . "'><img src='" . $this->skinpath . "images/folder.png' border='0' alt='[F]' /> " . $title . "</a></td></tr>";
     }
     $str .= "</table>";
     return $str;
 }
示例#2
0
function bh_foldersarray($path = "/", $level = 0, $opento = "/", $username = "******", $fulllist = 0, $accesslevel = 1)
{
    global $bhconfig;
    $files = array();
    $files[] = array('path' => $path, 'level' => $level);
    if ($fulllist == 0) {
        # See if we're too deep anyway
        if (substr_count($path, "/") > substr_count($opento, "/")) {
            return $files;
        }
        # Check to see if we're allowed to search this directory
        if ($path != substr($opento, 0, strlen($path))) {
            return $files;
        }
    }
    if (defined("BH_ROOT")) {
        $handle = opendir($bhconfig['fileroot'] . $path);
    } else {
        $handle = opendir($bhconfig['fileroot'] . $path);
    }
    while (false !== ($file = readdir($handle))) {
        # Check to see if we're allowed to view it.
        if (bh_checkrights($path . $file . "/", $username) >= $accesslevel) {
            if ($bhconfig['hidedotfiles'] == 1) {
                if (!preg_match("/^\\.{1,2}/", $file) && is_dir($bhconfig['fileroot'] . $path . $file)) {
                    $files = array_merge($files, bh_foldersarray($path . $file . "/", $level + 1, $opento, $username, $fulllist, $accesslevel));
                }
            } else {
                if (!preg_match("/^\\.{1,2}\$/", $file) && is_dir($bhconfig['fileroot'] . $path . $file)) {
                    $files = array_merge($files, bh_foldersarray($path . $file . "/", $level + 1, $opento, $username, $fulllist, $accesslevel));
                }
            }
        }
    }
    closedir($handle);
    return $files;
}