I have searched but i would like to be able to have something like this on my sites homepage
Domains Registered: 1987
Websites Hosted: 988
Bandwidth Used: 1.8TB
Etc. How could i create this for now?
I have searched but i would like to be able to have something like this on my sites homepage
Domains Registered: 1987
Websites Hosted: 988
Bandwidth Used: 1.8TB
Etc. How could i create this for now?
I second that with
Total data hosted:
Being added to that list.
Also, having it run in a cronjob and set the data into the database.
any body have an idea where to start..if it could even be done without modifying the whmcs code.. im pretty good at developing php and mysql, id take a crack at it as i want it on my page.. how easily can i plugin to whmcs other than direct database querys?
You could even go as far as doing per domain as we are looking into doingPHP Code:$domaincount = mysql_query("SELECT * FROM tbldomains");
$num_domains = mysql_num_rows($domaincount);
// Display the results
echo $num_domains;
There may be an easyer way fo doing it but this is the solution i am going to try.PHP Code:
$domaincount = mysql_query("SELECT * FROM tbldomains WHERE domain IS LIKE '.it'");
$num_tld= mysql_num_rows($domaincount);
// Display Number of .it domains registered
echo $num_tld;
BUT in all this i must say some javascript code from WHMCS would be awsome![]()
Here's my full working solution.
Result:PHP Code:<?php
include("configuration.php");
function mksize($bytes)
{
$bytes = max(0, $bytes);
if ($bytes < 1000)
return floor($bytes) . " B";
elseif ($bytes < 1000 * 1024)
return floor($bytes / 1024) . " kB";
elseif ($bytes < 1000 * 1048576)
return floor($bytes / 1048576) . " MB";
elseif ($bytes < 1000 * 1073741824)
return floor($bytes / 1073741824) . " GB";
else
return floor($bytes / 1099511627776) . " TB";
}
mysql_connect($db_host, $db_username, $db_password) or die ("Could not connect to MySQL");
mysql_select_db ($db_name) or die ("Could not select database");
$get_hosting = "SELECT * FROM tblhosting";
$hosting_query = mysql_query ($get_hosting) or die ("Hosting query failed");
$hosting = mysql_num_rows($hosting_query);
$get_domains = "SELECT * FROM tbldomains";
$domains_query = mysql_query ($get_domains) or die ("Domains query failed");
$domains = mysql_num_rows($domains_query);
while ($hosting_row = mysql_fetch_array($hosting_query)) {
$addbandwidth += $hosting_row["bwusage"];
$addwebspace += $hosting_row["diskusage"];
}
$bandwidth = mksize($addbandwidth);
$webspace = mksize($addwebspace);
echo "
<b>Domains Registered:</b> $domains <br />
<b>Websites Hosted:</b> $hosting <br />
<b>Bandwidth Used:</b> $bandwidth <br />
<b>Webspace Used:</b> $webspace <br />
";
?>
Domains Registered: 100
Websites Hosted: 150
Bandwidth Used: 100 GB
Webspace Used: 300 GB
ahh awsome. do you mind if i pinch this as it is abviosly better than mine lol
Nope, I posted it free so people would have to buy before they can use.
Yeah use it, let me know how it works.
Could add a code where it uses Ajax and you can display on your website.
Note: Also don't need a cronjob, because it pulls the data from the accounts and adds them together and displays in a sizable format...the data gets updated using the WHMCS cronjob.
Last edited by EastsideHosting; 07-25-10 at 05:04 PM.
You my friend are a genius. Thanks very much for sharing the script. It works perfectly!
Jack
@EastsideHosting
Im gonna give that a shot.. looks awesome for now..
how about emails sent/recieved.. i believe i saw something like that on hostgator at one point.. is that even possible without tapping into whm itself?
I'm have tested the script on a test page before going live. I'm going to be using it to show:
"We are proudly hosting --- websites wordwide!"
on our homepage. Thanks very much EastsideHosting once again. You should add that to the WHMCS mods directory since it's very useful.
Jack
█ Web hosting templates The best WHMCS & Wordpress + WHMCS templates | WHMCS Services
not sure if its just mine or not but its not showing the bandwidth and space used properly.. only shows like 7kb space used and 8kb transfered.
That also happened to me. I'm currently only using the script for showing how many websites are being hosted though.
Jack
█ Web hosting templates The best WHMCS & Wordpress + WHMCS templates | WHMCS Services
and whmcs and whm both report way more used
Just a quick mod to your script to allow TLD specific counts as we wish to do with out .it's, .com's and .net's
I can see this script growing very quicklyPHP Code:<?php
include("configuration.php");
function mksize($bytes)
{
$bytes = max(0, $bytes);
if ($bytes < 1000)
return floor($bytes) . " B";
elseif ($bytes < 1000 * 1024)
return floor($bytes / 1024) . " kB";
elseif ($bytes < 1000 * 1048576)
return floor($bytes / 1048576) . " MB";
elseif ($bytes < 1000 * 1073741824)
return floor($bytes / 1073741824) . " GB";
else
return floor($bytes / 1099511627776) . " TB";
}
mysql_connect($db_host, $db_username, $db_password) or die ("Could not connect to MySQL");
mysql_select_db ($db_name) or die ("Could not select database");
$get_hosting = "SELECT * FROM tblhosting";
$hosting_query = mysql_query ($get_hosting) or die ("Hosting query failed");
$hosting = mysql_num_rows($hosting_query);
$get_domains = "SELECT * FROM tbldomains";
$domains_query = mysql_query ($get_domains) or die ("Domains query failed");
$domains = mysql_num_rows($domains_query);
/* copy and rename for each TLD you wish to count */
/*Important DO NOT remove the % as this creats a wild card.
Add your tld after the % remebering to also have a . in there aswell otherwise
it will search the entire domain name and not just the TLD.*/
$get_domain_it = "SELECT * FROM tbldomains WHERE domain LIKE '%.it'";
$domains_it_query = mysql_query ($get_domain_it) or die ("Domains .it query failed");
$domains_it = mysql_num_rows($domains_it_query);
$get_domain_com = "SELECT * FROM tbldomains WHERE domain LIKE '%.com'";
$domains_com_query = mysql_query ($get_domain_com) or die ("Domains .com query failed");
$domains_com = mysql_num_rows($domains_com_query);
$get_domain_net = "SELECT * FROM tbldomains WHERE domain LIKE '%.net'";
$domains_net_query = mysql_query ($get_domain_net) or die ("Domains .net query failed");
$domains_net = mysql_num_rows($domains_net_query);
while ($hosting_row = mysql_fetch_array($hosting_query)) {
$addbandwidth += $hosting_row["bwusage"];
$addwebspace += $hosting_row["diskusage"];
}
$bandwidth = mksize($addbandwidth);
$webspace = mksize($addwebspace);
echo "
<b>Domains Registered:</b> $domains <br />
<b>.IT's Registered:</b> $domains_it <br />
<b>.COM's Registered:</b> $domains_com <br />
<b>.NET's Registered:</b> $domains_net <br />
<b>Websites Hosted:</b> $hosting <br />
<b>Bandwidth Used:</b> $bandwidth <br />
<b>Webspace Used:</b> $webspace <br />
";
?>