Hi,
I am attempting to use the following code to login to webmail using cURL and PHP. It is able to login (I am able to get it to display the logged in content), but it doesn't do the redirect to the webmail page, instead just spitting back the html itself it seems.
PHP Code:<?php
error_reporting(E_ALL);
// get user name and password from $_POST
$cpanelemail = $_POST['emailaddress'];
$cpanelemailpass = $_POST['pass'];
if ($cpanelemail != '' || $cpanelemailpass != '') {
// build cPanel webmail URL
$post2 = array();
$post2['user'] = $cpanelemail;
$post2['pass'] = $cpanelemailpass;
$post2['goto_uri'] = '/';
$post['login_theme'] = 'cpanel';
//print_r($post2);
$url = 'https://xxx.site.com:2096/login/';
//$cookie="cpanel_cookie.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $post2);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'Ocookie.txt');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
//$content = curl_exec($ch);
curl_exec($ch);
//curl_close($ch);
//print $content;
}
else {
// empty variables / no login details provided
print header("Location: cpanel_login.php?failed=2");
}
//exit;
?>



LinkBack URL
About LinkBacks
Reply With Quote




