4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: bananaboy on May 05, 2010, 11:35:38 PM
-
moin ...
hatte vor langer zeit mal ein plugin zusammengefummelt welches den webspace bzw. dessen belegung ausliest und anzeigen kann .
ansich finde ich es soweit ganz ok ... nur bin ich "bisken blind auffe augen" :mrgreen:
ich bekomme den balken nicht auf 100% des fenters ...
kommt da jemand drauf den balken auch auf 100% zu strecken sodas er trotzdem richtig anzeigt ?
hier mal das plugin ....
ihr müsst es nur an euren server anpassen ...
also größe in MB und absoluten pfad zum webspace und zum media-ordner
BITTE DEN CODE UNTEN NUTZEN ->>
danke
gruss
"bananaboy"
-
moin ...
ich hab jetzt alles mögliche versucht ...
aber ich komme leider in dieser form nicht zum gewünschten erfolg.
hatte zwar eine idee bzw. versucht es anders darzustellen, jedoch wurde es quasi ähnlich eines tortendiagramms
eben nur als linie dargestellt .
also anteilsmäßig aber nicht überlappend .
zuletzt hatte ich noch 'ne idee welche ansich auch funktionierte nur spielt da mal wieder der IE und der Safari nicht mit ... firefox hatte damit aber kein problem .
naja ...
ich habe es nun wie folgt in meinem plugin ordner ...
wer's haben möchte ... bitte .
webspace.php
<?php // PLUGIN_TITLE: Webspace Verbrauch
$nozip = 1;
define('IN_CP', 1);
$root_path = (!eregi("\/plugins\/", $_SERVER['PHP_SELF'])) ? "./../" : "./../../";
define('ROOT_PATH', $root_path);
require(ROOT_PATH.'admin/admin_global.php');
show_admin_header();
/*** Konfiguration ***/
// Maximale Webspacekapazitaet
// wird in Megabyte (MB) angegeben
$maxspace = "5000";
// Farben fuer der Ausgabe
$free = "#1F8624";
$used = "#E21D1D";
$data = "#FCC543";
// Breite des Balkens (in Pixel)
$width = "800";
/****** Script *******/
// Source anzeigen
if ($_GET['source'] == true) { show_source(basename($PHP_SELF)); exit; }
// damit keine Fehler angezeigt werden,
// wenn Verzeichnisse nicht gelesen werden koennen
error_reporting(0);
// Verzeichnisse lesen und Groesse zurückgeben
function dirsize($directory)
{
if (!is_dir($directory)) return -1;
$size = 0;
if ($DIR = opendir($directory))
{
while (($dirfile = readdir($DIR)) !== false)
{
if (is_link($directory.'/'.$dirfile) || $dirfile == '.' || $dirfile == '..' || $dirfile == 'logfiles' || $dirfile == 'phptemp')
continue;
if (is_file($directory.'/'.$dirfile))
$size += filesize($directory.'/'.$dirfile);
else if (is_dir($directory.'/'.$dirfile))
{
$dirSize = dirsize($directory.'/'.$dirfile);
if ($dirSize >= 0) $size += $dirSize;
else return -1;
}
}
closedir($DIR);
}
return $size;
}
// Ausgabe
function editsize($bytes, $cfr, $cd)
{
$kb = "1024";
$mb = $kb * "1024";
$gb = $mb * "1024";
$tb = $gb * "1024";
if ($bytes < $kb) { $size = $bytes; $ext = "Byte"; }
elseif ($bytes < $mb) { $size = $bytes / $kb; $ext = "KB"; }
elseif ($bytes < $gb) { $size = $bytes / $mb; $ext = "MB"; }
elseif ($bytes < $tb) { $size = $bytes / $gb; $ext = "GB"; }
if ($cfr == "c") { $size = ceil($size); }
elseif ($cfr == "f") { $size = floor($size); }
elseif ($cfr == "r") { $size = round($size, 2); }
if ($cd == "c") { $size = str_replace(".", ",", $size); }
elseif ($cd == "d") { $size = str_replace(",", ".", $size); }
return $size." ".$ext;
}
// Hier den Pfad anpassen ! (als 4images plugin so lassen oder absoluten Pfad des Servers angeben)
$usedspace = dirsize("./../../");
$usedspace_2 = dirsize("./../../data/media/");
if ($usedspace < "0") { echo "Fehler: Konnte Dateien nicht lesen."; }
else {
$maxspace = $maxspace * 1024 * 1024;
$freespace = $maxspace - $usedspace;
$dataspace = $usedspace_2;
$used_p = round(($usedspace * 100) / $maxspace, 2); $used_p = str_replace(".", ",", $used_p);
$free_p = round(($freespace * 100) / $maxspace, 2); $free_p = str_replace(".", ",", $free_p);
$data_p = round(($dataspace * 100) / $maxspace, 2); $data_p = str_replace(".", ",", $data_p);
$width_used = ($width * $used_p) / 100;
if ($width_used >= $width) { $width_used = $width;
}
$width_data = ($width * $data_p) / 100;
if ($width_data >= $width) { $width_data = $width;
}
}
?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td class="tableborder"> <table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr class="tableheader">
<td colspan="2"><a name=""><b><span class="tableheader">Webspace Verbrauch</span></b></a>
</td>
</tr>
<tr class="tablerow" valign="top">
<td colspan="2" ><p class="rowtitle">
<style type="text/css" media="all">
* { font-size:11px; font-weight:bold; }
body { text-align:left; margin:0px; padding:20px; cursor:default; }
div.used { width:<?=$width?>; background-color:<?=$free?>; padding:0px; margin:0px; border:1px black solid; }
div.free { text-align:left; width:<?=$width_used?>; background-color:<?=$used?>; padding:0px; margin:0px; }
div.data { text-align:left; width:<?=$width_data?>; background-color:<?=$data?>; padding:0px; margin:0px; }
.tused { white-space:nowrap; color:<?=$used?>; }
.tfree { white-space:nowrap; color:<?=$free?>; }
.tdata { white-space:nowrap; color:<?=$data?>; }
.uebersicht { text-align:left; padding:5px; margin:0px 5px 0px 0px; white-space:nowrap; }
</style>
<table border="1" width="100%" cellspacing="20" cellpadding="20" style="border-collapse: collapse">
<tr>
<td>
<p align="center">
<div style="<?=$width?>">
<div class="used"><div class="free"><div class="data"> </div></div></div>
<div><div style="float:left;">0%</div><div style="float:right;">100%</div></div>
<div style="text-align:center;">
<br /><br />
<fieldset class="uebersicht">
<legend><span style="font-weight:bold;">Webspace Übersicht</span></legend>
<div style="float:left; width:70%;">
<div style="float:left; white-space:nowrap;">gesamt:</div><div style="float:right; white-space:nowrap;"><?=editsize($maxspace, r, c);?></div><br />
<div class="tused" style="float:left;">belegt:</div><div class="tused" style="float:right;"><?=editsize($usedspace, r, c);?></div><br />
<div class="tdata" style="float:left;">media:</div><div class="tdata" style="float:right;"><?=editsize($dataspace, r, c);?></div><br />
<div class="tfree" style="float:left;">frei:</div><div class="tfree" style="float:right;"><?=editsize($freespace, r, c);?></div><br />
</div>
<div style="float:left; width:5%;"> ~ <br /> ~ <br /> ~ <br /> ~ <br /></div>
<div style="float:left; width:25%; text-align:right;"><span style="white-space:nowrap;">
100 %</span><br /><span class="tused"><?=$used_p?> %</span><br /><span class="tdata"><?=$data_p?> %</span><br />
<span class="tfree"><?=$free_p?> %</span><br /></div>
</fieldset>
</div>
</div>
</td>
</tr>
</table></td>
</tr>
</table>
</table>
<?php
END;
show_admin_footer();
?>
hab mal ein bild dazu gepackt damit man es sehen kann wie es aussieht :wink:
mein webspace beträgt zwar 10gb aber ich habe im script mal 500 mb eingetragen damit man den balken besser sehen kann :mrgreen:
gruss
"bananaboy"
-
Richtig COOL!
Danke dafür!
Bekomme aber folgende Fehlermeldung:
Warning: require(./../admin/admin_global.php) [function.require]: failed to open stream: No such file or directory in /www/htdocs/w00b2576/gamevote/admin/plugins/webspace.php on line 7
Warning: require(./../admin/admin_global.php) [function.require]: failed to open stream: No such file or directory in /www/htdocs/w00b2576/gamevote/admin/plugins/webspace.php on line 7
Fatal error: require() [function.require]: Failed opening required './../admin/admin_global.php' (include_path='.:/usr/share/php:..') in /www/htdocs/w00b2576/gamevote/admin/plugins/webspace.php on line 7
-
moin ...
wie sieht es denn mit deinen anderen plugins aus ... ?
haben die auch folgendes im kopf stehen ?
<?php // PLUGIN_TITLE: hier der titel
$nozip = 1;
define('IN_CP', 1);
$root_path = (eregi("\/plugins\/", $PHP_SELF)) ? "./../../" : "./../";
define('ROOT_PATH', $root_path);
require(ROOT_PATH.'admin/admin_global.php');
show_admin_header();
und das hier ... ist das dein absoluter pfad ?
/www/htdocs/w00b2576/gamevote/
welches der beiden scripte hast du denn genommen ?
gruss
"bananaboy"
-
Es läuft nun,
musste nur den Headbreich ändern in:
$nozip = 1;
define('IN_CP', 1);
$root_path = (!eregi("\/plugins\/", $_SERVER['PHP_SELF'])) ? "./../" : "./../../";
define('ROOT_PATH', $root_path);
require(ROOT_PATH.'admin/admin_global.php');
-
...
ok ... super ! :thumbup:
ich ändere das dann auch gleich mal in dem script oben und im download .
viel spass
gruss
"bananaboy"
-
nice and easy. thanks!
-
Hi!
...
kommt da jemand drauf den balken auch auf 100% zu strecken sodas er trotzdem richtig anzeigt ?....
das sollte funktionieren:
<?php // PLUGIN_TITLE: Webspace Verbrauch
$nozip = 1;
define('IN_CP', 1);
define('ROOT_PATH', "./../../");
require(ROOT_PATH.'admin/admin_global.php');
show_admin_header();
/*** Konfiguration ***/
// Maximale Webspacekapazitaet
// wird in Megabyte (MB) angegeben
$maxspace = "10000";
// Farben fuer der Ausgabe
$free = "#1F8624";
$used = "#E21D1D";
$data = "#FCC543";
/****** Script *******/
// Source anzeigen
if ($_GET['source'] == true) { show_source(basename($PHP_SELF)); exit; }
// damit keine Fehler angezeigt werden,
// wenn Verzeichnisse nicht gelesen werden koennen
error_reporting(0);
// Verzeichnisse lesen und Groesse zurückgeben
function dirsize($directory)
{
if (!is_dir($directory)) return -1;
$size = 0;
if ($DIR = opendir($directory))
{
while (($dirfile = readdir($DIR)) !== false)
{
if (is_link($directory.'/'.$dirfile) || $dirfile == '.' || $dirfile == '..' || $dirfile == 'logfiles' || $dirfile == 'phptemp')
continue;
if (is_file($directory.'/'.$dirfile))
$size += filesize($directory.'/'.$dirfile);
else if (is_dir($directory.'/'.$dirfile))
{
$dirSize = dirsize($directory.'/'.$dirfile);
if ($dirSize >= 0) $size += $dirSize;
else return -1;
}
}
closedir($DIR);
}
return $size;
}
// Ausgabe
function editsize($bytes, $cfr, $cd){
$kb = "1024";
$mb = $kb * "1024";
$gb = $mb * "1024";
$tb = $gb * "1024";
if($bytes < $kb) {$size = $bytes;$ext = "Byte";}
elseif($bytes < $mb) {$size = $bytes / $kb; $ext = "KB";}
elseif($bytes < $gb) {$size = $bytes / $mb; $ext = "MB";}
elseif($bytes < $tb) {$size = $bytes / $gb; $ext = "GB";}
if($cfr == "c") {$size = ceil($size);}
elseif($cfr == "f") {$size = floor($size);}
elseif($cfr == "r") {$size = round($size, 2);}
if($cd == "c") {$size = str_replace(".", ",", $size);}
elseif ($cd == "d") { $size = str_replace(",", ".", $size);}
return $size." ".$ext;
}
$usedspace = dirsize($root_path);
$usedspace_2 = dirsize($root_path."/data/media/");
if($usedspace < "0"){
echo "Fehler: Konnte Dateien nicht lesen.";
}
else{
$maxspace = $maxspace * 1024 * 1024;
$freespace = $maxspace - $usedspace;
$dataspace = $usedspace_2;
$free_p = round(($freespace * 100) / $maxspace, 2);
$used_p = round(($usedspace * 100) / $maxspace, 2);
$data_p = round(($dataspace * 100) / $maxspace,2);
$free_width = round($free_p,1)."%";
$data_width = round($data_p,1)."%";
$used_width = round($used_p - $data_p,1)."%";
$all = $free_width + $data_width + $used_width;
$free_p = str_replace(".", ",", $free_p);
$used_p = str_replace(".", ",", $used_p);
$data_p = str_replace(".", ",", $data_p);
}
?>
<style type="text/css">
*{font-size:11px;font-weight:bold;}
body{text-align:left; margin:0px;padding:20px;}
.used{float:left;height:20px;width:<?=$used_width?>;background-color:<?=$used?>;padding:0px;margin:0px;}
.free{background-color:<?=$free?>;height:20px;width:100%;padding:0px 0px 0px 0px; margin:0px; border:1px black solid;}
.data{float:left;height:20px;width:<?=$data_width?>;background-color:<?=$data?>;padding:0px;margin:0px;}
.tused{white-space:nowrap;color:<?=$used?>;}
.tfree{white-space:nowrap;color:<?=$free?>;}
.tdata{white-space:nowrap;color:<?=$data?>;}
.uebersicht{text-align:left;padding:5px;margin:0px 5px 0px 0px;}
</style>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td class="tableborder">
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr class="tableheader">
<td colspan="2"><a name=""><b><span class="tableheader">Webspace Verbrauch</span></b></a>
</td>
</tr>
<tr class="tablerow" valign="top">
<td colspan="2" ><p class="rowtitle">
<table border="0" width="100%" cellspacing="20" cellpadding="20" style="border-collapse: collapse">
<tr>
<td>
<div class="free">
<div class="data"></div>
<div class="used"></div>
<div style="clear:both;"></div>
</div>
<div style="float:left;">0</div><div style="text-align:right;"><?=editsize($maxspace, r, c);?></div>
<br>
<br>
<fieldset class="uebersicht">
<legend><span style="font-weight:bold;">Webspace Übersicht</span></legend>
<div style="float:left; width:70%;">
<div style="float:left; white-space:nowrap;">gesamt:</div><div style="float:right; white-space:nowrap;"><?=editsize($maxspace, r, c);?></div><br>
<div class="tused" style="float:left;">belegt:</div><div class="tused" style="float:right;"><?=editsize($usedspace, r, c);?></div><br>
<div class="tdata" style="float:left;">media:</div><div class="tdata" style="float:right;"><?=editsize($dataspace, r, c);?></div><br>
<div class="tfree" style="float:left;">frei:</div><div class="tfree" style="float:right;"><?=editsize($freespace, r, c);?></div><br>
</div>
<div style="float:left; width:5%;"> ~ <br> ~ <br> ~ <br> ~ <br></div>
<div style="float:left; width:25%; text-align:right;">
<span style="white-space:nowrap;">100 %</span><br>
<span class="tused"><?=$used_p?> %</span><br>
<span class="tdata"><?=$data_p?> %</span><br>
<span class="tfree"><?=$free_p?> %</span><br>
</div>
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
END;
show_admin_footer();
?>
-
Fehler: Konnte Dateien nicht lesen.
Das kommt wenn ich die Datei aufrufe :cry:
Woran kann das liegen?
-
Fehler: Konnte Dateien nicht lesen..
welche datei ?
wo hast du sie hineinkopiert?
wo rufst du sie auf?
-
Die Datei von bananaboy´s 2tem Posting
ich rufe die Datei so auf : admin/webspace.php?action=Webspace
CHMOD 644
Hab sie im CP eingebaut und komischerweise läuft es auf einer anderen Domain bzw. Subdomain
Ich hab 2 Domains und auch bei beiden die gleichen Einstellungen im Confixx
Apache ASP-Unterstützung an
SSI-Unterstützung an
PHP-Unterstützung an (ausführen als Apache-Modul, PHP 'safe_mode' aktiviert )
CGI-Unterstützung an
Perl-Unterstützung an
Python-Unterstützung an
FastCGI-Unterstützung (erforderlich für Ruby on Rails) an
-
ich rufe die Datei so auf : admin/webspace.php?action=Webspace....
in der datei gibt es kein action=webspace versuchs doch mal ganz normal
admin/plugins/webspace.php
ich habe mal meine version geändert versuch die mal
-
das mit dem "action" hab ich nur so von den anderen übernommen im Adminbereich,aber funzt auch ohne nicht und mit deiner Änderung hab ich lediglich eine weisse Seite
edit:
Habs hinbekommen mit einem Teil deiner Version :lol:
hab aus
$usedspace = dirsize("./../../");
$usedspace_2 = dirsize("./../../data/media/");
$usedspace = dirsize($root_path);
$usedspace_2 = dirsize($root_path."/data/media/");
gemacht und siehe da es funzt