Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Find user homedir

Discussion in 'cPanel Developers' started by tecwithquestion, Sep 6, 2017.

Tags:
  1. tecwithquestion

    tecwithquestion Well-Known Member

    Joined:
    Oct 20, 2014
    Messages:
    57
    Likes Received:
    1
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Hello

    In x3 I was using below code to find user's home dir
    <cpanel PHP="loadvars()">
    $homedir = $_CPANEL['USERDATA']['home'];


    Can someone please tell how can I find user homedir using live.php file ?

    Thanks
     
    #1 tecwithquestion, Sep 6, 2017
    Last edited: Sep 6, 2017
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,167
    Likes Received:
    1,933
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. host2media

    host2media Registered

    Joined:
    Jan 5, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    51
    Hello,

    This is still not working at my end if someone could explain more please

    in x3 I used this
    Code:
    <cpanel PHP="loadvars()">
    $HOMEDIR = $_CPANEL['USERDATA']['home'];
    
    function get_settings() {
        global $HOMEDIR, $SETTINGS;
        $phpini= file_get_contents("$HOMEDIR/php.ini");
    
    note that  my script works perfectly if I save it .php but header and footer will be missing and if I save it .live.php
    it returns with an error
    
    in the new paper lantern theme I tried the following :
    
    <?php
    $get_userdata = $cpanel->uapi(                // Get domain user data.
        'DomainInfo', 'domains_data',
        array(
            'format'    => 'hash',
        )
    );
    
    function get_settings() {
        global $HOMEDIR, $SETTINGS;
        $phpini= file_get_contents("$get_userdata/php.ini");
    
    ?>
    
    but didn't work.

    please advice

    and is it still possible to use header and footer in .php ? what will be the code

    Thank You
     
    #3 host2media, Nov 13, 2017
    Last edited by a moderator: Nov 13, 2017
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,167
    Likes Received:
    1,933
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    We document how to do this under "Step 2" at:

    Tutorial - Create a New Paper Lantern Interface in PHP - Software Development Kit - cPanel Documentation

    What specific error message are you receiving?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. host2media

    host2media Registered

    Joined:
    Jan 5, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    51
    this is the error i am getting :

    Child failed to make LIVEAPI connection to cPanel.

    is there any way to keep using .php header and footer and avoid .live.php ? because my script is running perfectly when i save it .php the only thing is that its missing the header/footer , my only issue is with $HOMEDIR with live php,

    please help.

    thank you
     
  6. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,167
    Likes Received:
    1,933
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    You could use Template Toolkit instead if you have no requirement for PHP at all:

    Tutorial - Create a New Paper Lantern Interface - Software Development Kit - cPanel Documentation

    Otherwise, consider sending an email to integration@cpanel.net for additional feedback on your custom script.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice