Exemple #1
0
        public LoginTable addLoginTable(String tableName, string tableColumns)
        {
            LoginTable newTable = new LoginTable(m_Connection, tableName, tableColumns, true);

            m_TableList.Add(newTable);
            return(newTable);
        }
        static void Main(string[] args)
        {
            if (File.Exists("database.db"))
            {
                m_Database = new SQLDatabase("database.db", true);

                m_LoginsTable = m_Database.getLoginTable("logins");
                m_UserTable   = m_Database.getUsersTable("users");
                m_IDTable     = m_Database.getIdTable("ID");
            }
            else
            {
                m_Database = new SQLDatabase("database.db");

                m_LoginsTable = m_Database.addLoginTable("logins",
                                                         "name varchar(20) NOT NULL, " +
                                                         "passwordHash varchar(512) NOT NULL, " +
                                                         "passwordSalt varchar(512) NOT NULL, " +
                                                         "passwordRenewalDate varchar(128) NOT NULL, " +
                                                         "isLoggedIn varchar(8), " +
                                                         "id int NOT NULL");

                m_UserTable = m_Database.addUsersTable("users",
                                                       "name varchar(24) NOT NULL, " +
                                                       "id int NOT NULL, " +
                                                       "securityLevel int NOT NULL");

                m_IDTable = m_Database.addIDTable("ID",
                                                  "name varchar(24) NOT NULL, " +
                                                  "nextID int");

                m_LoginsTable.AddEntry(new string[] { "admin", "J1NF8m6ZRuDcx/5038/xP/zVdHPwg2YEdpOZvEVRFCw=", "IxBicNFzHtBa5GBFOuZTatjPTmVvgQ0JQ5NHwp+BOTI=", DateTime.MaxValue.Date.ToShortDateString(), "false", "0" });
                m_UserTable.AddEntry(new string[] { "admin", "0", "999" });

                m_IDTable.AddIDEntry("next", 1);
            }

            controls = new Controls(m_UserTable, m_LoginsTable);

            Socket serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            // Local address
            serverSocket.Bind(new IPEndPoint(IPAddress.Parse(serverIPAddress), 8500));

            serverSocket.Listen(32);

            bool bQuit = false;

            Console.WriteLine("This is the server!");

            while (!bQuit)
            {
                // When there is a new connection, create a new socket reference
                Socket serverClient = serverSocket.Accept();

                // Start a new thread assigned to this socket
                Thread myThread = new Thread(ReceiveClientProcess);
                myThread.Start(serverClient);

                Thread.Sleep(500);

                // Perform any new connection actions. Log timestamp etc
            }
        }