...

View Full Version : Display WHM page using PHP?



rfresh
06-27-2010, 06:21 PM
I would like to create a PHP script that displays a page in my WHM control panel (WHM is similar to cPanel). The page I'd like to display has this URL:

http://whm_account.com:2086/scripts/showbw

Of course just running that URL in a browser won't work because you have to be logged in. My question is: can I get logged in somehow using PHP before I run this URL to display my bandwidth page from a PHP script?

Thanks

Rowsdower!
06-28-2010, 01:26 PM
I would like to create a PHP script that displays a page in my WHM control panel (WHM is similar to cPanel). The page I'd like to display has this URL:

http://whm_account.com:2086/scripts/showbw

Of course just running that URL in a browser won't work because you have to be logged in. My question is: can I get logged in somehow using PHP before I run this URL to display my bandwidth page from a PHP script?

Thanks

You want to take a cPanel page and make the data public? You could just create a copy of the page, edit it to remove the cPanel controls and such, and then just link to that. Or, really, I should say that you could just open up the bandwidth page's source code and copy the script that generates the bandwidth data. Then just plop that into your own bandwidth page.

Otherwise you could cURL (http://php.net/manual/en/book.curl.php) your own cPanel, but that just seems silly.

jfreak53
06-28-2010, 02:00 PM
Go to cpanels site and read up on it's API interface. Very easy to use, years ago I made my own cPanel interface using the API for my clients when I was on a shared hosting service. WHM works the same way, just have to study it's API, WHMCS uses WHM's API very well. So there's no real need to compromise your WHM's security, better to use the API than curl.

Go to their site, search google. And they also have their own forum with users who are WHM and cPanel experts to help you with the API.

Now for the BW page, I don't know about WHM's page, but I know in the olden days cPanel's bandwidth programs you could make a cron job to generate it once a week or day or however then in that same cron script copy it to a web directory, I also use to do this in the very beginning, might be the same with WHM.

Rowsdower!
06-28-2010, 08:24 PM
...So there's no real need to compromise your WHM's security, better to use the API than curl...

No doubt about that. I'm totally unfamiliar with these API's (I don't use either script, personally), but if they have a good way to get at it through their own built-in coding I'd do that before anything else.

So, yeah, forget about the cURL! :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum