Example #1
0
        private void cmdUpgrade_Click(object sender, EventArgs e)
        {
            try
            {
                using (OpenFileDialog OFD = new OpenFileDialog())
                {
                    OFD.FileName = "GameSrv.db";
                    OFD.Filter   = "GameSrv.db|GameSrv.db";
                    if (OFD.ShowDialog() == DialogResult.OK)
                    {
                        richTextBox1.Clear();
                        using (RMSQLiteConnection DB = new RMSQLiteConnection(Path.GetDirectoryName(OFD.FileName), Path.GetFileName(OFD.FileName), false))
                        {
                            SQL = "SELECT Value FROM ConfigTbl WHERE Option = '_DBVERSION'";
                            if (DB.ExecuteScalar(SQL).ToString() == "6")
                            {
                                // Values that can be harvested for gamesrv.ini
                                HandleGameSrvDotIni(DB);

                                // Values that can be harvested for logoffprocess.ini (LogoutProcessTbl order by StepNumber)
                                HandleLogOffOrOnProcessDotIni(DB, "off", "out");
                                HandleLogOffOrOnProcessDotIni(DB, "on", "in");

                                // Values that can be harvested for doors
                                HandleDoors(DB);

                                // Values that can be harvested for menus
                                HandleMenus(DB);

                                // Values that can be harvested for users
                                HandleUsers(DB);
                            }
                            else
                            {
                                Dialog.Error("Sorry, that file doesn't appear to be from a GameSrv v10.04.02 install", "Upgrade aborted");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Dialog.Error("Error upgrading: " + ex.Message, "Upgrade failed");
            }
        }
Example #2
0
        private void HandleGameSrvDotIni(RMSQLiteConnection DB)
        {
            AddToLog("Importing settings for gamesrv.ini");
            using (IniFile Ini = new IniFile(StringUtils.PathCombine(ProcessUtils.StartupPath, "config", "gamesrv.ini")))
            {
                string BBSName = DB.ExecuteScalar("SELECT Value FROM ConfigTbl WHERE Option = 'BBSName'").ToString();
                Ini.WriteString("CONFIGURATION", "BBSName", BBSName);
                AddToLog(" - BBSName = " + BBSName);

                string SysopName      = DB.ExecuteScalar("SELECT Value FROM ConfigTbl WHERE Option = 'SysOpName'").ToString();
                string SysopFirstName = SysopName;
                string SysopLastName  = "";
                if (SysopName.Trim().Contains(" "))
                {
                    string[] SysopNameElements = SysopName.Split(' ');
                    SysopFirstName = SysopNameElements[0];
                    SysopLastName  = string.Join(" ", SysopNameElements, 1, SysopNameElements.Length - 1);
                }
                Ini.WriteString("CONFIGURATION", "SysopFirstName", SysopFirstName);
                AddToLog(" - SysopFirstName = " + SysopFirstName);
                Ini.WriteString("CONFIGURATION", "SysopLastName", SysopLastName);
                AddToLog(" - SysopLastName = " + SysopLastName);

                string SysopEmail = DB.ExecuteScalar("SELECT Value FROM ConfigTbl WHERE Option = 'SysOpEmailAddress'").ToString();
                Ini.WriteString("CONFIGURATION", "SysopEmail", SysopEmail);
                AddToLog(" - SysopEmail = " + SysopEmail);

                int FirstNode = Convert.ToInt32(DB.ExecuteScalar("SELECT Value FROM ConfigTbl WHERE Option = 'FirstNode'"));
                int Nodes     = Convert.ToInt32(DB.ExecuteScalar("SELECT Value FROM ConfigTbl WHERE Option = 'Nodes'"));
                int LastNode  = FirstNode + Nodes - 1;
                Ini.WriteString("CONFIGURATION", "FirstNode", FirstNode.ToString());
                AddToLog(" - FirstNode = " + FirstNode.ToString());
                Ini.WriteString("CONFIGURATION", "LastNode", LastNode.ToString());
                AddToLog(" - LastNode = " + LastNode.ToString());

                string TimePerCall = DB.ExecuteScalar("SELECT MinutesPerCall FROM GroupTbl WHERE GroupID = 2").ToString();
                Ini.WriteString("CONFIGURATION", "TimePerCall", TimePerCall);
                AddToLog(" - TimePerCall = " + TimePerCall);

                string NextUserId = DB.ExecuteScalar("SELECT MAX(UserID) + 1 FROM UserTbl").ToString();
                Ini.WriteString("CONFIGURATION", "NextUserId", NextUserId);
                AddToLog(" - NextUserId = " + NextUserId);

                if (DB.ExecuteScalar("SELECT COUNT(*) FROM ServerThreadTbl WHERE ConnectionType = 2").ToString() != "0")
                {
                    string TelnetServerIP = DB.ExecuteScalar("SELECT LocalAddress FROM ServerThreadTbl WHERE ConnectionType = 2 ORDER BY ServerThreadID LIMIT 1").ToString();
                    Ini.WriteString("CONFIGURATION", "TelnetServerIP", TelnetServerIP);
                    AddToLog(" - TelnetServerIP = " + TelnetServerIP);

                    string TelnetServerPort = DB.ExecuteScalar("SELECT LocalPort FROM ServerThreadTbl WHERE ConnectionType = 2 ORDER BY ServerThreadID LIMIT 1").ToString();
                    Ini.WriteString("CONFIGURATION", "TelnetServerPort", TelnetServerPort);
                    AddToLog(" - TelnetServerPort = " + TelnetServerPort);
                }

                if (DB.ExecuteScalar("SELECT COUNT(*) FROM ServerThreadTbl WHERE ConnectionType = 1").ToString() != "0")
                {
                    string RLoginServerIP = DB.ExecuteScalar("SELECT LocalAddress FROM ServerThreadTbl WHERE ConnectionType = 1 ORDER BY ServerThreadID LIMIT 1").ToString();
                    Ini.WriteString("CONFIGURATION", "RLoginServerIP", RLoginServerIP);
                    AddToLog(" - RLoginServerIP = " + RLoginServerIP);

                    string RLoginServerPort = DB.ExecuteScalar("SELECT LocalPort FROM ServerThreadTbl WHERE ConnectionType = 1 ORDER BY ServerThreadID LIMIT 1").ToString();
                    Ini.WriteString("CONFIGURATION", "RLoginServerPort", RLoginServerPort);
                    AddToLog(" - RLoginServerPort = " + RLoginServerPort);
                }

                _PasswordPepper = (chkPlaintextPasswords.Checked) ? "DISABLE" : StringUtils.RandomString(100);
                Ini.WriteString("CONFIGURATION", "PasswordPepper", _PasswordPepper);
                AddToLog(" - PasswordPepper = " + _PasswordPepper);
            }
            AddToLog("");
        }