Author Topic: [Plugin] webspace verbrauch  (Read 10544 times)

0 Members and 1 Guest are viewing this topic.

Offline bananaboy

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
[Plugin] webspace verbrauch
« 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


Code: [Select]
BITTE DEN CODE UNTEN NUTZEN ->>




danke


gruss
"bananaboy"
« Last Edit: May 08, 2010, 10:29:03 PM by bananaboy »

Offline bananaboy

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
Re: [Plugin] webspace verbrauch
« Reply #1 on: May 08, 2010, 05:28:10 PM »
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
Code: [Select]
<?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($size2); }

    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) / $maxspace2); $used_p str_replace("."","$used_p);
      
$free_p round(($freespace 100) / $maxspace2); $free_p str_replace("."","$free_p);
      
$data_p round(($dataspace 100) / $maxspace2); $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">&nbsp;</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%;">&nbsp;~&nbsp;<br />&nbsp;~&nbsp;<br />&nbsp;~&nbsp;<br />&nbsp;~&nbsp;<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"

« Last Edit: May 08, 2010, 11:02:04 PM by bananaboy »

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.808
  • I ♥ 4I
    • View Profile
Re: [Plugin] webspace verbrauch
« Reply #2 on: May 08, 2010, 10:05:56 PM »
Richtig COOL!
Danke dafür!

Bekomme aber folgende Fehlermeldung:
Code: [Select]
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

Offline bananaboy

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
Re: [Plugin] webspace verbrauch
« Reply #3 on: May 08, 2010, 10:19:01 PM »
moin ...

wie sieht es denn mit deinen anderen plugins aus ... ?

haben die auch folgendes im kopf stehen ?

Code: [Select]
<?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"

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.808
  • I ♥ 4I
    • View Profile
Re: [Plugin] webspace verbrauch
« Reply #4 on: May 08, 2010, 10:48:57 PM »
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');

Offline bananaboy

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
Re: [Plugin] webspace verbrauch
« Reply #5 on: May 08, 2010, 10:53:01 PM »
...

ok ... super !  :thumbup:

ich ändere das dann auch gleich mal in dem script oben und im download .


viel spass



gruss
"bananaboy"

Offline WWTNET

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: [Plugin] webspace verbrauch
« Reply #6 on: June 19, 2010, 07:48:04 AM »
nice and easy. thanks!

Rembrandt

  • Guest
Re: [Plugin] webspace verbrauch
« Reply #7 on: June 19, 2010, 09:59:29 PM »
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($size2);}
      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) / $maxspace2);
      
$used_p round(($usedspace 100) / $maxspace2);
      
$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($maxspacerc);?></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($maxspacerc);?></div><br>
                      <div class="tused" style="float:left;">belegt:</div><div class="tused" style="float:right;"><?=editsize($usedspacerc);?></div><br>
                      <div class="tdata" style="float:left;">media:</div><div class="tdata" style="float:right;"><?=editsize($dataspacerc);?></div><br>
                      <div class="tfree" style="float:left;">frei:</div><div class="tfree" style="float:right;"><?=editsize($freespacerc);?></div><br>
                    </div>
                    <div style="float:left; width:5%;">&nbsp;~&nbsp;<br>&nbsp;~&nbsp;<br>&nbsp;~&nbsp;<br>&nbsp;~&nbsp;<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();
?>

« Last Edit: July 31, 2010, 06:57:36 PM by Rembrandt »

Offline plati

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [Plugin] webspace verbrauch
« Reply #8 on: July 31, 2010, 05:25:19 PM »
Fehler: Konnte Dateien nicht lesen.
Das kommt wenn ich die Datei aufrufe  :cry:
Woran kann das liegen?


Rembrandt

  • Guest
Re: [Plugin] webspace verbrauch
« Reply #9 on: July 31, 2010, 05:43:17 PM »
Fehler: Konnte Dateien nicht lesen..

welche datei ?
wo hast du sie hineinkopiert?
wo rufst du sie auf?

Offline plati

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [Plugin] webspace verbrauch
« Reply #10 on: July 31, 2010, 06:48:42 PM »
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

Rembrandt

  • Guest
Re: [Plugin] webspace verbrauch
« Reply #11 on: July 31, 2010, 06:53:58 PM »

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

Offline plati

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [Plugin] webspace verbrauch
« Reply #12 on: July 31, 2010, 07:01:57 PM »
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
« Last Edit: July 31, 2010, 07:17:07 PM by plati »