コード例 #1
0
ファイル: User.cs プロジェクト: najosky/DarkEdenNetworkSite
        public override int GetHashCode()
        {
            int prime  = 31;
            int result = 1;

            result = prime * result + Id.BitShiftThenBitOr(prime);
            result = prime * result + Name.StringToInt().BitShiftThenBitOr(prime);
            result = prime * result + Gender.GenderToInt().BitShiftThenBitOr(prime);
            result = prime * result + BirthDate.DateToInt().BitShiftThenBitOr(prime);
            result = prime * result + Email.StringToInt().BitShiftThenBitOr(prime);
            result = prime * result + Phone.StringToInt().BitShiftThenBitOr(prime);
            result = prime * result + ZipCode.BitShiftThenBitOr(prime);
            result = prime * result + Address.StringToInt().BitShiftThenBitOr(prime);
            result = prime * result + UserName.StringToInt().BitShiftThenBitOr(prime);
            result = prime * result + Password.StringToInt().BitShiftThenBitOr(prime);
            result = prime * result + Pin.BitShiftThenBitOr(prime);
            result = prime * result + LoginIP.StringToInt().BitShiftThenBitOr(prime);
            result = prime * result + MacAddress.StringToInt().BitShiftThenBitOr(prime);
            result = prime * result + StartingDate.DateToInt().BitShiftThenBitOr(prime);
            result = prime * result + Access.AccessToInt().BitShiftThenBitOr(prime);
            result = prime * result + AccountPriority.AccountPriorityToInt().BitShiftThenBitOr(prime);
            result = prime * result + MembershipType.MembershipToInt().BitShiftThenBitOr(prime);
            result = prime * result + Email.StringToInt().BitShiftThenBitOr(prime);
            result = prime * result + BirthDate.ToString().StringToInt().BitShiftThenBitOr(prime);
            result = prime * result + LastLogin.DateToInt().BitShiftThenBitOr(prime);
            result = prime * result + LastLogout.DateToInt().BitShiftThenBitOr(prime);
            result = prime * result + Age.BitShiftThenBitOr(prime);
            return(result);
        }
コード例 #2
0
    public string insertLastLogin(LastLogin dataInsert)
    {
        string response = "";

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "";

        sql = "Insert Into LASTLOGIN(USER_ID, LAST_LOGIN_DATE) Values('" + dataInsert.User_Id + "','" + dataInsert.Last_Login_Date + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
        }
        return(response);
    }
コード例 #3
0
        public bool Handle(UpdateLastLoginTimestampCommand cmd)
        {
            var thisTime = DateTime.UtcNow;

            LastLogin = thisTime;

            return(LastLogin.Equals(thisTime));
        }
コード例 #4
0
        public void LastLoginClassTest()
        {
            // Arrange & Act
            LastLogin lastLogin = new LastLogin();

            //Assert
            Assert.IsNotNull(lastLogin);
        }
コード例 #5
0
        public void Save()
        {
            Logger.Log("Saving " + Username + " to the database", LogType.Debug);
            List <string> commands = new List <string>();

            commands.Add("UPDATE _players SET money=" + Money + ", lastlogin='******', firstlogin='******' WHERE UID=" + UID);
            commands.Add("UPDATE _players SET color='" + Color.SqlEscape() + "' WHERE UID=" + UID);
            DataSaved.Call(this, new DataSavedEventArgs(UID));
            Database.executeQuery(commands.ToArray());
        }
コード例 #6
0
        private void Update()
        {
            var user = GetUserEntity(UserId, _context);

            user.SetAttributeValue(AttributeMapApproved, Approved);
            user.SetAttributeValue(AttributeMapLastLogin, LastLogin.ToUniversalTime());

            _context.Attach(user);
            _context.UpdateObject(user);
            _context.SaveChanges();
            _context.Detach(user);
        }
コード例 #7
0
        public LoginForm()
        {
            InitializeComponent();
            var lastLogin = LastLogin.GetLastLogin();

            if (lastLogin != null)
            {
                usernameTextBox.Text       = lastLogin.Username;
                passwordTextBox.Text       = lastLogin.Password;
                rememberMeCheckBox.Checked = true;
            }
        }
コード例 #8
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (!Directory.Exists(location))
            {
                Directory.CreateDirectory(location);
            }


            //CONSOLE
            _writer = new ConsoleStringWriter(this);
            Console.SetOut(_writer);
            //END CONSOLE

            //SETTINGS
            lastLogin = new LastLogin();

            if (File.Exists(Path.Combine(location, "lastlogin")))
            {
                String[] lastLoginData = lastLogin.GetLastLogin();
                userText.Text = lastLoginData[0];
                passText.Text = lastLoginData[1];
            }

            try
            {
                FileStream stream = new FileStream(location + "settings", FileMode.Open);
                optionRememberBox.Checked = Convert.ToBoolean(stream.ReadByte());
                optionConsoleBox.Checked  = Convert.ToBoolean(stream.ReadByte());
            }
            catch (Exception) { }
            //END SETTINGS

            //SERVER STATUS
            status = new ServerStatus(this);
            //END SERVER STATUS

            //NEM
            nemQuery = new QueryNEM(this);
            //END NEM

            //VERSIONLIST
            versionList = new VersionList(this);
            //END VERSIONLIST

            //OLD REPO
            repo = new Repo.QueryRepo(this);
            //END OLD REPO

            //TECHNIC PLATFORM
            technicDefaultPacks = new TechnicDefaultPacks(this);
        }
コード例 #9
0
    public LastLogin getLastLogin(string UserId)
    {
        LastLogin userData = new LastLogin();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        oracleObj.SelectCommand = "Select * From LASTLOGIN Where USER_ID='" + UserId + "'";
        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            userData.User_Id         = rowData["USER_ID"].ToString();
            userData.Last_Login_Date = rowData["LAST_LOGIN_DATE"].ToString();
        }

        return(userData);
    }
コード例 #10
0
        private bool inspection_Login()
        {
            bool flag = false;

            if (!isLogin)
            {
                LastLogin = Login;
                isLogin   = !isLogin;
            }
            if (tbLogin.Text.Length >= 4)
            {
                btnOK.Enabled = inspection(Login);

                using (var sConn = new NpgsqlConnection(sb.ToString()))
                {
                    sConn.Open();
                    var selectLogin = new NpgsqlCommand
                    {
                        Connection  = sConn,
                        CommandText = @"SELECT count(*) FROM users WHERE users.login = @Login"
                    };
                    selectLogin.Parameters.AddWithValue("@Login", Login.ToLowerInvariant());
                    int m = Int32.Parse(selectLogin.ExecuteScalar().ToString().Trim());
                    if (m == 1 && Login.ToLower() != LastLogin.ToLower() && btnOK.Text == "Изменить" || m == 1 && btnOK.Text == "Добавить")
                    {
                        //логин занят
                        epMain.SetError(tbLogin, "К сожалению, логин занят");
                    }
                    else
                    {
                        //логин свободен
                        epMain.SetError(tbLogin, "");
                        flag = true;
                    }
                }
            }
            else
            {
                epMain.SetError(tbLogin, "Логин должен быть от 4 до 15, состоящий из букв, цифр, знаков тире и подчеркивания");
                flag = false;
            }
            return(flag);
        }
コード例 #11
0
        /// <summary>
        /// Save or update records for the table
        /// </summary>
        /// <param name="listDataLastLogin">List of data to store LastLogin.</param>
        /// <returns>The result of processing the list.</returns>
        /// <author>Mauricio Suárez.</author>
        public bool SaveLastLogin(List <LastLoginDto> listLastLoginDto)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())
            {
                ObjectContext         objectContext = ((IObjectContextAdapter)context).ObjectContext;
                ObjectSet <LastLogin> set           = objectContext.CreateObjectSet <LastLogin>();
                string[] entityOrderDetailKeys      = set.EntitySet.ElementType.KeyMembers.Select(k => k.Name).ToArray();

                bool[] resultValidateInsertOrUpdate = ConditionalQuery.ValidatePrimaryKeyValueInDto(listLastLoginDto, entityOrderDetailKeys);

                int resultValidateInsertOrUpdateCount = resultValidateInsertOrUpdate.Count();

                int i = 0;
                foreach (LastLoginDto dtoLastLogin in listLastLoginDto)
                {
                    if (resultValidateInsertOrUpdateCount > 0)
                    {
                        LastLogin entityOrderDetail = null;
                        if (resultValidateInsertOrUpdate[i])
                        {
                            entityOrderDetail = Mapper.Map <LastLoginDto, LastLogin>(dtoLastLogin);
                            context.Entry(entityOrderDetail).State = System.Data.Entity.EntityState.Modified;
                            context.LastLogin.Attach(entityOrderDetail);
                        }
                        else
                        {
                            context.LastLogin.Add(Mapper.Map <LastLoginDto, LastLogin>(dtoLastLogin));
                        }
                    }
                    else
                    {
                        context.LastLogin.Add(Mapper.Map <LastLoginDto, LastLogin>(dtoLastLogin));
                    }
                    i++;
                }

                context.SaveChanges();
            }

            return(true);
        }
コード例 #12
0
        public void save()
        {
            OnSQLSaveEvent.Call(this);
            if (cancelmysql)
            {
                cancelmysql = false; return;
            }

            // Player disconnected before SQL data was retrieved
            if (!gotSQLData)
            {
                return;
            }
            long blocks = PlayerData.Pack(TotalPlaced, TotalModified);
            long drawn  = PlayerData.Pack(TotalDeleted, TotalDrawn);

            Database.UpdateRows("Players", "IP=@0, LastLogin=@1, totalLogin=@2, totalDeaths=@3, Money=@4, " +
                                "totalBlocks=@5, totalCuboided=@6, totalKicked=@7, TimeSpent=@8, Messages=@9", "WHERE Name=@10",
                                ip, LastLogin.ToString(Database.DateFormat),
                                TimesVisited, TimesDied, money, blocks,
                                drawn, TimesBeenKicked, (long)TotalTime.TotalSeconds, TotalMessagesSent, name);
        }
コード例 #13
0
    public string updateLastLogin(LastLogin updateData)
    {
        string        response  = "";
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "Update LASTLOGIN Set LAST_LOGIN_DATE='" + updateData.Last_Login_Date + "' Where USER_ID='" + updateData.User_Id + "'";

        oracleObj.UpdateCommand = sql;

        try
        {
            if (oracleObj.Update() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString() + " ";
        }

        return(response);
    }
コード例 #14
0
ファイル: Reference.cs プロジェクト: AlineGuan/odata.net
 public void AddToLastLogin(LastLogin lastLogin)
 {
     base.AddObject("LastLogin", lastLogin);
 }
コード例 #15
0
ファイル: Reference.cs プロジェクト: AlineGuan/odata.net
 public static LastLogin CreateLastLogin(string username, global::System.DateTimeOffset loggedIn, global::System.TimeSpan duration)
 {
     LastLogin lastLogin = new LastLogin();
     lastLogin.Username = username;
     lastLogin.LoggedIn = loggedIn;
     lastLogin.Duration = duration;
     return lastLogin;
 }
コード例 #16
0
     public override string ToString()
     {
         return($@"
 <customer customer-no=""{CustomerId}""> 
     <credentials>
         <login>{Email}</login>
         <password encrypted=""false"">{Password}</password>
         <enabled-flag>true</enabled-flag>
         <password-question />
         <password-answer />
     </credentials>
     <profile>
         <salutation/>
         <title>{Title}</title>
         <first-name>{FirstName}</first-name>
         <second-name/>
         <last-name>{LastName}</last-name>
         <suffix/>
         <company-name>{CompanyName}</company-name>
         <job-title/>
         <email>{Email}</email>
         <phone-home>{Phone}</phone-home>
         <phone-business>{PhoneWork}</phone-business>
         <phone-mobile/>
         <fax>{Fax}</fax>
         <gender></gender>
         <creation-date>{CreationDate.ToUniversalTime().ToString("yyy-MM-ddTHH:mm:ssZ")}</creation-date>
         <last-login-time>{LastLogin.ToUniversalTime().ToString("yyy-MM-ddTHH:mm:ssZ")}</last-login-time>
         <last-visit-time>{LastLogin.ToUniversalTime().ToString("yyy-MM-ddTHH:mm:ssZ")}</last-visit-time>
         <preferred-locale/>
         <custom-attributes>
             <custom-attribute attribute-id=""priceLevel"">{GetPriceLevel}</custom-attribute>
         </custom-attributes>
     </profile>
     <addresses>
         <address address-id=""Billing"" preferred=""true"">
             <salutation/>
             <title/>
             <first-name>{AttentionFirstName}</first-name>
             <second-name>{AttentionSecondName}</second-name>
             <last-name>{AttentionLastName}</last-name>
             <suffix/>
             <company-name>{CompanyName}</company-name>
             <job-title/>
             <address1>{Address}</address1>
             <address2>{Address2}</address2>
             <suite/>
             <postbox/>
             <city>{City}</city>
             <postal-code>{PostalCode}</postal-code>
             <state-code>{StateAbbrev}</state-code>
             <country-code>US</country-code>
             <phone>{Phone}</phone>
         </address>
         <address address-id=""Shipping"" preferred=""false"">
             <salutation/>
             <title/>
             <first-name>{ShippingAttentionFirstName}</first-name>
             <second-name>{ShippingAttentionSecondName}</second-name>
             <last-name>{ShippingAttentionLastName}</last-name>
             <suffix/>
             <company-name>{Shipping_CompanyName}</company-name>
             <job-title/>
             <address1>{Shipping_Address}</address1>
             <address2>{Shipping_Address2}</address2>
             <suite/>
             <postbox/>
             <city>{Shipping_City}</city>
             <postal-code>{Shipping_PostalCode}</postal-code>
             <state-code>{Shipping_StateAbbrev}</state-code>
             <country-code>US</country-code>
             <phone>{Shipping_Phone}</phone>
         </address>
     </addresses>
     <note/>
 </customer>");
     }
コード例 #17
0
        public override string ToString()
        {
            const string oddelovac = MujSystem.oddelovac;
            string       s         = JeAdmin.ToString() + oddelovac + Username + oddelovac + HesloHash + oddelovac + Jmeno + oddelovac + Prijmeni + oddelovac + LastLogin.ToString() + oddelovac + ChciNoveHeslo.ToString();

            return(s);
        }
コード例 #18
0
ファイル: User.cs プロジェクト: khnatovska/ShkolaSoftheme
 public string GetLastLogin()
 {
     return(LastLogin.ToString());
 }
コード例 #19
0
        private void AutoHangarWorker(Hangar Plugin)
        {
            //Significant performance increase
            if (MySession.Static.Ready)
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();

                List <MyCubeGrid> ExportedGrids          = new List <MyCubeGrid>();
                List <MyIdentity> ExportPlayerIdentities = new List <MyIdentity>();

                Hangar.Debug("AutoHangar: Getting Players!");
                var PlayerIdentities = MySession.Static.Players.GetAllIdentities().OfType <MyIdentity>();


                foreach (MyIdentity player in PlayerIdentities)
                {
                    if (player == null)
                    {
                        continue;
                    }

                    DateTime LastLogin;
                    LastLogin = player.LastLoginTime;

                    ulong SteamID = MySession.Static.Players.TryGetSteamId(player.IdentityId);
                    if (LastLogin.AddDays(Plugin.Config.AutoHangarDayAmount) < DateTime.Now)
                    {
                        //AutoHangarBlacklist
                        if (!Plugin.Config.AutoHangarPlayerBlacklist.Any(x => x.SteamID == SteamID))
                        {
                            ExportPlayerIdentities.Add(player);
                        }
                    }
                }

                Hangar.Debug("AutoHangar: Total players to check-" + ExportPlayerIdentities.Count());
                int GridCounter = 0;

                //This gets all the grids
                foreach (MyIdentity player in ExportPlayerIdentities)
                {
                    ulong id = 0;
                    try
                    {
                        id = MySession.Static.Players.TryGetSteamId(player.IdentityId);
                    }
                    catch
                    {
                        Hangar.Debug("Identitiy doesnt have a SteamID! Shipping!");
                        continue;
                    }


                    if (id == 0)
                    {
                        //Sanity check
                        continue;
                    }

                    GridMethods methods = new GridMethods(id, Plugin.Config.FolderDirectory);
                    //string path = GridMethods.CreatePathForPlayer(Config.FolderDirectory, id);

                    if (!methods.LoadInfoFile(out PlayerInfo Data))
                    {
                        return;
                    }



                    ConcurrentBag <List <MyCubeGrid> > gridGroups = GridFinder.FindGridList(player.IdentityId, false);
                    if (gridGroups.Count == 0)
                    {
                        continue;
                    }


                    long LargestGridID = 0;

                    if (Plugin.Config.KeepPlayersLargestGrid)
                    {
                        //First need to find their largets grid
                        int BlocksCount = 0;

                        foreach (List <MyCubeGrid> grids in gridGroups)
                        {
                            int        GridBlockCounts        = 0;
                            int        LargestSingleGridCount = 0;
                            MyCubeGrid LargetsGrid            = grids[0];
                            foreach (MyCubeGrid grid in grids)
                            {
                                if (grid.BlocksCount > LargestSingleGridCount)
                                {
                                    LargestSingleGridCount = grid.BlocksCount;
                                    LargetsGrid            = grid;
                                }
                            }

                            GridBlockCounts = LargetsGrid.BlocksCount;

                            if (GridBlockCounts > BlocksCount)
                            {
                                BlocksCount   = GridBlockCounts;
                                LargestGridID = LargetsGrid.EntityId;
                            }
                        }
                    }



                    foreach (List <MyCubeGrid> grids in gridGroups)
                    {
                        if (grids.Count == 0)
                        {
                            continue;
                        }


                        if (grids[0].IsRespawnGrid && Plugin.Config.DeleteRespawnPods)
                        {
                            grids[0].Close();
                            continue;
                        }


                        Result result = new Result();
                        result.grids = grids;

                        var BiggestGrid = grids[0];
                        foreach (MyCubeGrid grid in grids)
                        {
                            if (grid.BlocksCount > BiggestGrid.BlocksCount)
                            {
                                BiggestGrid = grid;
                            }
                        }


                        if (Plugin.Config.KeepPlayersLargestGrid)
                        {
                            if (BiggestGrid.EntityId == LargestGridID)
                            {
                                //Skip players largest grid
                                continue;
                            }
                        }


                        //Grid Size Checks
                        if (BiggestGrid.GridSizeEnum == MyCubeSize.Large)
                        {
                            if (BiggestGrid.IsStatic && !Plugin.Config.AutoHangarStaticGrids)
                            {
                                continue;
                            }
                            else if (!BiggestGrid.IsStatic && !Plugin.Config.AutoHangarLargeGrids)
                            {
                                continue;
                            }
                        }
                        else if (BiggestGrid.GridSizeEnum == MyCubeSize.Small && !Plugin.Config.AutoHangarSmallGrids)
                        {
                            continue;
                        }



                        result.biggestGrid = BiggestGrid;
                        result.GetGrids    = true;

                        //Check for existing grid names
                        Utils.FormatGridName(Data, result);



                        if (methods.SaveGrids(result.grids, result.GridName, Plugin))
                        {
                            //Load player file and update!
                            //Fill out grid info and store in file
                            HangarChecks.GetBPDetails(result, Plugin.Config, out GridStamp Grid);

                            Grid.GridName = result.GridName;
                            Data.Grids.Add(Grid);


                            GridCounter++;
                            Hangar.Debug(result.biggestGrid.DisplayName + " was sent to Hangar due to inactivity!");
                        }
                        else
                        {
                            Hangar.Debug(result.biggestGrid.DisplayName + " FAILED to Hangar due to inactivity!");
                        }
                    }

                    //Save players file!
                    methods.SaveInfoFile(Data);
                }
                stopWatch.Stop();
                TimeSpan ts = stopWatch.Elapsed;

                Hangar.Debug("AutoHangar: Finished Hangaring -" + GridCounter + " grids! Action took: " + ts.ToString());
            }
        }
コード例 #20
0
 private void loginButton_Click(object sender, EventArgs e)
 {
     loginButton.Enabled = false;
     Task.Factory.StartNew(() =>
     {
         try
         {
             Program.Session = Session.DoLogin(usernameTextBox.Text, passwordTextBox.Text);
             // Login successful
             if (rememberMeCheckBox.Checked)
             {
                 var lastLogin      = new LastLogin();
                 lastLogin.Username = usernameTextBox.Text;
                 lastLogin.Password = passwordTextBox.Text;
                 LastLogin.SetLastLogin(lastLogin);
             }
             else
             {
                 if (File.Exists(LastLogin.LastLoginFile))
                 {
                     File.Delete(LastLogin.LastLoginFile);
                 }
             }
             if (this.InvokeRequired)
             {
                 this.Invoke(new Action(Close));
             }
             else
             {
                 this.Close();
             }
         }
         catch (UnauthorizedAccessException ex)
         {
             if (MessageBox.Show(ex.Message + Environment.NewLine +
                                 "Would you like to use offline mode?", "Login Error", MessageBoxButtons.YesNo)
                 == DialogResult.Yes)
             {
                 Program.Session = new Session(usernameTextBox.Text);
                 if (this.InvokeRequired)
                 {
                     this.Invoke(new Action(Close));
                 }
                 else
                 {
                     this.Close();
                 }
             }
             else
             {
                 if (loginButton.InvokeRequired)
                 {
                     loginButton.Invoke(new Action(() => loginButton.Enabled = true));
                 }
                 else
                 {
                     loginButton.Enabled = true;
                 }
             }
         }
         catch (Exception ex)
         {
         }
     });
 }
コード例 #21
0
    void InitializeButtons()
    {
        arr = new char[4];
        if (PlayerPrefs.HasKey("DataStream"))
        {
            arr = PlayerPrefs.GetString("DataStream").ToCharArray();

            CurrentTime = DateTime.Now;
            if (PlayerPrefs.HasKey("LastLogin"))
            {
                for (int i = 0; i < 4; i++)
                {
                    MakeButtonsInteractive(i, false);
                }
                if (arr[0] == '0')
                {
                    MakeButtonsInteractive(0, true);
                }
                if (arr[1] == '0')
                {
                    MakeButtonsInteractive(1, true);
                }
                if (arr[2] == '0')
                {
                    MakeButtonsInteractive(2, true);
                }
                if (arr[3] == '0')
                {
                    MakeButtonsInteractive(3, true);
                }
                if (arr[0] == '1' || arr[1] == '1' || arr[2] == '1' || arr[3] == '1')
                {
                    LastLogin = DateTime.Parse(PlayerPrefs.GetString("LastLogin"), System.Globalization.CultureInfo.CurrentCulture);
                    Debug.Log(LastLogin.ToString());

                    if (DateTime.Compare(LastLogin.Date, CurrentTime.Date) < 0)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            MakeButtonsInteractive(i, true);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            MakeButtonsInteractive(i, false);
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < 4; i++)
                {
                    MakeButtonsInteractive(i, true);
                }
            }
        }
        else
        {
            for (int i = 0; i < 4; i++)
            {
                MakeButtonsInteractive(i, true);
            }
        }
    }
コード例 #22
0
 private void UserControl1_Load(object sender, EventArgs e)
 {
     UCNameLbl.Text       = StudentName + " " + StudentSurname;
     UCLastLoginLbl.Text  = LastLogin.ToShortDateString();
     UCProfilePhoto.Image = Image;
 }
コード例 #23
0
        public void Load()
        {
            Logger.Log("Loading " + Username + " from the database", LogType.Debug);
            DataTable playerdb = Database.fillData("SELECT * FROM _players WHERE Name='" + Username.SqlEscape() + "'");

            if (playerdb.Rows.Count == 0)
            {
                FirstLogin = DateTime.Now;
                LastLogin  = DateTime.Now;
                Money      = 0;
                Database.executeQuery("INSERT INTO _players (Name, IP, firstlogin, lastlogin, money, color) VALUES ('" + Username.SqlEscape() + "', '" + Ip.SqlEscape() + "', '" + FirstLogin.ToString("yyyy-MM-dd HH:mm:ss").SqlEscape() + "', '" + LastLogin.ToString("yyyy-MM-dd HH:mm:ss").SqlEscape() + "', 0, '" + Color.SqlEscape() + "')");
                DataTable temp = Database.fillData("SELECT * FROM _players WHERE Name='" + Username.SqlEscape() + "'");
                if (temp.Rows.Count != 0)
                {
                    UID = int.Parse(temp.Rows[0]["UID"].ToString());
                }
                temp.Dispose();
            }
            else
            {
                UID        = int.Parse(playerdb.Rows[0]["UID"].ToString());
                FirstLogin = DateTime.Parse(playerdb.Rows[0]["firstlogin"].ToString());
                LastLogin  = DateTime.Now;
                Money      = int.Parse(playerdb.Rows[0]["money"].ToString());
                Color      = playerdb.Rows[0]["color"].ToString();
                //TODO Add total login and total Blocks
            }
            playerdb.Dispose();
            LoadExtra();
            //Because milk
            this.OnPlayerDisconnect.Important += delegate {
                Save();
            };
        }
コード例 #24
0
        static void Main(string[] args)
        {
            ProxySettings = new ProxySettings();
            // Load plugins into AppDomain
            foreach (var plugin in Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll"))
            {
                try
                {
                    Assembly.LoadFile(plugin);
                }
                catch { }
            }
            LoadPlugins();

            bool remoteSet = false, localSet = false;

            // Interpret command line args
            for (int i = 0; i < args.Length; i++)
            {
                var arg = args[i];
                if (arg.StartsWith("-"))
                {
                    switch (arg)
                    {
                    case "--authenticate-clients":
                        ProxySettings.AuthenticateClients = true;
                        break;

                    case "--local-endpoint":
                        ProxySettings.LocalEndPoint = ParseEndPoint(args[++i]);
                        break;

                    case "--remote-endpoint":
                        ProxySettings.RemoteEndPoint = ParseEndPoint(args[++i], 25565);
                        break;

                    case "--filter":
                        ProxySettings.PacketFilter = ParseFilter(args[++i]);
                        break;

                    case "--unfilter":
                        var filter = ParseFilter(args[++i]);
                        ProxySettings.PacketFilter.RemoveAll(p => filter.Contains(p));
                        break;

                    case "--omit-client":
                        ProxySettings.LogClient = false;
                        break;

                    case "--omit-server":
                        ProxySettings.LogServer = false;
                        break;

                    case "--username":
                        ProxySettings.Username = args[++i];
                        break;

                    case "--password":
                        ProxySettings.Password = args[++i];
                        break;

                    case "--help":
                        DisplayHelp();
                        return;

                    default:
                        var eventArgs = new UnrecognizedArgumentEventArgs
                        {
                            Argument = arg,
                            Args     = args,
                            Index    = i,
                            Handled  = false
                        };
                        if (UnrecognizedArgument != null)
                        {
                            UnrecognizedArgument(null, eventArgs);
                        }
                        if (!eventArgs.Handled)
                        {
                            Console.WriteLine("Invalid command line arguments. Use --help for more information.");
                            return;
                        }
                        break;
                    }
                }
                else
                {
                    if (!remoteSet)
                    {
                        ProxySettings.RemoteEndPoint = ParseEndPoint(arg, 25565);
                        remoteSet = true;
                    }
                    else if (!localSet)
                    {
                        ProxySettings.LocalEndPoint = ParseEndPoint(arg);
                        localSet = true;
                    }
                    else
                    {
                        var eventArgs = new UnrecognizedArgumentEventArgs
                        {
                            Argument = arg,
                            Args     = args,
                            Index    = i,
                            Handled  = false
                        };
                        if (UnrecognizedArgument != null)
                        {
                            UnrecognizedArgument(null, eventArgs);
                        }
                        if (!eventArgs.Handled)
                        {
                            Console.WriteLine("Invalid command line arguments. Use --help for more information.");
                            return;
                        }
                    }
                }
            }

            if (ProxySettings.Password == null)
            {
                // Grab lastlogin if possible
                var login = LastLogin.GetLastLogin();
                if (login != null)
                {
                    if (ProxySettings.Username == null)
                    {
                        ProxySettings.Username = login.Username;
                    }
                    ProxySettings.Password = login.Password;
                }
            }

            Listener = new TcpListener(ProxySettings.LocalEndPoint);
            Sessions = new List <Proxy>();
            Listener.Start();
            Listener.BeginAcceptTcpClient(AcceptClient, null);

            Console.WriteLine("Proxy started on " + ProxySettings.LocalEndPoint);

            Console.WriteLine("Press 'q' to exit.");

            ConsoleKeyInfo cki = new ConsoleKeyInfo();

            do
            {
                cki = Console.ReadKey();
            } while (cki.KeyChar != 'q');
        }
コード例 #25
0
    protected void cmdLogin_Click(object sender, EventArgs e)
    {
        //ตรวจสอบ Capcha
        //if (rpHash(Request.Form["defaultReal"]) == Request.Form["realPersonHash"])
        //{

        //ตรวจสอบ user + password ที่ Ldap Server
        //string permit = new Ldap().getAuthenticationMember(txtUSERNAME.Text.Trim(), txtPASSWORD.Text.Trim());

        //ตรวจสอบ user + password ที่ database
        string           password = getMD5(txtPASSWORD.Text.Trim());
        string           permit;
        string           sql         = "Select * From USERS_INFO Where USER_ID = '" + txtUSERNAME.Text.Trim() + "' And PASSWORD = '******'";
        List <UsersInfo> chkUserInfo = new UsersInfo().getUsersFromCommand(sql);

        if (chkUserInfo.Count > 0)
        {
            permit = "200";
        }
        else
        {
            permit = "0";
        }

        //Connect to LDap success
        if (permit == "200")
        {
            Session.Remove("login_data");
            UserLoginData login_data = new UserLoginData();

            login_data = new CheckLogin().CheckUserLogin(txtUSERNAME.Text.ToLower(), "");


            if (login_data != null)
            {
                UsersInfo userInfo = new UsersInfo().getUsers(login_data.User_ID);

                //user status = activate
                if (userInfo.STATUS == "0001")
                {
                    //Write log file
                    LogData data = new LogData();
                    data.Username   = login_data.User_ID;
                    data.ModuleCode = "300";     // Login Code
                    data.StatusCode = "100";     // 100 = Success

                    new Log().WriteLog(data);

                    //Update Last login
                    LastLogin lastLogin = new LastLogin();
                    lastLogin.User_Id         = login_data.User_ID;
                    lastLogin.Last_Login_Date = DateTime.Now.ToString();

                    int userCount = new Log().getCountUser(login_data.User_ID);
                    if (userCount == 0)
                    {
                        new Log().insertLastLogin(lastLogin);
                    }
                    else
                    {
                        new Log().updateLastLogin(lastLogin);
                    }

                    //ลบ session count
                    Session.Remove("count");

                    //Login Pass redirect to main menu
                    Session["login_data"] = login_data;
                    Response.Redirect("choose_roles.aspx");
                }
                //user status = deactivate
                else
                {
                    //0003 = ถูกระงับการใช้งานชั่วคราว
                    if (userInfo.STATUS == "0003")
                    {
                        //find difference 24hrs after deactivate user
                        LastLogin lastLoginData = new Log().getLastLogin(login_data.User_ID);
                        DateTime  StartTime     = DateTime.Parse(lastLoginData.Last_Login_Date);
                        DateTime  EndTime       = DateTime.Now;
                        TimeSpan  ts            = EndTime - StartTime;

                        //update user status to activate after login 24hrs
                        if (ts.Days >= 1)
                        {
                            //Update Last login
                            LastLogin lastLogin = new LastLogin();
                            lastLogin.User_Id         = login_data.User_ID;
                            lastLogin.Last_Login_Date = DateTime.Now.ToString();
                            new Log().updateLastLogin(lastLogin);

                            //Update UserInfo status
                            //0001 = ใช้งาน
                            string updateStatus = new UsersInfo().updateUserStatus("0001", login_data.User_ID);

                            //Write log file
                            LogData data = new LogData();
                            data.Username   = login_data.User_ID;
                            data.ModuleCode = "300";     // Login Code
                            data.StatusCode = "100";     // 100 = Success
                            new Log().WriteLog(data);


                            //ลบ session count
                            Session.Remove("count");

                            //Login Pass redirect to main menu
                            Session["login_data"] = login_data;
                            Response.Redirect("choose_roles.aspx");
                        }
                        else
                        {
                            lblMsg.Text = "Login เกินจำนวนที่กำหนด ระงับการใช้งานชั่วคราว (24 ชม.)";
                        }
                    }
                    else
                    {
                        lblMsg.Text = "ระงับการใช้งาน โปรดติดต่อผู้ดูแลระบบ";
                    }
                }
            }
        }
        else
        {
            count = Convert.ToInt16(Session["count"]);
            count++;
            Session["count"] = count;

            //Write log file
            LogData data = new LogData();
            data.Username   = txtUSERNAME.Text;
            data.ModuleCode = "300";     // Login Code
            data.StatusCode = "200";     // 200 = Failed

            new Log().WriteLog(data);
            //

            if (count >= 3)
            {
                //ตรวจสอบ user ก่อน update
                int countUser = new UsersInfo().getCountUsers(txtUSERNAME.Text);

                if (countUser > 0)
                {
                    lblMsg.Text = "Login เกินจำนวนที่กำหนด ระงับการใช้งานชั่วคราว (24 ชม.)";

                    //Update Last login
                    LastLogin lastLogin = new LastLogin();
                    lastLogin.User_Id         = txtUSERNAME.Text;
                    lastLogin.Last_Login_Date = DateTime.Now.ToString();
                    new Log().updateLastLogin(lastLogin);

                    //Update UserInfo status
                    //0003 = ระงับการใช้งานชั่วคราว
                    string updateStatus = new UsersInfo().updateUserStatus("0003", txtUSERNAME.Text);
                }
                else
                {
                    Session.Remove("count");
                    lblMsg.Text = "ตรวจสอบ Login name หรือ Password อีกครั้ง!";
                }
            }
            else
            {
                lblMsg.Text = "ตรวจสอบ Login name หรือ Password อีกครั้ง*";
            }
        }
        //}
        //else
        //{
        //    defaultReal.Text = "";
        //    lblMsg.Text = "Capcha ไม่ถูกต้องโปรดทำใหม่อีกครั้ง";
        //}
    }
コード例 #26
0
        private static void AutoHangarWorker()
        {
            //Significant performance increase
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            List <MyCubeGrid> ExportedGrids          = new List <MyCubeGrid>();
            List <long>       ExportPlayerIdentities = new List <long>();

            Log.Warn("AutoHangar: Getting Players!");

            foreach (MyIdentity player in MySession.Static.Players.GetAllIdentities())
            {
                if (player == null)
                {
                    continue;
                }

                DateTime LastLogin;
                LastLogin = player.LastLoginTime;

                ulong SteamID = MySession.Static.Players.TryGetSteamId(player.IdentityId);

                if (SteamID == 0)
                {
                    continue;
                }

                if (LastLogin.AddDays(Config.AutoHangarDayAmount) < DateTime.Now)
                {
                    //AutoHangarBlacklist
                    if (!Config.AutoHangarPlayerBlacklist.Any(x => x.SteamID == SteamID))
                    {
                        ExportPlayerIdentities.Add(player.IdentityId);
                    }
                }
            }

            Log.Warn("AutoHangar: Total players to check:" + ExportPlayerIdentities.Count());
            int GridCounter = 0;

            //This gets all the grids
            foreach (long player in ExportPlayerIdentities)
            {
                ulong id = MySession.Static.Players.TryGetSteamId(player);



                //string path = GridMethods.CreatePathForPlayer(Config.FolderDirectory, id);
                ConcurrentBag <List <MyCubeGrid> > gridGroups = GridUtilities.FindGridList(player, false);
                //Log.Warn(player + ":" + gridGroups.Count);

                if (gridGroups.Count == 0)
                {
                    continue;
                }


                long LargestGridID = 0;

                if (Config.KeepPlayersLargestGrid)
                {
                    //First need to find their largets grid
                    int BlocksCount = 0;

                    foreach (List <MyCubeGrid> grids in gridGroups)
                    {
                        int        GridBlockCounts        = 0;
                        int        LargestSingleGridCount = 0;
                        MyCubeGrid LargetsGrid            = grids[0];
                        foreach (MyCubeGrid grid in grids)
                        {
                            if (grid.BlocksCount > LargestSingleGridCount)
                            {
                                LargestSingleGridCount = grid.BlocksCount;
                                LargetsGrid            = grid;
                            }
                        }

                        GridBlockCounts = LargetsGrid.BlocksCount;

                        if (GridBlockCounts > BlocksCount)
                        {
                            BlocksCount   = GridBlockCounts;
                            LargestGridID = LargetsGrid.EntityId;
                        }
                    }
                }


                if (gridGroups.Count == 0)
                {
                    continue;
                }

                PlayerHangar PlayersHangar = new PlayerHangar(id, null);
                foreach (List <MyCubeGrid> grids in gridGroups)
                {
                    if (grids.Count == 0)
                    {
                        continue;
                    }


                    if (grids[0].IsRespawnGrid && Config.DeleteRespawnPods)
                    {
                        grids[0].Close();
                        continue;
                    }


                    GridResult Result = new GridResult();
                    Result.Grids = grids;

                    var BiggestGrid = grids[0];
                    foreach (MyCubeGrid grid in grids)
                    {
                        if (grid.BlocksCount > BiggestGrid.BlocksCount)
                        {
                            BiggestGrid = grid;
                        }
                    }

                    Result.BiggestGrid = BiggestGrid;

                    if (Config.KeepPlayersLargestGrid)
                    {
                        if (BiggestGrid.EntityId == LargestGridID)
                        {
                            //Skip players largest grid
                            continue;
                        }
                    }


                    //Grid Size Checks
                    if (BiggestGrid.GridSizeEnum == MyCubeSize.Large)
                    {
                        if (BiggestGrid.IsStatic && !Config.AutoHangarStaticGrids)
                        {
                            continue;
                        }
                        else if (!BiggestGrid.IsStatic && !Config.AutoHangarLargeGrids)
                        {
                            continue;
                        }
                    }
                    else if (BiggestGrid.GridSizeEnum == MyCubeSize.Small && !Config.AutoHangarSmallGrids)
                    {
                        continue;
                    }


                    GridStamp Stamp = Result.GenerateGridStamp();
                    GridUtilities.FormatGridName(PlayersHangar, Stamp);



                    if (PlayersHangar.SaveGridsToFile(Result, Stamp.GridName))
                    {
                        //Load player file and update!
                        //Fill out grid info and store in file
                        PlayersHangar.SaveGridStamp(Stamp, false, true);
                        GridCounter++;
                        Log.Info(Result.BiggestGrid.DisplayName + " was sent to Hangar due to inactivity!");
                    }
                    else
                    {
                        Log.Info(Result.BiggestGrid.DisplayName + " FAILED to Hangar due to inactivity!");
                    }
                }

                //Save players file!
                PlayersHangar.SavePlayerFile();
            }
            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;

            Log.Warn("Finished Hangaring: " + GridCounter + " grids! Action took: " + ts.ToString());
        }
コード例 #27
0
        //AutoSellsGrids (HotPile of s***e)
        private void AutoSellWorker(Hangar Plugin)
        {
            String[] subdirectoryEntries = Directory.GetDirectories(Plugin.Config.FolderDirectory);
            foreach (string subdir in subdirectoryEntries)
            {
                string FolderName = new DirectoryInfo(subdir).Name;

                //Path.GetDirectoryName(subdir+"\\");

                if (FolderName == "PublicOffers")
                {
                    continue;
                }

                //Main.Debug(FolderName);
                ulong SteamID;
                try
                {
                    SteamID = Convert.ToUInt64(FolderName);
                }
                catch
                {
                    continue;
                    //Not a valid steam dir;
                }


                //Check playerlast logon
                //MyPlayer.PlayerId CurrentPlayer = MySession.Static.Players.GetAllPlayers().First(x => x.SteamId == SteamID);
                MyIdentity identity;
                DateTime   LastLogin;
                try
                {
                    string playername = MySession.Static.Players.TryGetIdentityNameFromSteamId(SteamID);
                    identity = MySession.Static.Players.GetAllIdentities().First(x => x.DisplayName == playername);

                    //Main.Debug(identity.DisplayName);


                    //MyPlayer.PlayerId PlayerID = MySession.Static.Players.GetAllPlayers().First(x => x.SteamId == SteamID);
                    //CurrentPlayer = MySession.Static.Players.GetPlayerById(0);
                    LastLogin = identity.LastLoginTime;
                    if (LastLogin.AddDays(Plugin.Config.SellAFKDayAmount) < DateTime.Now)
                    {
                        Hangar.Debug("Grids will be auto sold by auction!");
                    }
                    else
                    {
                        //Main.Debug(LastLogin.AddDays(MaxDayCount).ToString());
                        continue;
                    }
                }
                catch
                {
                    //Perhaps players was removed? Should we delete thy folder? Nah. WE SHALL SELL
                    continue;
                }


                PlayerInfo Data = new PlayerInfo();
                try
                {
                    Data = JsonConvert.DeserializeObject <PlayerInfo>(File.ReadAllText(Path.Combine(subdir, "PlayerInfo.json")));

                    if (Data == null || Data.Grids == null || Data.Grids.Count == 0)
                    {
                        //Delete folder
                        Directory.Delete(subdir);
                        continue;
                    }
                }
                catch (Exception p)
                {
                    //Main.Debug("Unable File IO exception!", e, Main.ErrorType.Warn);
                    //File is prob null/missing
                    continue;
                }


                foreach (GridStamp grid in Data.Grids)
                {
                    //
                    if (grid.GridForSale == true)
                    {
                        //This grid could be for sale somewhere else. We need to remove it

                        try
                        {
                            int index = GridMarket.GridList.FindIndex(x => x.Name == grid.GridName);
                            CrossServerMessage message = new CrossServerMessage();
                            message.Type = CrossServer.MessageType.RemoveItem;
                            message.List.Add(GridMarket.GridList[index]);

                            //Send all servers that we removed an item
                            Servers.Update(message);

                            GridMarket.GridList.RemoveAt(index);
                            grid.GridForSale = false;
                        }
                        catch
                        {
                            //Could be a bugged grid?
                            grid.GridForSale = false;
                        }
                    }

                    string Description = "Sold by server due to inactivity at a discounted price! Originial owner: " + identity.DisplayName;


                    long Price = (long)grid.MarketValue;
                    if (grid.MarketValue == 0)
                    {
                        Price = grid.NumberofBlocks * grid.GridPCU;
                    }

                    grid.MarketValue = Price;

                    Price            = Price / 2;
                    grid.GridForSale = true;

                    if (!SellOnMarket(subdir, grid, Data, identity, Price, Description))
                    {
                        Hangar.Debug("Unkown error on grid sell! Grid doesnt exist! (Dont manually delete files!)");
                        return;
                    }
                }

                FileSaver.Save(Path.Combine(subdir, "PlayerInfo.json"), Data);
                //File.WriteAllText(Path.Combine(subdir, "PlayerInfo.json"), JsonConvert.SerializeObject(Data));
            }
        }