1
我试图自动登录到cPanel,然后将用户重定向到Awstats页面。 但我遇到了一些麻烦。 唯一的工作方法,我发现是这样的:外部cPanel登录并重定向
<form method="post" id="login-form" action="http://domain.com:2082/login">
<input type="hidden" name="login_theme" id="login_theme" value="cpanel">
<input type="hidden" name="goto_uri" id="goto_uri" value="awstats.pl?config=euqueroinvestir.com&lang=pt">
<input type="hidden" name="user" id="user" value="myuser">
<input type="hidden" name="pass" id="pass" value="mypass">
</form>
<script>window.onload = function() { document.forms["login-form"].submit(); }</script>
但是,正如你所看到的,如果用户查看源代码,密码会以纯文本明确。我不能那样做。所以我尝试了cUrl,但现在我遇到了标题,cookies等问题。
这是我最后一次尝试:
$url = "http://domain.com:2082/login";
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POSTFIELDS, "user=myuser&pass=mypass");
$result = curl_exec($curl);
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$header = substr($result, 0, $header_size);
$body = substr($result, $header_size);
curl_close($curl);
$header = str_replace("\r", '', $header);
$header = explode("\n", $header);
foreach ($header as $h) {
header ($h);
}
$parts = explode('URL=', $result);
$session_parts = explode('/frontend/', $parts[1]);
$token = $session_parts[0];
header('Location: http://domain.com:2082'.$token.'/awstats.pl?config=domain.com&ssl=&lang=pt');
有了这个,我可以得到一个安全令牌,并在foreach($标题为$ H)环是我试图建立来自卷边客户端头和饼干到用户浏览器。
每一个帮助将不胜感激。 是的,我通过谷歌搜索了很多。