コード例 #1
0
 /// <summary>
 ///     Creates a new database entry for the agent.
 ///     Note: we only allow for this on the grid side
 /// </summary>
 /// <param name="agentID"></param>
 public void CreateNewAgent(UUID agentID)
 {
     List<object> values = new List<object> {agentID, "AgentInfo"};
     IAgentInfo info = new IAgentInfo {PrincipalID = agentID};
     values.Add(OSDParser.SerializeLLSDXmlString(info.ToOSD())); //Value which is a default Profile
     GD.Insert("userdata", values.ToArray());
 }
コード例 #2
0
ファイル: EngineerSkills.cs プロジェクト: goncalopereira/Gr1d
 public static void Decompile(IAgentInfo agentInfo, IEngineer5 engineer)
 {
     if (!agentInfo.Effects.Contains(AgentEffect.Decompile))
     {
         engineer.Decompile(agentInfo);
     }
 }
コード例 #3
0
ファイル: BanCheck.cs プロジェクト: velus/Async-Sim-Testing
        public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
                                   string password, out object data)
        {
            data = null;

            string ip = "";
            string version = "";
            string platform = "";
            string mac = "";
            string id0 = "";

            if (request != null)
            {
                ip = request.ContainsKey("ip") ? (string) request["ip"] : "";
                version = request.ContainsKey("version") ? (string) request["version"] : "";
                platform = request.ContainsKey("platform") ? (string) request["platform"] : "";
                mac = request.ContainsKey("mac") ? (string) request["mac"] : "";
                id0 = request.ContainsKey("id0") ? (string) request["id0"] : "";
            }

            string message;
            if (!m_module.CheckUser(account.PrincipalID, ip,
                                    version,
                                    platform,
                                    mac,
                                    id0, out message))
            {
                return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, message, false);
            }
            return null;
        }
コード例 #4
0
ファイル: Scout.cs プロジェクト: ChrisAnn/Gr1d
 public virtual void OnArrivedActions(IAgentInfo arriver, IAgentUpdateInfo agentUpdate)
 {
     if (arriver.Owner != agentUpdate.Owner)
     {
         this.Attack(arriver);
     }
 }
コード例 #5
0
ファイル: Lieutenant.cs プロジェクト: ChrisAnn/Gr1d
        public override void OnAttackedActions(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
        {
            if ((attacker.EffectFlags & AgentEffect.Decompile) != AgentEffect.Decompile)
                Engineer.Decompile(attacker, this);

            base.OnAttackedActions(attacker, agentUpdate);
        }
コード例 #6
0
ファイル: Engineer.cs プロジェクト: goncalopereira/Gr1d
 public static void Pin(IEngineer2 engineer, IAgentInfo attacker)
 {
     if (!attacker.Effects.Contains(AgentEffect.Pin))
     {
         engineer.Pin(attacker);
     }
 }
コード例 #7
0
ファイル: MyEngineer.cs プロジェクト: kid/GridPlayer
 public void OnArrived(IAgentInfo arriver, IAgentUpdateInfo agentUpdate)
 {
     if (this.Clan != arriver.Clan)
     {
         this.Attack(arriver);
     }
 }
コード例 #8
0
ファイル: Lieutenant.cs プロジェクト: ChrisAnn/Gr1d
        public override void OnArrivedActions(IAgentInfo arriver, IAgentUpdateInfo agentUpdate)
        {
            if (arriver.Owner != agentUpdate.Owner)
                if ((arriver.EffectFlags & AgentEffect.Decompile) != AgentEffect.Decompile)
                    Engineer.Decompile(arriver, this);

            base.OnArrivedActions(arriver, agentUpdate);
        }
コード例 #9
0
ファイル: Scout.cs プロジェクト: ChrisAnn/Gr1d
        public void OnAttacked(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
        {
            Deck.Trace(":: OnAttacked", TraceType.Verbose);
            Deck.Trace(String.Format("Owner:{0} Level:{1}", attacker.Owner, attacker.Level), TraceType.Warning);

            try
            {
                OnAttackedActions(attacker, agentUpdate);
            }
            catch (Exception e)
            {
                Deck.Trace(string.Format("Exception in OnAttacked: {0}", e.Message), TraceType.Error);
            }
        }
コード例 #10
0
ファイル: OnAgent.cs プロジェクト: goncalopereira/Gr1d
        public static void AttackAndTrySkills(IAgentInfo target, IAgent engineer, IDeck deck, IAgentUpdateInfo update)
        {
            if (target == null)
            {
                deck.Trace("Target is null",TraceType.Information);
                return;
            }

            deck.Trace(string.Format("Attack: Owner {0} Level {1} Stack {2} at {3}:{4}:{5}", target.Owner, target.Level,  target.Stack,
               update.Node.Row, update.Node.Column, update.Node.Layer), TraceType.Information);

            engineer.Attack(target);

            Skills(target, update, engineer);
        }
コード例 #11
0
ファイル: Sergeant.cs プロジェクト: ChrisAnn/Gr1d
 public override void OnArrivedActions(IAgentInfo arriver, IAgentUpdateInfo agentUpdate)
 {
     if (arriver.Owner != agentUpdate.Owner)
         base.OnArrivedActions(arriver, agentUpdate);
     else
     {
         try
         {
             Engineer.Mentor(agentUpdate.Node.MyAgents, this);
         }
         catch (Exception ex)
         {
             Deck.Trace(string.Format("Exception in {0}. Message: {1}. StackTrace {2})", this.ToString(), ex.Message, ex.StackTrace), TraceType.Error);
         }
     }
 }
コード例 #12
0
ファイル: TheExplorer.cs プロジェクト: merxbj/src
 public void OnArrived(IAgentInfo arriver, IAgentUpdateInfo agentUpdate)
 {
     if (arriver.Clan != agentUpdate.Clan)
     {
         if (arriver.Level >= agentUpdate.Level + 1)
         {
             this.Attack(arriver);
         }
         else
         {
             deck.Trace("Agent met by another agent with too high level! Will not attack.", TraceType.Verbose);
         }
     }
     else
     {
         deck.Trace("Agent met by another agent from the same clan! Will not attack.", TraceType.Verbose);
     }
 }
コード例 #13
0
ファイル: Move.cs プロジェクト: goncalopereira/Gr1d
        public static void GreedyMoveToFirstAgent(IAgentUpdateInfo agentUpdate, IAgent agent, IAgentInfo agentBeingAttacked)
        {
            IEnumerable<INodeInformation> agentBeingAttackedMoved =
                agentUpdate.Node.Exits.Values.Where(x => x.OpposingAgents.Contains(agentBeingAttacked));

            if (agentBeingAttackedMoved.Count() > 0)
            {
                PickMove(agentUpdate, agentBeingAttackedMoved,agent);
            }
            else
            {
                IEnumerable<INodeInformation> possibleNodes =
                    agentUpdate.Node.Exits.Values.Where(x => x.OpposingAgents.Count() > 0).OrderBy(
                        x => x.OpposingAgents.Count());

                PickMove(agentUpdate, possibleNodes, agent);
            }
        }
コード例 #14
0
 public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
                            string password, out object data)
 {
     data = null;
     //
     // Authenticate this user
     //
     if (authType == "UserAccount")
     {
         password = password.StartsWith("$1$") ? password.Remove(0, 3) : Util.Md5Hash(password); //remove $1$
     }
     string token = m_AuthenticationService.Authenticate(account.PrincipalID, authType, password, 30);
     UUID secureSession = UUID.Zero;
     if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
         return LLFailedLoginResponse.AuthenticationProblem;
     data = secureSession;
     return null;
 }
コード例 #15
0
ファイル: OnAgent.cs プロジェクト: goncalopereira/Gr1d
        private static void Skills(IAgentInfo target, IAgentUpdateInfo update, IAgent engineer)
        {
            if (!(engineer is Bishop)

              //  && HaveAtLeastTwoMoreAgentsThanEnemiesInSameNode(update)

                )
            {

                if (engineer is IEngineer6)
                {
                    EngineerSkills.Scaffold(target.Node, (IEngineer6)engineer);
                    return;
                }

                if (engineer is IEngineer5)
                {
                    EngineerSkills.Decompile(target, (IEngineer5)engineer);
                    return;
                }

                if (engineer is IEngineer4)
                {
                    EngineerSkills.Mentor(update, (IEngineer4)engineer);
                    return;
                }

                if (engineer is IEngineer3)
                {
                    EngineerSkills.Struts(target.Node, (IEngineer3)engineer);
                    return;
                }

                if (engineer is IEngineer2)
                {
                    EngineerSkills.Pin(target, (IEngineer2)engineer);
                    return;
                }
            }
        }
コード例 #16
0
        protected void UnBlockUser(string[] cmdparams)
        {
            if (cmdparams.Length < 3)
            {
                MainConsole.Instance.Info("Wrong number of parameters for block user");
                return;
            }
            UUID         AgentID;
            PresenceInfo info;

            if (!UUID.TryParse(cmdparams[2], out AgentID))
            {
                UserAccount account = m_accountService.GetUserAccount(null, Util.CombineParams(cmdparams, 2));
                if (account == null)
                {
                    MainConsole.Instance.Warn("Cannot find user.");
                    return;
                }
                AgentID = account.PrincipalID;
            }
            info = GetInformation(AgentID);
            if (info == null)
            {
                MainConsole.Instance.Warn("Cannot find user.");
                return;
            }
            info.Flags = PresenceInfo.PresenceInfoFlags.Clean;
            presenceInfo.UpdatePresenceInfo(info);

            var        conn      = Aurora.DataManager.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo agentInfo = conn.GetAgent(AgentID);

            agentInfo.Flags &= IAgentFlags.TempBan;
            agentInfo.Flags &= IAgentFlags.PermBan;
            conn.UpdateAgent(agentInfo);

            MainConsole.Instance.Fatal("User block removed");
        }
コード例 #17
0
ファイル: AssortedCAPS.cs プロジェクト: TagsRocks/Aurora-Sim
        private byte[] ProcessUpdateAgentLanguage(Stream request, UUID agentID)
        {
            OSDMap rm = OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)) as OSDMap;

            if (rm == null)
            {
                return(MainServer.BadRequest);
            }
            IAgentConnector AgentFrontend = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();

            if (AgentFrontend != null)
            {
                IAgentInfo IAI = AgentFrontend.GetAgent(agentID);
                if (IAI == null)
                {
                    return(MainServer.BadRequest);
                }
                IAI.Language         = rm["language"].AsString();
                IAI.LanguageIsPublic = int.Parse(rm["language_is_public"].AsString()) == 1;
                AgentFrontend.UpdateAgent(IAI);
            }
            return(MainServer.BlankResponse);
        }
コード例 #18
0
        OSDMap UnBanUser(OSDMap map)
        {
            OSDMap resp = new OSDMap();

            resp ["Finished"] = OSD.FromBoolean(true);

            UUID       agentID  = map ["UserID"].AsUUID();
            IAgentInfo GetAgent = DataPlugins.RequestPlugin <IAgentConnector> ().GetAgent(agentID);

            if (GetAgent != null)
            {
                GetAgent.Flags &= IAgentFlags.PermBan;
                GetAgent.Flags &= IAgentFlags.TempBan;
                if (GetAgent.OtherAgentInformation.ContainsKey("TemporaryBanInfo") == true)
                {
                    GetAgent.OtherAgentInformation.Remove("TemporaryBanInfo");
                }

                DataPlugins.RequestPlugin <IAgentConnector> ().UpdateAgent(GetAgent);
            }

            return(resp);
        }
コード例 #19
0
        public void UpdateAgent(IAgentInfo agent)
        {
            /*object remoteValue = DoRemoteForUser(agent.PrincipalID, agent.ToOSD());
             * if (remoteValue != null)
             *  return;*/

            List <object> SetValues = new List <object> {
                OSDParser.SerializeLLSDXmlString(agent.ToOSD())
            };
            List <string> SetRows = new List <string> {
                "Value"
            };


            List <object> KeyValue = new List <object> {
                agent.PrincipalID, "AgentInfo"
            };

            List <string> KeyRow = new List <string> {
                "ID", "`Key`"
            };

            GD.Update("userdata", SetValues.ToArray(), SetRows.ToArray(), KeyRow.ToArray(), KeyValue.ToArray());
        }
コード例 #20
0
        byte[] BanUser(OSDMap map)
        {
            OSDMap     resp     = new OSDMap();
            UUID       agentID  = map["UserID"].AsUUID();
            IAgentInfo GetAgent = DataManager.RequestPlugin <IAgentConnector>().GetAgent(agentID);

            if (GetAgent == null)
            {
                resp["Finished"] = OSD.FromBoolean(true);
                string       xmlString = OSDParser.SerializeJsonString(resp);
                UTF8Encoding encoding  = new UTF8Encoding();
                return(encoding.GetBytes(xmlString));
            }
            else
            {
                GetAgent.Flags &= ~IAgentFlags.PermBan;
                DataManager.RequestPlugin <IAgentConnector>().UpdateAgent(GetAgent);

                resp["Finished"] = OSD.FromBoolean(true);
                string       xmlString = OSDParser.SerializeJsonString(resp);
                UTF8Encoding encoding  = new UTF8Encoding();
                return(encoding.GetBytes(xmlString));
            }
        }
コード例 #21
0
ファイル: AssortedCAPS.cs プロジェクト: x8ball/Aurora-Sim
        private Hashtable ProcessUpdateAgentInfo(Hashtable mDhttpMethod, UUID agentID)
        {
            OSD    r        = OSDParser.DeserializeLLSDXml((string)mDhttpMethod["requestbody"]);
            OSDMap rm       = (OSDMap)r;
            OSDMap access   = (OSDMap)rm["access_prefs"];
            string Level    = access["max"].AsString();
            int    maxLevel = 0;

            if (Level == "PG")
            {
                maxLevel = 0;
            }
            if (Level == "M")
            {
                maxLevel = 1;
            }
            if (Level == "A")
            {
                maxLevel = 2;
            }
            IAgentConnector data = DataManager.RequestPlugin <IAgentConnector>();

            if (data != null)
            {
                IAgentInfo agent = data.GetAgent(agentID);
                agent.MaturityRating = maxLevel;
                data.UpdateAgent(agent);
            }
            Hashtable cancelresponsedata = new Hashtable();

            cancelresponsedata["int_response_code"]   = 200; //501; //410; //404;
            cancelresponsedata["content_type"]        = "text/plain";
            cancelresponsedata["keepalive"]           = false;
            cancelresponsedata["str_response_string"] = "";
            return(cancelresponsedata);
        }
コード例 #22
0
        public override void FromOSD(OSDMap map)
        {
            AgentInfo = new IAgentInfo();
            AgentInfo.FromOSD((OSDMap)(map["AgentInfo"]));
            UserAccount = new UserAccount();
            UserAccount.FromOSD((OSDMap)(map["UserAccount"]));
            if (!map.ContainsKey("ActiveGroup"))
            {
                ActiveGroup = null;
            }
            else
            {
                ActiveGroup = new GroupMembershipData();
                ActiveGroup.FromOSD((OSDMap)(map["ActiveGroup"]));
            }
            GroupMemberships = ((OSDArray)map["GroupMemberships"]).ConvertAll <GroupMembershipData>((o) =>
            {
                GroupMembershipData
                group =
                    new GroupMembershipData
                        ();
                group
                .FromOSD
                    ((OSDMap
                      )o);
                return(group);
            });
            OfflineMessages = ((OSDArray)map["OfflineMessages"]).ConvertAll <GridInstantMessage>((o) =>
            {
                GridInstantMessage
                group =
                    new GridInstantMessage
                        ();
                group.FromOSD(
                    (OSDMap)o);
                return(group);
            });
            MuteList = ((OSDArray)map["MuteList"]).ConvertAll <MuteList>((o) =>
            {
                MuteList group = new MuteList();
                group.FromOSD((OSDMap)o);
                return(group);
            });

            if (map.ContainsKey("Appearance"))
            {
                Appearance = new AvatarAppearance();
                Appearance.FromOSD((OSDMap)map["Appearance"]);
            }
            if (map.ContainsKey("FriendOnlineStatuses"))
            {
                FriendOnlineStatuses = ((OSDArray)map["FriendOnlineStatuses"]).ConvertAll <UUID>((o) => { return(o); });
            }
            if (map.ContainsKey("Friends"))
            {
                Friends = ((OSDArray)map["Friends"]).ConvertAll <FriendInfo>((o) =>
                {
                    FriendInfo f = new FriendInfo();
                    f.FromOSD((OSDMap)o);
                    return(f);
                });
            }
        }
コード例 #23
0
ファイル: Engineer2.cs プロジェクト: goncalopereira/Gr1d
 public void OnAttacked(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
 {
     Agent = attacker;
     AttackAndTryPin();
 }
コード例 #24
0
        private bool OnAllowedIncomingAgent(IScene scene, AgentCircuitData agent, bool isRootAgent, out string reason)
        {
            #region Incoming Agent Checks

            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, agent.AgentID);

            IScenePresence Sp = scene.GetScenePresence(agent.AgentID);
            if (account == null)
            {
                reason = "Failed authentication.";
                return(false); //NO!
            }

            if (LoginsDisabled)
            {
                reason = "Logins Disabled";
                return(false);
            }

            //Check how long its been since the last TP
            if (m_enabledBlockTeleportSeconds && Sp != null && !Sp.IsChildAgent)
            {
                if (TimeSinceLastTeleport.ContainsKey(Sp.Scene.RegionInfo.RegionID))
                {
                    if (TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] > Util.UnixTimeSinceEpoch())
                    {
                        reason = "Too many teleports. Please try again soon.";
                        return(false); // Too soon since the last TP
                    }
                }
                TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] = Util.UnixTimeSinceEpoch() + ((int)(SecondsBeforeNextTeleport));
            }

            //Gods tp freely
            if ((Sp != null && Sp.GodLevel != 0) || account.UserLevel != 0)
            {
                reason = "";
                return(true);
            }

            //Check whether they fit any ban criteria
            if (Sp != null)
            {
                foreach (string banstr in BanCriteria)
                {
                    if (Sp.Name.Contains(banstr))
                    {
                        reason = "You have been banned from this region.";
                        return(false);
                    }
                    else if (((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString().Contains(banstr))
                    {
                        reason = "You have been banned from this region.";
                        return(false);
                    }
                }
                //Make sure they exist in the grid right now
                OpenSim.Services.Interfaces.IAgentInfoService presence = scene.RequestModuleInterface <IAgentInfoService>();
                if (presence == null)
                {
                    reason = String.Format("Failed to verify user presence in the grid for {0} in region {1}. Presence service does not exist.", account.Name, scene.RegionInfo.RegionName);
                    return(false);
                }

                OpenSim.Services.Interfaces.UserInfo pinfo = presence.GetUserInfo(agent.AgentID.ToString());

                if (pinfo == null || (!pinfo.IsOnline && ((agent.teleportFlags & (uint)TeleportFlags.ViaLogin) == 0)))
                {
                    reason = String.Format("Failed to verify user presence in the grid for {0}, access denied to region {1}.", account.Name, scene.RegionInfo.RegionName);
                    return(false);
                }
            }

            EstateSettings ES = scene.RegionInfo.EstateSettings;

            IEntityCountModule entityCountModule = scene.RequestModuleInterface <IEntityCountModule>();
            if (entityCountModule != null && scene.RegionInfo.RegionSettings.AgentLimit
                < entityCountModule.RootAgents + 1)
            {
                reason = "Too many agents at this time. Please come back later.";
                return(false);
            }

            List <EstateBan> EstateBans = new List <EstateBan>(ES.EstateBans);
            int i = 0;
            //Check bans
            foreach (EstateBan ban in EstateBans)
            {
                if (ban.BannedUserID == agent.AgentID)
                {
                    if (Sp != null)
                    {
                        string banIP = ((System.Net.IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString();

                        if (ban.BannedHostIPMask != banIP) //If it changed, ban them again
                        {
                            //Add the ban with the new hostname
                            ES.AddBan(new EstateBan()
                            {
                                BannedHostIPMask   = banIP,
                                BannedUserID       = ban.BannedUserID,
                                EstateID           = ban.EstateID,
                                BannedHostAddress  = ban.BannedHostAddress,
                                BannedHostNameMask = ban.BannedHostNameMask
                            });
                            //Update the database
                            ES.Save();
                        }
                    }

                    reason = "Banned from this region.";
                    return(false);
                }
                if (Sp != null)
                {
                    IPAddress   end  = Sp.ControllingClient.EndPoint;
                    IPHostEntry rDNS = null;
                    try
                    {
                        rDNS = Dns.GetHostEntry(end);
                    }
                    catch (System.Net.Sockets.SocketException)
                    {
                        m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
                        rDNS = null;
                    }
                    if (ban.BannedHostIPMask == agent.IPAddress ||
                        (rDNS != null && rDNS.HostName.Contains(ban.BannedHostIPMask)) ||
                        end.ToString().StartsWith(ban.BannedHostIPMask))
                    {
                        //Ban the new user
                        ES.AddBan(new EstateBan()
                        {
                            EstateID           = ES.EstateID,
                            BannedHostIPMask   = agent.IPAddress,
                            BannedUserID       = agent.AgentID,
                            BannedHostAddress  = agent.IPAddress,
                            BannedHostNameMask = agent.IPAddress
                        });
                        ES.Save();

                        reason = "Banned from this region.";
                        return(false);
                    }
                }
                i++;
            }

            //Estate owners/managers/access list people/access groups tp freely as well
            if (ES.EstateOwner == agent.AgentID ||
                new List <UUID>(ES.EstateManagers).Contains(agent.AgentID) ||
                new List <UUID>(ES.EstateAccess).Contains(agent.AgentID) ||
                (Sp != null && new List <UUID>(ES.EstateGroups).Contains(Sp.ControllingClient.ActiveGroupId)))
            {
                reason = "";
                return(true);
            }

            if (ES.DenyAnonymous && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (ES.DenyIdentified && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (ES.DenyTransacted && ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse) == (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            long m_Day = 25 * 60 * 60; //Find out day length in seconds
            if (scene.RegionInfo.RegionSettings.MinimumAge != 0 && (account.Created - Util.UnixTimeSinceEpoch()) < (scene.RegionInfo.RegionSettings.MinimumAge * m_Day))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (!ES.PublicAccess)
            {
                reason = "You may not enter this region.";
                return(false);
            }

            IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo      agentInfo      = null;
            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(agent.AgentID);
                if (agentInfo == null)
                {
                    AgentConnector.CreateNewAgent(agent.AgentID);
                    agentInfo = AgentConnector.GetAgent(agent.AgentID);
                }
            }


            if (agentInfo != null && scene.RegionInfo.AccessLevel > Util.ConvertMaturityToAccessLevel((uint)agentInfo.MaturityRating))
            {
                reason = "The region has too high of a maturity level. Blocking teleport.";
                return(false);
            }

            if (agentInfo != null && ES.DenyMinors && (agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
            {
                reason = "The region has too high of a maturity level. Blocking teleport.";
                return(false);
            }

            #endregion

            reason = "";
            return(true);
        }
コード例 #25
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator)
        {
            var vars = new Dictionary <string, object>();

            string error = "";
            UUID   user  = httpRequest.Query.ContainsKey("userid") ? UUID.Parse(httpRequest.Query["userid"].ToString()) :
                           UUID.Parse(requestParameters["userid"].ToString());

            IUserAccountService userService = webInterface.Registry.RequestModuleInterface <IUserAccountService>();
            var         agentService        = Aurora.DataManager.DataManager.RequestPlugin <IAgentConnector>();
            UserAccount account             = userService.GetUserAccount(null, user);
            IAgentInfo  agent = agentService.GetAgent(user);

            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitPasswordChange")
            {
                string password     = requestParameters["password"].ToString();
                string passwordconf = requestParameters["passwordconf"].ToString();

                if (password != passwordconf)
                {
                    error = "Passwords do not match";
                }
                else
                {
                    IAuthenticationService authService = webInterface.Registry.RequestModuleInterface <IAuthenticationService>();
                    if (authService != null)
                    {
                        error = authService.SetPassword(user, "UserAccount", password) ? "" : "Failed to set your password, try again later";
                    }
                    else
                    {
                        error = "No authentication service was available to change your password";
                    }
                }
            }
            else if (requestParameters.ContainsKey("Submit") &&
                     requestParameters["Submit"].ToString() == "SubmitEmailChange")
            {
                string email = requestParameters["email"].ToString();

                if (userService != null)
                {
                    account.Email = email;
                    userService.StoreUserAccount(account);
                }
                else
                {
                    error = "No authentication service was available to change your password";
                }
            }
            else if (requestParameters.ContainsKey("Submit") &&
                     requestParameters["Submit"].ToString() == "SubmitDeleteUser")
            {
                userService.DeleteUser(user, "", false, false);
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitTempBanUser")
            {
                int timeDays    = int.Parse(requestParameters["TimeDays"].ToString());
                int timeHours   = int.Parse(requestParameters["TimeHours"].ToString());
                int timeMinutes = int.Parse(requestParameters["TimeMinutes"].ToString());
                agent.Flags |= IAgentFlags.TempBan;
                DateTime until = DateTime.Now.AddDays(timeDays).AddHours(timeHours).AddMinutes(timeMinutes);
                agent.OtherAgentInformation["TemperaryBanInfo"] = until;
                agentService.UpdateAgent(agent);
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitBanUser")
            {
                agent.Flags |= IAgentFlags.PermBan;
                agentService.UpdateAgent(agent);
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitUnbanUser")
            {
                agent.Flags &= ~IAgentFlags.TempBan;
                agent.Flags &= ~IAgentFlags.PermBan;
                agent.OtherAgentInformation.Remove("TemperaryBanInfo");
                agentService.UpdateAgent(agent);
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitLoginAsUser")
            {
                Authenticator.ChangeAuthentication(httpRequest, account);
                webInterface.Redirect(httpResponse, "/", filename);
                return(vars);
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitKickUser")
            {
                string message = requestParameters["KickMessage"].ToString();
                IGridWideMessageModule messageModule = webInterface.Registry.RequestModuleInterface <IGridWideMessageModule>();
                if (messageModule != null)
                {
                    messageModule.KickUser(account.PrincipalID, message);
                }
            }
            string bannedUntil = "";
            bool   userBanned  = agent == null ? false : ((agent.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan || (agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan);

            if (userBanned)
            {
                if ((agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan && agent.OtherAgentInformation["TemperaryBanInfo"].AsDate() < DateTime.Now)
                {
                    userBanned   = false;
                    agent.Flags &= ~IAgentFlags.TempBan;
                    agent.Flags &= ~IAgentFlags.PermBan;
                    agent.OtherAgentInformation.Remove("TemperaryBanInfo");
                    agentService.UpdateAgent(agent);
                }
                else
                {
                    DateTime bannedTime = agent.OtherAgentInformation["TemperaryBanInfo"].AsDate();
                    bannedUntil = string.Format("{0} {1}", bannedTime.ToShortDateString(), bannedTime.ToLongTimeString());
                }
            }
            vars.Add("NotUserBanned", !userBanned);
            vars.Add("UserBanned", userBanned);
            vars.Add("BannedUntil", bannedUntil);
            vars.Add("EmailValue", account.Email);
            vars.Add("UserID", account.PrincipalID);
            vars.Add("UserName", account.Name);
            vars.Add("ErrorMessage", error);
            vars.Add("ChangeUserInformationText", translator.GetTranslatedString("ChangeUserInformationText"));
            vars.Add("ChangePasswordText", translator.GetTranslatedString("ChangePasswordText"));
            vars.Add("NewPasswordText", translator.GetTranslatedString("NewPasswordText"));
            vars.Add("NewPasswordConfirmationText", translator.GetTranslatedString("NewPasswordConfirmationText"));
            vars.Add("ChangeEmailText", translator.GetTranslatedString("ChangeEmailText"));
            vars.Add("NewEmailText", translator.GetTranslatedString("NewEmailText"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserNameText"));
            vars.Add("PasswordText", translator.GetTranslatedString("PasswordText"));
            vars.Add("DeleteUserText", translator.GetTranslatedString("DeleteUserText"));
            vars.Add("DeleteText", translator.GetTranslatedString("DeleteText"));
            vars.Add("DeleteUserInfoText", translator.GetTranslatedString("DeleteUserInfoText"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            vars.Add("Login", translator.GetTranslatedString("Login"));

            vars.Add("AdminLoginInAsUserText", translator.GetTranslatedString("AdminLoginInAsUserText"));
            vars.Add("AdminLoginInAsUserInfoText", translator.GetTranslatedString("AdminLoginInAsUserInfoText"));
            vars.Add("AdminDeleteUserText", translator.GetTranslatedString("AdminDeleteUserText"));
            vars.Add("AdminDeleteUserInfoText", translator.GetTranslatedString("AdminDeleteUserInfoText"));
            vars.Add("AdminUnbanUserText", translator.GetTranslatedString("AdminUnbanUserText"));
            vars.Add("AdminTempBanUserText", translator.GetTranslatedString("AdminTempBanUserText"));
            vars.Add("AdminTempBanUserInfoText", translator.GetTranslatedString("AdminTempBanUserInfoText"));
            vars.Add("AdminBanUserText", translator.GetTranslatedString("AdminBanUserText"));
            vars.Add("AdminBanUserInfoText", translator.GetTranslatedString("AdminBanUserInfoText"));
            vars.Add("BanText", translator.GetTranslatedString("BanText"));
            vars.Add("UnbanText", translator.GetTranslatedString("UnbanText"));
            vars.Add("TimeUntilUnbannedText", translator.GetTranslatedString("TimeUntilUnbannedText"));
            vars.Add("EdittingText", translator.GetTranslatedString("EdittingText"));
            vars.Add("BannedUntilText", translator.GetTranslatedString("BannedUntilText"));

            vars.Add("KickAUserText", translator.GetTranslatedString("KickAUserText"));
            vars.Add("KickMessageText", translator.GetTranslatedString("KickMessageText"));
            vars.Add("KickUserText", translator.GetTranslatedString("KickUserText"));

            List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> >();

            for (int i = 0; i <= 100; i++)
            {
                daysArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > hoursArgs = new List <Dictionary <string, object> >();

            for (int i = 0; i <= 23; i++)
            {
                hoursArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > minutesArgs = new List <Dictionary <string, object> >();

            for (int i = 0; i <= 59; i++)
            {
                minutesArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            vars.Add("Days", daysArgs);
            vars.Add("Hours", hoursArgs);
            vars.Add("Minutes", minutesArgs);
            vars.Add("DaysText", translator.GetTranslatedString("DaysText"));
            vars.Add("HoursText", translator.GetTranslatedString("HoursText"));
            vars.Add("MinutesText", translator.GetTranslatedString("MinutesText"));

            return(vars);
        }
コード例 #26
0
 public void OnAttacked(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
 {
     throw new NotImplementedException();
 }
コード例 #27
0
ファイル: GE.cs プロジェクト: goncalopereira/Gr1d
 public void OnAttacked(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
 {
     _deck.Trace(string.Format("Attacked {0}:{1}:{2}", attacker.Owner, attacker.Level, attacker.Type),TraceType.Warning);
     this.Attack(attacker);
     Move.MoveToFirst(agentUpdate, this);
 }
コード例 #28
0
		public static ITargetAgentResult Init3(this IPirate2 self, IAgentInfo target) {
			var dlg = Init3Delegate;
			if (null != dlg) { return dlg(self, target); }

			return IPirate2SkillExtensions.Init3(self,target);
		}
コード例 #29
0
ファイル: TheExplorer.cs プロジェクト: merxbj/src
 public void OnAttacked(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
 {
     this.Attack(attacker); // just fight back - don't know what else to do, now
 }
コード例 #30
0
ファイル: Engineer1.cs プロジェクト: goncalopereira/Gr1d
 public void OnAttacked(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
 {
     _deck.Trace(String.Format("Attacked {0}:{1}:{2}", attacker.Owner, attacker.Level, attacker.Type),TraceType.Warning);
     this.Attack(attacker);
     this.Move(agentUpdate.Node.Exits.First().Value);
 }
コード例 #31
0
		public static ITargetAgentResult Feint(this IPirate3 self, IAgentInfo target) {
			var dlg = FeintDelegate;
			if (null != dlg) { return dlg(self, target); }

			return IPirate3SkillExtensions.Feint(self, target);
		}
コード例 #32
0
ファイル: Rook.cs プロジェクト: goncalopereira/Gr1d
 public override void OnAttacked(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
 {
     RookAttack(agentUpdate);
 }
コード例 #33
0
		public static ITargetAgentResult Summon(this IPirate4 self, IAgentInfo target) {
			var dlg = SummonDelegate;
			if (null != dlg) { return dlg(self, target); }

			return IPirate4SkillExtensions.Summon(self, target);
		}
コード例 #34
0
        public IAgentInfo GetAgent(UUID PrincipalID)
        {
            IAgentInfo agent;

            if (!m_cache.TryGetValue(PrincipalID, out agent))
            {
                return(agent);
            }

            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["PRINCIPALID"] = PrincipalID.ToString();
            sendData["METHOD"]      = "getagent";

            string reqString = WebUtils.BuildQueryString(sendData);

            try
            {
                List <string> m_ServerURIs =
                    m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf(PrincipalID.ToString(),
                                                                                            "RemoteServerURI");
                foreach (Dictionary <string, object> replyData in from m_ServerURI in m_ServerURIs select SynchronousRestFormsRequester.MakeRequest("POST",
                                                                                                                                                    m_ServerURI + "/auroradata",
                                                                                                                                                    reqString) into reply where reply != string.Empty select WebUtils.ParseXmlResponse(reply))
                {
                    if (replyData != null)
                    {
                        if (!replyData.ContainsKey("result"))
                        {
                            return(null);
                        }

                        Dictionary <string, object> .ValueCollection replyvalues = replyData.Values;
                        foreach (object f in replyvalues)
                        {
                            if (f is Dictionary <string, object> )
                            {
                                agent = new IAgentInfo();
                                agent.FromKVP((Dictionary <string, object>)f);
                                m_cache.AddOrUpdate(PrincipalID, agent, new TimeSpan(0, 30, 0));
                            }
                            else
                            {
                                MainConsole.Instance.DebugFormat(
                                    "[AuroraRemoteAgentConnector]: GetAgent {0} received invalid response type {1}",
                                    PrincipalID, f.GetType());
                            }
                        }
                        // Success
                        return(agent);
                    }

                    else
                    {
                        MainConsole.Instance.DebugFormat("[AuroraRemoteAgentConnector]: GetAgent {0} received null response",
                                                         PrincipalID);
                    }
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.DebugFormat("[AuroraRemoteAgentConnector]: Exception when contacting server: {0}", e);
            }

            return(null);
        }
コード例 #35
0
        OSDMap CreateAccount(OSDMap map)
        {
            bool   Verified = false;
            string Name     = map ["Name"].AsString();

            string Password = "";

            if (map.ContainsKey("Password"))
            {
                Password = map ["Password"].AsString();
            }
            else
            {
                Password = map ["PasswordHash"].AsString();  //is really plaintext password, the system hashes it later. Not sure why it was called PasswordHash to start with. I guess the original design was to have the PHP code generate the salt and password hash, then just simply store it here
            }

            //string PasswordSalt = map["PasswordSalt"].AsString(); //not being used
            string HomeRegion    = map ["HomeRegion"].AsString();
            string Email         = map ["Email"].AsString();
            string AvatarArchive = map ["AvatarArchive"].AsString();
            int    userLevel     = map ["UserLevel"].AsInteger();
            string UserTitle     = map ["UserTitle"].AsString();

            //server expects: 0 is PG, 1 is Mature, 2 is Adult - use this when setting MaxMaturity and MaturityRating
            //viewer expects: 13 is PG, 21 is Mature, 42 is Adult

            int MaxMaturity = 2;                //set to adult by default

            if (map.ContainsKey("MaxMaturity")) //MaxMaturity is the highest level that they can change the maturity rating to in the viewer
            {
                MaxMaturity = map ["MaxMaturity"].AsInteger();
            }

            int MaturityRating = MaxMaturity;      //set the default to whatever MaxMaturity was set tom incase they didn't define MaturityRating

            if (map.ContainsKey("MaturityRating")) //MaturityRating is the rating the user wants to be able to see
            {
                MaturityRating = map ["MaturityRating"].AsInteger();
            }

            bool activationRequired = map.ContainsKey("ActivationRequired") ? map ["ActivationRequired"].AsBoolean() : false;

            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> ();

            if (accountService == null)
            {
                return(null);
            }

            if (!Password.StartsWith("$1$", System.StringComparison.Ordinal))
            {
                Password = "******" + Util.Md5Hash(Password);
            }
            Password = Password.Remove(0, 3);  //remove $1$

            accountService.CreateUser(Name, Password, Email);
            UserAccount       user             = accountService.GetUserAccount(null, Name);
            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
            IGridService      gridService      = m_registry.RequestModuleInterface <IGridService> ();

            if (agentInfoService != null && gridService != null)
            {
                GridRegion r = gridService.GetRegionByName(null, HomeRegion);
                if (r != null)
                {
                    agentInfoService.SetHomePosition(user.PrincipalID.ToString(), r.RegionID, new Vector3(r.RegionSizeX / 2, r.RegionSizeY / 2, 20), Vector3.Zero);
                }
                else
                {
                    MainConsole.Instance.DebugFormat("[API]: Could not set home position for user {0}, region \"{1}\" did not produce a result from the grid service", Name, HomeRegion);
                }
            }

            Verified = user != null;
            UUID userID = UUID.Zero;

            OSDMap resp = new OSDMap();

            resp ["Verified"] = OSD.FromBoolean(Verified);

            if (Verified)
            {
                userID         = user.PrincipalID;
                user.UserLevel = userLevel;

                // could not find a way to save this data here.
                DateTime RLDOB     = map ["RLDOB"].AsDate();
                string   RLGender  = map ["RLGender"].AsString();
                string   RLName    = map ["RLName"].AsString();
                string   RLAddress = map ["RLAddress"].AsString();
                string   RLCity    = map ["RLCity"].AsString();
                string   RLZip     = map ["RLZip"].AsString();
                string   RLCountry = map ["RLCountry"].AsString();
                string   RLIP      = map ["RLIP"].AsString();



                IAgentConnector con = DataPlugins.RequestPlugin <IAgentConnector> ();
                con.CreateNewAgent(userID);

                IAgentInfo agent = con.GetAgent(userID);

                agent.MaxMaturity    = MaxMaturity;
                agent.MaturityRating = MaturityRating;

                agent.OtherAgentInformation ["RLDOB"]     = RLDOB;
                agent.OtherAgentInformation ["RLGender"]  = RLGender;
                agent.OtherAgentInformation ["RLName"]    = RLName;
                agent.OtherAgentInformation ["RLAddress"] = RLAddress;
                agent.OtherAgentInformation ["RLCity"]    = RLCity;
                agent.OtherAgentInformation ["RLZip"]     = RLZip;
                agent.OtherAgentInformation ["RLCountry"] = RLCountry;
                agent.OtherAgentInformation ["RLIP"]      = RLIP;
                if (activationRequired)
                {
                    UUID activationToken = UUID.Random();
                    agent.OtherAgentInformation ["WebUIActivationToken"] = Util.Md5Hash(activationToken.ToString() + ":" + Password);
                    resp ["WebUIActivationToken"] = activationToken;
                }
                con.UpdateAgent(agent);

                accountService.StoreUserAccount(user);

                IProfileConnector profileData = DataPlugins.RequestPlugin <IProfileConnector> ();
                IUserProfileInfo  profile     = profileData.GetUserProfile(user.PrincipalID);
                if (profile == null)
                {
                    profileData.CreateNewProfile(user.PrincipalID);
                    profile = profileData.GetUserProfile(user.PrincipalID);
                }
                if (AvatarArchive.Length > 0)
                {
                    profile.AArchiveName = AvatarArchive;
                }
                //    MainConsole.Instance.InfoFormat("[WebUI] Triggered Archive load of " + profile.AArchiveName);
                profile.IsNewUser = true;

                profile.MembershipGroup = UserTitle;
                profile.CustomType      = UserTitle;

                profileData.UpdateUserProfile(profile);
                //   MainConsole.Instance.RunCommand("load avatar archive " + user.FirstName + " " + user.LastName + " Devil");
            }

            resp ["UUID"] = OSD.FromUUID(userID);
            return(resp);
        }
コード例 #36
0
ファイル: MyRobot.cs プロジェクト: timothypratley/MyAgent
 public void OnAttacked(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
 {
 }
コード例 #37
0
 public void CacheAgent(IAgentInfo agent)
 {
     m_cache.Cache(agent.PrincipalID, agent);
 }
コード例 #38
0
ファイル: BanCheck.cs プロジェクト: velus/Async-Sim-Testing
 public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
                            string password, out object data)
 {
     data = null;
     string ip = request != null && request.ContainsKey("ip") ? (string) request["ip"] : "127.0.0.1";
     ip = ip.Split(':')[0]; //Remove the port
     IPAddress userIP = IPAddress.Parse(ip);
     if (IPBans.Contains(userIP))
         return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                                          "Your account cannot be accessed on this computer.", false);
     foreach (string ipRange in IPRangeBans)
     {
         string[] split = ipRange.Split('-');
         if (split.Length != 2)
             continue;
         IPAddress low = IPAddress.Parse(ip);
         IPAddress high = IPAddress.Parse(ip);
         NetworkUtils.IPAddressRange range = new NetworkUtils.IPAddressRange(low, high);
         if (range.IsInRange(userIP))
             return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                                              "Your account cannot be accessed on this computer.", false);
     }
     return null;
 }
コード例 #39
0
 public void UpdateAgent(IAgentInfo agent)
 {
     //No creating from sims!
 }
コード例 #40
0
        OSDMap GetProfile(OSDMap map)
        {
            OSDMap resp   = new OSDMap();
            string Name   = map ["Name"].AsString();
            UUID   userID = map ["UUID"].AsUUID();

            UserAccount account = Name != "" ?
                                  m_registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, Name) :
                                  m_registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, userID);

            if (account != null)
            {
                OSDMap accountMap = new OSDMap();

                accountMap ["Created"]     = account.Created;
                accountMap ["Name"]        = account.Name;
                accountMap ["PrincipalID"] = account.PrincipalID;
                accountMap ["Email"]       = account.Email;

                TimeSpan diff  = DateTime.Now - Util.ToDateTime(account.Created);
                int      years = (int)diff.TotalDays / 356;
                int      days  = years > 0 ? (int)diff.TotalDays / years : (int)diff.TotalDays;
                accountMap ["TimeSinceCreated"] = years + " years, " + days + " days"; // if we're sending account.Created do we really need to send this string ?

                IProfileConnector profileConnector = DataPlugins.RequestPlugin <IProfileConnector> ();
                IUserProfileInfo  profile          = profileConnector.GetUserProfile(account.PrincipalID);
                if (profile != null)
                {
                    resp ["profile"] = profile.ToOSD(false); //not trusted, use false

                    if (account.UserFlags == 0)
                    {
                        account.UserFlags = 2; //Set them to no info given
                    }
                    string flags = ((IUserProfileInfo.ProfileFlags)account.UserFlags).ToString();
                    IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile.ToString();

                    accountMap ["AccountInfo"] = (profile.CustomType != "" ? profile.CustomType :
                                                  account.UserFlags == 0 ? "Resident" : "Admin") + "\n" + flags;
                    UserAccount partnerAccount = m_registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, profile.Partner);
                    if (partnerAccount != null)
                    {
                        accountMap ["Partner"]     = partnerAccount.Name;
                        accountMap ["PartnerUUID"] = partnerAccount.PrincipalID;
                    }
                    else
                    {
                        accountMap ["Partner"]     = "";
                        accountMap ["PartnerUUID"] = UUID.Zero;
                    }
                }
                IAgentConnector agentConnector = DataPlugins.RequestPlugin <IAgentConnector> ();
                IAgentInfo      agent          = agentConnector.GetAgent(account.PrincipalID);
                if (agent != null)
                {
                    OSDMap agentMap = new OSDMap();
                    agentMap ["RLName"]    = agent.OtherAgentInformation ["RLName"].AsString();
                    agentMap ["RLGender"]  = agent.OtherAgentInformation ["RLGender"].AsString();
                    agentMap ["RLAddress"] = agent.OtherAgentInformation ["RLAddress"].AsString();
                    agentMap ["RLZip"]     = agent.OtherAgentInformation ["RLZip"].AsString();
                    agentMap ["RLCity"]    = agent.OtherAgentInformation ["RLCity"].AsString();
                    agentMap ["RLCountry"] = agent.OtherAgentInformation ["RLCountry"].AsString();
                    resp ["agent"]         = agentMap;
                }
                resp ["account"] = accountMap;
            }

            return(resp);
        }
コード例 #41
0
 public void OnArrived(IAgentInfo arriver, IAgentUpdateInfo agentUpdate)
 {
     throw new NotImplementedException();
 }
コード例 #42
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            if (requestParameters.ContainsKey("Submit"))
            {
                string AvatarName     = requestParameters["AvatarName"].ToString();
                string AvatarPassword = requestParameters["AvatarPassword"].ToString();
                string FirstName      = requestParameters["FirstName"].ToString();
                string LastName       = requestParameters["LastName"].ToString();
                string UserAddress    = requestParameters["UserAddress"].ToString();
                string UserZip        = requestParameters["UserZip"].ToString();
                string UserCity       = requestParameters["UserCity"].ToString();
                string UserEmail      = requestParameters["UserEmail"].ToString();
                string UserDOBMonth   = requestParameters["UserDOBMonth"].ToString();
                string UserDOBDay     = requestParameters["UserDOBDay"].ToString();
                string UserDOBYear    = requestParameters["UserDOBYear"].ToString();
                string AvatarArchive  = requestParameters.ContainsKey("AvatarArchive") ? requestParameters["AvatarArchive"].ToString() : "";
                bool   ToSAccept      = requestParameters.ContainsKey("ToSAccept") && requestParameters["ToSAccept"].ToString() == "Accepted";

                IGenericsConnector generics = Aurora.DataManager.DataManager.RequestPlugin <IGenericsConnector>();
                var settings = generics.GetGeneric <GridSettings>(UUID.Zero, "WebSettings", "Settings");

                if (ToSAccept)
                {
                    AvatarPassword = Util.Md5Hash(AvatarPassword);

                    IUserAccountService accountService = webInterface.Registry.RequestModuleInterface <IUserAccountService>();
                    UUID   userID = UUID.Random();
                    string error  = accountService.CreateUser(userID, settings.DefaultScopeID, AvatarName, AvatarPassword, UserEmail);
                    if (error == "")
                    {
                        IAgentConnector con = Aurora.DataManager.DataManager.RequestPlugin <IAgentConnector>();
                        con.CreateNewAgent(userID);
                        IAgentInfo agent = con.GetAgent(userID);
                        agent.OtherAgentInformation["RLFirstName"]  = FirstName;
                        agent.OtherAgentInformation["RLLastName"]   = LastName;
                        agent.OtherAgentInformation["RLAddress"]    = UserAddress;
                        agent.OtherAgentInformation["RLCity"]       = UserCity;
                        agent.OtherAgentInformation["RLZip"]        = UserZip;
                        agent.OtherAgentInformation["UserDOBMonth"] = UserDOBMonth;
                        agent.OtherAgentInformation["UserDOBDay"]   = UserDOBDay;
                        agent.OtherAgentInformation["UserDOBYear"]  = UserDOBYear;

                        /*if (activationRequired)
                         * {
                         *  UUID activationToken = UUID.Random();
                         *  agent.OtherAgentInformation["WebUIActivationToken"] = Util.Md5Hash(activationToken.ToString() + ":" + PasswordHash);
                         *  resp["WebUIActivationToken"] = activationToken;
                         * }*/
                        con.UpdateAgent(agent);

                        if (AvatarArchive != "")
                        {
                            IProfileConnector profileData = Aurora.DataManager.DataManager.RequestPlugin <IProfileConnector>();
                            profileData.CreateNewProfile(userID);

                            IUserProfileInfo profile = profileData.GetUserProfile(userID);
                            profile.AArchiveName = AvatarArchive + ".database";
                            profile.IsNewUser    = true;
                            profileData.UpdateUserProfile(profile);
                        }

                        response = "<h3>Successfully created account, redirecting to main page</h3>" +
                                   "<script language=\"javascript\">" +
                                   "setTimeout(function() {window.location.href = \"index.html\";}, 3000);" +
                                   "</script>";
                    }
                    else
                    {
                        response = "<h3>" + error + "</h3>";
                    }
                }
                else
                {
                    response = "<h3>You did not accept the Terms of Service agreement.</h3>";
                }
                return(null);
            }

            List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> >();

            for (int i = 1; i <= 31; i++)
            {
                daysArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > monthsArgs = new List <Dictionary <string, object> >();

            for (int i = 1; i <= 12; i++)
            {
                monthsArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > yearsArgs = new List <Dictionary <string, object> >();

            for (int i = 1900; i <= 2013; i++)
            {
                yearsArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            vars.Add("Days", daysArgs);
            vars.Add("Months", monthsArgs);
            vars.Add("Years", yearsArgs);

            List <AvatarArchive> archives = Aurora.DataManager.DataManager.RequestPlugin <IAvatarArchiverConnector>().GetAvatarArchives(true);

            List <Dictionary <string, object> > avatarArchives = new List <Dictionary <string, object> >();
            IWebHttpTextureService webTextureService           = webInterface.Registry.
                                                                 RequestModuleInterface <IWebHttpTextureService>();

            foreach (var archive in archives)
            {
                avatarArchives.Add(new Dictionary <string, object> {
                    { "AvatarArchiveName", archive.Name },
                    { "AvatarArchiveSnapshotID", archive.Snapshot },
                    { "AvatarArchiveSnapshotURL", webTextureService.GetTextureURL(UUID.Parse(archive.Snapshot)) }
                });
            }

            vars.Add("AvatarArchive", avatarArchives);


            IConfig loginServerConfig = webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs["LoginService"];
            string  tosLocation       = "";

            if (loginServerConfig != null && loginServerConfig.GetBoolean("UseTermsOfServiceOnFirstLogin", false))
            {
                tosLocation = loginServerConfig.GetString("FileNameOfTOS", "");
            }
            string ToS = "There are no Terms of Service currently. This may be changed at any point in the future.";

            if (tosLocation != "")
            {
                System.IO.StreamReader reader = new System.IO.StreamReader(System.IO.Path.Combine(Environment.CurrentDirectory, tosLocation));
                ToS = reader.ReadToEnd();
                reader.Close();
            }
            vars.Add("ToSMessage", ToS);
            vars.Add("TermsOfServiceAccept", translator.GetTranslatedString("TermsOfServiceAccept"));
            vars.Add("TermsOfServiceText", translator.GetTranslatedString("TermsOfServiceText"));
            vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled"));
            vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText"));
            vars.Add("AvatarNameText", translator.GetTranslatedString("AvatarNameText"));
            vars.Add("AvatarPasswordText", translator.GetTranslatedString("Password"));
            vars.Add("AvatarPasswordConfirmationText", translator.GetTranslatedString("PasswordConfirmation"));
            vars.Add("AvatarScopeText", translator.GetTranslatedString("AvatarScopeText"));
            vars.Add("FirstNameText", translator.GetTranslatedString("FirstNameText"));
            vars.Add("LastNameText", translator.GetTranslatedString("LastNameText"));
            vars.Add("UserAddressText", translator.GetTranslatedString("UserAddressText"));
            vars.Add("UserZipText", translator.GetTranslatedString("UserZipText"));
            vars.Add("UserCityText", translator.GetTranslatedString("UserCityText"));
            vars.Add("UserCountryText", translator.GetTranslatedString("UserCountryText"));
            vars.Add("UserDOBText", translator.GetTranslatedString("UserDOBText"));
            vars.Add("UserEmailText", translator.GetTranslatedString("UserEmailText"));
            vars.Add("Accept", translator.GetTranslatedString("Accept"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            vars.Add("SubmitURL", "register.html");

            return(vars);
        }
コード例 #43
0
        private bool OnAllowedIncomingTeleport(UUID userID, IScene scene, Vector3 Position, out Vector3 newPosition, out string reason)
        {
            newPosition = Position;
            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, userID);

            IScenePresence Sp = scene.GetScenePresence(userID);

            if (account == null)
            {
                reason = "Failed authentication.";
                return(false); //NO!
            }

            //Make sure that this user is inside the region as well
            if (Position.X < -2f || Position.Y < -2f ||
                Position.X > scene.RegionInfo.RegionSizeX + 2 || Position.Y > scene.RegionInfo.RegionSizeY + 2)
            {
                m_log.DebugFormat(
                    "[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping",
                    Position, Name, userID);
                bool changedX = false;
                bool changedY = false;
                while (Position.X < 0)
                {
                    Position.X += scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }
                while (Position.X > scene.RegionInfo.RegionSizeX)
                {
                    Position.X -= scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }

                while (Position.Y < 0)
                {
                    Position.Y += scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }
                while (Position.Y > scene.RegionInfo.RegionSizeY)
                {
                    Position.Y -= scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }

                if (changedX)
                {
                    Position.X = scene.RegionInfo.RegionSizeX - Position.X;
                }
                if (changedY)
                {
                    Position.Y = scene.RegionInfo.RegionSizeY - Position.Y;
                }
            }

            //Check that we are not underground as well
            float posZLimit = scene.RequestModuleInterface <ITerrainChannel>()[(int)Position.X, (int)Position.Y] + (float)1.25;

            if (posZLimit >= (Position.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit)))
            {
                Position.Z = posZLimit;
            }

            IAgentConnector AgentConnector = DataManager.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo      agentInfo      = null;

            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(userID);
            }

            ILandObject             ILO = null;
            IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILO = parcelManagement.GetLandObject(Position.X, Position.Y);
            }

            if (ILO == null)
            {
                //Can't find land, give them the first parcel in the region and find a good position for them
                ILO      = parcelManagement.AllParcels()[0];
                Position = parcelManagement.GetParcelCenterAtGround(ILO);
            }

            //parcel permissions
            if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block
            {
                if (Sp == null)
                {
                    reason = "Banned from this parcel.";
                    return(true);
                }

                if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                {
                    //We found a place for them, but we don't need to check any further
                    return(true);
                }
            }
            //Move them out of banned parcels
            ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags;

            if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup &&
                (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList &&
                (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
            {
                //One of these is in play then
                if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(true);
                    }
                    if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID)
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                            //We found a place for them, but we don't need to check any further
                            return(true);
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(true);
                    }
                    //All but the people on the access list are banned
                    if (ILO.IsRestrictedFromLand(userID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                            //We found a place for them, but we don't need to check any further
                            return(true);
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(true);
                    }
                    //All but the people on the pass/access list are banned
                    if (ILO.IsRestrictedFromLand(Sp.UUID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                            //We found a place for them, but we don't need to check any further
                            return(true);
                        }
                    }
                }
            }

            EstateSettings ES = scene.RegionInfo.EstateSettings;

            //Move them to the nearest landing point
            if (!ES.AllowDirectTeleport)
            {
                if (!scene.Permissions.IsGod(userID))
                {
                    Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle);
                    if (telehub != null)
                    {
                        if (telehub.SpawnPos.Count == 0)
                        {
                            Position = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                        }
                        else
                        {
                            int LastTelehubNum = 0;
                            if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
                            {
                                LastTelehubNum = 0;
                            }
                            Position = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                            LastTelehubNum++;
                            if (LastTelehubNum == telehub.SpawnPos.Count)
                            {
                                LastTelehubNum = 0;
                            }
                            LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
                        }
                    }
                }
            }
            if (!scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
            {
                if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land
                {
                    //Find a new parcel for them
                    List <ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position);
                    if (Parcels.Count == 0)
                    {
                        IScenePresence SP;
                        scene.TryGetScenePresence(userID, out SP);
                        newPosition = parcelManagement.GetNearestRegionEdgePosition(SP);
                    }
                    else
                    {
                        bool found = false;
                        //We need to check here as well for bans, can't toss someone into a parcel they are banned from
                        foreach (ILandObject Parcel in Parcels)
                        {
                            if (!Parcel.IsBannedFromLand(userID))
                            {
                                //Now we have to check their userloc
                                if (ILO.LandData.LandingType == 2)
                                {
                                    continue;                           //Blocked, check next one
                                }
                                else if (ILO.LandData.LandingType == 1) //Use their landing spot
                                {
                                    newPosition = Parcel.LandData.UserLocation;
                                }
                                else //They allow for anywhere, so dump them in the center at the ground
                                {
                                    newPosition = parcelManagement.GetParcelCenterAtGround(Parcel);
                                }
                                found = true;
                            }
                        }
                        if (!found) //Dump them at the edge
                        {
                            if (Sp != null)
                            {
                                newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                            }
                            else
                            {
                                reason = "Banned from this parcel.";
                                return(true);
                            }
                        }
                    }
                }
                else if (ILO.LandData.LandingType == 1) //Move to tp spot
                {
                    if (ILO.LandData.UserLocation != Vector3.Zero)
                    {
                        newPosition = ILO.LandData.UserLocation;
                    }
                    else // Dump them at the nearest region corner since they havn't set a landing point
                    {
                        newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                    }
                }
            }

            //We assume that our own region isn't null....
            if (agentInfo != null)
            {
                //Can only enter prelude regions once!
                int flags = scene.GridService.GetRegionFlags(scene.RegionInfo.ScopeID, scene.RegionInfo.RegionID);
                if (flags != -1 && ((flags & (int)Aurora.Framework.RegionFlags.Prelude) == (int)Aurora.Framework.RegionFlags.Prelude) && agentInfo != null)
                {
                    if (agentInfo.OtherAgentInformation.ContainsKey("Prelude" + scene.RegionInfo.RegionID))
                    {
                        reason = "You may not enter this region as you have already been to this prelude region.";
                        return(false);
                    }
                    else
                    {
                        agentInfo.OtherAgentInformation.Add("Prelude" + scene.RegionInfo.RegionID, OSD.FromInteger((int)IAgentFlags.PastPrelude));
                        AgentConnector.UpdateAgent(agentInfo); //This only works for standalones... and thats ok
                    }
                }
            }


            if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0)
            {
                if ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) == (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null)
            {
                if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            newPosition = Position;
            reason      = "";
            return(true);
        }
コード例 #44
0
ファイル: GAgent.cs プロジェクト: goncalopereira/Gr1d
 public virtual void OnAttacked(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
 {
     throw new NotImplementedException();
 }
コード例 #45
0
        /// <summary>
        /// Creates a user
        /// TODO: Does not implement the restrict to estate option
        /// </summary>
        /// <param name="map"></param>
        /// <returns></returns>
        private OSD CreateUser(OSDMap map)
        {
            //Required params
            string username     = map["username"];
            int    last_name_id = map["last_name_id"];
            string email        = map["email"];
            string password     = map["password"];
            string dob          = map["dob"];

            //Optional params
            int    limited_to_estate = map["limited_to_estate"];
            string start_region_name = map["start_region_name"];
            float  start_local_x     = map["start_local_x"];
            float  start_local_y     = map["start_local_y"];
            float  start_local_z     = map["start_local_z"];
            float  start_look_at_x   = map["start_look_at_x"];
            float  start_look_at_y   = map["start_look_at_y"];
            float  start_look_at_z   = map["start_look_at_z"];
            OSD    resp = null;

            if (username != "" && last_name_id != 0 && email != "" &&
                password != "" && dob != "")
            {
                IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService>();
                if (m_lastNameRegistry.ContainsKey(last_name_id))
                {
                    string      lastName = m_lastNameRegistry[last_name_id];
                    UserAccount user     = accountService.GetUserAccount(null, username, lastName);
                    if (user == null)
                    {
                        //The pass is in plain text... so put it in and create the account
                        accountService.CreateUser(username + " " + lastName, password, email);
                        DateTime time = DateTime.ParseExact(dob, "YYYY-MM-DD", System.Globalization.CultureInfo.InvariantCulture);
                        user = accountService.GetUserAccount(null, username, lastName);
                        //Update the dob
                        user.Created = Util.ToUnixTime(time);
                        accountService.StoreUserAccount(user);

                        IAgentConnector agentConnector = Aurora.Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();
                        if (agentConnector != null)
                        {
                            agentConnector.CreateNewAgent(user.PrincipalID);
                            if (map.ContainsKey("limited_to_estate"))
                            {
                                IAgentInfo agentInfo = agentConnector.GetAgent(user.PrincipalID);
                                agentInfo.OtherAgentInformation["LimitedToEstate"] = limited_to_estate;
                                agentConnector.UpdateAgent(agentInfo);
                            }
                        }

                        MainConsole.Instance.Info("[RegApi]: Created new user " + user.Name);
                        try
                        {
                            if (start_region_name != "")
                            {
                                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>();
                                if (agentInfoService != null)
                                {
                                    agentInfoService.SetHomePosition(user.PrincipalID.ToString(),
                                                                     m_registry.RequestModuleInterface <IGridService>().GetRegionByName
                                                                         (null, start_region_name).RegionID,
                                                                     new Vector3(start_local_x,
                                                                                 start_local_y,
                                                                                 start_local_z),
                                                                     new Vector3(start_look_at_x,
                                                                                 start_look_at_y,
                                                                                 start_look_at_z));
                                }
                            }
                        }
                        catch
                        {
                            MainConsole.Instance.Warn("[RegApi]: Encountered an error when setting the home position of a new user");
                        }
                        OSDMap r = new OSDMap();
                        r["agent_id"] = user.PrincipalID;
                        resp          = r;
                    }
                    else //Already exists
                    {
                        resp = false;
                    }
                }
                else //Could not find last name
                {
                    resp = false;
                }
            }
            else //Not enough params
            {
                resp = false;
            }

            return(resp);
        }
コード例 #46
0
        public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType, string password, out object data)
        {
            data = null;

            if (request == null)
            {
                return(null);//If its null, its just a verification request, allow them to see things even if they are banned
            }
            bool   tosExists   = false;
            string tosAccepted = "";

            if (request.ContainsKey("agree_to_tos"))
            {
                tosExists   = true;
                tosAccepted = request["agree_to_tos"].ToString();
            }

            //MAC BANNING START
            string mac = (string)request["mac"];

            if (mac == "")
            {
                return(new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, "Bad Viewer Connection", false));
            }

            string channel = "Unknown";

            if (request.Contains("channel") && request["channel"] != null)
            {
                channel = request["channel"].ToString();
            }

            IAgentConnector agentData = Aurora.DataManager.DataManager.RequestPlugin <IAgentConnector>();

            if (mac != "")
            {
                string reason = "";
                if (!agentData.CheckMacAndViewer(mac, channel, out reason))
                {
                    return(new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                                                     reason, false));
                }
            }
            bool AcceptedNewTOS = false;

            //This gets if the viewer has accepted the new TOS
            if (!agentInfo.AcceptTOS && tosExists)
            {
                if (tosAccepted == "0")
                {
                    AcceptedNewTOS = false;
                }
                else if (tosAccepted == "1")
                {
                    AcceptedNewTOS = true;
                }
                else
                {
                    AcceptedNewTOS = bool.Parse(tosAccepted);
                }

                if (agentInfo.AcceptTOS != AcceptedNewTOS)
                {
                    agentInfo.AcceptTOS = AcceptedNewTOS;
                    agentData.UpdateAgent(agentInfo);
                }
            }
            if (!AcceptedNewTOS && !agentInfo.AcceptTOS && m_UseTOS)
            {
                StreamReader reader = new StreamReader(Path.Combine(Environment.CurrentDirectory, m_TOSLocation));
                string       TOS    = reader.ReadToEnd();
                reader.Close();
                reader.Dispose();
                return(new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, TOS, false));
            }

            if ((agentInfo.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan)
            {
                MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: Login failed for user {0}, reason: user is permanently banned.", account.Name);
                return(LLFailedLoginResponse.PermanentBannedProblem);
            }

            if ((agentInfo.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan)
            {
                bool   IsBanned = true;
                string until    = "";

                if (agentInfo.OtherAgentInformation.ContainsKey("TemperaryBanInfo"))
                {
                    DateTime bannedTime = agentInfo.OtherAgentInformation["TemperaryBanInfo"].AsDate();
                    until = string.Format(" until {0} {1}", bannedTime.ToShortDateString(), bannedTime.ToLongTimeString());

                    //Check to make sure the time hasn't expired
                    if (bannedTime.Ticks < DateTime.Now.Ticks)
                    {
                        //The banned time is less than now, let the user in.
                        IsBanned = false;
                    }
                }

                if (IsBanned)
                {
                    MainConsole.Instance.InfoFormat("[LLOGIN SERVICE]: Login failed for user {0}, reason: user is temporarily banned {0}.", until, account.Name);
                    return(new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, string.Format("You are blocked from connecting to this service{0}.", until), false));
                }
            }
            return(null);
        }
コード例 #47
0
        public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
                                   string password, out object data)
        {
            IAgentConnector agentData = Framework.Utilities.DataManager.RequestPlugin<IAgentConnector>();
            data = null;

            if (request == null)
                return null;
                    //If its null, its just a verification request, allow them to see things even if they are banned

            bool tosExists = false;
            string tosAccepted = "";
            if (request.ContainsKey("agree_to_tos"))
            {
                tosExists = true;
                tosAccepted = request["agree_to_tos"].ToString();
            }

            //MAC BANNING START
            string mac = (string) request["mac"];
            if (mac == "")
                return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, "Bad Viewer Connection", false);

            /*string channel = "Unknown";
            if (request.Contains("channel") && request["channel"] != null)
                channel = request["channel"].ToString();*/

            bool AcceptedNewTOS = false;
            //This gets if the viewer has accepted the new TOS
            if (!agentInfo.AcceptTOS && tosExists)
            {
                if (tosAccepted == "0")
                    AcceptedNewTOS = false;
                else if (tosAccepted == "1")
                    AcceptedNewTOS = true;
                else
                    AcceptedNewTOS = bool.Parse(tosAccepted);

                if (agentInfo.AcceptTOS != AcceptedNewTOS)
                {
                    agentInfo.AcceptTOS = AcceptedNewTOS;
                    agentData.UpdateAgent(agentInfo);
                }
            }
            if (!AcceptedNewTOS && !agentInfo.AcceptTOS && m_UseTOS)
                return new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, File.ReadAllText(Path.Combine(Environment.CurrentDirectory, m_TOSLocation)), false);

            if ((agentInfo.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan)
            {
                MainConsole.Instance.InfoFormat(
                    "[LLOGIN SERVICE]: Login failed for user {0}, reason: user is permanently banned.", account.Name);
                return LLFailedLoginResponse.PermanentBannedProblem;
            }

            if ((agentInfo.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan)
            {
                bool IsBanned = true;
                string until = "";

                if (agentInfo.OtherAgentInformation.ContainsKey("TemperaryBanInfo"))
                {
                    DateTime bannedTime = agentInfo.OtherAgentInformation["TemperaryBanInfo"].AsDate();
                    until = string.Format(" until {0} {1}", bannedTime.ToLocalTime().ToShortDateString(),
                                          bannedTime.ToLocalTime().ToLongTimeString());

                    //Check to make sure the time hasn't expired
                    if (bannedTime.Ticks < DateTime.Now.ToUniversalTime().Ticks)
                    {
                        //The banned time is less than now, let the user in.
                        IsBanned = false;
                    }
                }

                if (IsBanned)
                {
                    MainConsole.Instance.InfoFormat(
                        "[LLOGIN SERVICE]: Login failed for user {0}, reason: user is temporarily banned {1}.",
                        account.Name, until);
                    return new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                                                     string.Format(
                                                         "You are blocked from connecting to this service{0}.", until),
                                                     false);
                }
            }
            return null;
        }
コード例 #48
0
ファイル: edit_user.cs プロジェクト: nhede/WhiteCore-Dev
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            string error  = "";
            UUID   userID = httpRequest.Query.ContainsKey("userid")
                            ? UUID.Parse(httpRequest.Query["userid"].ToString())
                            : UUID.Parse(requestParameters["userid"].ToString());

            IUserAccountService userService = webInterface.Registry.RequestModuleInterface <IUserAccountService>();
            var         agentService        = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();
            UserAccount account             = userService.GetUserAccount(null, userID);
            IAgentInfo  agent = agentService.GetAgent(userID);

            if (agent == null)
            {
                error = "No agent information is available";
            }

            // Set user type
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitSetUserType")
            {
                string UserType  = requestParameters ["UserType"].ToString();
                int    UserFlags = webInterface.UserTypeToUserFlags(UserType);

                // set the user account type
                account.UserFlags = UserFlags;
                userService.StoreUserAccount(account);

                if (agent != null)
                {
                    agent.OtherAgentInformation ["UserFlags"] = UserFlags;
                    agentService.UpdateAgent(agent);
                    response = "User has been updated.";
                }
                else
                {
                    response = "Agent information is not available! Has the user logged in yet?";
                }

                IProfileConnector profileData =
                    Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>();
                if (profileData != null)
                {
                    IUserProfileInfo profile = profileData.GetUserProfile(userID);
                    if (profile == null)
                    {
                        profileData.CreateNewProfile(userID);
                        profile = profileData.GetUserProfile(userID);
                    }

                    profile.MembershipGroup = webInterface.UserFlagToType(UserFlags, webInterface.EnglishTranslator);     // membership is english
                    profileData.UpdateUserProfile(profile);
                }

                response = "User has been updated.";
                return(null);
            }

            // Password change
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitPasswordChange")
            {
                string password     = requestParameters["password"].ToString();
                string passwordconf = requestParameters["passwordconf"].ToString();

                if (password != passwordconf)
                {
                    response = "Passwords do not match";
                }
                else
                {
                    IAuthenticationService authService =
                        webInterface.Registry.RequestModuleInterface <IAuthenticationService>();
                    if (authService != null)
                    {
                        response = authService.SetPassword(userID, "UserAccount", password)
                                       ? "Successfully set password"
                                       : "Failed to set your password, try again later";
                    }
                    else
                    {
                        response = "No authentication service was available to change your password";
                    }
                }
                return(null);
            }

            // Email change
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitEmailChange")
            {
                string email = requestParameters["email"].ToString();

                if (userService != null)
                {
                    account.Email = email;
                    userService.StoreUserAccount(account);
                    response = "Successfully updated email";
                }
                else
                {
                    response = "No authentication service was available to change your password";
                }
                return(null);
            }

            // Delete user
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitDeleteUser")
            {
                string username = requestParameters["username"].ToString();
                response = "Deleted user successfully";
                if (username == account.Name)
                {
                    userService.DeleteUser(account.PrincipalID, account.Name, "", false, false);
                }
                else
                {
                    response = "The user name did not match";
                }
                return(null);
            }

            // Temp Ban user
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitTempBanUser")
            {
                int timeDays    = int.Parse(requestParameters["TimeDays"].ToString());
                int timeHours   = int.Parse(requestParameters["TimeHours"].ToString());
                int timeMinutes = int.Parse(requestParameters["TimeMinutes"].ToString());

                if (agent != null)
                {
                    agent.Flags |= IAgentFlags.TempBan;
                    DateTime until = DateTime.Now.AddDays(timeDays).AddHours(timeHours).AddMinutes(timeMinutes);
                    agent.OtherAgentInformation ["TemperaryBanInfo"] = until;
                    agentService.UpdateAgent(agent);
                    response = "User has been banned.";
                }
                else
                {
                    response = "Agent information is not available! Has the user logged in yet?";
                }

                return(null);
            }

            // Ban user
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitBanUser")
            {
                if (agent != null)
                {
                    agent.Flags |= IAgentFlags.PermBan;
                    agentService.UpdateAgent(agent);
                    response = "User has been banned.";
                }
                else
                {
                    response = "Agent information is not available! Has the user logged in yet?";
                }

                return(null);
            }

            //UnBan user
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitUnbanUser")
            {
                if (agent != null)
                {
                    agent.Flags &= ~IAgentFlags.TempBan;
                    agent.Flags &= ~IAgentFlags.PermBan;
                    agent.OtherAgentInformation.Remove("TemperaryBanInfo");
                    agentService.UpdateAgent(agent);
                    response = "User has been unbanned.";
                }
                else
                {
                    response = "Agent information is not available! Has the user logged in yet?";
                }

                return(null);
            }

            // Login as user
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitLoginAsUser")
            {
                Authenticator.ChangeAuthentication(httpRequest, account);
                webInterface.Redirect(httpResponse, "/");
                return(vars);
            }

            // Kick user
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitKickUser")
            {
                string message = requestParameters["KickMessage"].ToString();
                IGridWideMessageModule messageModule =
                    webInterface.Registry.RequestModuleInterface <IGridWideMessageModule>();
                if (messageModule != null)
                {
                    messageModule.KickUser(account.PrincipalID, message);
                }
                response = "User has been kicked.";
                return(null);
            }

            // Message user
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitMessageUser")
            {
                string message = requestParameters["Message"].ToString();
                IGridWideMessageModule messageModule =
                    webInterface.Registry.RequestModuleInterface <IGridWideMessageModule>();
                if (messageModule != null)
                {
                    messageModule.MessageUser(account.PrincipalID, message);
                }
                response = "User has been sent the message.";
                return(null);
            }

            // page variables
            string bannedUntil = "";
            bool   userBanned  = agent == null
                                  ? false
                                  : ((agent.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan ||
                                     (agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan);
            bool TempUserBanned = false;

            if (userBanned)
            {
                if ((agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan &&
                    agent.OtherAgentInformation["TemperaryBanInfo"].AsDate() < DateTime.Now.ToUniversalTime())
                {
                    userBanned   = false;
                    agent.Flags &= ~IAgentFlags.TempBan;
                    agent.Flags &= ~IAgentFlags.PermBan;
                    agent.OtherAgentInformation.Remove("TemperaryBanInfo");
                    agentService.UpdateAgent(agent);
                }
                else
                {
                    DateTime bannedTime = agent.OtherAgentInformation["TemperaryBanInfo"].AsDate();
                    TempUserBanned = bannedTime != Util.UnixEpoch;
                    bannedUntil    = string.Format("{0} {1}", bannedTime.ToShortDateString(), bannedTime.ToLongTimeString());
                }
            }
            bool userOnline = false;
            IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService>();

            if (agentInfoService != null)
            {
                UserInfo info = agentInfoService.GetUserInfo(account.PrincipalID.ToString());
                userOnline = info != null ? info.IsOnline : false;
            }
            vars.Add("UserOnline", userOnline);
            vars.Add("NotUserBanned", !userBanned);
            vars.Add("UserBanned", userBanned);
            vars.Add("TempUserBanned", TempUserBanned);
            vars.Add("BannedUntil", bannedUntil);
            vars.Add("EmailValue", account.Email);
            vars.Add("UserID", account.PrincipalID);
            vars.Add("UserName", account.Name);
            vars.Add("ErrorMessage", error);
            vars.Add("ChangeUserInformationText", translator.GetTranslatedString("ChangeUserInformationText"));
            vars.Add("ChangePasswordText", translator.GetTranslatedString("ChangePasswordText"));
            vars.Add("NewPasswordText", translator.GetTranslatedString("NewPasswordText"));
            vars.Add("NewPasswordConfirmationText", translator.GetTranslatedString("NewPasswordConfirmationText"));
            vars.Add("ChangeEmailText", translator.GetTranslatedString("ChangeEmailText"));
            vars.Add("NewEmailText", translator.GetTranslatedString("NewEmailText"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserNameText"));
            vars.Add("PasswordText", translator.GetTranslatedString("PasswordText"));
            vars.Add("DeleteUserText", translator.GetTranslatedString("DeleteUserText"));
            vars.Add("DeleteText", translator.GetTranslatedString("DeleteText"));
            vars.Add("DeleteUserInfoText", translator.GetTranslatedString("DeleteUserInfoText"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            vars.Add("Login", translator.GetTranslatedString("Login"));
            vars.Add("TypeUserNameToConfirm", translator.GetTranslatedString("TypeUserNameToConfirm"));

            vars.Add("AdminUserTypeInfoText", translator.GetTranslatedString("AdminUserTypeInfoText"));
            vars.Add("AdminSetUserTypeText", translator.GetTranslatedString("UserTypeText"));

            vars.Add("AdminLoginInAsUserText", translator.GetTranslatedString("AdminLoginInAsUserText"));
            vars.Add("AdminLoginInAsUserInfoText", translator.GetTranslatedString("AdminLoginInAsUserInfoText"));
            vars.Add("AdminDeleteUserText", translator.GetTranslatedString("AdminDeleteUserText"));
            vars.Add("AdminDeleteUserInfoText", translator.GetTranslatedString("AdminDeleteUserInfoText"));
            vars.Add("AdminUnbanUserText", translator.GetTranslatedString("AdminUnbanUserText"));
            vars.Add("AdminTempBanUserText", translator.GetTranslatedString("AdminTempBanUserText"));
            vars.Add("AdminTempBanUserInfoText", translator.GetTranslatedString("AdminTempBanUserInfoText"));
            vars.Add("AdminBanUserText", translator.GetTranslatedString("AdminBanUserText"));
            vars.Add("AdminBanUserInfoText", translator.GetTranslatedString("AdminBanUserInfoText"));
            vars.Add("BanText", translator.GetTranslatedString("BanText"));
            vars.Add("UnbanText", translator.GetTranslatedString("UnbanText"));
            vars.Add("TimeUntilUnbannedText", translator.GetTranslatedString("TimeUntilUnbannedText"));
            vars.Add("EdittingText", translator.GetTranslatedString("EdittingText"));
            vars.Add("BannedUntilText", translator.GetTranslatedString("BannedUntilText"));

            vars.Add("KickAUserInfoText", translator.GetTranslatedString("KickAUserInfoText"));
            vars.Add("KickAUserText", translator.GetTranslatedString("KickAUserText"));
            vars.Add("KickMessageText", translator.GetTranslatedString("KickMessageText"));
            vars.Add("KickUserText", translator.GetTranslatedString("KickUserText"));

            vars.Add("MessageAUserText", translator.GetTranslatedString("MessageAUserText"));
            vars.Add("MessageAUserInfoText", translator.GetTranslatedString("MessageAUserInfoText"));
            vars.Add("MessageUserText", translator.GetTranslatedString("MessageUserText"));

            List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> >();

            for (int i = 0; i <= 100; i++)
            {
                daysArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > hoursArgs = new List <Dictionary <string, object> >();

            for (int i = 0; i <= 23; i++)
            {
                hoursArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > minutesArgs = new List <Dictionary <string, object> >();

            for (int i = 0; i <= 59; i++)
            {
                minutesArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            vars.Add("Days", daysArgs);
            vars.Add("Hours", hoursArgs);
            vars.Add("Minutes", minutesArgs);
            vars.Add("DaysText", translator.GetTranslatedString("DaysText"));
            vars.Add("HoursText", translator.GetTranslatedString("HoursText"));
            vars.Add("MinutesText", translator.GetTranslatedString("MinutesText"));

            vars.Add("UserType", webInterface.UserTypeArgs(translator));

            return(vars);
        }
コード例 #49
0
ファイル: Engineer2.cs プロジェクト: goncalopereira/Gr1d
 public void OnArrived(IAgentInfo arriver, IAgentUpdateInfo agentUpdate)
 {
     Agent = arriver;
     AttackAndTryPin();
 }
コード例 #50
0
        private bool OnAllowedIncomingTeleport(UUID userID, IScene scene, Vector3 Position, uint TeleportFlags,
                                               out Vector3 newPosition, out string reason)
        {
            newPosition = Position;
            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, userID);

            IScenePresence Sp = scene.GetScenePresence(userID);

            if (account == null)
            {
                reason = "Failed authentication.";
                return(false); //NO!
            }


            //Make sure that this user is inside the region as well
            if (Position.X < -2f || Position.Y < -2f ||
                Position.X > scene.RegionInfo.RegionSizeX + 2 || Position.Y > scene.RegionInfo.RegionSizeY + 2)
            {
                MainConsole.Instance.DebugFormat(
                    "[EstateService]: AllowedIncomingTeleport was given an illegal position of {0} for avatar {1}, {2}. Clamping",
                    Position, Name, userID);
                bool changedX = false;
                bool changedY = false;
                while (Position.X < 0)
                {
                    Position.X += scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }
                while (Position.X > scene.RegionInfo.RegionSizeX)
                {
                    Position.X -= scene.RegionInfo.RegionSizeX;
                    changedX    = true;
                }

                while (Position.Y < 0)
                {
                    Position.Y += scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }
                while (Position.Y > scene.RegionInfo.RegionSizeY)
                {
                    Position.Y -= scene.RegionInfo.RegionSizeY;
                    changedY    = true;
                }

                if (changedX)
                {
                    Position.X = scene.RegionInfo.RegionSizeX - Position.X;
                }
                if (changedY)
                {
                    Position.Y = scene.RegionInfo.RegionSizeY - Position.Y;
                }
            }

            IAgentConnector AgentConnector = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo      agentInfo      = null;

            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(userID);
            }

            ILandObject             ILO = null;
            IParcelManagementModule parcelManagement = scene.RequestModuleInterface <IParcelManagementModule>();

            if (parcelManagement != null)
            {
                ILO = parcelManagement.GetLandObject(Position.X, Position.Y);
            }

            if (ILO == null)
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                //Can't find land, give them the first parcel in the region and find a good position for them
                ILO      = parcelManagement.AllParcels()[0];
                Position = parcelManagement.GetParcelCenterAtGround(ILO);
            }

            //parcel permissions
            if (ILO.IsBannedFromLand(userID)) //Note: restricted is dealt with in the next block
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                if (Sp == null)
                {
                    reason = "Banned from this parcel.";
                    return(false);
                }

                if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                {
                }
            }
            //Move them out of banned parcels
            ParcelFlags parcelflags = (ParcelFlags)ILO.LandData.Flags;

            if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup &&
                (parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList &&
                (parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                //One of these is in play then
                if ((parcelflags & ParcelFlags.UseAccessGroup) == ParcelFlags.UseAccessGroup)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(false);
                    }
                    if (Sp.ControllingClient.ActiveGroupId != ILO.LandData.GroupID)
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UseAccessList) == ParcelFlags.UseAccessList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(false);
                    }
                    //All but the people on the access list are banned
                    if (ILO.IsRestrictedFromLand(userID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                        }
                    }
                }
                else if ((parcelflags & ParcelFlags.UsePassList) == ParcelFlags.UsePassList)
                {
                    if (Sp == null)
                    {
                        reason = "Banned from this parcel.";
                        return(false);
                    }
                    //All but the people on the pass/access list are banned
                    if (ILO.IsRestrictedFromLand(Sp.UUID))
                    {
                        if (!FindUnBannedParcel(Position, Sp, userID, out ILO, out newPosition, out reason))
                        {
                        }
                    }
                }
            }

            EstateSettings      ES             = scene.RegionInfo.EstateSettings;
            TeleportFlags       tpflags        = (TeleportFlags)TeleportFlags;
            const TeleportFlags allowableFlags =
                OpenMetaverse.TeleportFlags.ViaLandmark | OpenMetaverse.TeleportFlags.ViaHome |
                OpenMetaverse.TeleportFlags.ViaLure |
                OpenMetaverse.TeleportFlags.ForceRedirect |
                OpenMetaverse.TeleportFlags.Godlike | OpenMetaverse.TeleportFlags.NineOneOne;

            //If the user wants to force landing points on crossing, we act like they are not crossing, otherwise, check the child property and that the ViaRegionID is set
            bool isCrossing = !ForceLandingPointsOnCrossing && (Sp != null && Sp.IsChildAgent &&
                                                                ((tpflags & OpenMetaverse.TeleportFlags.ViaRegionID) ==
                                                                 OpenMetaverse.TeleportFlags.ViaRegionID));

            //Move them to the nearest landing point
            if (!((tpflags & allowableFlags) != 0) && !isCrossing && !ES.AllowDirectTeleport)
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity(); //If we are moving the agent, clear their velocity
                }
                if (!scene.Permissions.IsGod(userID))
                {
                    Telehub telehub = RegionConnector.FindTelehub(scene.RegionInfo.RegionID,
                                                                  scene.RegionInfo.RegionHandle);
                    if (telehub != null)
                    {
                        if (telehub.SpawnPos.Count == 0)
                        {
                            Position = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                        }
                        else
                        {
                            int LastTelehubNum = 0;
                            if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
                            {
                                LastTelehubNum = 0;
                            }
                            Position = telehub.SpawnPos[LastTelehubNum] +
                                       new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                            LastTelehubNum++;
                            if (LastTelehubNum == telehub.SpawnPos.Count)
                            {
                                LastTelehubNum = 0;
                            }
                            LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
                        }
                    }
                }
            }
            else if (!((tpflags & allowableFlags) != 0) && !isCrossing &&
                     !scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
            //Telehubs override parcels
            {
                if (Sp != null)
                {
                    Sp.ClearSavedVelocity();                           //If we are moving the agent, clear their velocity
                }
                if (ILO.LandData.LandingType == (int)LandingType.None) //Blocked, force this person off this land
                {
                    //Find a new parcel for them
                    List <ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position);
                    if (Parcels.Count > 1)
                    {
                        newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                    }
                    else
                    {
                        bool found = false;
                        //We need to check here as well for bans, can't toss someone into a parcel they are banned from
                        foreach (ILandObject Parcel in Parcels.Where(Parcel => !Parcel.IsBannedFromLand(userID)))
                        {
                            //Now we have to check their userloc
                            if (ILO.LandData.LandingType == (int)LandingType.None)
                            {
                                continue; //Blocked, check next one
                            }
                            else if (ILO.LandData.LandingType == (int)LandingType.LandingPoint)
                            {
                                //Use their landing spot
                                newPosition = Parcel.LandData.UserLocation;
                            }
                            else //They allow for anywhere, so dump them in the center at the ground
                            {
                                newPosition = parcelManagement.GetParcelCenterAtGround(Parcel);
                            }
                            found = true;
                        }

                        if (!found) //Dump them at the edge
                        {
                            if (Sp != null)
                            {
                                newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                            }
                            else
                            {
                                reason = "Banned from this parcel.";
                                return(false);
                            }
                        }
                    }
                }
                else if (ILO.LandData.LandingType == (int)LandingType.LandingPoint)  //Move to tp spot
                {
                    newPosition = ILO.LandData.UserLocation != Vector3.Zero
                                      ? ILO.LandData.UserLocation
                                      : parcelManagement.GetNearestRegionEdgePosition(Sp);
                }
            }

            //We assume that our own region isn't null....
            if (agentInfo != null)
            {
                //Can only enter prelude regions once!
                if (scene.RegionInfo.RegionFlags != -1 &&
                    ((scene.RegionInfo.RegionFlags & (int)RegionFlags.Prelude) == (int)RegionFlags.Prelude) &&
                    agentInfo != null)
                {
                    if (agentInfo.OtherAgentInformation.ContainsKey("Prelude" + scene.RegionInfo.RegionID))
                    {
                        reason = "You may not enter this region as you have already been to this prelude region.";
                        return(false);
                    }
                    else
                    {
                        agentInfo.OtherAgentInformation.Add("Prelude" + scene.RegionInfo.RegionID,
                                                            OSD.FromInteger((int)IAgentFlags.PastPrelude));
                        AgentConnector.UpdateAgent(agentInfo);
                    }
                }
                if (agentInfo.OtherAgentInformation.ContainsKey("LimitedToEstate"))
                {
                    int LimitedToEstate = agentInfo.OtherAgentInformation["LimitedToEstate"];
                    if (scene.RegionInfo.EstateSettings.EstateID != LimitedToEstate)
                    {
                        reason = "You may not enter this reason, as it is outside of the estate you are limited to.";
                        return(false);
                    }
                }
            }


            if ((ILO.LandData.Flags & (int)ParcelFlags.DenyAnonymous) != 0)
            {
                if (account != null &&
                    (account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) ==
                    (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            if ((ILO.LandData.Flags & (uint)ParcelFlags.DenyAgeUnverified) != 0 && agentInfo != null)
            {
                if ((agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
                {
                    reason = "You may not enter this region.";
                    return(false);
                }
            }

            //Check that we are not underground as well
            ITerrainChannel chan = scene.RequestModuleInterface <ITerrainChannel>();

            if (chan != null)
            {
                float posZLimit = chan[(int)newPosition.X, (int)newPosition.Y] + (float)1.25;

                if (posZLimit >= (newPosition.Z) && !(Single.IsInfinity(posZLimit) || Single.IsNaN(posZLimit)))
                {
                    newPosition.Z = posZLimit;
                }
            }

            reason = "";
            return(true);
        }
コード例 #51
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars     = new Dictionary <string, object>();
            var settings = webInterface.GetWebUISettings();

            bool adminUser         = Authenticator.CheckAdminAuthentication(httpRequest, Constants.USER_GOD_CUSTOMER_SERVICE);
            bool allowRegistration = settings.WebRegistration;
            bool anonymousLogins;

            // allow configuration to override the web settings
            IConfig config = webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs ["LoginService"];

            if (config != null)
            {
                anonymousLogins   = config.GetBoolean("AllowAnonymousLogin", allowRegistration);
                allowRegistration = (allowRegistration || anonymousLogins);
            }

            if (!adminUser && !allowRegistration)
            {
                vars.Add("ErrorMessage", "");
                vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText"));
                vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled"));
                vars.Add("Registrations", false);
                vars.Add("NoRegistrations", true);
                return(vars);
            }

            if (requestParameters.ContainsKey("Submit"))
            {
                string AvatarName          = requestParameters["AvatarName"].ToString();
                string AvatarPassword      = requestParameters["AvatarPassword"].ToString();
                string AvatarPasswordCheck = requestParameters["AvatarPassword2"].ToString();
                string FirstName           = requestParameters["FirstName"].ToString();
                string LastName            = requestParameters["LastName"].ToString();
                //removed - greythane - deemed not used
                //string UserAddress = requestParameters["UserAddress"].ToString();
                //string UserZip = requestParameters["UserZip"].ToString();
                string UserCity       = requestParameters["UserCity"].ToString();
                string UserEmail      = requestParameters["UserEmail"].ToString();
                string UserHomeRegion = requestParameters["UserHomeRegion"].ToString();
                string UserDOBMonth   = requestParameters["UserDOBMonth"].ToString();
                string UserDOBDay     = requestParameters["UserDOBDay"].ToString();
                string UserDOBYear    = requestParameters["UserDOBYear"].ToString();
                string AvatarArchive  = requestParameters.ContainsKey("AvatarArchive")
                                           ? requestParameters["AvatarArchive"].ToString()
                                           : "";
                bool ToSAccept = requestParameters.ContainsKey("ToSAccept") &&
                                 requestParameters["ToSAccept"].ToString() == "Accepted";

                string UserType = requestParameters.ContainsKey("UserType")         // only admins can set membership
                    ? requestParameters ["UserType"].ToString()
                    : "Resident";

                // revise UserDOBMonth to a number
                UserDOBMonth = ShortMonthToNumber(UserDOBMonth);

                // revise Type flags
                int UserFlags = webInterface.UserTypeToUserFlags(UserType);

                // a bit of idiot proofing
                if (AvatarName == "")
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarNameError") + "</h3>";
                    return(null);
                }
                if ((AvatarPassword == "") || (AvatarPassword != AvatarPasswordCheck))
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarPasswordError") + "</h3>";
                    return(null);
                }
                if (UserEmail == "")
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarEmailError") + "</h3>";
                    return(null);
                }

                // Thish -  Only one space is allowed in the name to seperate First and Last of the avatar name
                if (AvatarName.Split(' ').Length != 2)
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarNameSpacingError") + "</h3>";
                    return(null);
                }

                // so far so good...
                if (ToSAccept)
                {
                    AvatarPassword = Util.Md5Hash(AvatarPassword);

                    IUserAccountService accountService =
                        webInterface.Registry.RequestModuleInterface <IUserAccountService>();
                    UUID   userID = UUID.Random();
                    string error  = accountService.CreateUser(userID, settings.DefaultScopeID, AvatarName, AvatarPassword,
                                                              UserEmail);
                    if (error == "")
                    {
                        // set the user account type
                        UserAccount account = accountService.GetUserAccount(null, userID);
                        account.UserFlags = UserFlags;
                        accountService.StoreUserAccount(account);

                        // create and save agent info
                        IAgentConnector con = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> ();
                        con.CreateNewAgent(userID);
                        IAgentInfo agent = con.GetAgent(userID);
                        agent.OtherAgentInformation ["RLFirstName"] = FirstName;
                        agent.OtherAgentInformation ["RLLastName"]  = LastName;
                        //agent.OtherAgentInformation ["RLAddress"] = UserAddress;
                        agent.OtherAgentInformation ["RLCity"] = UserCity;
                        //agent.OtherAgentInformation ["RLZip"] = UserZip;
                        agent.OtherAgentInformation ["UserDOBMonth"] = UserDOBMonth;
                        agent.OtherAgentInformation ["UserDOBDay"]   = UserDOBDay;
                        agent.OtherAgentInformation ["UserDOBYear"]  = UserDOBYear;
                        agent.OtherAgentInformation ["UserFlags"]    = UserFlags;

                        /*if (activationRequired)
                         * {
                         *  UUID activationToken = UUID.Random();
                         *  agent.OtherAgentInformation["WebUIActivationToken"] = Util.Md5Hash(activationToken.ToString() + ":" + PasswordHash);
                         *  resp["WebUIActivationToken"] = activationToken;
                         * }*/
                        con.UpdateAgent(agent);

                        // create user profile details
                        IProfileConnector profileData =
                            Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> ();
                        if (profileData != null)
                        {
                            IUserProfileInfo profile = profileData.GetUserProfile(userID);
                            if (profile == null)
                            {
                                profileData.CreateNewProfile(userID);
                                profile = profileData.GetUserProfile(userID);
                            }

                            if (AvatarArchive != "")
                            {
                                profile.AArchiveName = AvatarArchive;

                                List <AvatarArchive> avarchives = webInterface.Registry.RequestModuleInterface <IAvatarAppearanceArchiver>().GetAvatarArchives();
                                UUID snapshotUUID = UUID.Zero;
                                foreach (var archive in avarchives)
                                {
                                    if (archive.FolderName == AvatarArchive)
                                    {
                                        snapshotUUID = archive.Snapshot;
                                    }
                                }

                                if (snapshotUUID != UUID.Zero)
                                {
                                    profile.Image = snapshotUUID;
                                }
                            }
                            profile.MembershipGroup = webInterface.UserFlagToType(UserFlags, webInterface.EnglishTranslator);     // membership is english
                            profile.IsNewUser       = true;
                            profileData.UpdateUserProfile(profile);
                        }

                        IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService> ();
                        Vector3           position         = new Vector3(128, 128, 25);
                        Vector3           lookAt           = new Vector3(0, 0, 22);

                        if (agentInfoService != null)
                        {
                            agentInfoService.SetHomePosition(userID.ToString(), (UUID)UserHomeRegion, position, lookAt);
                        }

                        vars.Add("ErrorMessage", "Successfully created account, redirecting to main page");
                        response = "<h3>Successfully created account, redirecting to main page</h3>" +
                                   "<script language=\"javascript\">" +
                                   "setTimeout(function() {window.location.href = \"index.html\";}, 3000);" +
                                   "</script>";
                    }
                    else
                    {
                        vars.Add("ErrorMessage", "<h3>" + error + "</h3>");
                        response = "<h3>" + error + "</h3>";
                    }
                }
                else
                {
                    response = "<h3>You did not accept the Terms of Service agreement.</h3>";
                }
                return(null);
            }

            List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> >();

            for (int i = 1; i <= 31; i++)
            {
                daysArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > monthsArgs = new List <Dictionary <string, object> >();

            //for (int i = 1; i <= 12; i++)
            //    monthsArgs.Add(new Dictionary<string, object> {{"Value", i}});

            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Jan_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Feb_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Mar_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Apr_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("May_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Jun_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Jul_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Aug_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Sep_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Oct_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Nov_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Dec_Short") }
            });



            List <Dictionary <string, object> > yearsArgs = new List <Dictionary <string, object> >();

            for (int i = 1940; i <= 2013; i++)
            {
                yearsArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            vars.Add("Days", daysArgs);
            vars.Add("Months", monthsArgs);
            vars.Add("Years", yearsArgs);

            var sortBy = new Dictionary <string, bool>();

            sortBy.Add("RegionName", true);

            var RegionListVars = new List <Dictionary <string, object> >();
            var regions        = Framework.Utilities.DataManager.RequestPlugin <IRegionData>().Get((RegionFlags)0,
                                                                                                   RegionFlags.Hyperlink |
                                                                                                   RegionFlags.Foreign |
                                                                                                   RegionFlags.Hidden,
                                                                                                   null, null, sortBy);

            foreach (var region in regions)
            {
                RegionListVars.Add(new Dictionary <string, object> {
                    { "RegionName", region.RegionName },
                    { "RegionUUID", region.RegionID }
                });
            }

            vars.Add("RegionList", RegionListVars);
            vars.Add("UserHomeRegionText", translator.GetTranslatedString("UserHomeRegionText"));


            vars.Add("UserTypeText", translator.GetTranslatedString("UserTypeText"));
            vars.Add("UserType", webInterface.UserTypeArgs(translator));

            List <AvatarArchive> archives = webInterface.Registry.RequestModuleInterface <IAvatarAppearanceArchiver>().GetAvatarArchives();

            List <Dictionary <string, object> > avatarArchives = new List <Dictionary <string, object> >();
            IWebHttpTextureService webTextureService           = webInterface.Registry.
                                                                 RequestModuleInterface <IWebHttpTextureService>();

            foreach (var archive in archives)
            {
                avatarArchives.Add(new Dictionary <string, object>
                {
                    { "AvatarArchiveName", archive.FolderName },
                    { "AvatarArchiveSnapshotID", archive.Snapshot },
                    {
                        "AvatarArchiveSnapshotURL",
                        webTextureService.GetTextureURL(archive.Snapshot)
                    }
                });
            }

            vars.Add("AvatarArchive", avatarArchives);


            IConfig loginServerConfig =
                webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs["LoginService"];
            string tosLocation = "";

            if (loginServerConfig != null && loginServerConfig.GetBoolean("UseTermsOfServiceOnFirstLogin", false))
            {
                tosLocation = loginServerConfig.GetString("FileNameOfTOS", "");
                tosLocation = PathHelpers.VerifyReadFile(tosLocation, ".txt", Constants.DEFAULT_DATA_DIR);
            }
            string ToS = "There are no Terms of Service currently. This may be changed at any point in the future.";

            if (tosLocation != "")
            {
                System.IO.StreamReader reader =
                    new System.IO.StreamReader(System.IO.Path.Combine(Environment.CurrentDirectory, tosLocation));
                ToS = reader.ReadToEnd();
                reader.Close();
            }

            // check for user name seed
            string[] m_userNameSeed = null;
            if (loginServerConfig != null)
            {
                string userNameSeed = loginServerConfig.GetString("UserNameSeed", "");
                if (userNameSeed != "")
                {
                    m_userNameSeed = userNameSeed.Split(',');
                }
            }

            Utilities.MarkovNameGenerator ufNames = new Utilities.MarkovNameGenerator();
            Utilities.MarkovNameGenerator ulNames = new Utilities.MarkovNameGenerator();
            string[] nameSeed = m_userNameSeed == null ? Utilities.UserNames : m_userNameSeed;

            string firstName   = ufNames.FirstName(nameSeed, 3, 4);
            string lastName    = ulNames.FirstName(nameSeed, 5, 6);
            string enteredName = firstName + " " + lastName;

            vars.Add("AvatarName", enteredName);
            vars.Add("ToSMessage", ToS);
            vars.Add("TermsOfServiceAccept", translator.GetTranslatedString("TermsOfServiceAccept"));
            vars.Add("TermsOfServiceText", translator.GetTranslatedString("TermsOfServiceText"));
            vars.Add("RegistrationsDisabled", "");
            //vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled"));
            vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText"));
            vars.Add("AvatarNameText", translator.GetTranslatedString("AvatarNameText"));
            vars.Add("AvatarPasswordText", translator.GetTranslatedString("Password"));
            vars.Add("AvatarPasswordConfirmationText", translator.GetTranslatedString("PasswordConfirmation"));
            vars.Add("AvatarScopeText", translator.GetTranslatedString("AvatarScopeText"));
            vars.Add("FirstNameText", translator.GetTranslatedString("FirstNameText"));
            vars.Add("LastNameText", translator.GetTranslatedString("LastNameText"));
            vars.Add("UserAddressText", translator.GetTranslatedString("UserAddressText"));
            vars.Add("UserZipText", translator.GetTranslatedString("UserZipText"));
            vars.Add("UserCityText", translator.GetTranslatedString("UserCityText"));
            vars.Add("UserCountryText", translator.GetTranslatedString("UserCountryText"));
            vars.Add("UserDOBText", translator.GetTranslatedString("UserDOBText"));
            vars.Add("UserEmailText", translator.GetTranslatedString("UserEmailText"));
            vars.Add("Accept", translator.GetTranslatedString("Accept"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            vars.Add("SubmitURL", "register.html");
            vars.Add("ErrorMessage", "");
            vars.Add("Registrations", true);
            vars.Add("NoRegistrations", false);

            return(vars);
        }
コード例 #52
0
        byte[] ProcessUpdateAgentPreferences(Stream request, UUID agentID)
        {
            OSDMap rm = OSDParser.DeserializeLLSDXml(HttpServerHandlerHelpers.ReadFully(request)) as OSDMap;

            if (rm == null)
            {
                return(MainServer.BadRequest);
            }
            IAgentConnector data = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> ();

            if (data != null)
            {
                IAgentInfo agent = data.GetAgent(agentID);
                if (agent == null)
                {
                    return(MainServer.BadRequest);
                }
                // Access preferences ?
                if (rm.ContainsKey("access_prefs"))
                {
                    OSDMap accessPrefs = (OSDMap)rm ["access_prefs"];
                    string Level       = accessPrefs ["max"].AsString();
                    int    maxLevel    = 0;
                    if (Level == "PG")
                    {
                        maxLevel = 0;
                    }
                    if (Level == "M")
                    {
                        maxLevel = 1;
                    }
                    if (Level == "A")
                    {
                        maxLevel = 2;
                    }
                    agent.MaturityRating = maxLevel;
                }
                // Next permissions
                if (rm.ContainsKey("default_object_perm_masks"))
                {
                    OSDMap permsMap = (OSDMap)rm ["default_object_perm_masks"];
                    agent.PermEveryone  = permsMap ["Everyone"].AsInteger();
                    agent.PermGroup     = permsMap ["Group"].AsInteger();
                    agent.PermNextOwner = permsMap ["NextOwner"].AsInteger();
                }
                // Hoverheight
                if (rm.ContainsKey("hover_height"))
                {
                    agent.HoverHeight = rm ["hover_height"].AsReal();
                }
                // Language
                if (rm.ContainsKey("language"))
                {
                    agent.Language = rm ["language"].AsString();
                }
                // Show Language to others / objects
                if (rm.ContainsKey("language_is_public"))
                {
                    agent.LanguageIsPublic = rm ["language_is_public"].AsBoolean();
                }
                data.UpdateAgent(agent);
                // Build a response that can be send back to the viewer
                OSDMap resp            = new OSDMap();
                OSDMap respAccessPrefs = new OSDMap();
                respAccessPrefs ["max"] = Utilities.GetMaxMaturity(agent.MaxMaturity);
                resp ["access_prefs"]   = respAccessPrefs;
                OSDMap respDefaultPerms = new OSDMap();
                respDefaultPerms ["Everyone"]      = agent.PermEveryone;
                respDefaultPerms ["Group"]         = agent.PermGroup;
                respDefaultPerms ["NextOwner"]     = agent.PermNextOwner;
                resp ["default_object_perm_masks"] = respDefaultPerms;
                resp ["god_level"]          = 0; // *TODO: Add this
                resp ["hover_height"]       = agent.HoverHeight;
                resp ["language"]           = agent.Language;
                resp ["language_is_public"] = agent.LanguageIsPublic;

                return(OSDParser.SerializeLLSDXmlBytes(resp));
            }
            return(MainServer.BlankResponse);
        }
コード例 #53
0
        public LoginResponse Login(Hashtable request, UserAccount account, IAgentInfo agentInfo, string authType,
                                   string password, out object data)
        {
            IAgentConnector agentData = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();

            data = null;

            if (request == null)
            {
                return(null);
            }
            //If its null, its just a verification request, allow them to see things even if they are banned

            bool   tosExists   = false;
            string tosAccepted = "";

            if (request.ContainsKey("agree_to_tos"))
            {
                tosExists   = true;
                tosAccepted = request["agree_to_tos"].ToString();
            }

            //MAC BANNING START
            string mac = (string)request["mac"];

            if (mac == "")
            {
                data = "Bad Viewer Connection";
                return(new LLFailedLoginResponse(LoginResponseEnum.Indeterminant, data.ToString(), false));
            }

            // TODO: Some TPV's now send their version in the Channel

            /*
             * string channel = "Unknown";
             * if (request.Contains("channel") && request["channel"] != null)
             *  channel = request["channel"].ToString();
             */

            bool AcceptedNewTOS = false;

            //This gets if the viewer has accepted the new TOS
            if (!agentInfo.AcceptTOS && tosExists)
            {
                if (tosAccepted == "0")
                {
                    AcceptedNewTOS = false;
                }
                else if (tosAccepted == "1")
                {
                    AcceptedNewTOS = true;
                }
                else
                {
                    AcceptedNewTOS = bool.Parse(tosAccepted);
                }

                if (agentInfo.AcceptTOS != AcceptedNewTOS)
                {
                    agentInfo.AcceptTOS = AcceptedNewTOS;
                    agentData.UpdateAgent(agentInfo);
                }
            }
            if (!AcceptedNewTOS && !agentInfo.AcceptTOS && m_UseTOS)
            {
                data = "TOS not accepted";
                if (m_TOSLocation.ToLower().StartsWith("http://"))
                {
                    return(new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, m_TOSLocation, false));
                }

                // text file
                var ToSText = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, m_TOSLocation));
                return(new LLFailedLoginResponse(LoginResponseEnum.ToSNeedsSent, ToSText, false));
            }
            if ((agentInfo.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan)
            {
                MainConsole.Instance.InfoFormat(
                    "[LLOGIN SERVICE]: Login failed for user {0}, reason: user is permanently banned.", account.Name);
                data = "Permanently banned";
                return(LLFailedLoginResponse.PermanentBannedProblem);
            }

            if ((agentInfo.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan)
            {
                bool   IsBanned = true;
                string until    = "";

                if (agentInfo.OtherAgentInformation.ContainsKey("TemperaryBanInfo"))
                {
                    DateTime bannedTime = agentInfo.OtherAgentInformation["TemperaryBanInfo"].AsDate();
                    until = string.Format(" until {0} {1}", bannedTime.ToLocalTime().ToShortDateString(),
                                          bannedTime.ToLocalTime().ToLongTimeString());

                    //Check to make sure the time hasn't expired
                    if (bannedTime.Ticks < DateTime.Now.ToUniversalTime().Ticks)
                    {
                        //The banned time is less than now, let the user in.
                        IsBanned = false;
                    }
                }

                if (IsBanned)
                {
                    MainConsole.Instance.InfoFormat(
                        "[LLOGIN SERVICE]: Login failed for user {0}, reason: user is temporarily banned {1}.",
                        account.Name, until);
                    data = string.Format("You are blocked from connecting to this service{0}.", until);
                    return(new LLFailedLoginResponse(LoginResponseEnum.Indeterminant,
                                                     data.ToString(), false));
                }
            }
            return(null);
        }
コード例 #54
0
ファイル: TheExplorer.cs プロジェクト: VijayEluri/src
 public void OnAttacked(IAgentInfo attacker, IAgentUpdateInfo agentUpdate)
 {
     this.Attack(attacker); // just fight back - don't know what else to do, now
 }
コード例 #55
0
ファイル: MyRobot.cs プロジェクト: timothypratley/MyAgent
 public void OnArrived(IAgentInfo arriver, IAgentUpdateInfo agentUpdate)
 {
 }
コード例 #56
0
		public static ITargetAgentResult Attack(this IAgent self, IAgentInfo target) {
			var dlg = AttackDelegate;
			if (null != dlg) { return dlg(self, target); }

			return IAgentSkillExtensions.Attack(self, target);
		}