本文整理汇总了PHP中disk_free_space函数的典型用法代码示例。如果您正苦于以下问题:PHP disk_free_space函数的具体用法?PHP disk_free_space怎么用?PHP disk_free_space使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了disk_free_space函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* Implementation Create Backup functionality for Filesystem
*
* @throws \Magento\Framework\Exception
* @return boolean
*/
public function create()
{
set_time_limit(0);
ignore_user_abort(true);
$this->_lastOperationSucceed = false;
$this->_checkBackupsDir();
$fsHelper = new \Magento\Framework\Backup\Filesystem\Helper();
$filesInfo = $fsHelper->getInfo($this->getRootDir(), \Magento\Framework\Backup\Filesystem\Helper::INFO_READABLE | \Magento\Framework\Backup\Filesystem\Helper::INFO_SIZE, $this->getIgnorePaths());
if (!$filesInfo['readable']) {
throw new \Magento\Framework\Backup\Exception\NotEnoughPermissions('Not enough permissions to read files for backup');
}
$freeSpace = disk_free_space($this->getBackupsDir());
if (2 * $filesInfo['size'] > $freeSpace) {
throw new \Magento\Framework\Backup\Exception\NotEnoughFreeSpace('Not enough free space to create backup');
}
$tarTmpPath = $this->_getTarTmpPath();
$tarPacker = new \Magento\Framework\Backup\Archive\Tar();
$tarPacker->setSkipFiles($this->getIgnorePaths())->pack($this->getRootDir(), $tarTmpPath, true);
if (!is_file($tarTmpPath) || filesize($tarTmpPath) == 0) {
throw new \Magento\Framework\Exception('Failed to create backup');
}
$backupPath = $this->getBackupPath();
$gzPacker = new \Magento\Framework\Archive\Gz();
$gzPacker->pack($tarTmpPath, $backupPath);
if (!is_file($backupPath) || filesize($backupPath) == 0) {
throw new \Magento\Framework\Exception('Failed to create backup');
}
@unlink($tarTmpPath);
$this->_lastOperationSucceed = true;
return $this->_lastOperationSucceed;
}
示例2: disk_use
function disk_use($dir)
{
$df = disk_free_space($dir);
$dt = disk_total_space($dir);
$du = $dt - $df;
return $du / $dt * 100;
}
示例3: getMounts
public function getMounts()
{
// Time?
if (!empty($this->settings['timer'])) {
$t = new Timer('Mounted file systems');
}
// Get result of mount command
try {
$mount_res = $this->exec->exec('mount');
} catch (Exception $e) {
Errors::add('Linfo Core', 'Error running `mount` command');
return array();
}
// Match that up
if (preg_match_all('/^(\\S+) on (\\S+) type (\\S+) \\(.+\\)$/m', $mount_res, $mount_matches, PREG_SET_ORDER) == 0) {
return array();
}
// Store them here
$mounts = array();
// Go through
foreach ($mount_matches as $mount) {
// Should we not show this?
if (in_array($mount[1], $this->settings['hide']['storage_devices']) || in_array($mount[3], $this->settings['hide']['filesystems'])) {
continue;
}
// Get these
$size = @disk_total_space($mount[2]);
$free = @disk_free_space($mount[2]);
$used = $size - $free;
// Might be good, go for it
$mounts[] = array('device' => $mount[1], 'mount' => $mount[2], 'type' => $mount[3], 'size' => $size, 'used' => $used, 'free' => $free, 'free_percent' => (bool) $free != false && (bool) $size != false ? round($free / $size, 2) * 100 : false, 'used_percent' => (bool) $used != false && (bool) $size != false ? round($used / $size, 2) * 100 : false);
}
// Give it
return $mounts;
}
示例4: freeStorage
function freeStorage()
{
$bytes = disk_free_space(".");
$si_prefix = array('B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB');
$base = 1024;
$class = min((int) log($bytes, $base), count($si_prefix) - 1);
$free = sprintf('%1.2f', $bytes / pow($base, $class));
$bytes = disk_total_space(".");
$si_prefix = array('B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB');
$base = 1024;
$class = min((int) log($bytes, $base), count($si_prefix) - 1);
$total = sprintf('%1.2f', $bytes / pow($base, $class));
$used = $total - $free;
$percentage = round($used / $total * 100);
if ($percentage > '80') {
echo '
<div style="float:left"><img src="app/images/sd.png" align="middle"> SD Card <font color="red"> (Warning)</font>:
<br/><br/><div class="graph"><strong class="barGreen" style="width:' . $percentage . '%;">' . $percentage . '%</strong></div> <div class="clear"></div>; ';
} else {
echo '
<div style="float:left"><img src="app/images/sd.png" align="middle"> SD Card <font color="green"> (OK)</font>:
<br/><div class="graph"><strong class="barGreen" style="width:' . $percentage . '%;">' . $percentage . '%</strong></div> <div class="clear"></div>';
}
echo "<br/>Total: <strong>" . $total . "</strong> GB · ";
echo "Free: <strong>" . $free . "</strong> GB";
echo "</div>";
}
示例5: logData
/**
* logDiskUsageData
*
* Retrives data and logs it to file
*
* @param string $type type of logging default set to normal but it can be API too.
* @return string $string if type is API returns data as string
* *
*/
public function logData($type = false)
{
$class = __CLASS__;
$settings = Logger::$_settings->{$class};
$timestamp = time();
$drive = $settings['settings']['drive'];
if (is_dir($drive)) {
$spaceBytes = disk_total_space($drive);
$freeBytes = disk_free_space($drive);
$usedBytes = $spaceBytes - $freeBytes;
//$freeBytes = dataSize($Bytes);
//$percentBytes = $freeBytes ? round($freeBytes / $totalBytes, 2) * 100 : 0;
}
$string = $timestamp . '|' . $usedBytes . '|' . $spaceBytes . "\n";
$filename = sprintf($this->logfile, date('Y-m-d'));
LoadUtility::safefilerewrite($filename, $string, "a", true);
//If alerts are enabled, check for alerts
if (Alert::$alertStatus) {
$this->checkAlerts($timestamp, $usedBytes, $spaceBytes, $settings);
}
if ($type == "api") {
return $string;
} else {
return true;
}
}
示例6: index
public function index()
{
//服务器信息
$info = array('操作系统' => PHP_OS, '运行环境' => $_SERVER["SERVER_SOFTWARE"], 'PHP运行方式' => php_sapi_name(), 'MYSQL版本' => mysql_get_server_info(), '上传附件限制' => ini_get('upload_max_filesize'), '执行时间限制' => ini_get('max_execution_time') . "秒", '剩余空间' => round(@disk_free_space(".") / (1024 * 1024), 2) . 'M');
$this->assign('server_info', $info);
$this->display();
}
示例7: index
public function index()
{
//服务器信息
$info = array('操作系统' => PHP_OS, '运行环境' => $_SERVER["SERVER_SOFTWARE"], 'PHP运行方式' => php_sapi_name(), 'MYSQL版本' => mysql_get_server_info(), '85ZU版本' => ZU_VERSION . " [<a href='http://www.85zu.com' target='_blank'>访问官网</a>]", '上传附件限制' => ini_get('upload_max_filesize'), '执行时间限制' => ini_get('max_execution_time') . "秒", '剩余空间' => round(@disk_free_space(".") / (1024 * 1024 * 1024), 2) . 'G');
$this->assign('server_info', $info);
$this->display();
}
示例8: widgetHardDrives
function widgetHardDrives() {
global $drive;
$warningthreshold = 90;
if(empty($drive)) {
echo "<table border=\"0\" id=\"harddrives\">\n";
echo "\t<col id=\"col-disk\" />\n";
echo "\t<col id=\"col-capacity\" />\n";
echo "\t<col id=\"col-remaining\" />\n";
echo "\t<col id=\"col-progress\" />\n";
echo "\t<tr>\n";
echo "\t\t<th>Disk</th>\n";
echo "\t\t<th>Capacity</th>\n";
echo "\t\t<th>Remaining</th>\n";
echo "\t\t<th>%</th>\n";
echo "\t</tr>\n";
foreach( $drive as $drivelabel => $drivepath) {
echo "\t<tr>\n";
echo "\t\t<td>".$drivelabel."</td>\n";
echo "\t\t<td>".to_readable_size(disk_total_space($drivepath))."</td>\n";
echo "\t\t<td>".to_readable_size(disk_free_space($drivepath))."</td>\n";
echo "\t\t<td><div class=\"progressbar\"><div class=\"progress".((disk_used_percentage($drivepath) > $warningthreshold) ? " warning" : "")."\" style=\"width:".(disk_used_percentage($drivepath))."%\"></div><div class=\"progresslabel\">".sprintf("%u", disk_used_percentage($drivepath))."%</div></div></td>\n";
echo "\t</tr>\n";
}
echo "</table>\n";
}
else{
echo 'You have not configured this feature in the config file yet.';
}
}
示例9: index
public function index()
{
$_user = $this->uri->segment(1);
if (isset($_user) && !empty($_user) && preg_match("/^[a-zA-Z0-9-_]+\$/", $_user)) {
if (isset($this->session->userdata['frontlogin']) && $this->session->userdata['frontlogin'] == true && $this->session->userdata['frontuser'] == $_user) {
$_details = $this->mFrontend->getDetailsbyURL($_user);
if ($_details != false) {
$this->session->set_userdata('importUnique', uniqid('imp_', true));
$this->session->set_userdata('fileByCustomer', '1');
$errortype = isset($_GET['errortype']) ? $_GET['errortype'] : false;
$errormsg = isset($_GET['errormsg']) ? urldecode($_GET['errormsg']) : '';
$_data = array('title' => __('front_title_welcome'), 'site' => 'frontend/dashboard', 'user' => $_details, 'addnavi' => true, 'errortype' => $errortype, 'errormsg' => $errormsg, 'allowupload' => $_details->userCanUpload == '1' ? 'yes' : 'no', 'showfree' => $this->mGlobal->getConfig('SHOW_FREESPACE_USER')->configVal, 'diskfree' => disk_free_space(FCPATH), 'disktotal' => disk_total_space(FCPATH), 'folder' => isset($_details->defaultFolderID) && !is_null($_details->defaultFolderID) && !empty($_details->defaultFolderID) ? $_details->defaultFolderID : '');
if ($_details->userCanUpload == '1') {
$this->load->view('frontend', $_data);
} else {
redirect($_user . '/userfiles');
}
} else {
redirect($_user . '/error');
}
} else {
redirect($_user . '/login');
}
} else {
if (mGlobal::getConfig('SHOW_CENTRAL_LOGIN')->configVal == 'yes') {
redirect('login');
}
$_data = array('title' => __('front_title_welcome'), 'site' => 'frontend/index', 'header' => 'header', 'errtype' => false, 'errmsg' => '');
$this->load->view('frontend', $_data);
}
}
示例10: __construct
/**
* @param srCertificate $certificate
*/
public function __construct(srCertificate $certificate)
{
parent::__construct($certificate);
$this->setEmail(ilSetting::_lookupValue('common', 'admin_email'));
$this->setSubject($this->pl->txt('disk_space_warning_mail_subject'));
$this->setBody(sprintf($this->pl->txt('disk_space_warning_mail_message'), disk_free_space($this->certificate->getCertificatePath())));
}
开发者ID:studer-raimann,项目名称:Certificate,代码行数:10,代码来源:class.srCertificateDiskSpaceWarningNotification.php
示例11: processUpload
function processUpload($file, $username = null)
{
if (!$username) {
$username = fpCurrentUsername();
}
$tmpFile = $file["tmp_name"];
$mimeType = $file["type"];
$filename = utf8_decode($file["name"]);
$filename = cleanupFilename($filename);
$getcwd = getcwd();
$freeSpace = disk_free_space("/");
$uploaded = is_uploaded_file($tmpFile);
$message = "OK";
if (!$uploaded) {
return errorMessage("Uploaded file not found.");
}
//verify file type
if (!startsWith($mimeType, "image")) {
return errorMessage("Uploaded file {$filename} is not an image. ({$mimeType})");
}
//move file to destination dir
$dataRoot = getConfig("upload._diskPath");
$dataRootUrl = getConfig("upload.baseUrl");
createDir($dataRoot, $username);
$uploadDir = combine($dataRoot, $username);
$uploadedFile = combine($dataRoot, $username, $filename);
$filesize = filesize($tmpFile);
$success = move_uploaded_file($tmpFile, $uploadedFile);
debug("move to {$uploadedFile}", $success);
if (!$success) {
return errorMessage("Cannot move file into target dir.");
}
return processImage($uploadDir, $filename);
}
示例12: main
public function main()
{
$db = D('');
$db = DB::getInstance();
$tables = $db->getTables();
$info = array('license' => 'a', 'yourphp_VERSION' => '', 'SERVER_SOFTWARE' => PHP_OS . ' ' . $_SERVER["SERVER_SOFTWARE"], 'mysql_get_server_info' => php_sapi_name(), 'MYSQL_VERSION' => mysql_get_server_info(), 'upload_max_filesize' => ini_get('upload_max_filesize'), 'max_execution_time' => ini_get('max_execution_time') . L('miao'), 'disk_free_space' => round(@disk_free_space(".") / (1024 * 1024), 2) . 'M');
$this->assign('server_info', $info);
foreach ((array) $this->module as $rw) {
if ($rw['type'] == 1) {
$molule = M($rw['name']);
$rw['counts'] = $molule->count();
$mdata['moduledata'][] = $rw;
}
}
$molule = M('User');
$counts = $molule->count();
$userinfos = $molule->find($_SESSION['adminid']);
$mdata['moduledata'][] = array('title' => L('user_counts'), 'counts' => $counts);
$molule = M('Category');
$counts = $molule->count();
$mdata['moduledata'][] = array('title' => L('Category_counts'), 'counts' => $counts);
$this->assign($mdata);
$role = F('Role');
$userinfo = array('username' => $userinfos['username'], 'groupname' => $role[$userinfos['groupid']]['name'], 'logintime' => toDate($userinfos['last_logintime']), 'last_ip' => $userinfos['last_ip'], 'login_count' => $userinfos['login_count'] . L('ci'));
$this->assign('userinfo', $userinfo);
$this->display();
}
示例13: readDiskInfo
/**
* Reads the disk quota info
*
* @param integer $pow
* @param integer $dec
* @return array
*/
public static function readDiskInfo($pow = 2, $dec = 2)
{
$diskInformation = array();
if (function_exists('disk_free_space') && function_exists('disk_total_space')) {
$root = '';
if ($tmp = @disk_total_space($_SERVER["DOCUMENT_ROOT"])) {
$root = $_SERVER["DOCUMENT_ROOT"];
} else {
$sql = "SELECT packageDir FROM wcf" . WCF_N . "_package\n \t\t\tWHERE packageID = " . PACKAGE_ID;
$row = WCF::getDB()->getFirstRow($sql);
$root = FileUtil::getRealPath(WCF_DIR . $row['packageDir']);
}
if (!empty($root)) {
$diskInformation['totalSpace'] = round(disk_total_space($root) / pow(1024, $pow), $dec);
$diskInformation['freeSpace'] = round(disk_free_space($root) / pow(1024, $pow), $dec);
$diskInformation['usedSpace'] = round($diskInformation['totalSpace'] - $diskInformation['freeSpace'], $dec);
if ($diskInformation['totalSpace'] > 0) {
$diskInformation['freeQuota'] = round($diskInformation['freeSpace'] * 100 / $diskInformation['totalSpace'], $dec);
$diskInformation['usedQuota'] = round($diskInformation['usedSpace'] * 100 / $diskInformation['totalSpace'], $dec);
} else {
$diskInformation['freeQuota'] = $diskInformation['usedQuota'] = 0;
}
}
}
return $diskInformation;
}
示例14: getMounts
public function getMounts()
{
// Try using the `mount` command to get mounted file systems
try {
$res = $this->exec->exec('mount');
} catch (CallExtException $e) {
return array();
}
// Try matching up the output
if (preg_match_all('/^(\\S+) is .+ mounted on (\\S+) \\(.+\\)$/m', $res, $mount_matches, PREG_SET_ORDER) == 0) {
return array();
}
// Store them here
$mounts = array();
// Go through each match
foreach ($mount_matches as $mount) {
// These might be a waste
$size = @disk_total_space($mount[2]);
$free = @disk_free_space($mount[2]);
$used = $size - $free;
// Save it
$mounts[] = array('device' => $mount[1], 'mount' => $mount[2], 'type' => '?', 'size' => $size, 'used' => $used, 'free' => $free, 'free_percent' => (bool) $free != false && (bool) $size != false ? round($free / $size, 2) * 100 : false, 'used_percent' => (bool) $used != false && (bool) $size != false ? round($used / $size, 2) * 100 : false);
}
// Return them
return $mounts;
}
示例15: main
public function main()
{
//$upyun_img = $this->createImgUpYun();
$info = array('操作系统' => PHP_OS, '运行环境' => $_SERVER["SERVER_SOFTWARE"], 'PHP运行方式' => php_sapi_name(), '上传附件限制' => ini_get('upload_max_filesize'), '执行时间限制' => ini_get('max_execution_time') . '秒', '服务器时间' => date("Y年n月j日 H:i:s"), '北京时间' => gmdate("Y年n月j日 H:i:s", time() + 8 * 3600), '服务器域名/IP' => $_SERVER['SERVER_NAME'] . ' [ ' . gethostbyname($_SERVER['SERVER_NAME']) . ' ]', '服务器剩余空间' => round(disk_free_space(".") / (1024 * 1024), 2) . 'M', 'register_globals' => get_cfg_var("register_globals") == "1" ? "ON" : "OFF", 'magic_quotes_gpc' => 1 === get_magic_quotes_gpc() ? 'YES' : 'NO', 'magic_quotes_runtime' => 1 === get_magic_quotes_runtime() ? 'YES' : 'NO');
$this->assign('info', $info);
$this->display();
}