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.

Login in to WHM or cPanel through link, direct click

Discussion in 'General Discussion' started by Laurent Chammas, Sep 1, 2014.

  1. Laurent Chammas

    Laurent Chammas Registered

    Joined:
    Sep 1, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi,

    Sorry for the seemingly easy thread.

    Anyone, can you please share a PHP function (and example of application) for a direct loggin through link.

    I guess that will imply curl and cpsess.. but I would not want to mess with it on my own and get locked out of my own panel :)

    Ultimately, I will use the code for my clients to access their panel directly from our site.

    Thank you very mcuh for your help! !!!!
     
  2. Laurent Chammas

    Laurent Chammas Registered

    Joined:
    Sep 1, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Thank you for this :)

    Very useful!

    I have been playing around from the couple of links you provided and playing around with this one :

    PHP:
    <?php
     

     
    $whmusername 
    "test";
    $whmhash "long long hash";
    # some hash value
     
    $query "https://test.com:2087/";
     
    $curl curl_init();
    # Create Curl Object
    curl_setopt($curlCURLOPT_SSL_VERIFYHOST,0);
    # Allow certs that do not match the domain
    curl_setopt($curlCURLOPT_SSL_VERIFYPEER,0);
    # Allow self-signed certs
    curl_setopt($curlCURLOPT_RETURNTRANSFER,1);
    # Return contents of transfer on curl_exec
    $header[0] = "Authorization: WHM $whmusername:" preg_replace("'(\r|\n)'","",$whmhash);
    # Remove newlines from the hash
    curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
    # Set curl header
    curl_setopt($curlCURLOPT_URL$query);
    # Set your URL
    $result curl_exec($curl);
    # Execute Query, assign to $result
    if ($result == false) {
        
    error_log("curl_exec threw error \"" curl_error($curl) . "\" for $query");
    }
    curl_close($curl);
     
    print 
    $result;
     
    ?>
     
    it seems to log all right.. the only issue is that after succesful login it show me a page divided in 3 segments, each showing 404 errors (see attachment).

    I am sure that i am doing somehting worng :)

    Would you know what I am doing wrong?
     

    Attached Files:

  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  4. Laurent Chammas

    Laurent Chammas Registered

    Joined:
    Sep 1, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    OK .. so whwere should it go and how i change the address?

    As you can see in the code... it does now show anything such as "script/command" yet it takes me there .

    Thank you so very much :)
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    676
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    The example you provided was from the API Authentication document. You should follow the instructions on the following document if you have no need to utilize our API:

    Secure Remote Logins

    Note that the URL is generated by a Perl script in the example.

    Thank you.
     
Loading...

Share This Page