コード例 #1
0
ファイル: loginReactor.cs プロジェクト: habb0/Woodpecker
        /// <summary>
        /// 43 - "@k"
        /// </summary>
        public void REGISTER()
        {
            // The 'receive campaign mail etc' uses a Base64 boolean which is not supported by Woodpecker in this context, fix the request content by raw string replace
            Request.Content = Request.Content.Replace("@JA@A@@IA", ""); // Receive mails ('A' = true)
            Request.Content = Request.Content.Replace("@JA@A@@I@", ""); // Do not receive mails ('@' = false)

            userInformation newUser = new userInformation();

            newUser.Username = Request.getStructuredParameter(2);
            if (ObjectTree.Game.Users.getNameCheckError(false, newUser.Username) > 0)
                return;

            newUser.Password = Request.getStructuredParameter(3);
            if (!stringFunctions.passwordIsValid(newUser.Username, newUser.Password))
                return;
            newUser.Password = ObjectTree.Security.Cryptography.MD5.Hash(newUser.Password, newUser.Username.ToLower()); // Byebye password

            newUser.Figure = Request.getStructuredParameter(4);
            if (newUser.Figure.Length != 25 || !stringFunctions.isNumeric(newUser.Figure))
                return;

            newUser.Sex = 'M';
            if (Request.getStructuredParameter(5) == "F")
                newUser.Sex = 'F';

            newUser.Email = Request.getStructuredParameter(7);
            if (!stringFunctions.emailIsValid(newUser.Email))
                return;

            newUser.DateOfBirth = Request.getStructuredParameter(8);
            if (newUser.DateOfBirth.Split('.').Length != 3)
                return;

            ObjectTree.Game.Users.registerUser(this.Session, newUser);
        }
コード例 #2
0
ファイル: userManager.cs プロジェクト: habb0/Woodpecker
        /// <summary>
        /// Registers a new user by writing the given details into the 'users' table of the database.
        /// </summary>
        /// <param name="Session"></param>
        /// <param name="Info">The information about the new user in a userInformation object.</param>
        public void registerUser(Session Session, userInformation Info)
        {
            Database Database = new Database(false, true);

            Database.addParameterWithValue("username", Info.Username);
            Database.addParameterWithValue("password", Info.Password);
            Database.addParameterWithValue("role", "1");
            Database.addParameterWithValue("figure", Info.Figure);
            Database.addParameterWithValue("sex", Info.Sex.ToString());
            Database.addParameterWithValue("motto", Configuration.getConfigurationValue("users.registration.motto"));
            Database.addParameterWithValue("motto_messenger", Configuration.getConfigurationValue("users.registration.messengermotto"));
            Database.addParameterWithValue("credits", Configuration.getNumericConfigurationValue("users.registration.credits"));
            Database.addParameterWithValue("tickets", Configuration.getNumericConfigurationValue("users.registration.tickets"));
            Database.addParameterWithValue("film", 0);
            Database.addParameterWithValue("email", Info.Email);
            Database.addParameterWithValue("dob", Info.DateOfBirth);

            Database.Open();
            if (Database.Ready)
            {
                //Database.runQuery("CALL register_user(@username,@password,@figure,@sex,@email,@dob,@receivemails)");
                Database.runQuery(
                    "INSERT INTO users " +
                    "(username,password,role,signedup,figure,sex,motto,motto_messenger,credits,tickets,film,lastactivity,club_lastupdate,email,dob) " +
                    "VALUES " +
                    "(@username,@password,@role,NOW(),@figure,@sex,@motto,@motto_messenger,@credits,@tickets,@film,NOW(),NOW(),@email,@dob)");

                Logging.Log("Created user '" + Info.Username + "'.", Logging.logType.userVisitEvent);
            }
            else
            {
                Logging.Log("Failed to create user " + Info.Username + ", because the database was not contactable!", Logging.logType.commonWarning);
            }
        }
コード例 #3
0
        /// <summary>
        /// 43 - "@k"
        /// </summary>
        public void REGISTER()
        {
            // The 'receive campaign mail etc' uses a Base64 boolean which is not supported by Woodpecker in this context, fix the request content by raw string replace
            Request.Content = Request.Content.Replace("@JA@A@@IA", ""); // Receive mails ('A' = true)
            Request.Content = Request.Content.Replace("@JA@A@@I@", ""); // Do not receive mails ('@' = false)

            userInformation newUser = new userInformation();

            newUser.Username = Request.getStructuredParameter(2);
            if (Engine.Game.Users.getNameCheckError(false, newUser.Username) > 0)
            {
                return;
            }

            newUser.Password = Request.getStructuredParameter(3);
            if (!stringFunctions.passwordIsValid(newUser.Username, newUser.Password))
            {
                return;
            }
            newUser.Password = Engine.Security.Cryptography.MD5.Hash(newUser.Password, newUser.Username.ToLower()); // Byebye password

            newUser.Figure = Request.getStructuredParameter(4);
            if (newUser.Figure.Length != 25 || !stringFunctions.isNumeric(newUser.Figure))
            {
                return;
            }

            newUser.Sex = 'M';
            if (Request.getStructuredParameter(5) == "F")
            {
                newUser.Sex = 'F';
            }

            newUser.Email = Request.getStructuredParameter(7);
            if (!stringFunctions.emailIsValid(newUser.Email))
            {
                return;
            }

            newUser.DateOfBirth = Request.getStructuredParameter(8);
            if (newUser.DateOfBirth.Split('.').Length != 3)
            {
                return;
            }

            Engine.Game.Users.registerUser(this.Session, newUser);
            //Session.gameConnection.sendLocalizedError("Registration through the client is not currently supported.");
            //Engine.Sessions.destroySession(Session.ID);
        }
コード例 #4
0
        public userInformation getUserInfo(int userID, bool forceRefresh)
        {
            if (!forceRefresh && mUserSessions.ContainsKey(userID)) // Why load it? :)
            {
                return(mUserSessions[userID].User);
            }

            userInformation returnInfo = new userInformation();
            Database        Database   = new Database(false, true);

            Database.addParameterWithValue("userid", userID);
            Database.Open();

            if (Database.Ready)
            {
                try
                {
                    DataRow dRow = Database.getRow("SELECT username,password,ticket,role,figure,sex,motto,motto_messenger,credits,tickets,film,currentbadge,lastactivity,club_daysleft,club_monthsleft,club_monthsexpired,club_lastupdate,email,dob FROM users WHERE id = @userid");
                    returnInfo.ID                = userID;
                    returnInfo.Username          = (string)dRow["username"];
                    returnInfo.Password          = (string)dRow["password"];
                    returnInfo.Role              = (userRole)(int.Parse(dRow["role"].ToString()));
                    returnInfo.Figure            = (string)dRow["figure"];
                    returnInfo.Sex               = Convert.ToChar(dRow["sex"].ToString());
                    returnInfo.Motto             = (string)dRow["motto"];
                    returnInfo.messengerMotto    = (string)dRow["motto_messenger"];
                    returnInfo.Credits           = (int)dRow["credits"];
                    returnInfo.Tickets           = (int)dRow["tickets"];
                    returnInfo.Film              = (int)dRow["film"];
                    returnInfo.Badge             = (string)dRow["currentbadge"];
                    returnInfo.lastActivity      = (DateTime)dRow["lastactivity"];
                    returnInfo.Email             = (string)dRow["email"];
                    returnInfo.DateOfBirth       = (string)dRow["dob"];
                    returnInfo.clubDaysLeft      = (int)dRow["club_daysleft"];
                    returnInfo.clubMonthsLeft    = (int)dRow["club_monthsleft"];
                    returnInfo.clubMonthsExpired = (int)dRow["club_monthsexpired"];
                    returnInfo.clubLastUpdate    = (DateTime)dRow["club_lastupdate"];
                    returnInfo.SSO               = (string)dRow["ticket"];
                }
                catch { returnInfo = null; }
            }

            return(returnInfo);
        }
コード例 #5
0
        public userInformation getUserInfoByTicket(string ssoTicket)
        {
            userInformation returnInfo = new userInformation();
            Database        Database   = new Database(false, true);

            Database.addParameterWithValue("ticket", ssoTicket);
            Database.Open();

            if (Database.Ready)
            {
                try
                {
                    DataRow dRow = Database.getRow("SELECT * FROM users WHERE ticket = @ticket");
                    returnInfo.ID                = (int)dRow["id"];
                    returnInfo.Username          = (string)dRow["username"];
                    returnInfo.Password          = (string)dRow["password"];
                    returnInfo.Role              = (userRole)(int.Parse(dRow["role"].ToString()));
                    returnInfo.Figure            = (string)dRow["figure"];
                    returnInfo.Sex               = Convert.ToChar(dRow["sex"].ToString());
                    returnInfo.Motto             = (string)dRow["motto"];
                    returnInfo.messengerMotto    = (string)dRow["motto_messenger"];
                    returnInfo.Credits           = (int)dRow["credits"];
                    returnInfo.Tickets           = (int)dRow["tickets"];
                    returnInfo.Film              = (int)dRow["film"];
                    returnInfo.Badge             = (string)dRow["currentbadge"];
                    returnInfo.lastActivity      = (DateTime)dRow["lastactivity"];
                    returnInfo.Email             = (string)dRow["email"];
                    returnInfo.DateOfBirth       = (string)dRow["dob"];
                    returnInfo.clubDaysLeft      = (int)dRow["club_daysleft"];
                    returnInfo.clubMonthsLeft    = (int)dRow["club_monthsleft"];
                    returnInfo.clubMonthsExpired = (int)dRow["club_monthsexpired"];
                    returnInfo.clubLastUpdate    = (DateTime)dRow["club_lastupdate"];
                    returnInfo.SSO               = (string)dRow["ticket"];
                    Logging.Log("SELECT username,password,ticket,role,figure,sex,motto,motto_messenger,credits,tickets,film,currentbadge,lastactivity,club_daysleft,club_monthsleft,club_monthsexpired,club_lastupdate,email,dob FROM users WHERE ticket = " + ssoTicket + ";;");
                    Logging.Log(returnInfo.SSO);
                }
                catch { returnInfo = null; }
            }

            return(returnInfo);
        }
コード例 #6
0
ファイル: userManager.cs プロジェクト: habb0/Woodpecker
        /// <summary>
        /// Returns a boolean indicating if a given user posesses a given badge.
        /// </summary>
        /// <param name="User">The database ID of the user to check.</param>
        /// <param name="Badge">The badge to check.</param>
        public bool userHasBadge(userInformation User, string Badge)
        {
            if ((Badge == "HC1" && User.hasClub) || (Badge == "HC2" && User.hasGoldClub)) // Club badge
            {
                return(true);
            }

            if (ObjectTree.Game.Roles.roleHasBadge(User.Role, Badge)) // Role badge
            {
                return(true);
            }

            // Private badge check
            Database Database = new Database(false, true);

            Database.addParameterWithValue("userid", User.ID);
            Database.addParameterWithValue("badge", Badge);
            Database.Open();

            return(Database.findsResult("SELECT userid FROM users_badges WHERE userid = @userid AND badge = @badge LIMIT 1")); // True if this user has the searched badge as private
        }
コード例 #7
0
ファイル: roomManager.cs プロジェクト: habb0/Woodpecker
        public roomInformation[] getFlatsForUser(userInformation User)
        {
            List<roomInformation> Rooms = new List<roomInformation>();
            Database Database = new Database(false, true);
            Database.addParameterWithValue("ownerid", User.ID);
            Database.Open();

            if (Database.Ready)
            {
                DataTable dTable = Database.getTable("SELECT rooms.*,users.username AS owner FROM rooms LEFT JOIN users ON (rooms.ownerid = users.id) WHERE ownerid = @ownerid");
                foreach (DataRow dRow in dTable.Rows)
                {
                    Rooms.Add(roomInformation.ParseFlat(dRow));
                }
            }

            return Rooms.ToArray();
        }
コード例 #8
0
ファイル: roomManager.cs プロジェクト: habb0/Woodpecker
        /// <summary>
        /// Returns the favorite rooms of a given user as a string.
        /// </summary>
        /// <param name="User">The userInformation object of the user to retrieve the favorite rooms for.</param>
        public string getFavoriteRooms(userInformation User)
        {
            int guestRoomCount = 0;
            StringBuilder Rooms = new StringBuilder();

            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", User.ID);
            Database.Open();
            DataTable dTable = Database.getTable("SELECT rooms.*,users.username AS owner FROM rooms LEFT JOIN users ON rooms.ownerid = users.id WHERE rooms.id IN (SELECT roomid FROM rooms_favorites WHERE userid = @userid) ORDER BY rooms.id DESC LIMIT 30"); // User flats first

            foreach (DataRow dRow in dTable.Rows)
            {
                roomInformation Room = roomInformation.Parse(dRow, true);
                if (Room.isUserFlat)
                    guestRoomCount++;

                Rooms.Append(Room.ToString(User));
            }

            fuseStringBuilder FSB = new fuseStringBuilder();
            FSB.appendWired(guestRoomCount);
            FSB.Append(Rooms.ToString());

            return FSB.ToString();
        }
コード例 #9
0
        /// <summary>
        /// 4 - "@D"
        /// </summary>
        public void TRY_LOGIN()
        {
            string          Username    = Request.getParameter(0);
            userInformation userDetails = Engine.Game.Users.getUserInfo(Username, true);

            if (userDetails == null) // User not found
            {
                Session.gameConnection.sendLocalizedError("login incorrect: Wrong username");
            }
            else
            {
                string Password = Request.getParameter(1);
                Password = Engine.Security.Cryptography.MD5.Hash(Password, userDetails.Username.ToLower()); // Hash the password

                if (userDetails.Password == Password)                                                       // All details match!
                {
                    Session.User = userDetails;
                    userDetails  = null;

                    string banReason = "";
                    if (Engine.Game.Moderation.isBanned(Session.User.ID, out banReason))
                    {
                        Session.isValid = false;
                        Session.gameConnection.sendMessage(genericMessageFactory.createBanCast(banReason));
                        return;
                    }

                    Engine.Sessions.destroySessions(Session.User.ID); // Destroy previous sessions

                    Session.User.sessionID = Session.ID;
                    Session.Access.userID  = Session.User.ID;
                    Session.Access.Update();
                    Session.User.updateLastActivity();
                    Session.User.updateClub(false);

                    Session.gameConnection.reactorHandler.unRegister(new loginReactor().GetType()); // Unregister the login reactor
                    Engine.Game.Users.addUserSession(this.Session);
                    Session.gameConnection.reactorHandler.Register(new userReactor());              // Register a userReactor
                    Session.gameConnection.reactorHandler.Register(new storeReactor());             // Register a storeReactor
                    Session.gameConnection.reactorHandler.Register(new navigatorReactor());         // Register a navigatorReactor
                    Session.gameConnection.reactorHandler.Register(new arcadeReactor());            // Register an arcadeReactor
                    if (Session.User.hasFuseRight("fuse_moderator_access"))
                    {
                        Session.gameConnection.reactorHandler.Register(new moderationReactor());
                    }

                    Session.refreshFuseRights();

                    Response.Initialize(3); // "@C" (login OK)
                    sendResponse();

                    if (Session.User.hasClub)
                    {
                        Session.refreshFigureParts();
                    }

                    Session.itemStripHandler = new itemStripHandler(Session.User.ID); // Load hand items etc

                    Logging.Log("User '" + Session.User.Username + "' [id: " + Session.User.ID + "] with role '" + Session.User.Role.ToString() + "' logged in.", Logging.logType.userVisitEvent);
                    return;
                }
                else
                {
                    Session.gameConnection.sendLocalizedError("login incorrect: Wrong password");
                }
            }
            //Session.gameConnection.sendLocalizedError("Login through the client is not currently supported.");
            //Engine.Sessions.destroySession(Session.ID);
        }
コード例 #10
0
ファイル: Session.cs プロジェクト: habb0/Woodpecker
        /// <summary>
        /// Destroys the session and clears up all used resources.
        /// </summary>
        public void Destroy()
        {
            if (this.isHoldingUser)
            {
                ObjectTree.Game.Users.removeUserSession(this.User.ID);
                this.leaveRoom(false);
                this.User = null;

                this.itemStripHandler.saveHandItems();
                this.itemStripHandler.Clear();
                this.itemStripHandler = null;
            }
            this.gameConnection.Abort();
            this.gameConnection = null;
        }
コード例 #11
0
ファイル: userManager.cs プロジェクト: habb0/Woodpecker
        /// <summary>
        /// Returns a boolean indicating if a given user posesses a given badge.
        /// </summary>
        /// <param name="User">The database ID of the user to check.</param>
        /// <param name="Badge">The badge to check.</param>
        public bool userHasBadge(userInformation User, string Badge)
        {
            if ((Badge == "HC1" && User.hasClub) || (Badge == "HC2" && User.hasGoldClub)) // Club badge
                return true;

            if (ObjectTree.Game.Roles.roleHasBadge(User.Role, Badge)) // Role badge
                return true;

            // Private badge check
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", User.ID);
            Database.addParameterWithValue("badge", Badge);
            Database.Open();

            return Database.findsResult("SELECT userid FROM users_badges WHERE userid = @userid AND badge = @badge LIMIT 1"); // True if this user has the searched badge as private
        }
コード例 #12
0
ファイル: userManager.cs プロジェクト: habb0/Woodpecker
        /// <summary>
        /// Registers a new user by writing the given details into the 'users' table of the database.
        /// </summary>
        /// <param name="Session"></param>
        /// <param name="Info">The information about the new user in a userInformation object.</param>
        public void registerUser(Session Session, userInformation Info)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("username", Info.Username);
            Database.addParameterWithValue("password", Info.Password);
            Database.addParameterWithValue("role", "1");
            Database.addParameterWithValue("figure", Info.Figure);
            Database.addParameterWithValue("sex", Info.Sex.ToString());
            Database.addParameterWithValue("motto", Configuration.getConfigurationValue("users.registration.motto"));
            Database.addParameterWithValue("motto_messenger", Configuration.getConfigurationValue("users.registration.messengermotto"));
            Database.addParameterWithValue("credits", Configuration.getNumericConfigurationValue("users.registration.credits"));
            Database.addParameterWithValue("tickets", Configuration.getNumericConfigurationValue("users.registration.tickets"));
            Database.addParameterWithValue("film", 0);
            Database.addParameterWithValue("email", Info.Email);
            Database.addParameterWithValue("dob", Info.DateOfBirth);

            Database.Open();
            if (Database.Ready)
            {
                //Database.runQuery("CALL register_user(@username,@password,@figure,@sex,@email,@dob,@receivemails)");
                Database.runQuery(
                    "INSERT INTO users " +
                    "(username,password,role,signedup,figure,sex,motto,motto_messenger,credits,tickets,film,lastactivity,club_lastupdate,email,dob) " +
                    "VALUES " +
                    "(@username,@password,@role,NOW(),@figure,@sex,@motto,@motto_messenger,@credits,@tickets,@film,NOW(),NOW(),@email,@dob)");

                Logging.Log("Created user '" + Info.Username + "'.", Logging.logType.userVisitEvent);
            }
            else
                Logging.Log("Failed to create user " + Info.Username + ", because the database was not contactable!", Logging.logType.commonWarning);
        }
コード例 #13
0
ファイル: userManager.cs プロジェクト: habb0/Woodpecker
        public userInformation getUserInfo(int userID, bool forceRefresh)
        {
            if (!forceRefresh && _userSessions.ContainsKey(userID)) // Why load it? :)
                return _userSessions[userID].User;

            userInformation returnInfo = new userInformation();
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", userID);
            Database.Open();

            if (Database.Ready)
            {
                try
                {
                    DataRow dRow = Database.getRow("SELECT username,password,role,figure,sex,motto,motto_messenger,credits,tickets,film,currentbadge,lastactivity,club_daysleft,club_monthsleft,club_monthsexpired,club_lastupdate,email,dob FROM users WHERE id = @userid");
                    returnInfo.ID = userID;
                    returnInfo.Username = (string)dRow["username"];
                    returnInfo.Password = (string)dRow["password"];
                    returnInfo.Role = (userRole)(int.Parse(dRow["role"].ToString()));
                    returnInfo.Figure = (string)dRow["figure"];
                    returnInfo.Sex = Convert.ToChar(dRow["sex"].ToString());
                    returnInfo.Motto = (string)dRow["motto"];
                    returnInfo.messengerMotto = (string)dRow["motto_messenger"];
                    returnInfo.Credits = (int)dRow["credits"];
                    returnInfo.Tickets = (int)dRow["tickets"];
                    returnInfo.Film = (int)dRow["film"];
                    returnInfo.Badge = (string)dRow["currentbadge"];
                    returnInfo.lastActivity = (DateTime)dRow["lastactivity"];
                    returnInfo.Email = (string)dRow["email"];
                    returnInfo.DateOfBirth = (string)dRow["dob"];
                    returnInfo.clubDaysLeft = (int)dRow["club_daysleft"];
                    returnInfo.clubMonthsLeft = (int)dRow["club_monthsleft"];
                    returnInfo.clubMonthsExpired = (int)dRow["club_monthsexpired"];
                    returnInfo.clubLastUpdate = (DateTime)dRow["club_lastupdate"];
                }
                catch { returnInfo = null; }
            }

            return returnInfo;
        }
コード例 #14
0
ファイル: messengerManager.cs プロジェクト: habb0/Woodpecker
        /// <summary>
        /// Writes a buddy request from a given user to another user into the database, and notifies the receiver with the new request if it's online.
        /// </summary>
        /// <param name="User">The userInformation object of the user that sends the request.</param>
        /// <param name="userID2">The database ID of the receiving user.</param>
        public void requestBuddy(userInformation User, int userID2)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", User.ID);
            Database.addParameterWithValue("userid2", userID2);
            Database.Open();
            Database.runQuery("INSERT INTO messenger_buddylist(userid,buddyid) VALUES (@userid,@userid2)");

            if (ObjectTree.Game.Users.userIsLoggedIn(userID2)) // Receiver is online
            {
                serverMessage Message = new serverMessage(132); // "BD"
                Message.appendWired(User.ID);
                Message.appendClosedValue(User.Username);

                ObjectTree.Game.Users.trySendGameMessage(userID2, Message);
            }
        }
コード例 #15
0
ファイル: messengerManager.cs プロジェクト: habb0/Woodpecker
 /// <summary>
 /// Returns the max amount of buddies a given user can have on his buddy list for the messenger. The user's role and club subscription is being checked.
 /// </summary>
 /// <param name="User">The userInformation object containing the values to calculate the length with.</param>
 public int getMaxBuddyListLength(userInformation User)
 {
     if (User.hasFuseRight("fuse_extended_buddylist"))
         return this._maxBuddyListLength_Extended;
     else
         return this._maxBuddyListLength;
 }
コード例 #16
0
ファイル: roomInformation.cs プロジェクト: habb0/Woodpecker
        /// <summary>
        /// Parses the generic roomInformation object to a room information string.
        /// </summary>
        /// <param name="viewingUser">The userInformation object of the user that requests the flat information string.</param>
        public string ToString(userInformation viewingUser)
        {
            fuseStringBuilder FSB = new fuseStringBuilder();
            FSB.appendWired(this.ID); // Room ID
            if (!this.isUserFlat) // Public space flag
                FSB.appendWired(true);

            FSB.appendClosedValue(this.Name); // Room name

            if (this.isUserFlat) // User flat
            {
                if (this.showOwner || this.ownerID == viewingUser.ID || viewingUser.hasFuseRight("fuse_see_all_roomowners"))
                    FSB.appendClosedValue(this.Owner);
                else
                    FSB.Append("-");
                FSB.appendClosedValue(this.accessType.ToString());
            }

            FSB.appendWired(this.currentVisitors);
            FSB.appendWired(this.maxVisitors);

            if (!this.isUserFlat)
                FSB.appendWired(this.categoryID);

            FSB.appendClosedValue(this.Description);
            if (!this.isUserFlat)
            {
                FSB.appendWired(this.ID);
                FSB.appendWired(false);
                FSB.appendClosedValue(this.CCTs);
                FSB.appendWired(false);
                FSB.appendWired(true);
            }

            return FSB.ToString();
        }