Web Hosting Talk







View Full Version : Accessing Cpanel Stats via php


Madkid
01-20-2009, 06:56 AM
Hi there
I was wondering if it was possible to access the cpanel stats via php? Is there any scripts that will do this? I am in the process of setting up a custom client website and I would like to bring in some of the cpanel stats into it?
If you can't directly access the cpanel stats would it also be possible to run a cron job to insert the stats into a MYSQL database every day or something?
Many thanks

Artemirk
01-20-2009, 07:40 AM
http://www.cpanel.net/plugins/xmlapi/accountsummary.html
"Calling this URL in WebHost Manager: /xml-api/accountsummary?user=username and get pertient account information for a specific account"
Use it in you bash,perl or php script and parse status from xml output.

Madkid
01-20-2009, 07:46 AM
Thanks a million
Only problem it that the directory is password protected and requires you to be logged onto the admin cpanel account. I wonder if there is a script that could hold the details of your cpanel.

Madkid
01-20-2009, 08:04 AM
I wonder if there is a script that could hold the details of your cpanel and then parse the xml into php?

Artemirk
01-20-2009, 08:11 AM
http://www.cpanel.net/support/docs/remoteaccess-php.htm
Also you can see example at
http://bakery.cakephp.org/articles/view/cpanel-api-component
cpanel-api-component class you can use for call xml-api/accountsummary

Madkid
01-20-2009, 08:33 AM
Where does that script need to be uploaded?

Madkid
01-20-2009, 09:05 AM
I get errors such as Fatal error: Class 'Object' not found in /home/andrew/public_html/Cpanel/a.php on line 8

01globalnet
01-20-2009, 10:44 AM
See attachment - I am using it for my clients that I do not wish to give 'em cpanel access.
Edit index.php with user, pass, domain and unzip the icons, upload and enter password protection from Cpanel.
Taken from: http://www.josheli.com/vox/

cPanelDavidG
01-20-2009, 01:33 PM
Thanks a million
Only problem it that the directory is password protected and requires you to be logged onto the admin cpanel account. I wonder if there is a script that could hold the details of your cpanel.
You could always use curl or php's built-in fsockopen() function to handle authentication. You can authenticate using user/password or user/hash (remote access key). If you are familiar with PHP and need help with WHM's hash authentication, let me know as it's a bit different than the typical base64 encoded user:password authentication.

Madkid
01-22-2009, 06:40 PM
Thanks a million.
I'm using the cPanel API script - http://phpclasses.fonant.com/browse/package/3534.html
When I install it and put in my cpanel ip/domain, username/password port etc I get the following...
Hosting Package:
Disk Space Used: 0 MB
MySQL Space Used: 0 MB
Bandwidth Used: 0 MB
Contact Email:
Free Space: Unlimited MB
Domains:
Warning: Invalid argument supplied for foreach() in /home/abrvirtu/public_html/cp/example.php on line 16
Mail Accounts:
Warning: Invalid argument supplied for foreach() in /home/abrvirtu/public_html/cp/example.php on line 28
FTP Accounts:
Databases:
DB Users:
Redirects:
What I'm I doing wrong? Are the functions in that script not vaild with the cPanel Api anymore? I'm confused because the script is obviously connecting with my cPanel but not displaying any results.

cPanelDavidG
01-23-2009, 12:32 PM
Thanks a million.
I'm using the cPanel API script - http://phpclasses.fonant.com/browse/package/3534.html
When I install it and put in my cpanel ip/domain, username/password port etc I get the following...
Hosting Package:
Disk Space Used: 0 MB
MySQL Space Used: 0 MB
Bandwidth Used: 0 MB
Contact Email:
Free Space: Unlimited MB
Domains:
Warning: Invalid argument supplied for foreach() in /home/abrvirtu/public_html/cp/example.php on line 16
Mail Accounts:
Warning: Invalid argument supplied for foreach() in /home/abrvirtu/public_html/cp/example.php on line 28
FTP Accounts:
Databases:
DB Users:
Redirects:
What I'm I doing wrong? Are the functions in that script not vaild with the cPanel Api anymore? I'm confused because the script is obviously connecting with my cPanel but not displaying any results.
The script you mention is a third party script not affiliated with cPanel.
As that script prompts for port numbers and themes, it does not appear to be using our APIs as our APIs are not dependent on such things. Our APIs interact with the back-end of cPanel/WHM rather than parsing the cPanel interface.
There is a WHT thread that addresses getting cPanel stats via our APIs at:
http://www.webhostingtalk.com/showthread.php?p=5416428