本文整理汇总了PHP中OC_Filesystem::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Filesystem::getMimeType方法的具体用法?PHP OC_Filesystem::getMimeType怎么用?PHP OC_Filesystem::getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Filesystem
的用法示例。
在下文中一共展示了OC_Filesystem::getMimeType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
function search($query)
{
$files = OC_Filesystem::search($query);
$results = array();
foreach ($files as $file) {
if (OC_Filesystem::is_dir($file)) {
$results[] = new OC_Search_Result(basename($file), '', OC_Helper::linkTo('files', 'index.php?dir=' . $file), 'Files');
} else {
$mime = OC_Filesystem::getMimeType($file);
$mimeBase = substr($mime, 0, strpos($mime, '/'));
switch ($mimeBase) {
case 'audio':
break;
case 'text':
$results[] = new OC_Search_Result(basename($file), '', OC_Helper::linkTo('files', 'download.php?file=' . $file), 'Text');
break;
case 'image':
$results[] = new OC_Search_Result(basename($file), '', OC_Helper::linkTo('files', 'download.php?file=' . $file), 'Images');
break;
default:
if ($mime == 'application/xml') {
$results[] = new OC_Search_Result(basename($file), '', OC_Helper::linkTo('files', 'download.php?file=' . $file), 'Text');
} else {
$results[] = new OC_Search_Result(basename($file), '', OC_Helper::linkTo('files', 'download.php?file=' . $file), 'Files');
}
}
}
}
return $results;
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:30,代码来源:owncloud_lib_search_provider_file.php
示例2: getMimeType
/**
* try to detect the mime type of a file
*
* @param string path
* @return string guessed mime type
*/
static function getMimeType($path)
{
return OC_Filesystem::getMimeType($path);
}
示例3: play
public static function play($params)
{
$username = !self::checkAuth($params);
if ($username) {
echo "<root>\n\t<error code='400'>Invalid login</error>\n</root>";
return;
}
if ($song = OC_MEDIA_COLLECTION::getSong($params['song'])) {
OC_Util::setupFS($song["song_user"]);
header('Content-type: ' . OC_Filesystem::getMimeType($song['song_path']));
header('Content-Length: ' . $song['song_size']);
OC_Filesystem::readfile($song['song_path']);
}
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:14,代码来源:owncloud_apps_media_lib_ampache.php
示例4: getContentType
/**
* Returns the mime-type for a file
*
* If null is returned, we'll assume application/octet-stream
*
* @return mixed
*/
public function getContentType()
{
return OC_Filesystem::getMimeType($this->path);
}
示例5: header
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
// Init owncloud
// Check if we are a user
OCP\User::checkLoggedIn();
$filename = $_GET["file"];
if (!OC_Filesystem::file_exists($filename)) {
header("HTTP/1.0 404 Not Found");
$tmpl = new OCP\Template('', '404', 'guest');
$tmpl->assign('file', $filename);
$tmpl->printPage();
exit;
}
$ftype = OC_Filesystem::getMimeType($filename);
header('Content-Type:' . $ftype);
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
OCP\Response::disableCaching();
header('Content-Length: ' . OC_Filesystem::filesize($filename));
@ob_end_clean();
OC_Filesystem::readfile($filename);
示例6: basename
$tmpl->assign('dir', basename($dir));
$tmpl->assign('filename', basename($path));
$tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
if (isset($_GET['path'])) {
$getPath = $_GET['path'];
} else {
$getPath = '';
}
$tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . '&download&dir=' . $_GET['dir'] . '&path=' . $getPath);
} else {
// Show file preview if viewer is available
$tmpl->assign('uidOwner', $uidOwner);
$tmpl->assign('dir', dirname($path));
$tmpl->assign('filename', basename($path));
$tmpl->assign('mimetype', OC_Filesystem::getMimeType($path));
if ($type == 'file') {
$tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . '&file=' . $_GET['file'] . '&download');
} else {
if (isset($_GET['path'])) {
$getPath = $_GET['path'];
} else {
$getPath = '';
}
$tmpl->assign('downloadURL', OCP\Util::linkToPublic('files') . '&download&dir=' . $_GET['dir'] . '&path=' . $getPath);
}
}
$tmpl->printPage();
}
exit;
}
示例7: array
OC_JSON::error(array("data" => array("message" => $errors[$error])));
exit;
}
}
$files = $_FILES['files'];
$dir = $_POST['dir'];
$dir .= '/';
$error = '';
$totalSize = 0;
foreach ($files['size'] as $size) {
$totalSize += $size;
}
if ($totalSize > OC_Filesystem::free_space('/')) {
OC_JSON::error(array("data" => array("message" => "Not enough space available")));
exit;
}
$result = array();
if (strpos($dir, '..') === false) {
$fileCount = count($files['name']);
for ($i = 0; $i < $fileCount; $i++) {
$target = stripslashes($dir) . $files['name'][$i];
if (OC_Filesystem::fromUploadedFile($files['tmp_name'][$i], $target)) {
$result[] = array("status" => "success", 'mime' => OC_Filesystem::getMimeType($target), 'size' => OC_Filesystem::filesize($target), 'name' => $files['name'][$i]);
}
}
OC_JSON::encodedPrint($result);
exit;
} else {
$error = 'invalid dir';
}
OC_JSON::error(array('data' => array('error' => $error, "file" => $fileName)));
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_files_ajax_upload.php
示例8: play
public function play($params)
{
if (!$this->checkAuth($params)) {
$this->error(400, 'Invalid Login');
}
if ($song = $this->collection->getSong($params['song'])) {
\OC_Util::setupFS($song["song_user"]);
header('Content-type: ' . \OC_Filesystem::getMimeType($song['song_path']));
\OC_Filesystem::readfile($song['song_path']);
}
}
示例9: getContentType
/**
* Returns the mime-type for a file
*
* If null is returned, we'll assume application/octet-stream
*
* @return mixed
*/
public function getContentType()
{
if (isset($this->fileinfo_cache['mimetype'])) {
return $this->fileinfo_cache['mimetype'];
}
return OC_Filesystem::getMimeType($this->path);
}
示例10: OC_Template
$breadcrumbNav = new OC_Template("files", "part.breadcrumb", "");
$breadcrumbNav->assign("breadcrumb", $breadcrumb);
$breadcrumbNav->assign("baseURL", OC_Helper::linkTo("files_sharing", "get.php") . "?token=" . $token . "&path=");
$list = new OC_Template("files", "part.list", "");
$list->assign("files", $files);
$list->assign("baseURL", OC_Helper::linkTo("files_sharing", "get.php") . "?token=" . $token . "&path=");
$list->assign("downloadURL", OC_Helper::linkTo("files_sharing", "get.php") . "?token=" . $token . "&path=");
$list->assign("readonly", true);
$tmpl = new OC_Template("files", "index", "user");
$tmpl->assign("fileList", $list->fetchPage());
$tmpl->assign("breadcrumb", $breadcrumbNav->fetchPage());
$tmpl->assign("readonly", true);
$tmpl->printPage();
} else {
//get time mimetype and set the headers
$mimetype = OC_Filesystem::getMimeType($source);
header("Content-Transfer-Encoding: binary");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");
header('Content-Disposition: filename="' . basename($source) . '"');
header("Content-Type: " . $mimetype);
header("Content-Length: " . OC_Filesystem::filesize($source));
//download the file
@ob_clean();
OC_Filesystem::readfile($source);
}
} else {
header("HTTP/1.0 404 Not Found");
$tmpl = new OC_Template("", "404", "guest");
$tmpl->printPage();
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_apps_files_sharing_get.php
示例11: unset
$songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']);
if ($songId == 0) {
unset($_SESSION['collection']);
$songId = OC_MEDIA_SCANNER::scanFile($arguments['path']);
}
if ($songId > 0) {
$song = OC_MEDIA_COLLECTION::getSong($songId);
$song['artist'] = OC_MEDIA_COLLECTION::getArtistName($song['song_artist']);
$song['album'] = OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
OC_JSON::encodedPrint($song);
}
}
break;
case 'play':
ob_end_clean();
$ftype = OC_Filesystem::getMimeType($arguments['path']);
$songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']);
OC_MEDIA_COLLECTION::registerPlay($songId);
header('Content-Type:' . $ftype);
// calc an offset of 24 hours
$offset = 3600 * 24;
// calc the string in GMT not localtime and add the offset
$expire = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
//output the HTTP header
header($expire);
header('Cache-Control: max-age=3600, must-revalidate');
header('Pragma: public');
header('Accept-Ranges: bytes');
header('Content-Length: ' . OC_Filesystem::filesize($arguments['path']));
$gmt_mtime = gmdate('D, d M Y H:i:s', OC_Filesystem::filemtime($arguments['path'])) . ' GMT';
header("Last-Modified: " . $gmt_mtime);
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_apps_media_ajax_api.php
示例12: header
if (OC_User::checkPassword($user, $pass)) {
OC_Util::setupFS($user);
OC_MEDIA_COLLECTION::$uid = $user;
} else {
exit;
}
if (isset($_POST['play']) and $_POST['play'] == 'true') {
if (!isset($_POST['song'])) {
exit;
}
$song = OC_MEDIA_COLLECTION::getSong($_POST['song']);
$ftype = OC_Filesystem::getMimeType($song['song_path']);
header('Content-Type:' . $ftype);
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . OC_Filesystem::filesize($song['song_path']));
OC_Filesystem::readfile($song['song_path']);
}
$artist = isset($_POST['artist']) ? '%' . $_POST['artist'] . '%' : '';
$album = isset($_POST['album']) ? '%' . $_POST['album'] . '%' : '';
$song = isset($_POST['song']) ? $_POST['song'] : '';
$artist = OC_MEDIA_COLLECTION::getArtistId($artist);
$album = OC_MEDIA_COLLECTION::getAlbumId($album, $artist);
$songs = OC_MEDIA_COLLECTION::getSongs($artist, $album, $song);
$baseUrl = OC_Util::getServerURL() . OC_Helper::linkTo('media', 'tomahawk.php');
$results = array();
foreach ($songs as $song) {
$results[] = (object) array('artist' => OC_MEDIA_COLLECTION::getArtistName($song['song_artist']), 'album' => OC_MEDIA_COLLECTION::getAlbumName($song['song_album']), 'track' => $song['song_name'], 'source' => 'ownCloud', 'mimetype' => OC_Filesystem::getMimeType($song['song_path']), 'extension' => substr($song['song_path'], strrpos($song['song_path'], '.')), 'url' => $baseUrl . '?play=true&song=' . $song['song_id'], 'bitrate' => round($song['song_id'] / $song['song_length'], 0), 'duration' => round($song['song_length'], 0), 'size' => $song['song_size'], 'score' => (double) 1.0);
}
OC_JSON::encodedPrint($results);
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_apps_media_tomahawk.php