Publishing System Settings Logout Login Register
How to list accounts that are in WHM
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on November 26th, 2008
4256 views
PHP Coding
This tutorial will show you how to create a script that will help display the accounts that are currently on your Web Host Manager.

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


<?php
$host = "localhost"; // Default: localhost.
$user = "WHMUSER"; // 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.
$accts = listaccts($host,$user,$accesshash,0); // Use cPanel List Accounts Function.
foreach ($accts as $key => $value){ // Split the cPanel Function array into bits.
echo "Username:$key<br>Domain: $value[0]<br>Package: $value[1]<br>Owner: $value[2]<Br><br>"; // Echos the Bits.
}
?>


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. $accts is a variable for the function listaccts which go listaccts(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.

Domain Username: $key
Domain: $value[0]
Package: $value[1]
Owner Of Account: $value[2]

Thanks for reading and if your interested i am posting another tutorial on how to list packages as 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