这是我尝试登录的 smf 的登录表单的来源
<form id="guest_form" action="http://example.com/index.php?action=login2" method="post" accept-charset="UTF-8" onsubmit="hashLoginPassword(this, '828560f91ef51ab12e80def32be06ad4');">
<div class="info">Please <a href="http://example.com/index.php?action=login">login</a> or <a href="http://example.com/index.php?action=register">register</a>.</div>
<input type="text" name="user" size="10" class="input_text" />
<input type="password" name="passwrd" size="10" class="input_password" />
<select name="cookielength">
<option value="60">1 Hour</option>
<option value="1440">1 Day</option>
<option value="10080">1 Week</option>
<option value="43200">1 Month</option>
<option value="-1" selected="selected">Forever</option>
</select>
<input type="submit" value="Login" class="button_submit" /><br />
<div class="info">Login with username, password and session length</div>
<input type="hidden" name="hash_passwrd" value="" />
</form>
这是我想出的php代码:
<?php
$user = "test";
$pass = "test";
$url="http://www.jasper88.5gbfree.com/index.php?action=login2";
$curl_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11';
$curl_httpheader = array( 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Accept-Language: en-us,en;q=0.5',
'Accept-Encoding: gzip,deflate',
'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' );
$referer = "http://www.jasper88.5gbfree.com";
$postdata = "user=$user&passwrd=$pass&cookielength=-1&submit=Login";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_FAILONERROR, false );
curl_setopt ($ch, CURLOPT_TIMEOUT, false );
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ($ch, CURLOPT_USERAGENT, $curl_useragent );
curl_setopt ($ch, CURLOPT_REFERER, $referer);
curl_setopt ($ch, CURLOPT_COOKIESESSION, true );
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_COOKIEJAR, "/cok4.txt");
curl_setopt ($ch, CURLOPT_COOKIEFILE, "/cok4.txt");
curl_setopt ($ch, CURLOPT_VERBOSE, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, true);
$result = curl_exec ($ch);
echo $result;
if (curl_error($ch)) {
echo curl_error($ch);
}
?>
我收到此错误:会话验证失败。请尝试注销并重新登录,然后重试。
谁能帮我?服务器是我的,如果您想尝试代码,则可以登录。