The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to get cPanel username and domain name

Discussion in 'cPanel Developers' started by NixTree, Feb 28, 2012.

  1. NixTree

    NixTree Well-Known Member

    Joined:
    Aug 19, 2010
    Messages:
    386
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Gods Own Country
    cPanel Access Level:
    Root Administrator
    Hi geeks :)

    Even though I have been working with cPanel servers for the past 2.5 years, I am a newbie in the development area. In fact I started learning PHP today!

    I would like to write a cPanel plugin; I need to have the cPanel user name and its domains and assign those to variables in the script! I am trying to achieve this via PHP - but not sure how to do this!

    As I said, I am a newbie in PHP and if anybody would like to help me - please get me a detailed explanation :)

    Thank you,
    Nibin.
     
    #1 NixTree, Feb 28, 2012
    Last edited: Feb 28, 2012
  2. BlaineM.

    BlaineM. cPanel QA Analyst
    Staff Member

    Joined:
    Apr 4, 2011
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hey Nibin,

    Since you're wanting to create a plugin, I would recommend reading the following about Creating a cPanel Plugin and also using LivePHP

    Also, we ship an example of LivePHP within the x3 theme directory: test.live.php

    Hope that helps get you on your way.
     
  3. NixTree

    NixTree Well-Known Member

    Joined:
    Aug 19, 2010
    Messages:
    386
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Gods Own Country
    cPanel Access Level:
    Root Administrator
    Hello Blaine :)

    Thank you for the reply! I have managed to find something; but I would like to know if there is any clean API call to find all domains ( sub, add-on and parked domains ) and IP address associated with an account?

    Thank you,
    Nibin.
     
    #3 NixTree, Feb 29, 2012
    Last edited: Feb 29, 2012
  4. NixTree

    NixTree Well-Known Member

    Joined:
    Aug 19, 2010
    Messages:
    386
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Gods Own Country
    cPanel Access Level:
    Root Administrator
    Hello,

    I use LIvePHP to get main domain and its IP

    $cpanel->fetch('$CPDATA{\'DNS\'}');
    $cpanel->cpanelprint('$ip');

    Now I need to know, how to get all domains ( parked, add-on and sub domains ) of an account using the same method ( or via something else perhaps ).

    Thank you,
    Nibin.
     
  5. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
    This will grab main, sub and addon domains:

    ApiDomainLookup < ApiDocs/Api2 < TWiki


    This will grab parked domains:

    ApiPark < ApiDocs/Api2 < TWiki

    Depending on your setup, you may also want to take into account whether or not some of those domains are redirected:

    ApiMime < ApiDocs/Api2 < TWiki
     
Loading...

Share This Page