Publishing System Settings Logout Login Register
How to list packages that are on WHM
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on November 26th, 2008
3822 views
PHP Coding
This tutorial will show you how to list all packages that are in your WHM (Web Host Manager)

#!/usr/local/cpanel/3rdparty/bin/php 

<?php
$host = "localhost"; // Default: localhost.
$user = "WHM USERNAME"; // Username to login to WHM.
$accesshash = 'WHMACCESSHASH'; // Access Hash from WHM.
$usessl=0; // Use SSL To connect.

require '/usr/local/cpanel/Cpanel/Accounting.php.inc'; // Include cPanel Accounting File.
$pkgs = listpkgs($host,$user,$accesshash,0); // Use cPanel List Accounts Function.
foreach ($pkgs as $key => $value){  // Split the cPanel Function array into bits.
echo "Package Name: $key<br>Quota: $value[2]mb<br>Bandwidth: $value[10]mb<br>FTP Accounts: $value[5]<Br>Email Accounts: $value[7]<br>Email Lists: $value[8]<br>Databases: $value[6]<Br>Subdomains: $value[9]<br>Parked Domains: $value[12]<br>Addon Domains: $value[13]<br>Dedicated IP: $value[0]<br>Frontpage Extensions: $value[3]<br>CGI Access: $value[1]<br>Theme: $value[4]<br>Feature List: $value[14]<br>Language: $value[15]<Br><br><br><Br>"; // Echo The Bits Of The Array
}
?>


The first line checks if you are connecting to the whm on the same server as the script then the username/accesshash and usessl are there to actually connect to the WHM. The Accesshash can be found by logging into your WHM and clicking Remote Access Hash. The next line retrieves the accounting file which is already installed by cPanel. $pkgs is a variable for the function listpkgs which go listpkgs(hostname, whmusername, whmaccesshash, usingssl); next it will split the array up from the function and will do so for all accounts. And finally it will echo the details.

These ids are the ones that are in $value[id]

1-CGI Access
2-Quota
3-Frontpage
4-Theme
5-FTP Accts
6-Databases
7-Email Accts
8-Email Lists
9-SubDomains
10-Bandwidths
11-Dedi IP
12-Parked Domains
13-Addon Domains
14-Featurelist
15-Language

Thanks for reading and if your interested i am posting another tutorial on how to list accounts well this is all on pixel2life.com and check out my site www.pk-scripts.co.uk
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
Peter Kelly

Website Development Tutorials Written by Peter Kelly (http://www.peter-kelly.me).
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top