本文整理汇总了PHP中FileSystem::formatFileSize方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::formatFileSize方法的具体用法?PHP FileSystem::formatFileSize怎么用?PHP FileSystem::formatFileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::formatFileSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_default
public function action_default()
{
if (Modul::hasAccess('system') == false) {
return '<div class="notice error">Sie haben keinen Zugriff</div>';
}
$query = $GLOBALS['pdo']->prepare("SELECT count(vmID) AS `vms`, SUM(IF(status=1,1,0)) AS `vms_on` FROM vm");
$query->execute();
$data = $query->fetch();
$query = $GLOBALS['pdo']->prepare("SELECT imageID FROM images");
$query->execute();
$images = $query->rowCount();
$tmp = new RainTPL();
$tmp->assign('vms', $data['vms']);
$tmp->assign('vms_on', $data['vms_on']);
$tmp->assign('images', $images);
$ram = Server::getRamSettings();
if ($ram) {
$ram_usage = FileSystem::formatFileSize($ram['used']) . ' / ' . FileSystem::formatFileSize($ram['all']);
} else {
$ram_usage = 'linux only';
}
$tmp->assign('ram_usage', $ram_usage);
$cpu = Server::getCPUusage();
if ($cpu) {
$cpu_usage = implode(" ", array_values($cpu));
} else {
$cpu_usage = 'linux only';
}
$tmp->assign('cpu_usage', $cpu_usage);
$free = disk_free_space('/');
$all = disk_total_space('/');
$tmp->assign('free', FileSystem::formatFileSize($all - $free));
$tmp->assign('all', FileSystem::formatFileSize($all));
$qemu_ram = Server::getQemuRamTemp();
if ($qemu_ram !== false) {
$tmp->assign('ram_qemu', FileSystem::formatFileSize($qemu_ram));
} else {
$tmp->assign('ram_qemu', 'linux only');
}
$roles = '';
$query = $GLOBALS['pdo']->prepare("SELECT * FROM roles");
$query->execute();
while ($ds = $query->fetch()) {
$roles .= '<option value="' . $ds['roleID'] . '">' . $ds['name'] . '</option>';
}
$roles = str_replace('value="' . $GLOBALS['config']['default_role'] . '"', 'value="' . $GLOBALS['config']['default_role'] . '" selected="selected"', $roles);
$tmp->assign('roles', $roles);
foreach ($GLOBALS['config'] as $key => $value) {
$tmp->assign($key, $value);
}
return $tmp->draw('system', true);
}
示例2: action_status
public function action_status()
{
$image = $_GET['image'];
$query = $GLOBALS['pdo']->prepare("SELECT * FROM images WHERE imageID= :imageID");
$query->bindValue(":imageID", $image, PDO::PARAM_INT);
$query->execute();
if ($query->rowCount() > 0) {
$data = $query->fetch();
$tmp2 = new RainTPL();
$tmp2->assign('path', $data['path']);
$tmp2->assign('type', 'n/a');
$tmp2->assign('virtual_size', 'n/a');
$tmp2->assign('real_size', 'n/a');
$status = Image::getStatus($data['imageID']);
if ($data['type'] == "usb") {
$tmp2->assign('type', "USB");
$tmp2->assign('path', $data['path'] . " - " . Server::getUsbDeviceName($data['path']));
} elseif (isset($status['type'])) {
$tmp2->assign('type', $status['type']);
$tmp2->assign('virtual_size', FileSystem::formatFileSize($status['virtual_size']));
$tmp2->assign('real_size', FileSystem::formatFileSize(Helper::toBytes($status['real_size'])));
}
return $tmp2->draw('images_status', true);
} else {
return '<div class="notice warning">Es existiert kein Image mit dieser ID</div>';
}
}
示例3: action_default
public function action_default()
{
$tmp2 = new RainTPL();
$query = $GLOBALS['pdo']->prepare("SELECT * FROM vm WHERE owner = :owner");
$query->bindValue(":owner", $_SESSION['user']->id, PDO::PARAM_INT);
$query->execute();
if ($query->rowCount() > 0) {
$vms = array();
while ($ds = $query->fetch()) {
if ($ds['lastrun'] != '0000-00-00') {
$lastrun = date("d.m.Y H:i", strtotime($ds['lastrun']));
} else {
$lastrun = '---';
}
if ($ds['status'] == QemuMonitor::RUNNING) {
$buttons = '<a href="index.php?site=myvm&action=stop&vmID=' . $ds['vmID'] . '" class="button red small center"><span class="icon" data-icon="Q"></span>Stop</a>';
$buttons .= '<a href="screenshot.php?vmID=' . $ds['vmID'] . '" class="button small center"><span class="icon" data-icon="0"></span>Screenshot</a>';
if ($ds['password']) {
$buttons .= '<a href="vnc.php?vmID=' . $ds['vmID'] . '" class="button small center grey"><span class="icon" data-icon="0"></span>VNC</a>';
$buttons .= '<a href="index.php?site=vnc&vmID=' . $ds['vmID'] . '" class="button small center grey"><span class="icon" data-icon="0"></span>Web-VNC</a>';
} else {
$buttons .= '<a href="#' . $ds['vmID'] . '" disabled="disabled" class="button small center grey vm_disabled"><span class="icon" data-icon="0"></span>VNC</a>';
}
} else {
$buttons = '<a href="index.php?site=myvm&action=start&vmID=' . $ds['vmID'] . '" class="button green small center"><span class="icon" data-icon=" "></span>Start</a>';
$buttons .= '<a class="button small center grey"><span class="icon" data-icon="G"></span>Edit</a>';
}
$vm = array();
$vm['lastrun'] = $lastrun;
$vm['buttons'] = $buttons;
$vm['name'] = $ds['name'];
$vm['ram'] = FileSystem::formatFileSize($ds['ram'] * 1024 * 1024, 0);
$vms[] = $vm;
}
$tmp2->assign('vms', $vms);
return $tmp2->draw('myvm_table', true);
} else {
return "Du hast noch keine VM. Du musst warten bis dir eine zugeteilt wird von den Admins.";
}
}
示例4: action_default
public function action_default()
{
if (Modul::hasAccess('vm_edit', 'vm_create', 'vm_remove') == false) {
return '<div class="notice error">Sie haben keinen Zugriff</div>';
}
$tmp2 = new RainTPL();
$query = $GLOBALS['pdo']->query("SELECT * FROM vm");
$query2 = $GLOBALS['pdo']->prepare("SELECT *,i.path,i.type FROM vm_images v JOIN images i ON i.imageID=v.imageID WHERE v.vmID = :vmID");
$query2->bindParam(':vmID', $vmID, PDO::PARAM_INT);
if ($query->rowCount()) {
$vms = array();
while ($ds = $query->fetch()) {
$vmID = $ds['vmID'];
if ($ds['lastrun'] != '0000-00-00 00:00:00') {
$lastrun = date("d.m.Y H:i", strtotime($ds['lastrun']));
} else {
$lastrun = '---';
}
if ($ds['status'] == QemuMonitor::RUNNING) {
$buttons = '<a href="index.php?site=vms&action=stop&vmID=' . $ds['vmID'] . '" class="button red small center "><span class="icon" data-icon="Q"></span>Stop</a>';
$buttons .= '<a href="vnc.php?vmID=' . $ds['vmID'] . '"class="button small center grey"><span class="icon" data-icon="0"></span>VNC</a>';
} else {
$buttons = '<a href="index.php?site=vms&action=start&vmID=' . $ds['vmID'] . '" class="button green small center"><span class="icon" data-icon=" "></span>Start</a>';
$buttons .= '<a href="index.php?site=vms&action=edit&vmID=' . $ds['vmID'] . '" class="button small center grey"><span class="icon" data-icon="G"></span>Edit</a>';
$buttons .= '<a href="index.php?site=vms&action=clone&vmID=' . $ds['vmID'] . '" class="button small center grey"><span class="icon" data-icon="R"></span>Clone</a>';
$buttons .= '<a href="index.php?site=vms&action=delete&vmID=' . $ds['vmID'] . '" class="button small center grey"><span class="icon" data-icon="T"></span>Delete</a>';
}
$vm = array();
$vm['name'] = $ds['name'];
$vm['owner'] = User::getUserName($ds['owner']);
$vm['ram'] = FileSystem::formatFileSize($ds['ram'] * 1024 * 1024, 0);
$vm['lastrun'] = $lastrun;
$vm['buttons'] = $buttons;
$images = array();
$query2->execute();
while ($dq = $query2->fetch()) {
$images[] = $dq['name'];
}
$vm['images'] = implode(", ", $images);
$vms[] = $vm;
}
$tmp2->assign('vms', $vms);
} else {
$tmp2->assign('vms', "Es gibt noch keine VMs.");
}
return $tmp2->draw('vms_main', true);
}