当前位置: 首页>>代码示例>>PHP>>正文


PHP disk_free_space函数代码示例

本文整理汇总了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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:37,代码来源:Filesystem.php

示例2: disk_use

function disk_use($dir)
{
    $df = disk_free_space($dir);
    $dt = disk_total_space($dir);
    $du = $dt - $df;
    return $du / $dt * 100;
}
开发者ID:albertok,项目名称:haarpcache,代码行数:7,代码来源:haarp.php

示例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;
 }
开发者ID:Ali-Shaikh,项目名称:linfo,代码行数:35,代码来源:OpenBSD.php

示例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> &nbsp; &nbsp;  <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> &nbsp; &nbsp;  <div class="clear"></div>';
        }
        echo "<br/>Total: <strong>" . $total . "</strong> GB &middot ";
        echo "Free: <strong>" . $free . "</strong> GB";
        echo "</div>";
    }
开发者ID:idoop,项目名称:Raspcontrol,代码行数:27,代码来源:_hdd.php

示例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;
     }
 }
开发者ID:javinc,项目名称:loadavg,代码行数:35,代码来源:log.Disk.php

示例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();
 }
开发者ID:NeilFee,项目名称:vipxinbaigo,代码行数:7,代码来源:MainAction.class.php

示例7: index

 public function index()
 {
     //服务器信息
     $info = array('操作系统' => PHP_OS, '运行环境' => $_SERVER["SERVER_SOFTWARE"], 'PHP运行方式' => php_sapi_name(), 'MYSQL版本' => mysql_get_server_info(), '85ZU版本' => ZU_VERSION . "&nbsp;&nbsp;&nbsp; [<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();
 }
开发者ID:BGCX262,项目名称:ztoa-svn-to-git,代码行数:7,代码来源:MainAction.class.php

示例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.';

        }
}
开发者ID:resnostyle,项目名称:mediafrontpage,代码行数:32,代码来源:wHardDrives.php

示例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);
     }
 }
开发者ID:StudsPro,项目名称:islandpeeps.com,代码行数:31,代码来源:frontend.php

示例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);
}
开发者ID:araynaud,项目名称:FoodPortrait,代码行数:34,代码来源:fp_functions.php

示例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();
 }
开发者ID:anywn3773,项目名称:gzsrex,代码行数:27,代码来源:MainAction.class.php

示例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;
 }
开发者ID:Maggan22,项目名称:wbb3addons,代码行数:33,代码来源:AdminToolsUtil.class.php

示例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;
 }
开发者ID:impelling,项目名称:VegaDNS,代码行数:26,代码来源:class.OS_Minix.php

示例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();
 }
开发者ID:gzwyufei,项目名称:hp,代码行数:7,代码来源:PublicController.class.php


注:本文中的disk_free_space函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。