$query="SELECT userprofile_LLUUID, profile_firstname, profile_lastname, profile_passwdmd5, homesim_ip, homesim_port, homeasset_url, look_at, region_handle, position FROM local_user_profiles WHERE profile_firstname='".$firstname."' AND profile_lastname='".$lastname."' AND profile_passwdmd5='".$passwd."'";
// if we get here, the username/password is valid, but still need to check there's not an already existing session
$client=newIXR_Client($gridserver_url);
if(!$client->query('check_session_loggedin',Array('userprofile_LLUUID'=>$profiledata['userprofile_LLUUID'],'authkey'=>$gridserver_sendkey,'server_type'=>'login'))){// if this doesn't work, grid server is down - that's bad
returnArray(
'reason'=>'key',
'message'=>"Could not connect to grid server. Please try again later or contact the grid owner ".$grid_owner,
'login'=>"false"
);
}
$response=$client->getResponse();
if($response['authkey']!=$gridserver_recvkey){// if this doesn't match up, it's a fake grid server
returnArray(
'reason'=>'key',
'message'=>"Could not connect to grid server due to possible security issues. It is possible that the grid has been compromised. Please contact the grid owner ".$grid_owner." and report this issue",
'login'=>"false"
);
}
if($response['logged_in']==1){// if the user is already logged in, tell them
returnArray(
'reason'=>'presence',
'message'=>"You appear to already be logged into this grid, if your client has recently crashed then please try again later",
// this is the default invalid username/password error
returnArray(
'reason'=>'key',
'message'=>"You have entered an invalid name/password combination or are using an incompatible client. Please check with the grid owner ".$grid_owner." if you are sure your login details are accurate.",