本文整理汇总了PHP中OC_Filesystem::filesize方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Filesystem::filesize方法的具体用法?PHP OC_Filesystem::filesize怎么用?PHP OC_Filesystem::filesize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Filesystem
的用法示例。
在下文中一共展示了OC_Filesystem::filesize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPresentations
public static function getPresentations()
{
$presentations = array();
$list = \OC_FileCache::searchByMime('application', 'zip');
foreach ($list as $l) {
$info = pathinfo($l);
$size = \OC_Filesystem::filesize($l);
$mtime = \OC_Filesystem::filemtime($l);
$entry = array('url' => $l, 'name' => $info['filename'], 'size' => $size, 'mtime' => $mtime);
$presentations[] = $entry;
}
return $presentations;
}
示例2: preCopy
public function preCopy($path1, $path2)
{
return OC_Filesystem::filesize($path1) < $this->getFreeSpace() or $this->getFreeSpace() == 0;
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:4,代码来源:owncloud_lib_fileproxy_quota.php
示例3: validateZipDownload
/**
* checks if the selected files are within the size constraint. If not, outputs an error page.
*
* @param dir $dir
* @param files $files
*/
static function validateZipDownload($dir, $files)
{
if (!OC_Config::getValue('allowZipDownload', true)) {
$l = OC_L10N::get('files');
header("HTTP/1.0 409 Conflict");
$tmpl = new OC_Template('', 'error', 'user');
$errors = array(array('error' => $l->t('ZIP download is turned off.'), 'hint' => $l->t('Files need to be downloaded one by one.') . '<br/><a href="javascript:history.back()">' . $l->t('Back to Files') . '</a>'));
$tmpl->assign('errors', $errors);
$tmpl->printPage();
exit;
}
$zipLimit = OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB'));
if ($zipLimit > 0) {
$totalsize = 0;
if (is_array($files)) {
foreach ($files as $file) {
$totalsize += OC_Filesystem::filesize($dir . '/' . $file);
}
} else {
$totalsize += OC_Filesystem::filesize($dir . '/' . $files);
}
if ($totalsize > $zipLimit) {
$l = OC_L10N::get('files');
header("HTTP/1.0 409 Conflict");
$tmpl = new OC_Template('', 'error', 'user');
$errors = array(array('error' => $l->t('Selected files too large to generate zip file.'), 'hint' => 'Download the files in smaller chunks, seperately or kindly ask your administrator.<br/><a href="javascript:history.back()">' . $l->t('Back to Files') . '</a>'));
$tmpl->assign('errors', $errors);
$tmpl->printPage();
exit;
}
}
}
示例4: 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
示例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: OC_Template
$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();
die;
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_apps_files_sharing_get.php
示例7: getSize
/**
* Returns the size of the node, in bytes
*
* @return int
*/
public function getSize()
{
return OC_Filesystem::filesize($this->path);
}
示例8: fileSystemWatcherRename
/**
* called when files are deleted
* @param array $params
* @param string root (optional)
*/
public static function fileSystemWatcherRename($params, $root = '')
{
if (!$root) {
$root = OC_Filesystem::getRoot();
}
if ($root == '/') {
$root = '';
}
$oldPath = $params['oldpath'];
$newPath = $params['newpath'];
$fullOldPath = $root . $oldPath;
$fullNewPath = $root . $newPath;
if (($id = self::getFileId($fullOldPath)) != -1) {
$oldSize = self::getCachedSize($oldPath, $root);
} else {
return;
}
$size = OC_Filesystem::filesize($newPath);
self::increaseSize(dirname($fullOldPath), -$oldSize);
self::increaseSize(dirname($fullNewPath), $oldSize);
self::move($oldPath, $newPath);
}
示例9: get
/**
* return the content of a file or return a zip file containning multiply files
*
* @param dir $dir
* @param file $file ; seperated list of files to download
*/
public static function get($dir, $files)
{
if (strpos($files, ';')) {
$files = explode(';', $files);
}
if (is_array($files)) {
$zip = new ZipArchive();
$filename = sys_get_temp_dir() . "/ownCloud.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
exit("cannot open <{$filename}>\n");
}
foreach ($files as $file) {
$file = $dir . '/' . $file;
if (OC_Filesystem::is_file($file)) {
$tmpFile = OC_Filesystem::toTmpFile($file);
self::$tmpFiles[] = $tmpFile;
$zip->addFile($tmpFile, basename($file));
} elseif (OC_Filesystem::is_dir($file)) {
self::zipAddDir($file, $zip);
}
}
$zip->close();
} elseif (OC_Filesystem::is_dir($dir . '/' . $files)) {
$zip = new ZipArchive();
$filename = sys_get_temp_dir() . "/ownCloud.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
exit("cannot open <{$filename}>\n");
}
$file = $dir . '/' . $files;
self::zipAddDir($file, $zip);
$zip->close();
} else {
$zip = false;
$filename = $dir . '/' . $files;
}
if ($zip or OC_Filesystem::is_readable($filename)) {
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
if ($zip) {
header('Content-Type: application/zip');
header('Content-Length: ' . filesize($filename));
} else {
header('Content-Type: ' . OC_Filesystem::getMimeType($filename));
header('Content-Length: ' . OC_Filesystem::filesize($filename));
}
} elseif ($zip or !OC_Filesystem::file_exists($filename)) {
header("HTTP/1.0 404 Not Found");
$tmpl = new OC_Template('', '404', 'guest');
$tmpl->assign('file', $filename);
$tmpl->printPage();
// die('404 Not Found');
} else {
header("HTTP/1.0 403 Forbidden");
die('403 Forbidden');
}
@ob_end_clean();
if ($zip) {
readfile($filename);
unlink($filename);
} else {
OC_Filesystem::readfile($filename);
}
foreach (self::$tmpFiles as $tmpFile) {
if (file_exists($tmpFile) and is_file($tmpFile)) {
unlink($tmpFile);
}
}
}
示例10: round
/**
* Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
require_once '../lib/base.php';
OC_Util::checkLoggedIn();
// Highlight navigation entry
OC_Util::addScript('settings', 'personal');
OC_Util::addStyle('settings', 'settings');
OC_Util::addScript('3rdparty', 'chosen/chosen.jquery.min');
OC_Util::addStyle('3rdparty', 'chosen');
OC_App::setActiveNavigationEntry('personal');
// calculate the disc space
$used = OC_Filesystem::filesize('/');
$free = OC_Filesystem::free_space();
$total = $free + $used;
$relative = round($used / $total * 10000) / 100;
$email = OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
$lang = OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang', 'en');
$languageCodes = OC_L10N::findAvailableLanguages();
//put the current language in the front
unset($languageCodes[array_search($lang, $languageCodes)]);
array_unshift($languageCodes, $lang);
$languageNames = (include 'languageCodes.php');
$languages = array();
foreach ($languageCodes as $lang) {
$languages[] = array('code' => $lang, 'name' => $languageNames[$lang]);
}
// Return template
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:30,代码来源:owncloud_settings_personal.php
示例11: postFopen
public function postFopen($path, &$result)
{
if (!$result) {
return $result;
}
$meta = stream_get_meta_data($result);
if (self::isEncrypted($path)) {
fclose($result);
$result = fopen('crypt://' . $path, $meta['mode']);
} elseif (self::shouldEncrypt($path) and $meta['mode'] != 'r' and $meta['mode'] != 'rb') {
if (OC_Filesystem::file_exists($path) and OC_Filesystem::filesize($path) > 0) {
//first encrypt the target file so we don't end up with a half encrypted file
OCP\Util::writeLog('files_encryption', 'Decrypting ' . $path . ' before writing', OCP\Util::DEBUG);
$tmp = fopen('php://temp');
OCP\Files::streamCopy($result, $tmp);
fclose($result);
OC_Filesystem::file_put_contents($path, $tmp);
fclose($tmp);
}
$result = fopen('crypt://' . $path, $meta['mode']);
}
return $result;
}
示例12: array
}
if ($source) {
if (substr($source, 0, 8) != 'https://' and substr($source, 0, 7) != 'http://') {
OCP\JSON::error(array("data" => array("message" => "Not a valid source")));
exit;
}
$ctx = stream_context_create(null, array('notification' => 'progress'));
$sourceStream = fopen($source, 'rb', false, $ctx);
$target = $dir . '/' . $filename;
$result = OC_Filesystem::file_put_contents($target, $sourceStream);
if ($result) {
$target = OC_Filesystem::normalizePath($target);
$meta = OC_FileCache::get($target);
$mime = $meta['mimetype'];
$id = OC_FileCache::getId($target);
$eventSource->send('success', array('mime' => $mime, 'size' => OC_Filesystem::filesize($target), 'id' => $id));
} else {
$eventSource->send('error', "Error while downloading " . $source . ' to ' . $target);
}
$eventSource->close();
exit;
} else {
if ($content) {
if (OC_Filesystem::file_put_contents($dir . '/' . $filename, $content)) {
$meta = OC_FileCache::get($dir . '/' . $filename);
$id = OC_FileCache::getId($dir . '/' . $filename);
OCP\JSON::success(array("data" => array('content' => $content, 'id' => $id)));
exit;
}
} elseif (OC_Files::newFile($dir, $filename, 'file')) {
$meta = OC_FileCache::get($dir . '/' . $filename);
示例13: ob_end_clean
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);
OC_Filesystem::readfile($arguments['path']);
exit;
case 'find_music':
OC_JSON::encodedPrint(findMusic());
exit;
}
}
function findMusic($path = '')
{
$music = array();
$dh = OC_Filesystem::opendir($path);
if ($dh) {
while ($filename = readdir($dh)) {
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_apps_media_ajax_api.php
示例14: 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
示例15: getQuotaInfo
/**
* Returns available diskspace information
*
* @return array
*/
public function getQuotaInfo()
{
return array(OC_Filesystem::filesize('/'), OC_Filesystem::free_space());
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:9,代码来源:owncloud_lib_connector_sabre_directory.php