Example #1
0
        public void Add(Block b, int BlacklistCount)
        {
            if( BlacklistCount > Program.BLCOUNT )
                throw new ArgumentOutOfRangeException( );

            blocks.Add( new BlackListCheckResult( BlacklistCount, b ) );
        }
Example #2
0
        public Block[] getProxyBlocks( int limit )
        {
            string cmdText = "SELECT * FROM ipblocks i WHERE ipb_reason LIKE \"%proxy%\" AND ipb_user = 0";
            if( limit != 0 )
                cmdText += " LIMIT " + limit.ToString( );

            cmdText += ";";

            MySqlCommand cmd = new MySqlCommand( cmdText );

            cmd.Connection = db_connection;
            MySqlDataReader dr = cmd.ExecuteReader( );

            ArrayList blocks = new ArrayList( );

            while( dr.Read() )
            {
                object[ ] vals = new object[ dr.FieldCount ];
                dr.GetValues( vals );

                blocks.Add(Block.newFromDataRow( vals ));
            }

            dr.Close( );

            Block[ ] bA = new Block[ blocks.Count ];
            blocks.CopyTo( bA );
            return bA;
        }
 public BlackListCheckResult(int x, Block b )
 {
     blackListCount = x;
     blockInfo = b;
 }
Example #4
0
        public static Block newFromDataRow( object[ ] values )
        {
            Block b = null;
            try
            {

                b = new Block( );
                b.ipb_id = (int)( values[ 0 ] );
                b.ipb_address = Utility.Net.IPAddress.newFromEncodedString( (byte[ ])values[ 1 ] );
                b.ipb_user = (uint)values[ 2 ];
                b.ipb_by = (uint)values[ 3 ];
                b.ipb_reason = ASCIIEncoding.ASCII.GetString( (byte[ ])values[ 4 ] );

                //System.OverflowException was unhandled
                //Message="Value was either too large or too small for an Int32."
                //Source="mscorlib"
                //StackTrace:
                //     at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
                //     at MySql.Data.Types.MySqlDateTime.ParseMySql(String s, Boolean is41)
                //     at MySql.Data.Types.MySqlDateTime.Parse(String s)
                //     at MySql.Data.Types.MySqlDateTime..ctor(String s)
                //     at BlockedOpenProxyReviewerBot.Block.newFromDataRow(Object[] values) in C:\Users\stwalkerster\Documents\Visual Studio 2008\Projects\BlockedOpenProxyReviewerBot\BlockedOpenProxyReviewerBot\Block.cs:line 37
                //     at BlockedOpenProxyReviewerBot.Database.getProxyBlocks() in C:\Users\stwalkerster\Documents\Visual Studio 2008\Projects\BlockedOpenProxyReviewerBot\BlockedOpenProxyReviewerBot\Database.cs:line 44
                //     at BlockedOpenProxyReviewerBot.Program.runBot() in C:\Users\stwalkerster\Documents\Visual Studio 2008\Projects\BlockedOpenProxyReviewerBot\BlockedOpenProxyReviewerBot\Program.cs:line 37
                //     at BlockedOpenProxyReviewerBot.Program..ctor(String[] args) in C:\Users\stwalkerster\Documents\Visual Studio 2008\Projects\BlockedOpenProxyReviewerBot\BlockedOpenProxyReviewerBot\Program.cs:line 24
                //     at BlockedOpenProxyReviewerBot.Program.Main(String[] args) in C:\Users\stwalkerster\Documents\Visual Studio 2008\Projects\BlockedOpenProxyReviewerBot\BlockedOpenProxyReviewerBot\Program.cs:line 12
                //     at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
                //     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
                //     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
                //     at System.Threading.ThreadHelper.ThreadStart()
                //InnerException:

                byte[ ] x = (byte[ ])values[ 5 ];
                string y = ASCIIEncoding.ASCII.GetString( x );
                MySql.Data.Types.MySqlDateTime z = new MySql.Data.Types.MySqlDateTime(
                    int.Parse( y.Substring( 0, 4 ) ),
                    int.Parse( y.Substring( 4, 2 ) ),
                    int.Parse( y.Substring( 6, 2 ) ),
                    int.Parse( y.Substring( 8, 2 ) ),
                    int.Parse( y.Substring( 10, 2 ) ),
                    int.Parse( y.Substring( 12, 2 ) )
                    );
                b.ipb_timestamp = z.GetDateTime( );

                //  b.ipb_timestamp = new MySql.Data.Types.MySqlDateTime( ASCIIEncoding.ASCII.GetString( (byte[ ])values[ 5 ] ) ).GetDateTime( );

                b.ipb_auto = (bool)values[ 6 ];
                b.ipb_anon_only = (bool)values[ 7 ];
                b.ipb_create_account = (bool)values[ 8 ];
                b.ipb_expiry = ASCIIEncoding.ASCII.GetString( (byte[ ])values[ 9 ] );
                if( ( (byte[ ])values[ 10 ] ).Length == 4 )
                {
                    b.ipb_range_start = new IPAddress( (byte[ ])values[ 10 ] );
                }
                if( ( (byte[ ])values[ 11 ] ).Length == 4 )
                {
                    b.ipb_range_end = new IPAddress( (byte[ ])values[ 11 ] );
                }
                b.ipb_enable_autoblock = (bool)values[ 12 ];
                b.ipb_deleted = (bool)values[ 13 ];
                b.ipb_block_email = (bool)values[ 14 ];
                b.ipb_by_text = ASCIIEncoding.ASCII.GetString( (byte[ ])values[ 15 ] );
            }
            catch( OverflowException )
            {
            }
            return b;
        }