exit; } if (isset($_GET["stop-web"])) { stop_web(); exit; } if (isset($_GET["restart-web"])) { restart_web(); exit; } if (isset($_GET["restart-wifidog"])) { restart_wifidog(); exit; } if (isset($_GET["remove-session"])) { remove_session(); exit; } if (isset($_GET["ArticaHotSpotInterface"])) { ArticaHotSpotInterface(); exit; } if (isset($_GET["force-restart-progress"])) { restart_progress(); exit; } if (isset($_GET["reconfigure-progress"])) { reconfigure_progress(); exit; } while (list($num, $line) = each($_GET)) {
function process_login($method_name, $params, $userID) { $config =& get_config(); $userService = $config['user_service']; log_message('debug', "Processing new login request"); $req = $params[0]; $fullname = $req["first"] . ' ' . $req["last"]; // Sanity check the request, make sure it's somewhat valid if (empty($userID)) { if (!isset($req["first"], $req["last"], $req["passwd"]) || empty($req["first"]) || empty($req["last"]) || empty($req["passwd"])) { return array('reason' => 'key', 'login' => 'false', 'message' => "Login request must contain a first name, last name, and password and they cannot be blank"); } // Authorize the first/last/password and resolve it to a user account UUID log_message('debug', "Doing password-based authorization for user {$fullname}"); $userID = authorize_identity($fullname, $req['passwd']); if (empty($userID)) { return array('reason' => 'key', 'login' => 'false', 'message' => "Sorry! We couldn't log you in.\nPlease check to make sure you entered the right\n * Account name\n * Password\nAlso, please make sure your Caps Lock key is off."); } log_message('debug', sprintf("Authorization success for %s", $userID)); } else { log_message('debug', sprintf("Using pre-authenticated capability for %s", $userID)); } // Get information about the user account $user = get_user_by_id($userID); if (empty($user)) { return array('reason' => 'key', 'login' => 'false', 'message' => "Sorry! We couldn't log you in. User account information could not be retrieved. If this problem persists, please contact the grid operator."); } $login_success = true; //ensure username has the same case as in the database $fullname = $user['Name']; if (!empty($user['UserFlags'])) { // get_user_by_id() fully decodes the structure, this is not needed //$userflags = json_decode($user['UserFlags'], TRUE); $userflags = $user['UserFlags']; if (!empty($userflags['Suspended']) && (bool) $userflags['Suspended'] === true) { $login_success = false; log_message('debug', "User " . $user['Name'] . " is banned."); } else { if ($user['AccessLevel'] < $config['access_level_minimum']) { if ($config['validation_required']) { if (!empty($userflags['Validated'])) { $login_success = $userflags['Validated']; } else { $login_success = false; } if (!$login_success) { log_message('debug', "User " . $user['Name'] . " has not validated their email."); } } } } } else { if ($user['AccessLevel'] < $config['access_level_minimum'] && $config['validation_required']) { $login_success = false; log_message('debug', "User " . $user['Name'] . " has not validated their email."); } } if (!$login_success) { return array('reason' => 'key', 'login' => 'false', 'message' => "Sorry! We couldn't log you in. User account has been suspended or is not yet activated. If this problem persists, please contact the grid operator."); } $lastLocation = null; if (isset($user['LastLocation'])) { $lastLocation = SceneLocation::fromOSD($user['LastLocation']); } $homeLocation = null; if (isset($user['HomeLocation'])) { $homeLocation = SceneLocation::fromOSD($user['HomeLocation']); } log_message('debug', sprintf("User retrieval success for %s", $fullname)); // Check for an existing session $existingSession = get_session($userID); if (!empty($existingSession)) { log_message('debug', sprintf("Existing session %s found for %s in scene %s", $existingSession["SessionID"], $fullname, $existingSession["SceneID"])); $sceneID = null; if (UUID::TryParse($existingSession["SceneID"], $sceneID)) { inform_scene_of_logout($sceneID, $userID); } if (remove_session($userID)) { log_message('debug', "Removed existing session for {$fullname} ({$userID})"); } else { log_message('warn', "Failed to remove session for {$fullname} ({$userID})"); return array('reason' => 'presence', 'login' => 'false', 'message' => "You are already logged in from another location. Please try again later."); } } else { log_message('debug', "No existing session found for {$fullname} ({$userID})"); } // Create a login session $sessionID = null; $secureSessionID = null; $extradata = array('ClientIP' => $_SERVER['REMOTE_ADDR']); if (!add_session($userID, $sessionID, $secureSessionID, $extradata)) { return array('reason' => 'presence', 'login' => 'false', 'message' => "Failed to create a login session. Please try again later."); } log_message('debug', sprintf("Session creation success for %s (%s)", $fullname, $userID)); // Find the starting scene for this user $scene = null; $startPosition = null; $startLookAt = null; if (!find_start_location($req['start'], $lastLocation, $homeLocation, $scene, $startPosition, $startLookAt) || !isset($scene->ExtraData['ExternalAddress'], $scene->ExtraData['ExternalPort'])) { return array('reason' => 'presence', 'login' => 'false', 'message' => "Error connecting to the grid. No suitable region to connect to."); } $lludpAddress = $scene->ExtraData['ExternalAddress']; $lludpPort = $scene->ExtraData['ExternalPort']; // Generate a circuit code srand(make_seed()); $circuitCode = rand(); // Prepare a login to the destination scene $seedCapability = NULL; $appearance = $user['LLPackedAppearance']; if (!create_opensim_presence($scene, $userID, $circuitCode, $fullname, $appearance, $sessionID, $secureSessionID, $startPosition, $seedCapability)) { return array('reason' => 'presence', 'login' => 'false', 'message' => "Failed to establish a presence in the destination region. Please try again later."); } log_message('debug', sprintf("Presence creation success for %s (%s) in %s with seedcap %s", $fullname, $userID, $scene->Name, $seedCapability)); // Build the response $response = array(); $response['seconds_since_epoch'] = time(); $response['login'] = '******'; $response['agent_id'] = (string) $userID; list($response['first_name'], $response['last_name']) = explode(' ', $fullname); $response['message'] = $config['message_of_the_day']; $response['udp_blacklist'] = $config['udp_blacklist']; $response['circuit_code'] = $circuitCode; $response['sim_ip'] = $lludpAddress; $response['sim_port'] = (int) $lludpPort; $response['seed_capability'] = $seedCapability; $response['region_x'] = (string) $scene->MinPosition->X; $response['region_y'] = (string) $scene->MinPosition->Y; $response['region_size_x'] = (string) ($scene->MaxPosition->X - $scene->MinPosition->X); $response['region_size_y'] = (string) ($scene->MaxPosition->Y - $scene->MinPosition->Y); $response['look_at'] = sprintf("[r%s, r%s, r%s]", $startLookAt->X, $startLookAt->Y, $startLookAt->Z); // TODO: If a valid $homeLocation is set, we should be pulling region_handle / position / lookat out of it $response['home'] = sprintf("{'region_handle':[r%s, r%s], 'position':[r%s, r%s, r%s], 'look_at':[r%s, r%s, r%s]}", $scene->MinPosition->X, $scene->MinPosition->Y, $startPosition->X, $startPosition->Y, $startPosition->Z, $startLookAt->X, $startLookAt->Y, $startLookAt->Z); $response['session_id'] = (string) $sessionID; $response['secure_session_id'] = (string) $secureSessionID; $req['options'][] = 'initial-outfit'; for ($i = 0; $i < count($req['options']); $i++) { $option = str_replace('-', '_', $req['options'][$i]); if (file_exists(BASEPATH . "options/Class.{$option}.php")) { if (include_once BASEPATH . "options/Class.{$option}.php") { $instance = new $option($user); $response[$req["options"][$i]] = $instance->GetResults(); } else { log_message('warn', "Unable to process login option: " . $option); } } else { log_message('debug', "Option " . $option . " not implemented."); } } $response["start_location"] = $req["start"]; $response["agent_access"] = 'A'; $response["agent_region_access"] = 'A'; $response["agent_access_max"] = 'A'; $response["agent_flags"] = 0; $response["ao_transition"] = 0; $response["inventory_host"] = "127.0.0.1"; log_message('info', sprintf("Login User=%s %s Channel=%s Start=%s Viewer=%s id0=%s Mac=%s", $req["first"], $req["last"], $req["channel"], $req["start"], $req["version"], $req["id0"], $req["mac"])); return $response; }
$error_msg = $lang['Empty_message']; } } elseif ($action == 'del') { if ($user->data['user_level'] == ADMIN && $user->data['session_logged_in']) { $shout_id = request_var('sh', 0); $sql = 'DELETE FROM ' . AJAX_SHOUTBOX_TABLE . ' WHERE shout_id =' . $shout_id; $db->sql_return_on_error(true); $result = $db->sql_query($sql); $db->sql_return_on_error(false); if (!$result) { $error = AJAX_SHOUTBOX_ERROR; $error_msg = $lang['Shoutbox_unable']; } } } elseif ($action == 'leave') { remove_session($error_msg); if ($error_msg != '') { pseudo_die(AJAX_SHOUTBOX_ERROR, $error_msg); } } else { pseudo_die(AJAX_SHOUTBOX_ERROR, "unknown action"); } // Send back the XHR response pseudo_die($error, $error_msg); } if (!$shoutbox_template_parse) { // Load templates $template->set_filenames(array('shoutbox' => 'ajax_shoutbox_body.tpl')); } $template->assign_vars(array('L_SHOUTBOX' => $lang['Ajax_Shoutbox'], 'L_USERNAME' => $lang['Username'], 'L_MESSAGE' => $lang['Message'], 'L_DELETE' => $lang['Delete'], 'L_CONFIRM' => $lang['Confirm_delete_pm'], 'L_SUMBIT' => $lang['Submit'], 'L_ARCHIVE' => $lang['Ajax_Archive'], 'L_UNABLE' => $lang['Shoutbox_unable'], 'L_TIMEOUT' => $lang['Shoutbox_timeout'], 'L_WIO' => $lang['Who_is_Chatting'], 'L_START_PRIVATE_CHAT' => $lang['Start_Private_Chat'], 'L_GUESTS' => $lang['Online_guests'], 'L_TOTAL' => $lang['Online_total'], 'L_USERS' => $lang['Online_registered'], 'L_TOP_SHOUTERS' => $lang['Top_Ten_Shouters'], 'L_SHOUTBOX_ONLINE_EXPLAIN' => $lang['Shoutbox_online_explain'], 'DELETE_IMG' => '<img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" />', 'L_SHOUTBOX_EMPTY' => $lang['Shoutbox_empty'], 'L_SHOUT_ROOMS' => $lang['Shout_rooms'], 'L_PUBLIC_ROOM' => $lang['Public_room'], 'L_PRIVATE_ROOM' => $lang['Private_room'], 'L_SHOUT_PREFIX' => 'shout_', 'L_USER_PREFIX' => 'user_', 'L_ROOM_PREFIX' => 'room_', 'U_ARCHIVE' => append_sid(CMS_PAGE_AJAX_CHAT . '?mode=archive'))); if ($config['shout_allow_guest'] > 0) {