HOME  FORUM  LINKS

Site Menu

Development

Director

Hosting Support

Quick Links

PHP

Some PHP snippets and applications supporting hosting functions in the CPANEL/WHM environment

WHMStats

WHMSTATS 1.5

**************************update 30Nov05
I have revised the code for Cpanel 10.8.0 Go direct to this code

v1.5 zip file

v1.5 php file (rename text file)
*********************************************

WHMSTATS 1.3

**************************update 28Nov05
due to some changes to the html layout, in particular, additional linefeeds I have revised the code for Cpanel 10.2 Go direct to this code

v1.3 zip file

v1.3 php file (rename text file)
*********************************************

WHMSTATS 1.2

**************************update 05May03
due to some change (?) with curl I have opted to use the non-secure URLs.
one benefit of doing this was that the temp files were no longer required
so you need only configure the script for it to run.
*********************************************

WHMSTATS 1

Here is a simple method of monitoring the diskspace and bandwidth of the domains under your control.

The code basically mimics what we normally do when we use the WHM funcrions. It uses curl so that our username and password info is relayed via SSL. (The method works equally well using non-secure access as well)

Firstly, my code executes the "listaccts" WHM script. The domain data is then extracted. A report of domains reaching their disk space limit is output and then a list of all accounts (comma-delimited values). The warning threshold value $mbHigh can be set by you. The details are followed by the total disk usage in MB.

Next, from an array created from step 1, I execute the limit bandwidth function "limitbw" for each domain and output the results. I use the limitbw functions because it gives both actual and domain limit for the domain. I do not use the show bandwidth function "showbw" as it simply gives the current actual value and no bandwidth limit. The report also gives an alert list of domains exceeding a threshold percentage bandwidth: this value $bwHigh is currently set to 90% and you can set whatever value you wish. The report is followed by a figure for your total current bandwidth usage.

To run the program you must firstly edit the access details as shown below:
$userName="xxxxxxxx"; // your WHM userName
$uPassword="xxxxxxxx"; // your WHM password
$domainName="www.xxxx.com"; // your primary domain
$mbHigh=90; // Disk space percentage warning message trigger
$bwHigh=90; // Bandwidth warning trigger

Then simply execute the file from your browser eg http://www.mydomain.com/whmstuff/whmstats.php

I need to give some caveats:
1. I am not a php coder and I know my code is inefficient and does not exploit php functions as it should or make effective use of regular expressions. You may also find some redundant variables and some twisted logic. I apologise in advance.
An experienced coder will notice that I retrieve the html data into memory, write it to a disk file and then read the disk file to begin processing the data. The reason for this inefficiency is that I originally developed the method by testing against a flat file and then did not have the time (or inclination) to discover how to do it from the memory data.
2. This code is simpler than my working model which uses a mysql database, 7 day cycle data files and debug logging. my main model runs as a cron task and therefore outputs almost nothing to the standard output device. The version I am releasing here is designed to be run manually. To use it as a cron job would require the conversion of "<BR>" tags to "\n" and also the removal of any html formatting i.e.. <HR>, <STRONG>.. etc. OR you could output the results to a disk file.

I hope the code is useful to the HTTPME community. I would like to ask if anyone improves the code, would they mind sharing it with the community.

For the tar.gzip archive http://www.domaj.com/files/whmstats.tar.gz
For the php file (Right-click and save) http://www.domaj.com/files/whmstats.php

Version 1.2 Code

<?PHP
$myVersion
=1.2;
/*
  WHM Reseller Disk and Bandwidth Data monitoring v1.2
  Tony Domigan (DOMAJ) tony@domaj.com
  http://www.domaj.com

**************************update 05May03
due to some change (?) with curl I have opted to use the non-secure URLs
one benefit of doing this was that the temp files were no longer required
so you need only configure the script for it to run.
*********************************************************************

  Following on from a request for my method of monitoring disk and bandwidth
  stats I have decided to release a simpler version of my method. My not-so-
  simple method involves using a database as well.

  Please use this code at your own risk. I am no PHP coder as you will probably
  see from the following code. I would appreciate being kept informed of any
  changes you make, however, so that I and others can benefit from your wisdom.

  Tony Domigan 17Jan03

  Oh! a last note: My main program has been running successfully for over 6 months (on MARS) but
  that is not to say I have not had the odd hiccup. One irritation is that the WHM scripts
  move around during Cpanel/WHM changes. Most scripts reside in the "scripts" subdirectory:
  lately, however, they have moved to the "scripts2" subdirectory.
*/
/*
    accounts processing - start of configuration
    modify your details here
*/
$userName="xxxxxxxx";        // your WHM userName
$uPassword="xxxxxxxx";        // your WHM password
$domainName="www.xxxxxxxxx.com";// your primary domain
$mbHigh=90;                    // Disk space percentage warning message trigger
$bwHigh=90;                    // Bandwidth warning trigger
/*
    accounts processing - end of configuration
*/
$F1="http://$userName:$uPassword@$domainName:2086/scripts2/listaccts";
$Fx="http://$userName:$uPassword@$domainName:2086/";
$today = date('Y-m-d H:i:s');
$output = "";
$unique_start = "<tr class=tdshade";
$line_end = "</tr>";
$unique_end = "</table></pre>";
$accountTotal = 0;
$domainList = array();

echo
"<H2><CENTER>Account Data<BR>$domainName<BR>$today</CENTER></H2><HR>";
echo
"<STRONG>DiskSpace Alerts (Threshold:$mbHigh)</STRONG><HR>";

   
$data = @file("$F1");
;
/* process the html page */   
   
if ( is_array($data) )
   {
        
$Accounts = array(); //init the storage array
        
$accountsIndex = 0;  //init account counter
        
$totalMB = 0;
      foreach (
$data as $line )
      {
           
$howmany = strpos($line,$unique_start);            
           if (
$howmany===0)
           {
            
$rec = array();
            
$Accounts = array();
            
$rec = split("<td>",$line);
            while (list(
$key,$value) = each($rec))
            {
                if (
$value!='')
                {
                    
array_push($Accounts,strip_tags($value));                
                };
//if
            
}; //while
            
$accountTotal++;
            
$domain = $Accounts[1];
            
$ip= $Accounts[2];
            
$client = $Accounts[3];
            
$email = $Accounts[4];            
            
$cdate = $Accounts[5];
            
$chome = $Accounts[6];
            
$quota = $Accounts[7];
            
$spaceUsed = $Accounts[8];
            
$package = $Accounts[9];
            
$theme = $Accounts[10];
            
$reseller = $Accounts[11];
            
// calculated variables
            
$firstSpace = strpos($spaceUsed," ");
            (
$firstSpace == 0 ? $mbused = 0 : $mbused = trim(substr($spaceUsed,0,$firstSpace)));//*1024);
            
$firstSpace = strpos($quota," ");
            (
$firstSpace == 0 ? $mbQuota = 0 : $mbQuota = trim(substr($quota,0,$firstSpace)));//*1024);
            
($mbused == 0 ? $mbpercent = 0 : $mbpercent = ($mbused/$mbQuota)*100);
            (
$mbpercent < $mbHigh ? $warning = "OK": $warning ="ALERT");            
            
$totalMB += $mbused;
            if (
$warning == "ALERT")
                echo
"$domain Actual/Allocated=$mbused/$mbQuota (".(int) $mbpercent."%)<BR>";
            
$output.="$today,$domain,$ip,$client,$email,$cdate,$chome,$quota,$spaceUsed,$package,$theme,$reseller,$totalMB,$mbused,".(int) $mbpercent.",$warning<br>";
            
array_push($domainList,$client);
           }
       }
   }
   else {
       echo(
"OOPS! No array was detected.<br>");  
   }
echo
"<HR><STRONG>Account Listing</STRONG><BR>$output<HR>";
echo
"Total Accounts Processed: $accountTotal<BR>Total Used Disk Space: $totalMB MB<HR>";
/*
    get domain bw
*/

echo "<STRONG>Bandwidth Alerts (Threshold:$bwHigh)</STRONG><BR>";

$accountNumber=count($domainList); // count the number of rows

$output = '';
$bwCount = 0;
$totalBW = 0;
for (
$i=0; $i<$accountNumber; $i++)
{     
   
$F6 = $Fx."scripts2/limitbw?domain=$domainList[$i]&user=$domainList[$i]&submit-domain=Limit";


   
$data=@file($F6);
    if (
is_array($data) )
    {
        foreach (
$data as $line )
       {
        if ((
strpos($line,'"bwlimit')) and (strpos($line,'meg')))
        {
            
$rec = split("<td>",$line);
            
$loc = strpos($rec[0],'value="');
            
$endloc = strpos($rec[0],'"',$loc+7);
            
$bwlimit = substr($rec[0],$loc+7,$endloc-$loc-7);
            
$bwpct = 0;
            if (
$bwlimit>0 and $bwactual>0)
            {
                
$bwpct = ($bwactual*100)/$bwlimit;
            }
            (
$bwpct < $bwHigh ? $warning = "OK": $warning ="ALERT");
            if (
$warning=="ALERT")
                echo (
"$domain Bandwidth ALERT $bwactual/$bwlimit (".(int) $bwpct."%)<BR>");
            
$output .="$bwlimit,".(int) $bwpct.",$warning<BR>";
            
$totalBW+=$bwactual;
            
$bwCount++;
        }
        elseif ((
strpos($line,'meg')))
        {
            
$rec = split("<td>",$line);            
            
$tempit = strip_tags($rec[0]);
            
$loc = strpos($tempit,' meg');
            
$bwactual = trim(substr($tempit,1,$loc-1));
            
$output.="$today,$domain,$bwactual,";
        }
        elseif ((
strpos($line,'name="user"')))
        {
            
$rec = split("<td>",$line);            
            
$tempit = strip_tags($rec[0]);
            
$loc = strpos($tempit," [$domainlist[$i]");
            
$domain = ltrim(substr($tempit,1,$loc-1));
        }
    }
    }
}
echo
"<HR><STRONG>Bandwidth Data</STRONG><BR>$output<HR>";
echo (
"Completed Bandwidth Processing<BR>");
echo
"Total bandwidths: $bwCount [$totalBW MB]<BR>";
echo (
"<HR>Version $myVersion Original code by DOMAJ http://www.domaj.com tony@domaj.com<BR>");
?>


Version 1.3 Code

<?PHP
$myVersion
=1.3;  //cpanel 10.2
/*
  WHM Reseller Disk and Bandwidth Data monitoring v1.3
  Tony Domigan (DOMAJ) tony@domaj.com
  http://www.domaj.com

**************************update 28Nov05 ****************************
                        updated for cpanel 10.2
*********************************************************************

  Following on from a request for my method of monitoring disk and bandwidth
  stats I have decided to release a simpler version of my method. My not-so-
  simple method involves using a database as well.

  Please use this code at your own risk. I am no PHP coder as you will probably
  see from the following code. I would appreciate being kept informed of any
  changes you make, however, so that I and others can benefit from your wisdom.

  Tony Domigan 17Jan03
*/
/*
    accounts processing - start of configuration
    modify your details here
*/
$userName="xxxxxxxx";        // your WHM userName
$uPassword="xxxxxxxxx";        // your WHM password
$domainName="www.xxxxx.com";    // your primary domain
$mbHigh=90;            // Disk space percentage warning message trigger
$bwHigh=90;            // Bandwidth warning trigger
/*
    accounts processing - end of configuration
*/
$F1="http://$userName:$uPassword@$domainName:2086/scripts2/listaccts";
$Fx="http://$userName:$uPassword@$domainName:2086/";
$today = date('Y-m-d H:i:s');
$output = "";
$unique_start = "<tr class=tdshade";
$line_end = "</tr>";
$unique_end = "</table></pre>";
$accountTotal = 0;
$domainList = array();

echo
"<H2><CENTER>Account Data<BR>$domainName<BR>$today</CENTER></H2><HR>";
echo
"<STRONG>DiskSpace Alerts (Threshold:$mbHigh)</STRONG><HR>";

   
$data=@file($F1);
/* process the html page */

   
if ( is_array($data) )
   {
        
$Accounts = array(); //init the storage array
        
$accountsIndex = 0;  //init account counter
        
$totalMB = 0;
        
$emailList = array(); //init the email array
                
$output = '<table cellspacing="0" cellpadding="2" border="1">';
                
$output.= '<tr>';
                
$output.= '<td>DOMAIN</td><td>IP</td><td>USER</td><td>EMAIL</td>';
                
$output.= '<td>QUOTA__</td><td>USED__</td><td>PCT_</td><td>PACKAGE</td>';
                
$output.= '<td>THEME</td><td>RESELLER</td><td>WARNING</td>';
                
$output.= '</tr>';
              foreach (
$data as $line )
      {
           
$howmany = strpos($line,$unique_start);
           if (
$howmany===0)
           {
            
$rec = array();
            
$Accounts = array();
            
$rec = split("<td>",$line);
            while (list(
$key,$value) = each($rec))
            {
                if (
$value!='')
                {
                    
array_push($Accounts,strip_tags($value));
                };
//if
            
}; //while
            
$accountTotal++;
            
$domain = $Accounts[1];
            
$pass=1;
           }
           elseif (
$pass==1)
           {
               
$pass=2;
           }
           elseif (
$pass==2)
           {
            
$rec = split("<td>",$line);
            
$Accounts = array();
            while (list(
$key,$value) = each($rec))
            {
                if (
$value!='')
                {
                    
array_push($Accounts,strip_tags($value));
                };
//if
            
}; //while
            
$ip= $Accounts[1];
            
$client = $Accounts[2];
            
$email = $Accounts[3];
            
$cdate = $Accounts[4];
            
$chome = $Accounts[5];
            
$quota = $Accounts[6];
            
$spaceUsed = $Accounts[7];
            
$package = $Accounts[8];
            
$theme = $Accounts[9];
            
$reseller = $Accounts[10];
            
// calculated variables
            
$firstSpace = strpos($spaceUsed," ");
            (
$firstSpace == 0 ? $mbused = 0 : $mbused = trim(substr($spaceUsed,0,$firstSpace)));//*1024);
            
$firstSpace = strpos($quota," ");
            (
$firstSpace == 0 ? $mbQuota = 0 : $mbQuota = trim(substr($quota,0,$firstSpace)));//*1024);
            
($mbused == 0 ? $mbpercent = 0 : $mbpercent = ($mbused/$mbQuota)*100);
            (
$mbpercent < $mbHigh ? $warning = "OK": $warning ="ALERT");
               if (
$mbpercent<10){
                           
$bwpercent='0'.(int) $mbpercent.'%';
                        }
                           else {
                           
$bwpercent=(int) $mbpercent.'%';
                        }
            
$totalMB += $mbused;
            if (
$warning == "ALERT")
                echo
"$domain Actual/Allocated=$mbused/$mbQuota (".(int) $mbpercent."%)<BR>";
            
$output.=sprintf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%05d</td><td>%05d</td><td>%02d%%</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>",$domain,$ip,$client,$email,$mbQuota,$mbused,$bwpercent,$package,$theme,$reseller,$warning);
            
array_push($domainList,$client);
            
array_push($emailList,$email); //add to the email list array
            
$pass=0;
           }
//if

       
} //for
       
$output.="</table>";
   }
   else {
       echo(
"OOPS! No array was detected.<br>");
   }
echo
"<HR><STRONG>Account Listing</STRONG><BR>$output<HR>";
echo
"Total Accounts Processed: $accountTotal<BR>Total Used Disk Space: $totalMB MB<HR>";

/*
    get domain bw
*/

echo "<STRONG>Bandwidth Alerts (Threshold:$bwHigh)</STRONG><BR>";

$accountNumber=count($domainList); // count the number of rows

$output = '';
$bwCount = 0;
$totalBW = 0;

$output = '<table cellspacing="0" cellpadding="2" border="1">';
$output.= '<tr>';
$output.= '<td>Domain___________________</td>';
$output.= '<td>Actual BW</td><td>Quota BW</td>';
$output.= '<td>PCT%</td><td>WARNING</td>';
$output.= '</tr>';

for (
$i=0; $i<$accountNumber; $i++)
{
   
$F6 = $Fx."scripts2/limitbw?domain=$domainList[$i]&user=$domainList[$i]&submit-domain=Limit";

   
$data=@file($F6);
    if (
is_array($data) )
    {
        foreach (
$data as $line )
       {
        if ((
strpos($line,'"bwlimit')) and (strpos($line,'meg')))
        {
            
$rec = split("<td>",$line);
            
$loc = strpos($rec[0],'value="');
            
$endloc = strpos($rec[0],'"',$loc+7);
            
$bwlimit = substr($rec[0],$loc+7,$endloc-$loc-7);
            
$bwpct = 0;
            if (
$bwlimit>0 and $bwactual>0)
            {
                
$bwpct = ($bwactual*100)/$bwlimit;
            }
            (
$bwpct < $bwHigh ? $warning = "OK": $warning ="ALERT");
            if ((int)
$bwpct<10){
                           
$bwpercent='0'.(int) $bwpct.'%';
                           }
                           else {
                           
$bwpercent=(int) $bwpct.'%';
                        }
            if (
$warning=="ALERT")
                echo (
"$domain Bandwidth ALERT $bwactual/$bwlimit (".(int) $bwpct."%) email:$emailList[$i]<BR>");
            
$output.=sprintf("<td>%05d</td><td>%02d%%</td><td>%s</td></tr>",$bwlimit,$bwpercent,$warning);
            
$totalBW+=$bwactual;
            
$bwCount++;
        }
        elseif ((
strpos($line,'meg')))
        {
            
$rec = split("<td>",$line);
            
$tempit = strip_tags($rec[0]);
            
$loc = strpos($tempit,' meg');
            
$bwactual = trim(substr($tempit,1,$loc-1));
                        
$output.=sprintf("<tr><td>%s</td><td>%05d</td>",$domain,$bwactual);
        }
        elseif ((
strpos($line,'name="user"')))
        {
            
$rec = split("<td>",$line);
            
$tempit = strip_tags($rec[0]);
            
$loc = strpos($tempit," [$domainlist[$i]");
            
$domain = ltrim(substr($tempit,1,$loc-1));
        }
    }
    }
}
$output.='</table>';
$fp=fopen("temp.txt","w");
@
fwrite($fp,$output);
@
fclose($fp);
echo
"<HR><STRONG>Bandwidth Data</STRONG><BR>$output<HR>";
echo (
"Completed Bandwidth Processing<BR>");
echo
"Total bandwidths: $bwCount [$totalBW MB]<BR>";
echo (
"<HR>Version $myVersion Original code by DOMAJ http://www.domaj.com tony@domaj.com<BR>");
?>

Version 1.5 Code

<pre>
<?php
$myVersion
=1.5;
/*
  WHM Reseller Disk and Bandwidth Data monitoring
  Tony Domigan (DOMAJ) tony@domaj.com
  http://www.domaj.com

**************************update 30Nov05 ****************************
                        updated for cpanel 10.8
*********************************************************************

  Following on from a request for my method of monitoring disk and bandwidth
  stats I have decided to release a simpler version of my method. My not-so-
  simple method involves using a database as well.

  Please use this code at your own risk. I am no PHP coder as you will probably
  see from the following code. I would appreciate being kept informed of any
  changes you make, however, so that I and others can benefit from your wisdom.

  Tony Domigan 17Jan03
*/
/*
    accounts processing - start of configuration
    modify your details here
*/
$userName="xxxxxxxxxxx";        // your WHM userName
$uPassword="xxxxxxxxxx";        // your WHM password
$domainName="www.xxxxx.com";    // your primary domain
$mbHigh=90;            // Disk space percentage warning message trigger
$bwHigh=90;            // Bandwidth warning trigger
/*
    accounts processing - end of configuration
*/
$F1="http://$userName:$uPassword@$domainName:2086/scripts2/listaccts";
$Fx="http://$userName:$uPassword@$domainName:2086/";
$today = date('Y-m-d H:i:s');
$output = "";
$accountTotal = 0;
$domainList = array();

echo
"<H2><CENTER>Account Data<BR>$domainName<BR>$today</CENTER></H2><HR>";
echo
"<STRONG>DiskSpace Alerts (Threshold:$mbHigh)</STRONG><HR>";

$fp=fopen($F1,"r");
while (!
feof($fp)){$str .= fread ($fp, 1024);}
fclose($fp);

$str=str_replace("\r\n","",$str);
$str=str_replace("\n","",$str);

$do = preg_match_all("/<tr class=\"*tdshade.*>(.*)<\/tr>/U", $str, $matches);
if (
$do == true) {
    
$rec = array();
    
$emailList = array();
    
$output = '<table cellspacing="0" cellpadding="2" border="1">';
    
$output.= '<tr>';
    
$output.= '<td>DOMAIN</td><td>IP</td><td>USER</td><td>EMAIL</td>';
    
$output.= '<td>QUOTA__</td><td>USED__</td><td>PCT_</td><td>PACKAGE</td>';
    
$output.= '<td>THEME</td><td>RESELLER</td><td>WARNING</td>';
    
$output.= '</tr>';
    while (list(
$keyr,$valuer) = each($matches[0]))
    {
        
$rec = split("<td>",$valuer);
        
$Accounts = array();
        
array_push($Accounts,$rec);
        
$domain = trim(strip_tags($Accounts[0][1]));
        if (
$domain!=''){
            
$ip= trim(strip_tags($Accounts[0][2]));
            
$client = trim(strip_tags($Accounts[0][3]));
            
$email = trim(strip_tags($Accounts[0][4]));
            
$cdate = trim(strip_tags($Accounts[0][5]));
            
$chome = trim(strip_tags($Accounts[0][6]));
            
$quota = trim(strip_tags($Accounts[0][7]));
            
$spaceUsed = trim(strip_tags($Accounts[0][8]));
            
$package = trim(strip_tags($Accounts[0][9]));
            
$theme = trim(strip_tags($Accounts[0][10]));
            
$reseller = trim(strip_tags($Accounts[0][11]));
            
// calculated variables
            
$firstSpace = strpos($spaceUsed," ");
            (
$firstSpace == 0 ? $mbused = 0 : $mbused = trim(substr($spaceUsed,0,$firstSpace)));//*1024);
            
$firstSpace = strpos($quota," ");
            (
$firstSpace == 0 ? $mbQuota = 0 : $mbQuota = trim(substr($quota,0,$firstSpace)));//*1024);
            
($mbused == 0 ? $mbpercent = 0 : $mbpercent = ($mbused/$mbQuota)*100);
            (
$mbpercent < $mbHigh ? $warning = "OK": $warning ="ALERT");
            if (
$mbpercent<10){
               
$bwpercent='0'.(int) $mbpercent.'%';
            } else {
               
$bwpercent=(int) $mbpercent.'%';
            }
            
$totalMB += $mbused;
            if (
$warning == "ALERT")
                echo
"ALERT: $domain Actual/Allocated=$mbused/$mbQuota (".(int) $mbpercent."%) Email:$email<BR>";
            
$output.=sprintf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%05d</td><td>%05d</td><td>%02d%%</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>",$domain,$ip,$client,$email,$mbQuota,$mbused,$bwpercent,$package,$theme,$reseller,$warning);
            
array_push($domainList,$client); //add to the domain name list array
            
array_push($emailList,$email); //add to the email list array
        
}  //if not empty
    
}; //while recs
    
$output.="</table>";
    echo
"<HR><STRONG>Account Listing</STRONG><BR>$output<HR>";
    echo
"Total Accounts Processed: $accountTotal<BR>Total Used Disk Space: $totalMB MB<HR>";
}
else
  {echo
"ERROR: No data found<br>";}
/*
    get domain bw
*/
echo "<STRONG>Bandwidth Alerts (Threshold:$bwHigh)</STRONG><BR>";

$accountNumber=count($domainList); // count the number of rows

$output = '';
$bwCount = 0;
$totalBW = 0;

$output = '<table cellspacing="0" cellpadding="2" border="1">';
$output.= '<tr>';
$output.= '<td>Domain___________________</td>';
$output.= '<td>Actual BW</td><td>Quota BW</td>';
$output.= '<td>PCT%</td><td>WARNING</td>';
$output.= '</tr>';

for (
$i=0; $i<$accountNumber; $i++)
{
   
$F6 = $Fx."scripts2/limitbw?domain=$domainList[$i]&user=$domainList[$i]&submit-domain=Limit";

   
$data=@file($F6);
    if (
is_array($data) )
    {
        foreach (
$data as $line )
       {
        if ((
strpos($line,'"bwlimit')) and (strpos($line,'meg')))
        {
            
$rec = split("<td>",$line);
            
$loc = strpos($rec[0],'value="');
            
$endloc = strpos($rec[0],'"',$loc+7);
            
$bwlimit = substr($rec[0],$loc+7,$endloc-$loc-7);
            
$bwpct = 0;
            if (
$bwlimit>0 and $bwactual>0){
                
$bwpct = ($bwactual*100)/$bwlimit;
            }
            (
$bwpct < $bwHigh ? $warning = "OK": $warning ="ALERT");
            if ((int)
$bwpct<10){
               
$bwpercent='0'.(int) $bwpct.'%';
            } else {
               
$bwpercent=(int) $bwpct.'%';
            }
            if (
$warning=="ALERT")
                echo (
"$domain Bandwidth ALERT $bwactual/$bwlimit (".(int) $bwpct."%) email:$emailList[$i]<BR>");
            
$output.=sprintf("<td>%05d</td><td>%02d%%</td><td>%s</td></tr>",$bwlimit,$bwpercent,$warning);
            
$totalBW+=$bwactual;
            
$bwCount++;
        }
        elseif ((
strpos($line,'meg')))
        {
            
$rec = split("<td>",$line);
            
$tempit = strip_tags($rec[0]);
            
$loc = strpos($tempit,' meg');
            
$bwactual = trim(substr($tempit,1,$loc-1));
                        
$output.=sprintf("<tr><td>%s</td><td>%05d</td>",$domain,$bwactual);
        }
        elseif ((
strpos($line,'name="user"')))
        {
            
$rec = split("<td>",$line);
            
$tempit = strip_tags($rec[0]);
            
$loc = strpos($tempit," [$domainlist[$i]");
            
$domain = ltrim(substr($tempit,1,$loc-1));
        }
      }
    }
}
$output.='</table>';
echo
"<HR><STRONG>Bandwidth Data</STRONG><BR>$output<HR>";
echo (
"Completed Bandwidth Processing<BR>");
echo
"Total bandwidths: $bwCount [$totalBW MB]<BR>";
echo (
"<HR>Version $myVersion Original code by DOMAJ http://www.domaj.com tony@domaj.com<BR>");
?>

Recent Topics

The latest topics from the forum.

  1. Before Closing.Stop
  2. Stop A Script
  3. Buttons On Stage And Movie On A Window...
  4. Acrobat 8 and Director
  5. Flash Video And Director
  6. Problem with new install
  7. Urgent Help For Noob, Pretty Please?
  8. back to splashscreen when inactive
  9. Import Flash
  10. my truck game --- help
  11. opening microsoft word document and microsoft powerpoint slides
  12. My Director has no Text Field
  13. Toggle Sound On/Off for AVI Video
  14. Keyboard Input Fails to Trigger Handlers
  15. Center Movie In A Window
  16. Microsoft Word Web Browser v1.0
  17. Sine Graph Function
  18. The coloured problems
  19. A Little fix or two
  20. Sine Reverse
  21. Repeatedly replacing Director bitmap
  22. Japanese characters in Director MX
  23. k-director.com: Post Updates
  24. A blog about Adobe Director
  25. Centerstage
  26. Custom Cursor...Why It Does Not Work?
  27. Director Game!
  28. SLIDER POSITION...
  29. Bullet points in text member
  30. Activex component install
  31. quiz
  32. how to export embedded flash swf?
  33. SHOCKWAVE VIDEO
  34. Deleting Lines Comparing Time...I Have No Idea...
  35. Property not found error
  36. SHOCKWAVE PROBLEM
  37. text field focus
  38. ExitLock CloseRequest Quit Close Gadget
  39. F10 Key Code Does Not Work
  40. Director Game Development Survey
  41. baPrintFile()
  42. How do check if a printer is printing??

Useful Links

Google Translate
AltaVista Translate
Google Glossary

Google
Web www.domaj.com

EZ BAS Easy BAS.

Save hours of work on your Business Activity Statement using this simple, quick and efficient product.