prettify device edit form, move foldersize() to functions.inc.php

git-svn-id: http://www.observium.org/svn/observer/trunk@2551 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-09-23 10:16:31 +00:00
parent b4e93857c5
commit 40a9e83ee6
2 changed files with 73 additions and 59 deletions

View File

@@ -511,4 +511,29 @@ function getlocations()
return $locations; return $locations;
} }
function foldersize($path)
{
$total_size = 0;
$files = scandir($path);
$total_files = 0;
foreach($files as $t)
{
if (is_dir(rtrim($path, '/') . '/' . $t))
{
if ($t<>"." && $t<>"..")
{
$size = foldersize(rtrim($path, '/') . '/' . $t);
$total_size += $size;
}
} else {
$size = filesize(rtrim($path, '/') . '/' . $t);
$total_size += $size;
$total_files++;
}
}
return array($total_size, $total_files);
}
?> ?>

View File

@@ -49,32 +49,9 @@ if ($_POST['editing'])
$descr = $device['purpose']; $descr = $device['purpose'];
function foldersize($path) {
$total_size = 0;
$files = scandir($path);
$total_files = 0;
foreach($files as $t) {
if (is_dir(rtrim($path, '/') . '/' . $t)) {
if ($t<>"." && $t<>"..") {
$size = foldersize(rtrim($path, '/') . '/' . $t);
$total_size += $size;
}
} else {
$size = filesize(rtrim($path, '/') . '/' . $t);
$total_size += $size;
$total_files++;
}
}
return array($total_size, $total_files);
}
$override_sysLocation_bool = get_dev_attrib($device,'override_sysLocation_bool'); $override_sysLocation_bool = get_dev_attrib($device,'override_sysLocation_bool');
$override_sysLocation_string = get_dev_attrib($device,'override_sysLocation_string'); $override_sysLocation_string = get_dev_attrib($device,'override_sysLocation_string');
list($sizeondisk, $numrrds) = foldersize($config['rrd_dir']."/".$device['hostname']);
echo("<b>Size on Disk:" . formatStorage($sizeondisk) . " in " . $numrrds . " RRD files.</b>");
if ($updated && $update_message) if ($updated && $update_message)
{ {
@@ -91,23 +68,22 @@ if ($updated && $update_message)
<form id="delete_host" name="delete_host" method="post" action="<?php echo($config['base_url'].'/delhost/'); ?>"> <form id="delete_host" name="delete_host" method="post" action="<?php echo($config['base_url'].'/delhost/'); ?>">
<img src="images/16/server_delete.png" align="absmiddle"> <img src="images/16/server_delete.png" align="absmiddle">
<input type="hidden" name="id" value="<?php echo($device['device_id']); ?>"> <input type="hidden" name="id" value="<?php echo($device['device_id']); ?>">
<input type="submit" class="submit" name="Submit" value="Delete Host"> <input type="submit" class="submit" name="Submit" value="Delete device">
</form> </form>
</h5> </h5>
<form id="edit" name="edit" method="post" action="">
<form id="edit" name="edit" method="post" action=""> <input type=hidden name="editing" value="yes">
<input type=hidden name="editing" value="yes"> <table width="500" border="0">
<table width="500" border="0"> <tr>
<tr> <td colspan="2" align="right">Description:</td>
<td colspan="2" align="right">Description:</td> <td colspan="3"><input name="descr" size="32" value="<?php echo($device['purpose']); ?>"></input></td>
<td colspan="3"><input name="descr" size="32" value="<?php echo($device['purpose']); ?>"></input></td> </tr>
</tr> <tr>
<tr> <td colspan="2" align="right">
<td colspan="2" align="right"> Type:
Type: </td>
</td> <td>
<td> <select name="type">
<select name="type">
<?php <?php
$unknown = 1; $unknown = 1;
@@ -126,25 +102,38 @@ foreach ($config['device_types'] as $type)
echo(' <option value="other">Other</option>'); echo(' <option value="other">Other</option>');
} }
?> ?>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td width="40"><div style="padding-right: 5px; text-align: right"><input onclick="edit.sysLocation.disabled=!edit.override_sysLocation.checked" type="checkbox" name="override_sysLocation"<?php if ($override_sysLocation_bool) { echo(' checked="1"'); } ?> /></div></td> <td width="40"><div style="padding-right: 5px; text-align: right"><input onclick="edit.sysLocation.disabled=!edit.override_sysLocation.checked" type="checkbox" name="override_sysLocation"<?php if ($override_sysLocation_bool) { echo(' checked="1"'); } ?> /></div></td>
<td width="150" align="right">Override sysLocation:</td> <td align="right">Override sysLocation:</td>
<td><input name="sysLocation" size="32"<?php if (!$override_sysLocation_bool) { echo(' disabled="1"'); } ?> value="<?php echo($override_sysLocation_string); ?>" /></td> <td colspan="3"><input name="sysLocation" size="32"<?php if (!$override_sysLocation_bool) { echo(' disabled="1"'); } ?> value="<?php echo($override_sysLocation_string); ?>" /></td>
</tr> </tr>
<tr> <tr>
<td colspan="2"><div align="right">Disable</div></td> <td colspan="2"><div align="right">Disable</div></td>
<td><input name="disabled" type="checkbox" id="disabled" value="1" <?php if ($device["disabled"]) { echo("checked=checked"); } ?> /></td> <td><input name="disabled" type="checkbox" id="disabled" value="1" <?php if ($device["disabled"]) { echo("checked=checked"); } ?> /></td>
<td><div align="right">Ignore</div></td> <td><div align="right">Ignore</div></td>
<td><input name="ignore" type="checkbox" id="disable" value="1" <?php if ($device['ignore']) { echo("checked=checked"); } ?> /></td> <td><input name="ignore" type="checkbox" id="disable" value="1" <?php if ($device['ignore']) { echo("checked=checked"); } ?> />&nbsp;</td>
</tr> </tr>
</table> </table>
<input type="submit" name="Submit" value="Save" /> <input type="submit" name="Submit" value="Save" />
<label><br /> <label><br />
</label> </label>
</form> </form>
</td>
</tr>
</table>
<br />
</td> <?php
<td width="50"></td><td></td></tr></table>
print_optionbar_start();
list($sizeondisk, $numrrds) = foldersize($config['rrd_dir']."/".$device['hostname']);
echo("Size on Disk: <b>" . formatStorage($sizeondisk) . "</b> in <b>" . $numrrds . " RRD files</b>.");
print_optionbar_end();
?>