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.

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:
    1
    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:
    1
    cPanel Access Level:
    Root Administrator
  3. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    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!
     
Loading...

Share This Page