2008-11-20, 08:21 AM
I'm writing a cURL class to login to MyBB and send PMs and the like. I can log a user in and then make it move around the forums using a couple of functions, but I'm stumped as to how to get it to logout. When I call the logout_main() function and echo the contents it returns, I get the error below:
I have been appending the logoutkey to the URL, and have opened up member.php to try and figure out why it won't work - but I don't see any other checks performed. I also tried playing with the referrer value to no avail. Here's the function source if that helps:
Any ideas? Kind of new to using cURL so examples might be useful
MyBB Wrote:Your user ID could not be verified to log you out. This may have been because a malicious Javascript was attempting to log you out automatically. If you intended to log out, please click the Log Out button at the top menu.
I have been appending the logoutkey to the URL, and have opened up member.php to try and figure out why it won't work - but I don't see any other checks performed. I also tried playing with the referrer value to no avail. Here's the function source if that helps:
function logout_main() {
// Logs the bot user out of MyBB, has to get the logoutkey first though
$this->curl_handle = curl_init();
curl_setopt($this->curl_handle, CURLOPT_CONNECTTIMEOUT, $this->curl_connection_timeout);
curl_setopt($this->curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->curl_handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($this->curl_handle, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
curl_setopt($this->curl_handle, CURLOPT_URL, $this->board_url .'/index.php');
curl_setopt($this->curl_handle, CURLOPT_AUTOREFERER, true);
curl_setopt($this->curl_handle, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($this->curl_handle, CURLOPT_COOKIEFILE, $this->curl_cookie_directory .'/current.txt');
$this->curl_result = curl_exec($this->curl_handle);
$logout_key_start = strpos($this->curl_result, 'logoutkey=');
$logout_key = substr($this->curl_result, $logout_key_start + 10, 32);
curl_setopt($this->curl_handle, CURLOPT_REFERER, 'http://jdforums.co.cc/index.php');
curl_setopt($this->curl_handle, CURLOPT_URL, $this->board_url .'/member.php?action=logout&logoutkey='. $logout_key);
$this->curl_result = curl_exec($this->curl_handle);
return $this->curl_result;
}
Any ideas? Kind of new to using cURL so examples might be useful