Esempio n. 1
0
        public static bool FriendshipExists(SqlDatabaseClient MySqlClient, uint UserId1, uint UserId2, bool ConfirmedOnly)
        {
            MySqlClient.SetParameter("user1", UserId1);
            MySqlClient.SetParameter("user2", UserId2);
            MySqlClient.SetParameter("confirmed", (ConfirmedOnly ? 0 : 2));

            return (MySqlClient.ExecuteQueryRow("SELECT null FROM messenger_friendships WHERE user_1_id = @user1 AND user_2_id = @user2 AND confirmed != @confirmed OR user_2_id = @user1 AND user_1_id = @user2 AND confirmed != @confirmed LIMIT 1") != null);
        }
Esempio n. 2
0
 public static void CreateFriendship(SqlDatabaseClient MySqlClient, uint UserId1, uint UserId2, bool Confirmed)
 {
     for (int i = 0; i < (Confirmed ? 2 : 1); i++)
     {
         MySqlClient.SetParameter("user1", (i == 1 ? UserId1 : UserId2));
         MySqlClient.SetParameter("user2", (i == 1 ? UserId2 : UserId1));
         MySqlClient.SetParameter("accepted", (int)(Confirmed ? 1 : 0));
         MySqlClient.ExecuteNonQuery("INSERT INTO messenger_friendships (user_1_id,user_2_id,confirmed) VALUES (@user1,@user2,@accepted)");
     }
 }
Esempio n. 3
0
        public static void DeleteRoom(SqlDatabaseClient MySqlClient, uint RoomId)
        {
            MySqlClient.SetParameter("id", RoomId);
            MySqlClient.ExecuteNonQuery("DELETE FROM rooms WHERE id = @id LIMIT 1");

            MySqlClient.SetParameter("id", RoomId);
            MySqlClient.ExecuteNonQuery("DELETE FROM navigator_frontpage WHERE room_id = @id");

            RoomInfoLoader.RemoveFromCache(RoomId);
            Navigator.ReloadOfficialItems(MySqlClient);
        }
Esempio n. 4
0
        public static bool DestroyFriendship(SqlDatabaseClient MySqlClient, uint UserId1, uint UserId2)
        {
            int aff = 0;

            for (int i = 0; i < 2; i++)
            {
                MySqlClient.SetParameter("user1", (i == 1 ? UserId1 : UserId2));
                MySqlClient.SetParameter("user2", (i == 1 ? UserId2 : UserId1));
                aff += MySqlClient.ExecuteNonQuery("DELETE FROM messenger_friendships WHERE user_1_id = @user1 AND user_2_id = @user2 LIMIT 1");
            }

            return (aff > 0);
        }
Esempio n. 5
0
        public static void BanUser(SqlDatabaseClient MySqlClient, uint UserId, string MessageText, uint ModeratorId, double Length)
        {
            MySqlClient.SetParameter("userid", UserId);
            MySqlClient.SetParameter("reason", MessageText);
            MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent());
            MySqlClient.SetParameter("timestampex", UnixTimestamp.GetCurrent() + Length);
            MySqlClient.SetParameter("moderator", ModeratorId);
            MySqlClient.ExecuteNonQuery("INSERT INTO bans (user_id,reason_text,timestamp_created,timestamp_expire,moderator_id) VALUES (@userid,@reason,@timestamp,@timestampex,@moderator)");

            lock (mSyncRoot)
            {
                mCharacterBlacklist.Add(UserId);
            }
        }
Esempio n. 6
0
        public static List<uint> GetFriendsForUser(SqlDatabaseClient MySqlClient, uint UserId, int Confirmed)
        {
            List<uint> Friends = new List<uint>();

            MySqlClient.SetParameter("id", UserId);
            MySqlClient.SetParameter("confirmed", Confirmed);
            DataTable Table = MySqlClient.ExecuteQueryTable("SELECT user_2_id FROM messenger_friendships WHERE user_1_id = @id AND confirmed = @confirmed");

            foreach (DataRow Row in Table.Rows)
            {
                Friends.Add((uint)Row[0]);
            }

            return Friends;
        }
        public static CharacterInfo GetCharacterInfo(SqlDatabaseClient MySqlClient, uint CharacterId, uint LinkedClientId, bool IgnoreCache)
        {
            if (SessionManager.ContainsCharacterId(CharacterId))
            {
                Session Session = SessionManager.GetSessionByCharacterId(CharacterId);
                return Session.CharacterInfo;
            }

            if (!IgnoreCache)
            {
                CharacterInfo CachedInfo = TryGetInfoFromCache(CharacterId);

                if (CachedInfo != null)
                {
                    return CachedInfo;
                }
            }

            MySqlClient.SetParameter("id", CharacterId);
            DataRow Row = MySqlClient.ExecuteQueryRow("SELECT * FROM characters WHERE id = @id LIMIT 1");

            if (Row != null)
            {
                return GenerateCharacterInfoFromRow(MySqlClient, LinkedClientId, Row);
            }

            return null;
        }
Esempio n. 8
0
        public static void ReloadCache(SqlDatabaseClient MySqlClient)
        {
            lock (mSyncRoot)
            {
                mCharacterBlacklist.Clear();
                mRemoteAddressBlacklist.Clear();

                MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent());
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM bans WHERE timestamp_expire > @timestamp");

                foreach (DataRow Row in Table.Rows)
                {
                    uint UserId = (uint)Row["user_id"];
                    string RemoteAddr = (string)Row["remote_address"];

                    if (UserId > 0 && !mCharacterBlacklist.Contains(UserId))
                    {
                        mCharacterBlacklist.Add(UserId);
                    }

                    if (RemoteAddr.Length > 0 && !mRemoteAddressBlacklist.Contains(RemoteAddr))
                    {
                        mRemoteAddressBlacklist.Add(RemoteAddr);
                    }
                }
            }
        }
Esempio n. 9
0
        public void MarkNewItem(SqlDatabaseClient MySqlClient, int TabId, uint ItemId, bool SynchronizeDatabase = true)
        {
            lock (mSyncRoot)
            {
                if (!mInner.ContainsKey(TabId))
                {
                    mInner[TabId] = new List<uint>();
                }

                mInner[TabId].Add(ItemId);

                if (SynchronizeDatabase)
                {
                    MySqlClient.SetParameter("userid", mUserId);
                    MySqlClient.SetParameter("tabid", TabId);
                    MySqlClient.SetParameter("itemid", ItemId);
                    MySqlClient.ExecuteNonQuery("INSERT INTO new_items (user_id,tab_id,item_id) VALUES (@userid,@tabid,@itemid)");
                }
            }
        }
Esempio n. 10
0
        public static Pet CreatePet(SqlDatabaseClient MySqlClient, uint UserId, int Type, string Name, int Race)
        {
            MySqlClient.SetParameter("userid", UserId);
            MySqlClient.SetParameter("type", Type);
            MySqlClient.SetParameter("name", Name);
            MySqlClient.SetParameter("race", Race);
            MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent());

            string RawId = MySqlClient.ExecuteScalar("INSERT INTO pets (user_id,type,name,race,timestamp) VALUES (@userid,@type,@name,@race,@timestamp); SELECT LAST_INSERT_ID();").ToString();

            uint Id = 0;
            uint.TryParse(RawId, out Id);

            if (Id == 0)
            {
                return null;
            }

            return new Pet(Id, Name, Type, Race, UserId, 0, new Vector3(0, 0, 0), UnixTimestamp.GetCurrent(), 0, 120, 100, 0);
        }
Esempio n. 11
0
        public void AddOrUpdateData(SqlDatabaseClient MySqlClient, string Group, int Level, int Progress)
        {
            MySqlClient.SetParameter("userid", mUserId);
            MySqlClient.SetParameter("group", Group);
            MySqlClient.SetParameter("level", Level);
            MySqlClient.SetParameter("progress", Progress);

            lock (mSyncRoot)
            {
                if (mInner.ContainsKey(Group))
                {
                    mInner[Group].Level = Level;
                    mInner[Group].Progress = Progress;

                    MySqlClient.ExecuteNonQuery("UPDATE user_achievements SET level = @level, progress = @progress WHERE user_id = @userid AND group_id = @group LIMIT 1");
                }
                else
                {
                    mInner.Add(Group, new UserAchievement(Group, Level, Progress));

                    MySqlClient.ExecuteNonQuery("INSERT INTO user_achievements (user_id,group_id,level,progress) VALUES (@userid,@group,@level,@progress)");
                }
            }
        }
Esempio n. 12
0
        public void ReloadCache(SqlDatabaseClient MySqlClient)
        {
            lock (mSyncRoot)
            {
                mInner.Clear();

                MySqlClient.SetParameter("userid", mUserId);
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT group_id,level,progress FROM user_achievements WHERE user_id = @userid");

                foreach (DataRow Row in Table.Rows)
                {
                    string Group = (string)Row["group_id"];

                    mInner.Add(Group, new UserAchievement(Group, (int)Row["level"], (int)Row["progress"]));
                }
            }
        }
Esempio n. 13
0
        public static void FillCache(SqlDatabaseClient MySqlClient, uint LinkedItemId)
        {
            if (mCache.ContainsKey(LinkedItemId))
            {
                mCache.Remove(LinkedItemId);
            }

            uint IdValue = 0;

            MySqlClient.SetParameter("id", LinkedItemId);
            object Result = MySqlClient.ExecuteScalar("SELECT room_id FROM items WHERE id = @id LIMIT 1");

            if (Result != null)
            {
                IdValue = (uint)Result;
            }

            if (IdValue > 0)
            {
                mCache.Add(LinkedItemId, IdValue);
            }
        }
Esempio n. 14
0
        public static Item CreateItem(SqlDatabaseClient MySqlClient, uint DefinitionId, uint UserId, string Flags, string FlagsDisplay, double ExpireTimestamp, bool Untradable = false)
        {
            MySqlClient.SetParameter("definitionid", DefinitionId);
            MySqlClient.SetParameter("userid", UserId);
            MySqlClient.SetParameter("flags", Flags);
            MySqlClient.SetParameter("flagsd", FlagsDisplay);
            MySqlClient.SetParameter("untradable", Untradable ? "1" : "0");
            MySqlClient.SetParameter("expiretimestamp", ExpireTimestamp);

            string RawId = MySqlClient.ExecuteScalar("INSERT INTO items (definition_id,user_id,flags,flags_display,untradable,expire_timestamp) VALUES (@definitionid,@userid,@flags,@flagsd,@untradable,@expiretimestamp); SELECT LAST_INSERT_ID();").ToString();

            uint Id = 0;
            uint.TryParse(RawId, out Id);

            if (Id == 0)
            {
                return null;
            }

            return new Item(Id, DefinitionId, UserId, 0, new Vector3(), string.Empty, 0, Flags, Flags, Untradable, 0, 0,
                ExpireTimestamp);
        }
Esempio n. 15
0
        public void AddOrUpdateData(SqlDatabaseClient MySqlClient, uint QuestId, int Progress, bool ActiveQuest)
        {
            if (ActiveQuest)
            {
                if (mCurrentQuest > 0)
                {
                    MySqlClient.SetParameter("userid", mUserId);
                    MySqlClient.SetParameter("questid", mCurrentQuest);
                    MySqlClient.ExecuteNonQuery("UPDATE user_quests SET is_current = '0' WHERE user_id = @userid AND quest_id = @questid LIMIT 1");
                }

                mCurrentQuest = QuestId;
            }
            else if (mCurrentQuest == QuestId)
            {
                mCurrentQuest = 0;
            }

            MySqlClient.SetParameter("userid", mUserId);
            MySqlClient.SetParameter("questid", QuestId);
            MySqlClient.SetParameter("progress", Progress);
            MySqlClient.SetParameter("iscurrent", ActiveQuest ? "1" : "0");

            lock (mSyncRoot)
            {
                if (mInner.ContainsKey(QuestId))
                {
                    mInner[QuestId] = Progress;
                    MySqlClient.ExecuteNonQuery("UPDATE user_quests SET progress = @progress, is_current = @iscurrent WHERE user_id = @userid AND quest_id = @questid LIMIT 1");
                }
                else
                {
                    mInner.Add(QuestId, Progress);
                    MySqlClient.ExecuteNonQuery("INSERT INTO user_quests (user_id,quest_id,progress,is_current) VALUES (@userid,@questid,@progress,@iscurrent)");
                }
            }
        }
Esempio n. 16
0
 public void SynchronizeDatabase(SqlDatabaseClient MySqlClient)
 {
     MySqlClient.SetParameter("id", mId);
     MySqlClient.SetParameter("roomid", mRoomId);
     MySqlClient.SetParameter("roompos", mRoomPosition.ToString());
     MySqlClient.SetParameter("exp", mExperience);
     MySqlClient.SetParameter("energy", mEnergy);
     MySqlClient.SetParameter("happy", mHappiness);
     MySqlClient.SetParameter("score", mScore);
     MySqlClient.ExecuteNonQuery("UPDATE pets SET room_id = @roomid, room_pos = @roompos, experience = @exp, energy = @energy, happiness = @happy, score = @score WHERE id = @id LIMIT 1");
 }
Esempio n. 17
0
        public void ReloadCache(SqlDatabaseClient MySqlClient)
        {
            lock (mSyncRoot)
            {
                mInner.Clear();

                MySqlClient.SetParameter("userid", mUserId);
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT quest_id,progress,is_current FROM user_quests WHERE user_id = @userid");

                foreach (DataRow Row in Table.Rows)
                {
                    uint Id = (uint)Row["quest_id"];

                    mInner.Add(Id, (int)Row["progress"]);

                    if (Row["is_current"].ToString() == "1")
                    {
                        mCurrentQuest = Id;
                    }
                }
            }
        }
Esempio n. 18
0
        public static void LoadBotDefinitions(SqlDatabaseClient MySqlClient)
        {
            mBotDefinitions.Clear();
            mDefinedResponses.Clear();
            mDefinedSpeech.Clear();
            mPetHandlerIndex.Clear();

            DataTable ResponseTable = MySqlClient.ExecuteQueryTable("SELECT bot_id,triggers,responses,response_serve_id FROM bot_responses");

            foreach (DataRow Row in ResponseTable.Rows)
            {
                BotResponse Response = new BotResponse(Row["triggers"].ToString().Split('|').ToList(),
                    Row["responses"].ToString().Split('|').ToList(), (int)Row["response_serve_id"]);

                if (!mDefinedResponses.ContainsKey((uint)Row["bot_id"]))
                {
                    mDefinedResponses.Add((uint)Row["bot_id"], new List<BotResponse>());
                }

                mDefinedResponses[(uint)Row["bot_id"]].Add(Response);
            }

            DataTable SpeechTable = MySqlClient.ExecuteQueryTable("SELECT bot_id,message FROM bots_speech");

            foreach (DataRow Row in SpeechTable.Rows)
            {
                if (!mDefinedSpeech.ContainsKey((uint)Row["bot_id"]))
                {
                    mDefinedSpeech.Add((uint)Row["bot_id"], new List<string>());
                }

                mDefinedSpeech[(uint)Row["bot_id"]].Add((string)Row["message"]);
            }

            MySqlClient.SetParameter("enabled", "1");
            DataTable BotTable = MySqlClient.ExecuteQueryTable("SELECT * FROM bots WHERE enabled = @enabled");

            foreach (DataRow Row in BotTable.Rows)
            {
                BotWalkMode WMode = BotWalkMode.STAND;

                switch ((string)Row["walk_mode"])
                {
                    case "freeroam":

                        WMode = BotWalkMode.FREEROAM;
                        break;

                    case "defined":

                        WMode = BotWalkMode.SPECIFIED_RANGE;
                        break;
                }

                List<Vector2> DefinedPositions = new List<Vector2>();
                string[] DefPosBits = Row["pos_defined_range"].ToString().Split(';');

                foreach (string DefPosBit in DefPosBits)
                {
                    DefinedPositions.Add(Vector2.FromString(DefPosBit));
                }

                Bot Bot = new Bot((uint)Row["id"], (uint)Row["id"], (string)Row["ai_type"], (string)Row["name"],
                    (string)Row["look"], (string)Row["motto"], (uint)Row["room_id"],
                    Vector3.FromString((string)Row["pos_start"]), Vector2.FromString((string)Row["pos_serve"]),
                    DefinedPositions, WMode, (Row["kickable"].ToString() == "1"), (int)Row["rotation"],
                    (mDefinedResponses.ContainsKey((uint)Row["id"]) ? mDefinedResponses[(uint)Row["id"]] : new List<BotResponse>()),
                    (int)Row["effect"], (int)Row["response_distance"]);

                mBotDefinitions.Add((uint)Row["id"], Bot);

                int PetHandler = (int)Row["pet_type_handler_id"];

                if ((string)Row["ai_type"] == "pet")
                {
                    mPetHandlerIndex.Add(PetHandler, Bot);
                }
            }
        }
Esempio n. 19
0
        public void ReloadCache(SqlDatabaseClient MySqlClient)
        {
            lock (mSyncRoot)
            {
                mInner.Clear();

                MySqlClient.SetParameter("userid", mCharacterId);
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM pets WHERE user_id = @userid AND room_id = 0");

                foreach (DataRow Row in Table.Rows)
                {
                    Pet Pet = PetFactory.GetPetFromDatabaseRow(Row);
                    mInner.Add(Pet.Id, Pet);
                }
            }
        }
        /// <summary>
        /// Attemps to authenticate an user using an SSO (Single Sign On) ticket.
        /// </summary>
        /// <param name="Ticket">The ticket string.</param>
        /// <returns>Character id on success, 0 on authentication failure.</returns>
        public static uint TryAuthenticate(SqlDatabaseClient MySqlClient, string Ticket, string RemoteAddress)
        {
            lock (mAuthSyncRoot)
            {
                // Remove any spacing from single sign on ticket
                Ticket = Ticket.Trim();

                // Ensure the ticket meets the minimum length requirement
                if (Ticket.Length <= 5)
                {
                    mFailedLoginCount++;
                    Output.WriteLine("Login from " + RemoteAddress + " rejected: SSO ticket too short.");
                    return 0;
                }

                // Debug
                string DebugTicket = (string)ConfigManager.GetValue("debug.sso");
                if (DebugTicket.Length > 0 && Ticket == DebugTicket)
                    return 1;

                // Check the database for a matching single sign on ticket
                uint UserId = 0;
                string LogName = string.Empty;

                MySqlClient.SetParameter("ticket", Ticket);
                DataRow Row = MySqlClient.ExecuteQueryRow("SELECT id,username FROM characters WHERE auth_ticket = @ticket LIMIT 1");

                if (Row != null)
                {
                    UserId = (uint)Row["id"];
                    LogName = (string)Row["username"];

                    RemoveTicket(MySqlClient, (uint)Row["id"], RemoteAddress);
                }

                // Check if ticket was OK + Check for user id bans
                if (UserId <= 0)
                {
                    mFailedLoginCount++;
                    Output.WriteLine("Login from " + RemoteAddress + " rejected: invalid SSO ticket.");
                    return 0;
                }

                if (ModerationBanManager.IsUserIdBlacklisted(UserId))
                {
                    mFailedLoginCount++;
                    Output.WriteLine("Login from " + RemoteAddress + " rejected: blacklisted IP address.");
                    return 0;
                }

                // Disconnect any previous sessions for this account
                if (SessionManager.ContainsCharacterId(UserId))
                {
                    Session TargetSession = SessionManager.GetSessionByCharacterId(UserId);
                    SessionManager.StopSession(TargetSession.Id);
                }

                // Mark as a successful login and continue

                Output.WriteLine("User " + LogName + " (ID " + UserId + ") has logged in from " + RemoteAddress + ".");
                MySqlClient.ExecuteNonQuery("UPDATE characters SET online = '1' WHERE id = " + UserId + " LIMIT 1");
                mSuccessfulLoginCount++;
                return UserId;
            }
        }
 /// <summary>
 /// Removes the SSO (Single Sign On) ticket from the database after a successful login attempt.
 /// </summary>
 /// <param name="UserId">The character id to remove the ticket from.</param>
 private static void RemoveTicket(SqlDatabaseClient MySqlClient, uint UserId, string AddressToLog)
 {
     MySqlClient.SetParameter("id", UserId);
     MySqlClient.SetParameter("lastip", AddressToLog);
     MySqlClient.SetParameter("lastonline", UnixTimestamp.GetCurrent());
     MySqlClient.ExecuteNonQuery("UPDATE characters SET auth_ticket = '', last_ip = @lastip, timestamp_lastvisit = @lastonline WHERE id = @id LIMIT 1");
 }
Esempio n. 22
0
        public void UpdateScore(SqlDatabaseClient MySqlClient, int Amount)
        {
            mScore += Amount;

            MySqlClient.SetParameter("userid", mId);
            MySqlClient.SetParameter("score", mScore);
            MySqlClient.ExecuteNonQuery("UPDATE characters SET score = @score WHERE id = @userid LIMIT 1");
        }
Esempio n. 23
0
        public void SynchronizeDatabase(SqlDatabaseClient MySqlClient)
        {
            MySqlClient.SetParameter("id", mItemId);
            MySqlClient.SetParameter("data1", mData1);
            MySqlClient.SetParameter("data2", mData2);
            MySqlClient.SetParameter("data3", mData3);
            MySqlClient.SetParameter("data4", mData4);
            MySqlClient.SetParameter("data5", mData5);
            MySqlClient.SetParameter("time", mTime);

            MySqlClient.ExecuteNonQuery("UPDATE wired_items SET data1 = @data1, data2 = @data2, data3 = @data3, data4 = @data4, data5 = @data5, time = @time WHERE item_id = @id LIMIT 1");
        }
Esempio n. 24
0
        public void ReloadCache(SqlDatabaseClient MySqlClient)
        {
            lock (mInner)
            {
                mInner.Clear();

                MySqlClient.SetParameter("characterid", mCharacterId);
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT room_id FROM favorites WHERE user_id = @characterid LIMIT " + Navigator.MaxFavoritesPerUser);

                foreach (DataRow Row in Table.Rows)
                {
                    mInner.Add((uint)Row["room_id"]);
                }
            }
        }
Esempio n. 25
0
        public CharacterInfo(SqlDatabaseClient MySqlClient, uint SessionId, uint Id, string Username, uint Rank, bool Premium, string RealName, string Figure, 
            CharacterGender Gender, string Motto, int Credits, int ActivityPoints, double ActivityPointsLastUpdate,
            bool PrivacyAcceptFriends, uint HomeRoom, int Score, int ConfigVolume, int ModerationTickets,
            int ModerationTicketsAbusive, double ModerationTicketCooldown, int ModerationBans, int ModerationCautions,
            double TimestampLastOnline, double TimestampRegistered, int RespectPoints, int RespectCreditHuman,
            int RespectCreditPets, double ModerationMutedUntil)
        {
            mSessionId = SessionId;
            mId = Id;
            mUsername = Username;
            mRank = Rank;
            mPremium = Premium;
            mRealName = RealName;
            mFigure = Figure;
            mGender = Gender;
            mMotto = Motto;
            mCredits = Credits;

            mActivityPoints = ActivityPoints;
            mPrivacyAcceptFriends = PrivacyAcceptFriends;
            mHomeRoom = HomeRoom;
            mScore = Score;
            mConfigVolume = ConfigVolume;

            mRespectPoints = RespectPoints;
            mRespectCreditHuman = RespectCreditHuman;
            mRespectCreditPets = RespectCreditPets;

            mModerationTickets = ModerationTickets;
            mModerationTicketsAbusive = ModerationTicketsAbusive;
            mModerationTicketsCooldown = ModerationTicketCooldown;
            mModerationCautions = ModerationCautions;
            mModerationBans = ModerationBans;
            mModerationMutedUntil = ModerationMutedUntil;

            mCacheAge = UnixTimestamp.GetCurrent();
            mTimestampLastActivityPointsUpdate = ActivityPointsLastUpdate;
            mTimestampLastOnline = TimestampLastOnline;
            mTimestampRegistered = TimestampRegistered;

            mWardrobe = new Dictionary<int, WardrobeItem>();
            mTags = new List<string>();

            if (MySqlClient != null)
            {
                MySqlClient.SetParameter("userid", mId);
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM wardrobe WHERE user_id = @userid LIMIT 10");

                foreach (DataRow Row in Table.Rows)
                {
                    mWardrobe.Add((int)Row["slot_id"], new WardrobeItem((string)Row["figure"], (Row["gender"].ToString().ToLower() == "m" ? CharacterGender.Male : CharacterGender.Female)));
                }

                MySqlClient.SetParameter("userid", mId);
                DataTable TagsTable = MySqlClient.ExecuteQueryTable("SELECT * FROM tags WHERE user_id = @userid");

                foreach (DataRow Row in TagsTable.Rows)
                {
                    mTags.Add((string)Row["tag"]);
                }
            }
        }
Esempio n. 26
0
        public static void ReloadFlatCategories(SqlDatabaseClient MySqlClient)
        {
            int NumberLoaded = 0;

            lock (mFlatCategories)
            {
                mFlatCategories.Clear();
                mEventSearchQueries.Clear();

                MySqlClient.SetParameter("enabled", "1");
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM flat_categories WHERE enabled = @enabled ORDER BY order_num ASC");

                foreach (DataRow Row in Table.Rows)
                {
                    mFlatCategories.Add(new FlatCategory((int)Row["id"], (Row["visible"].ToString() == "1"),
                        (string)Row["title"], (Row["allow_trading"].ToString() == "1")));
                    NumberLoaded++;
                }

                DataTable EventQueries = MySqlClient.ExecuteQueryTable("SELECT * FROM navigator_event_search_categories");

                foreach (DataRow Row in EventQueries.Rows)
                {
                    mEventSearchQueries.Add(Row["query"].ToString().ToLower(), (int)Row["category_id"]);
                }
            }

            Output.WriteLine("Loaded " + NumberLoaded + " flat " + ((NumberLoaded != 1) ? "categories" : "category") + ".", OutputLevel.DebugInformation);
        }
Esempio n. 27
0
        private static List<Item> LoadPlaylist(SqlDatabaseClient MySqlClient, uint SoundManagerId)
        {
            List<Item> List = new List<Item>();

            MySqlClient.SetParameter("soundmanagerid", SoundManagerId);
            DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM items WHERE soundmanager_id = @soundmanagerid ORDER BY soundmanager_order ASC");

            foreach (DataRow Row in Table.Rows)
            {
                Item Item = ItemFactory.CreateFromDatabaseRow(Row);

                if (Item == null)
                {
                    continue;
                }

                List.Add(Item);
            }

            return List;
        }
Esempio n. 28
0
 private static void PerformDatabaseCleanup(SqlDatabaseClient MySqlClient)
 {
     MySqlClient.ExecuteNonQuery("UPDATE rooms SET current_users = 0");
     MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent());
     MySqlClient.ExecuteNonQuery("UPDATE room_visits SET timestamp_left = @timestamp WHERE timestamp_left = 0");
     MySqlClient.ExecuteNonQuery("UPDATE characters SET auth_ticket = ''");
 }
Esempio n. 29
0
        public static void ReloadOfficialItems(SqlDatabaseClient MySqlClient)
        {
            int NumberLoaded = 0;

            lock (mOfficialItems)
            {
                mOfficialItems.Clear();

                MySqlClient.SetParameter("enabled", "1");
                DataTable Table = MySqlClient.ExecuteQueryTable("SELECT * FROM navigator_frontpage WHERE enabled = @enabled ORDER BY order_num ASC");

                foreach (DataRow Row in Table.Rows)
                {
                    mOfficialItems.Add(new NavigatorOfficialItem((uint)Row["id"], (uint)Row["parent_id"], (uint)Row["room_id"],
                        (Row["is_category"].ToString() == "1"), (Row["display_type"].ToString() == "details" ?
                        NavigatorOfficialItemDisplayType.Detailed : NavigatorOfficialItemDisplayType.Banner),
                        (string)Row["name"], (string)Row["descr"], (Row["image_type"].ToString() == "internal" ?
                        NavigatorOfficialItemImageType.Internal : NavigatorOfficialItemImageType.External),
                        (string)Row["image_src"], (string)Row["banner_label"], (Row["category_autoexpand"].ToString() == "1")));
                    NumberLoaded++;
                }
            }

            Output.WriteLine("Loaded " + NumberLoaded + " navigator frontpage item(s).", OutputLevel.DebugInformation);
        }
Esempio n. 30
0
 private static void PerformDatabaseCleanup(SqlDatabaseClient MySqlClient)
 {
     MySqlClient.ExecuteNonQuery("UPDATE rooms SET current_users = 0");
     MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent());
     MySqlClient.ExecuteNonQuery("UPDATE room_visits SET timestamp_left = @timestamp WHERE timestamp_left = 0");
     MySqlClient.ExecuteNonQuery("UPDATE characters SET auth_ticket = ''");
     MySqlClient.ExecuteNonQuery("UPDATE characters SET online = '0'");
     MySqlClient.SetParameter("timestamp", UnixTimestamp.GetCurrent());
     MySqlClient.ExecuteNonQuery("UPDATE server_statistics SET sval = @timestamp WHERE skey = 'stamp' LIMIT 1");
     MySqlClient.ExecuteNonQuery("UPDATE server_statistics SET sval = '1' WHERE skey = 'online_state' LIMIT 1");
 }