コード例 #1
0
        $str .= "</tr>";
    }
    $str .= "\n</table></td></tr>";
}
$str .= "<tr><td colspan='3' class='bh_folderpane_classtitle'>" . $bhlang['title:folder_files'] . "</td></tr>\n";
if (is_array($this->content1)) {
    $even = 0;
    foreach ($this->content1 as $file) {
        if ($even == 0) {
            $str .= "<tr>";
        }
        $file['filepath'] = bh_fpclean($file['filepath']);
        unset($fileobj);
        $fileobj = new bhfile($file['filepath']);
        # Get system's description of file on *nix systems.
        if (bh_os() == "nix") {
            $cmdstr = "file -b " . escapeshellarg($fileobj->absfilepath);
            $systemdesc2 = `{$cmdstr}`;
            $systemdescarray = explode(",", $systemdesc2);
            $systemdesc = $systemdescarray[0];
            $systemdesc[0] = strtoupper($systemdesc[0]);
        } else {
            $systemdesc = strtoupper(bh_get_extension($file['filepath'])) . " file";
        }
        # Get any possible description from metadata
        if (!empty($fileobj->fileinfo['description'])) {
            $systemdesc = $fileobj->fileinfo['description'];
        } elseif (!empty($fileobj->fileinfo['desc'])) {
            $systemdesc = $fileobj->fileinfo['desc'];
        }
        # Stop JS/HTML insertion
コード例 #2
0
ファイル: mimetype.inc.php プロジェクト: hky/bytehoard
function bh_mimetype($filepath)
{
    global $bhconfig;
    $fileobj = new bhfile($filepath);
    if ($fileobj->is_dir()) {
        return "bytehoard/directory";
    } else {
        # If we can use unix file, then YES! YES! YES!
        if (bh_os() == "nix") {
            # Get what file says
            $cmdstr = "file -bi " . escapeshellarg($bhconfig['fileroot'] . $filepath);
            $fileoutput = `{$cmdstr}`;
            # Trim off any charset or language stuff
            $array1 = explode(",", $fileoutput);
            $fileoutput = $array1[0];
            $array1 = explode(";", $fileoutput);
            $fileoutput = $array1[0];
            $fileoutput = trim($fileoutput);
            $fileoutput = str_replace("\n", "", $fileoutput);
            return $fileoutput;
        }
        $extension = bh_get_extension($filepath);
        switch ($extension) {
            case "txt":
                return "text/plain";
                break;
            case "html":
            case "htm":
            case "txt":
                return "text/html";
                break;
            case "png":
                return "image/png";
                break;
            case "jpg":
            case "jpeg":
            case "jpe":
                return "image/jpeg";
                break;
            case "gif":
                return "image/gif";
                break;
            case "mp3":
                return "audio/x-mp3";
                break;
            case "ogg":
                return "audio/x-vorbis";
                break;
            case "wav":
                return "audio/wav";
                break;
            case "doc":
                return "application/msword";
                break;
            case "xls":
                return "application/vnd.ms-excel";
                break;
            case "ppt":
            case "pps":
                return "application/vnd.ms-powerpoint";
                break;
            default:
                return "application/octet-stream";
                break;
        }
    }
}