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!

external login form

Discussion in 'cPanel Developers' started by Robert Simpson, Jun 8, 2012.

  1. Robert Simpson

    Robert Simpson Registered

    Joined:
    Jun 8, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Root Administrator
    Hi folks,

    I'm producing a form for my hosting site which will (hopefully) log users directly into cPanel on their account, but I'm having some difficulty with the script which handles the form submission.

    Whenever I test it it just shows me the cPanel login for the domain being submitted, it doesn't log in.

    Would anyone mind having a look at it?

    Code:
    <?php
    
    // using $_GET to test sending the variables, the final form will use $_POST for obvious reasons
    
    if($_GET == TRUE) {
    	$vars = array(
    		'domain' => $_GET['d'],
    		'user' => $_GET['u'],
    		'pass' => $_GET['p'],
    	);
    } else {
    	echo "no vars";
    	exit;
    }
    
    // the rest of this is the redirect
    
    $curlHandler = curl_init();
    
    $curlOpts = array(
    	CURLOPT_URL => "https://".$vars['domain'].":2083/login/",
    	CURLOPT_FRESH_CONNECT => true,
    	CURLOPT_HEADER => false,
    	CURLOPT_POSTFIELDS => http_build_query($vars, "", "&"),
    	CURLOPT_RETURNTRANSFER => true,
    	CURLOPT_USERAGENT => "SHcPanelReDirect/0.1"
    );
    
    curl_setopt_array($curlHandler, $curlOpts);
    
    if(false === ($responseString = curl_exec($curlHandler))) {
    	exit("0 - No connection to server.");
    }
    
    echo $responseString;
    
    ?>
    Thanks in advance :)


    Cheers,
    Robert
     
  2. Robert Simpson

    Robert Simpson Registered

    Joined:
    Jun 8, 2012
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Root Administrator
  3. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,608
    Likes Received:
    32
    Trophy Points:
    238
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Hello Robert,

    I've moved this over to our developers section of the forum, since this is a coding question. You'll have better luck here getting assistance rather than in Themes & Branding area.

    Thanks!
     
    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