Page 1 of 3 123 LastLast
Results 1 to 15 of 33

Thread: WHMCS Hosting Stats Widget

  1. #1
    Join Date
    Jul 2010
    Posts
    15

    Default WHMCS Hosting Stats Widget

    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?

  2. #2
    Join Date
    Sep 2009
    Posts
    21

    Default

    I second that with

    Total data hosted:

    Being added to that list.

  3. #3
    Join Date
    Sep 2009
    Posts
    21

    Default

    Also, having it run in a cronjob and set the data into the database.

  4. #4
    Join Date
    Jul 2010
    Posts
    15

    Default

    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?

  5. #5
    Join Date
    Dec 2009
    Location
    Italy
    Posts
    145

    Default

    PHP Code:
    $domaincount mysql_query("SELECT * FROM tbldomains");

    $num_domains mysql_num_rows($domaincount);



    // Display the results

    echo $num_domains
    You could even go as far as doing per domain as we are looking into doing

    PHP Code:

    $domaincount 
    mysql_query("SELECT * FROM tbldomains WHERE domain IS LIKE '.it'");

    $num_tldmysql_num_rows($domaincount);

    // Display Number of .it domains registered

    echo $num_tld
    There may be an easyer way fo doing it but this is the solution i am going to try.

    BUT in all this i must say some javascript code from WHMCS would be awsome
    Making the cloud a better place
    Milliment.com | Milliment.it
    client.milliment.com

  6. #6
    Join Date
    Dec 2007
    Location
    Michigan
    Posts
    77

    Default

    Here's my full working solution.

    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 />
    "
    ;

    ?>
    Result:
    Domains Registered: 100
    Websites Hosted: 150
    Bandwidth Used: 100 GB
    Webspace Used: 300 GB

  7. #7
    Join Date
    Dec 2009
    Location
    Italy
    Posts
    145

    Default

    ahh awsome. do you mind if i pinch this as it is abviosly better than mine lol
    Making the cloud a better place
    Milliment.com | Milliment.it
    client.milliment.com

  8. #8
    Join Date
    Dec 2007
    Location
    Michigan
    Posts
    77

    Default

    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.

  9. #9
    Join Date
    Jul 2010
    Posts
    645

    Default

    You my friend are a genius. Thanks very much for sharing the script. It works perfectly!

    Jack

  10. #10
    Join Date
    Jul 2010
    Posts
    15

    Default

    @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?

  11. #11
    Join Date
    Jul 2010
    Posts
    645

    Default

    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

  12. #12
    Join Date
    Jul 2010
    Posts
    15

    Default

    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.

  13. #13
    Join Date
    Jul 2010
    Posts
    645

    Default

    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

  14. #14
    Join Date
    Jul 2010
    Posts
    15

    Default

    and whmcs and whm both report way more used

  15. #15
    Join Date
    Dec 2009
    Location
    Italy
    Posts
    145

    Default

    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

    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);
    /* 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 />
    "
    ;

    ?>
    I can see this script growing very quickly
    Making the cloud a better place
    Milliment.com | Milliment.it
    client.milliment.com

Page 1 of 3 123 LastLast

Similar Threads

  1. Stats on tickets in WHMCS
    By boldig in forum Customisation & Integration Questions
    Replies: 3
    Last Post: 12-11-12, 12:44 PM
  2. Hosting Account stats?
    By TheIdeaMan in forum General Discussion
    Replies: 0
    Last Post: 05-16-08, 02:08 PM