function login($username, $password)
{
global $_SERVER;
$post_fields = $this->array_to_http(array( // Generate post string
'username' => $username,
'password' => $password,
'autologin' => 1,[
'redirect' => 'index.php',
'login' => 'Log In',
));
$this->curl = curl_init();
curl_setopt ( $this->curl, CURLOPT_URL, $this->phpbb_url . 'login.php' );
curl_setopt ( $this->curl, CURLOPT_POST, true );
curl_setopt ( $this->curl, CURLOPT_POSTFIELDS, $post_fields );
curl_setopt ( $this->curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $this->curl, CURLOPT_HEADER, false );
curl_setopt ( $this->curl, CURLOPT_COOKIE, $this->cookie_name );
curl_setopt ( $this->curl, CURLOPT_COOKIEJAR, $this->cookie_name );
curl_setopt ( $this->curl, CURLOPT_COOKIEFILE, $this->cookie_name );
curl_setopt ( $this->curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
$result = curl_exec ( $this->curl );
if ( curl_errno ( $this->curl ) )
{
$this->error = array(
curl_errno($this->curl),
curl_error($this->curl),
);
curl_close ( $this->curl );
return false;
}
curl_close ( $this->curl ); // Close connection
return true; // Return result
}