Файл: id2759/PHP Version/fileman/space.php
Строк: 145
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | Aquonics File Manager |
// +----------------------------------------------------------------------+
// | Copyright (c) 2001 Aquonics Scripting |
// +----------------------------------------------------------------------+
// | You may not remove the copyright or redistribute the script in any |
// | form. This program is Freeware, please read the license at |
// | http://www.aquonics.com/license.php |
// | |
// | Visit www.aquonics.com for more top scripts, free and custom. |
// +----------------------------------------------------------------------+
// | Authors: Stephen Ball <stephen@aquonics.com> |
// +----------------------------------------------------------------------+
//
// $Id$
error_reporting(0); /* Turn off ugly error messages */
set_time_limit(60); /* Ensure the script doesn't time out */
// Try to include important files
// or die with an error message
if (!(include("./common.lib.php"))) {
die("<html><head><title>Error!</title></head><body bgcolor="#FFFFFF"><font size="2" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000"><center><b>There was an error loading the library file.</b></center></font></body></html>");
}
if (!(include("./settings.inc.php"))) {
die("<html><head><title>Error!</title></head><body bgcolor="#FFFFFF"><font size="2" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000"><center><b>There was an error loading the settings file.</b></center></font></body></html>");
}
$username = $HTTP_COOKIE_VARS["username"];
$password = $HTTP_COOKIE_VARS["password"];
// Find out the starttime
$starttime = starttime();
// Ensure the user is valid
if (validate_user($username, $password) == 0) {
header("Location: ./" . $login_script . "");
exit;
}
// Print the page header
html_header("Server Space");
// Create the $total variable
$total = 0;
// A function that gets the dirsize
function dirsize($dir) {
global $total;
chdir($dir);
$handle = opendir($dir);
while($entry = readdir($handle)) {
if (is_dir($dir . $entry) && $entry != ".." && $entry != ".") {
dirsize($dir . $entry . "/");
}
else if ($entry != ".." && $entry != ".") {
$total += filesize($dir . $entry);
}
}
closedir($handle);
return $total;
}
// A function to find out if GD with PNG support is installed
function gdinstalled() {
$os = php_uname();
$extension_dir = ini_get("extension_dir");
if (eregi("win", $os)) {
$lib = "php_gd.dll";
}
else {
$lib = "php_gd.so";
}
if (extension_loaded("gd")) {
$loaded = 1;
}
else if (ini_get("enable_dl") == 0) {
return false;
}
else if (ini_get("safe_mode") == 0) {
return false;
}
else if (!(extension_loaded("gd"))) {
ini_set("include_path", "./");
if (file_exists("./$lib") && dl($lib)) {
$loaded = 1;
}
}
if($loaded == 1) {
if (ImageTypes() & IMG_PNG) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
$used = dirsize($root_dir);
$free = $space - $used;
if (gdinstalled()) {
$graph = "<img src="images/chart.php?used=$used&free=$free" width="180" height="180" alt="Space Usage" /><font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000"><br /><b>Blue</b> - Free Space<br /><b>White</b> - Used Space</font>";
}
else {
$graph = "<img src="images/nogd.gif" width="180" height="180" alt="GD is not installed" /><font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000"><br /><center>No chart could be generated</center></font>";
}
// Print the form
?>
<tr>
<td align="left" bgcolor="#4682B4" colspan="2">
<table border="0" width="100%">
<tr>
<th align="left" bgcolor="#4682B4" valign="middle" width="99%"><img src="images/browse.gif" alt="Space Usage" border="0" /> <font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#FFFFFF">Server Space</font></th>
<td align="right" bgcolor="#4682B4" valign="middle" width="1%" nowrap="nowrap"><a href="<?=$main_script;?>"><img src="images/home.gif" alt="Home" border="0" /></a> <a href="<?=$space_script;?>"><img src="images/space.gif" alt="Server Space" border="0" /></a> <a href="<?=$login_script;?>?op=out"><img src="images/logout.gif" alt="Logout" border="0" /></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" bgcolor="#F5F5F5">
<table border="0" width="100%">
<tr>
<td align="left" valign="middle" width="15%"><?=$graph;?></td>
<td align="left" valign="top" width="85%"><font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000"><b>Figures</b><br /><br /><b>Used Space</b>: <?php echo formatsize($used); ?><br /><b>Free Space</b>: <?php echo formatsize($free); ?><br />____________________________<br /><br /><b>Total Space</b>: <?php echo formatsize($space); ?></font></td>
</tr>
</table>
</td>
</tr>
</table>
<?php
// Print out the page footer
html_footer($starttime);
?>