开发者

CPanel 11 Auto Login?

Does anyone know if there's a way to automatically login to CPanel 11 and then redirecting to somewhere else? I've tried everything, some things wor开发者_如何学Ck better than others, for example, using and iFrame I can achieve this but only in Firefox. Neither XMLHttpRequest nor Curl work. The only solution is recreating the form and autosubmitting it once the page loads, but this doesn't work for me as I don't want to go to the CPanel once logged in, I want to go to a menu of my own where I have a link that points to CPanel. Thanks in advance,

D


try this, not sure if it works:

POST: http://cpanelurl/login/

parameters: 
login_theme=cpanel&user=yourusername&pass=yourpassword&goto_uri=yoururl

example:
POST to: http://cpanel.spacenets.com/login/
parameters: login_theme=cpanel&user=bluebl&pass=23dff&goto_uri=http%3A%2F%2Fwww.youtube.com


Elements required to make this functionality are –

    Server/WHM Username
    Cpanel account Username
    Server login URL
    Server accesshash key

And for Accesshash key , New or already generated Access key can get from here:- WHM > Remote Access Key area and the Access Key located there. or it should be at this path “/usr/local/cpanel/bin/realmkaccesshash

$query = "https://$server_login_link:2087/json-api/create_user_session?
api.version=1&user=$cpanel_user&service=cpaneld";
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);

$header[0] = "Authorization: WHM $whmusername:" . 
preg_replace("'(\r|\n)'","",$hash);
curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_URL, $query);
$result = curl_exec($curl);

if ($result == false) {
   // your error log
}
if($result){
   $decoded_response = json_decode( $result, true );
   if(isset($decoded_response['data']) && !empty($decoded_response['data']))
    {
        $url = $decoded_response['data']['url'];
       return $url;        
   }

}   

When you will open the returned URL in a new tab then cpanel is already logged in for that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜