AlexVB

Member
Oct 23, 2007
13
1
53
I am writing some perl application which needs to get:

1) all domains that are accesible from web (including sub-domains, parked domains, addon domains, etc)
2) ip address to which user's domains are mapped to

for each cpanel user.

Which API i need to use for that purpose?

This application will work locally on the cpanel server.

Thanks
 

KostonConsulting

Well-Known Member
Verifed Vendor
Jun 17, 2010
255
1
68
San Francisco, CA
cPanel Access Level
Root Administrator
You should be able to use DomainLookup::getdocroots() and DNSLookup::name2ip() for these purposes. One should note that cPanel will output duplicate data for addon domains.

For example, domain1.com is your main domain on the account. You add domain2.com as an addon domain. When outputting all the domains, you get an entry for domain2.com as well as the subdomain alias domain2.domain1.com. I've found it necessary to remove this subdomain alias from anything that is shown to customers as it can cause a lot of confusion.

You can use the cPanel LiveAPI Perl module interface if you're going to have cPanel users directly interacting with the script via URL:

LiveAPI — Perl