Esempio n. 1
0
        internal bool SaveToFile()
        {
            string FileName = MForm.GetDataDirectory() + "NetStats.txt";

            ECTime RecTime = new ECTime();
            // OldTime.SetToYear1999();
            // ulong OldIndex = OldTime.GetIndex();

            try
            {
            using( StreamWriter SWriter = new StreamWriter( FileName  ))
              {
              foreach( KeyValuePair<string, IPStatusRec> Kvp in IPsDictionary )
            {
            RecTime.SetFromIndex( Kvp.Value.TimeIndex );

            string Line = Kvp.Key + "\t" +
              RecTime.ToLocalTimeString() + "\t" +
              RecTime.ToLocalDateString() + "\t" +
              Kvp.Value.TimeIndex.ToString() + "\t" +
              Kvp.Value.HackerCount.ToString() + "\t" +
              Kvp.Value.TimedOutCount.ToString() + "\t" +
              Kvp.Value.GoodWebRequestCount.ToString() + "\t" +
              Kvp.Value.TotalGoodWebRequestCount.ToString() + "\t" +
              Kvp.Value.Port80Count.ToString() + "\t" +
              Kvp.Value.Port443Count.ToString() + "\t" +
              Kvp.Value.Referer + "\t" +
              Kvp.Value.UserAgent + "\t" +
              Kvp.Value.HostName + "\t" +
              Kvp.Value.LastHostNameUpdate.ToString() + "\t" +
              Kvp.Value.BadWebPageCount.ToString(); //  + "\t" +
              // Kvp.Value.SentText;

            SWriter.WriteLine( Line );
            }

              SWriter.WriteLine( " " );
              }

            return true;

            }
            catch( Exception ) //  Except )
              {
              // "Error: Could not write
              return false;
              }
        }
Esempio n. 2
0
        internal void ShowIPStatus()
        {
            ECTime RecTime = new ECTime();
            MForm.ShowStatus( " " );

            string ShowS = "IP Address\t" +
                   "Server Time\t" +
                   "Server Date\t" +
                   "Hacker Count\t" +
                   "Timed Out Count\t" +
                   "Bad Web Page Count\t" +
                   "Good Web Request Count\t" +
                   "Total Good Web Request Count\t" +
                   "Port 80 Count\t" +
                   "GetPublicKeyCount\t" +
                   "TotalGetPublicKeyCount\t" +
                   "ConfirmBillingCount\t" +
                   "TotalConfirmBillingCount\t" +
                   "Referrer\t" +
                   "User Agent\t" +
                   "Host Name\t" +
                   "Sent Text";

            MForm.ShowStatus( ShowS );

            int HowMany = 0;
            foreach( KeyValuePair<string, IPStatusRec> Kvp in IPsDictionary )
              {
              // Don't show too many.  This is only meant as a quick way to show
              // some records.
              HowMany++;
              if( HowMany > 1000 )
            {
            MForm.ShowStatus( " " );
            MForm.ShowStatus( "Can't show more than 1000 IPs." );
            MForm.ShowStatus( " " );
            return;
            }

              RecTime.SetFromIndex( Kvp.Value.TimeIndex );

              ShowS = Kvp.Key + "\t" +
             RecTime.ToLocalTimeString() + "\t" +
             RecTime.ToLocalDateString() + "\t" +
             Kvp.Value.HackerCount.ToString( "N0" ) + "\t" +
             Kvp.Value.TimedOutCount.ToString( "N0" ) + "\t" +
             Kvp.Value.BadWebPageCount.ToString( "N0" ) + "\t" +
             Kvp.Value.GoodWebRequestCount.ToString( "N0" ) + "\t" +
             Kvp.Value.TotalGoodWebRequestCount.ToString( "N0" ) + "\t" +
             Kvp.Value.Port80Count.ToString( "N0" ) + "\t" +
             Kvp.Value.Port443Count.ToString( "N0" ) + "\t" +
             Kvp.Value.GetPublicKeyCount.ToString( "N0" ) + "\t" +
             Kvp.Value.TotalGetPublicKeyCount.ToString( "N0" ) + "\t" +
             Kvp.Value.ConfirmBillingCount.ToString( "N0" ) + "\t" +
             Kvp.Value.TotalConfirmBillingCount.ToString( "N0" ) + "\t" +
             Utility.CleanAsciiString( Kvp.Value.Referer, 300 ) + "\t" +
             Utility.CleanAsciiString( Kvp.Value.UserAgent, 300 ) + "\t" +
             Utility.CleanAsciiString( Kvp.Value.HostName, 300 ) + "\t" +
             Utility.CleanAsciiString( Kvp.Value.SentText, 300 );

              MForm.ShowStatus( ShowS );
              }

            MForm.ShowStatus( " " );
        }
Esempio n. 3
0
        internal bool ClearMidnightValues()
        {
            try
            {
            // The IP stuff is also kept in the server log.
            ECTime RecTime = new ECTime();
            ECTime OldTime = new ECTime();
            OldTime.SetToNow();
            OldTime.AddMinutes( -(60 * 24 * 30)); // 30 days.
            ulong OldIndex = OldTime.GetIndex();

            SortedDictionary<string, IPStatusRec> TempIPsDictionary = new SortedDictionary<string, IPStatusRec>();

            foreach( KeyValuePair<string, IPStatusRec> Kvp in IPsDictionary )
              {
              RecTime.SetFromIndex( Kvp.Value.TimeIndex );
              if( RecTime.GetIndex() < OldIndex )
            continue;

              // Keep totals on things like bad reg key count.
              IPStatusRec Rec = Kvp.Value;
              Rec.TimedOutCount = 0;
              Rec.GoodWebRequestCount = 0;
              // TotalGoodWebRequestCount
              // BadWebPageCount
              Rec.GetPublicKeyCount = 0;
              // Rec.TotalGetPublicKeyCount
              Rec.ConfirmBillingCount = 0;
              // Rec.TotalConfirmBillingCount

              TempIPsDictionary[Kvp.Key] = Rec;
              }

            IPsDictionary = TempIPsDictionary;
            return true;

            }
            catch( Exception Except )
              {
              MForm.ShowStatus( "Exception in ClearMidnightValues():" );
              MForm.ShowStatus( Except.Message );
              return false;
              }
        }