本文整理汇总了PHP中OC_Filesystem::free_space方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Filesystem::free_space方法的具体用法?PHP OC_Filesystem::free_space怎么用?PHP OC_Filesystem::free_space使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Filesystem
的用法示例。
在下文中一共展示了OC_Filesystem::free_space方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkQuota
/**
* This method is called before any HTTP method and forces users to be authenticated
*
* @param string $method
* @throws Sabre_DAV_Exception
* @return bool
*/
public function checkQuota($uri, $data = null)
{
$expected = $this->server->httpRequest->getHeader('X-Expected-Entity-Length');
$length = $expected ? $expected : $this->server->httpRequest->getHeader('Content-Length');
if ($length) {
if (substr($uri, 0, 1) !== '/') {
$uri = '/' . $uri;
}
list($parentUri, $newName) = Sabre_DAV_URLUtil::splitPath($uri);
if ($length > OC_Filesystem::free_space($parentUri)) {
throw new Sabre_DAV_Exception('Quota exceeded. File is too big.');
}
}
return true;
}
示例2: foreach
foreach ($_FILES['files']['error'] as $error) {
if ($error != 0) {
$errors = array(0 => $l->t("There is no error, the file uploaded with success"), 1 => $l->t("The uploaded file exceeds the upload_max_filesize directive in php.ini"), 2 => $l->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"), 3 => $l->t("The uploaded file was only partially uploaded"), 4 => $l->t("No file was uploaded"), 6 => $l->t("Missing a temporary folder"));
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 {
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-owncloud_.htaccess-,代码行数:31,代码来源:owncloud_files_ajax_upload.php
示例3: array
$breadcrumb = array();
$pathtohere = "";
foreach (explode("/", $dir) as $i) {
if ($i != "") {
$pathtohere .= "/" . str_replace('+', '%20', urlencode($i));
$breadcrumb[] = array("dir" => $pathtohere, "name" => $i);
}
}
// make breadcrumb und filelist markup
$list = new OC_Template("files", "part.list", "");
$list->assign("files", $files);
$list->assign("baseURL", OC_Helper::linkTo("files", "index.php") . "?dir=");
$list->assign("downloadURL", OC_Helper::linkTo("files", "download.php") . "?file=");
$breadcrumbNav = new OC_Template("files", "part.breadcrumb", "");
$breadcrumbNav->assign("breadcrumb", $breadcrumb);
$breadcrumbNav->assign("baseURL", OC_Helper::linkTo("files", "index.php") . "?dir=");
$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$freeSpace = OC_Filesystem::free_space('/');
$freeSpace = max($freeSpace, 0);
$maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
$tmpl = new OC_Template("files", "index", "user");
$tmpl->assign("fileList", $list->fetchPage());
$tmpl->assign("breadcrumb", $breadcrumbNav->fetchPage());
$tmpl->assign('dir', $dir);
$tmpl->assign('readonly', !OC_Filesystem::is_writable($dir));
$tmpl->assign("files", $files);
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
$tmpl->printPage();
示例4: getQuotaInfo
/**
* Returns available diskspace information
*
* @return array
*/
public function getQuotaInfo()
{
$rootInfo = OC_FileCache_Cached::get('');
return array($rootInfo['size'], OC_Filesystem::free_space());
}
示例5: quotaGet
/**
* get the quota of a user
* @param string $format
* @param string $user
* @return string xml/json
*/
private static function quotaGet($format, $user)
{
$login = OC_OCS::checkpassword();
if (OC_Group::inGroup($login, 'admin') or $login == $user) {
if (OC_User::userExists($user)) {
// calculate the disc space
$user_dir = '/' . $user . '/files';
OC_Filesystem::init($user_dir);
$rootInfo = OC_FileCache::get('');
$sharedInfo = OC_FileCache::get('/Shared');
$used = $rootInfo['size'] - $sharedInfo['size'];
$free = OC_Filesystem::free_space();
$total = $free + $used;
if ($total == 0) {
$total = 1;
}
// prevent division by zero
$relative = round($used / $total * 10000) / 100;
$xml = array();
$xml['quota'] = $total;
$xml['free'] = $free;
$xml['used'] = $used;
$xml['relative'] = $relative;
$txt = OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0);
echo $txt;
} else {
echo self::generateXml('', 'fail', 300, 'User does not exist');
}
} else {
echo self::generateXml('', 'fail', 300, 'You don´t have permission to access this ressource.');
}
}
示例6: 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
$rootInfo = OC_FileCache::get('');
$used = $rootInfo['size'];
$free = OC_Filesystem::free_space();
$total = $free + $used;
if ($total == 0) {
$total = 1;
}
// prevent division by zero
$relative = round($used / $total * 10000) / 100;
$email = OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
$lang = OC_Preferences::getValue(OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage());
$languageCodes = OC_L10N::findAvailableLanguages();
sort($languageCodes);
//put the current language in the front
unset($languageCodes[array_search($lang, $languageCodes)]);
array_unshift($languageCodes, $lang);
$languageNames = (include 'languageCodes.php');
$languages = array();
示例7: 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
示例8: OC_L10N
*
* @author Xavier Beurois
* @copyright 2012 Xavier Beurois www.djazz-lab.net
*
* This library is free software; you can redistribute it and/or
* 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 Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
OC_Util::checkAppEnabled('storage_charts');
OC::$CLASSPATH['OC_DLStCharts'] = "apps/storage_charts/lib/db.class.php";
OC::$CLASSPATH['OC_DLStChartsLoader'] = "apps/storage_charts/lib/loader.class.php";
$l = new OC_L10N('storage_charts', OC_L10N::findLanguage(array('en', 'fr')));
OC_App::register(array('order' => 60, 'id' => 'storage_charts', 'name' => 'Storage Charts'));
OC_App::addNavigationEntry(array('id' => 'storage_charts', 'order' => 60, 'href' => OC_Helper::linkTo('storage_charts', 'charts.php'), 'icon' => OC_Helper::imagePath('storage_charts', 'chart.png'), 'name' => 'DL Charts'));
OC_App::registerPersonal('storage_charts', 'settings');
$data_dir = OC_Config::getValue('datadirectory', '');
if (OC_User::getUser() && strlen($data_dir) != 0) {
$used = OC_DLStCharts::getTotalDataSize(OC::$CONFIG_DATADIRECTORY);
$total = OC_DLStCharts::getTotalDataSize($data_dir) + OC_Filesystem::free_space();
OC_DLStCharts::update($used, $total);
}
示例9: foreach
foreach ($_FILES['files']['error'] as $error) {
if ($error != 0) {
$l = OC_L10N::get('files');
$errors = array(UPLOAD_ERR_OK => $l->t('There is no error, the file uploaded with success'), UPLOAD_ERR_INI_SIZE => $l->t('The uploaded file exceeds the upload_max_filesize directive in php.ini: ') . ini_get('upload_max_filesize'), UPLOAD_ERR_FORM_SIZE => $l->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified' . ' in the HTML form'), UPLOAD_ERR_PARTIAL => $l->t('The uploaded file was only partially uploaded'), UPLOAD_ERR_NO_FILE => $l->t('No file was uploaded'), UPLOAD_ERR_NO_TMP_DIR => $l->t('Missing a temporary folder'), UPLOAD_ERR_CANT_WRITE => $l->t('Failed to write to disk'));
OCP\JSON::error(array('data' => array('message' => $errors[$error])));
exit;
}
}
$files = $_FILES['files'];
$dir = $_POST['dir'];
$error = '';
$totalSize = 0;
foreach ($files['size'] as $size) {
$totalSize += $size;
}
if ($totalSize > OC_Filesystem::free_space($dir)) {
OCP\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 = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
$target = OC_Filesystem::normalizePath($target);
if (is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
$meta = OC_FileCache::get($target);
$id = OC_FileCache::getId($target);
$result[] = array('status' => 'success', 'mime' => $meta['mimetype'], 'size' => $meta['size'], 'id' => $id, 'name' => basename($target));
}
示例10: array
$pathtohere .= '/' . $i;
$breadcrumb[] = array('dir' => $pathtohere, 'name' => $i);
}
}
// make breadcrumb und filelist markup
$list = new OCP\Template('files', 'part.list', '');
$list->assign('files', $files, false);
$list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
$list->assign('downloadURL', OCP\Util::linkTo('files', 'download.php') . '?file=', false);
$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$freeSpace = OC_Filesystem::free_space($dir);
$freeSpace = max($freeSpace, 0);
$maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
$permissions = OCP\PERMISSION_READ;
if (OC_Filesystem::isUpdatable($dir . '/')) {
$permissions |= OCP\PERMISSION_UPDATE;
}
if (OC_Filesystem::isDeletable($dir . '/')) {
$permissions |= OCP\PERMISSION_DELETE;
}
if (OC_Filesystem::isSharable($dir . '/')) {
$permissions |= OCP\PERMISSION_SHARE;
}
$tmpl = new OCP\Template('files', 'index', 'user');
$tmpl->assign('fileList', $list->fetchPage(), false);
$tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage(), false);