Exemplo n.º 1
0
        /// <summary>
        /// A namespace-accessible method for
        /// adding a user.
        /// </summary>
        /// <param name="theData">Form information (should contain user data)</param>
        internal static FormData AddUser(FormData theData)
        {
            string nick = theData["nick"];
             if (File.Exists(GetUserFile(nick)))
            throw new BGException("475", new string[] { nick });

             if (nick.Length < minNickLength)
            throw new BGException("477", new string[] { "Nickname", "" + minNickLength });

             if (nick.Length > maxNickLength)
            throw new BGException("478", new string[] { "Nickname", "" + maxNickLength });

             if (GetNotAllowed(nick, nickPattern) != "")
            throw new BGException("476", new string[] { "Nickname", GetNotAllowed(nick, nickPattern) });
             if (!Directory.Exists(WebServer.UserDir)) {
            Directory.CreateDirectory(WebServer.UserDir);
             }

             if (theData["password"] == "" || theData["passCheck"] == "")
            throw new BGException("473", new string[] { });

             theData["addtime"] = DateTime.Now.ToString();

             WriteUserDoc(theData);
             theData.AddValue("MSG", "User <b>'" + Uri.UnescapeDataString(nick +
            "'</b> added successfully.<br>\r\n"));
             return theData;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Places user information into a FormData variable.
        /// </summary>
        /// <param name="userName">User name to look up</param>
        /// <returns>Data for current user or null if user not found</returns>
        internal static FormData GetUserData(string userName)
        {
            string userFile = GetUserFile(userName);
             FormData theData = new FormData();
             if (!File.Exists(userFile)) {
            return theData;
             }
             lock (FileLocker.GetLock(userFile)) {
            XmlTextReader theReader = new XmlTextReader(userFile);

            theReader.MoveToContent();

            while (theReader.Read()) {
               if (theReader.NodeType == XmlNodeType.Element) {
                  theData.AddValue(theReader.Name, theReader.ReadString());
               }
            }
            theReader.Close();
            theReader = null;
             }
             return theData;
        }
Exemplo n.º 3
0
        /// <summary>
        /// A function used to handle GET messages
        /// </summary>
        /// <param name="httpVer">HTTP version</param>
        /// <param name="reqString">Requested File/Directory & input string</param>
        /// <param name="theSocket">Socket to utilize</param>
        private static FormData HandleFormGetMsg(string httpVer, string reqString)
        {
            string[] input = reqString.Substring(reqString.IndexOf('?') + 1).Split('&');
             FormData theData = new FormData();

             for (int i = 0; i < input.Length; i++) {
            theData.AddValue(input[i].Split('=')[0], input[i].Split('=')[1]);
             }

             return theData;
        }