當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Daemon::getMIME方法代碼示例

本文整理匯總了PHP中Daemon::getMIME方法的典型用法代碼示例。如果您正苦於以下問題:PHP Daemon::getMIME方法的具體用法?PHP Daemon::getMIME怎麽用?PHP Daemon::getMIME使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Daemon的用法示例。


在下文中一共展示了Daemon::getMIME方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init

    public function init()
    {
        if (!isset($this->attrs->server['FR_URL'])) {
            $this->status(404);
            $this->finish();
            return;
        }
        try {
            $this->stream = new AsyncStream($this->attrs->server['FR_URL']);
            if ($this->stream->fileMode) {
                if (substr($this->stream->filePath, -1) === '/' && is_dir($this->stream->filePath)) {
                    $found = FALSE;
                    foreach ($this->appInstance->indexFiles as $i) {
                        if (is_file($this->stream->filePath . $i)) {
                            $this->stream = new AsyncStream('file://' . $this->stream->filePath . $i);
                            $found = TRUE;
                            break;
                        }
                    }
                    if (!$found) {
                        if (isset($this->attrs->server['FR_AUTOINDEX']) && $this->attrs->server['FR_AUTOINDEX']) {
                            $h = opendir($this->stream->filePath);
                            if (!$h) {
                                $this->status(404);
                                $this->finish();
                                return;
                            }
                            ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
<head> 
<title>Index of /</title> 
<style type="text/css"> 
a, a:active {text-decoration: none; color: blue;}
a:visited {color: #48468F;}
a:hover, a:focus {text-decoration: underline; color: red;}
body {background-color: #F5F5F5;}
h2 {margin-bottom: 12px;}
table {margin-left: 12px;}
th, td { font: 90% monospace; text-align: left;}
th { font-weight: bold; padding-right: 14px; padding-bottom: 3px;}
td {padding-right: 14px;}
td.s, th.s {text-align: right;}
div.list { background-color: white; border-top: 1px solid #646464; border-bottom: 1px solid #646464; padding-top: 10px; padding-bottom: 14px;}
div.foot { font: 90% monospace; color: #787878; padding-top: 4px;}
</style> 
</head> 
<body> 
<pre class="header"Welcome!</pre><h2>Index of /</h2> 
<div class="list"> 
<table summary="Directory Listing" cellpadding="0" cellspacing="0"> 
<thead><tr><th class="n">Name</th><th class="m">Last Modified</th><th class="s">Size</th><th class="t">Type</th></tr></thead> 
<tbody> 
<tr><td class="n"><a href="../">Parent Directory</a>/</td><td class="m">&nbsp;</td><td class="s">- &nbsp;</td><td class="t">Directory</td></tr> 
<?php 
                            while (($fn = readdir($h)) !== FALSE) {
                                if ($fn === '.' || $fn === '..') {
                                    continue;
                                }
                                $path = $this->stream->filePath . $fn;
                                $type = is_dir($path) ? 'Directory' : Daemon::getMIME($path);
                                ?>
<tr><td class="n"><a href="<?php 
                                echo htmlspecialchars($fn) . ($type == 'Directory' ? '/' : '');
                                ?>
"><?php 
                                echo htmlspecialchars($fn);
                                ?>
</a></td><td class="m"><?php 
                                echo date('Y-M-D H:i:s', filemtime($path));
                                ?>
</td><td class="s"><?php 
                                echo $type === 'Directory' ? '-' : Daemon::humanSize(filesize($path));
                                ?>
 &nbsp;</td><td class="t"><?php 
                                echo $type;
                                ?>
</td></tr>
 <?php 
                            }
                            ?>
</tbody> 
</table> 
</div> 
<?php 
                            if (Daemon::$settings['expose']) {
                                echo '<div class="foot">phpDaemon/' . Daemon::$version . '</div>';
                            }
                            ?>
 
</body> 
</html><?php 
                            $this->finish();
                            return;
                        } else {
                            $this->status(403);
                            $this->finish();
                            return;
                        }
                    }
//.........這裏部分代碼省略.........
開發者ID:svcorp77,項目名稱:phpdaemon,代碼行數:101,代碼來源:FileReader.php


注:本文中的Daemon::getMIME方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。