• Welcome to Valhalla Legends Archive.
 
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - indulgence

#1
Web Development / Re: [HTML] Frames question
November 16, 2006, 11:47 AM
Just so long as no one uses a damned "Wrapper" div on the global level - ill be happy.  If you are trying to center content... style the HTML and BODY elements. kthx
#2
Visual Basic Programming / Re: VB.Net User Managment
November 16, 2006, 11:40 AM
Quote from: MyndFyre[vL] on November 16, 2006, 12:37 AM
However, I disagree on the use of the serialization framework.  XML is probably not so much an evildoer in this instance, but for sure the binary formatter does not emit version-flexible output.  Doing custom serialization as far as custom output or even writing custom XML files is FAR more flexible than trusting it to the serialization framework.
True, but not as simple, nor as quick.  The inability to (de)serialize DateTime objects is the killer - and you have to hack in a timespan and convert it
#3
Visual Basic Programming / Re: VB.Net User Managment
November 16, 2006, 12:07 AM
I would have created my user object, created a typed collection for the user object, marked both serializable, and serialized the user collection to file..

Serialization/Deserialization is much cleaner than the code to read - parse - proceed...


Namespace Management
    <Serializable()> Public Class User
        Public Name As String
        Public Password As String

        <XmlIgnore()> Public hash As New System.Security.Cryptography.HMACSHA1(System.Text.ASCIIEncoding.ASCII.GetBytes("mykey"))

        Public Sub New()

        End Sub
        Public Sub New(ByVal _Name As String, ByVal _Password As String)
            Name = _Name
            Password = _Password
        End Sub

        Public Function Validate(ByVal ClearTextPW As String) As Boolean
            Return GetPasswordHash(ClearTextPW).Equals(Password)
        End Function
        Public Function SetPassword(ByVal CleartextOldPW As String, ByVal CleartextNewPW As String) As Boolean
            If Validate(CleartextOldPW) Then
                Password = GetPasswordHash(CleartextNewPW)
                Return True
            End If
            Return False
        End Function

        Private Function GetPasswordHash(ByVal ClearTextPW As String) As String
            Return BitConverter.ToString(hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(ClearTextPW)))
        End Function
    End Class
    <Serializable()> Public Class UserCollection
        Inherits CollectionBase

        Private _Serializer As XmlSerializer = New System.Xml.Serialization.XmlSerializer(GetType(UserCollection))

        Default Public Property Items(ByVal index As Integer) As User
            Get
                If index >= 0 And index < list.Count Then Return DirectCast(List(index), User)
            End Get
            Set(ByVal Value As User)
                If index >= 0 And index < list.Count Then list(index) = Value
            End Set
        End Property
        Default Public Property Items(ByVal Name As String) As User
            Get
                Dim index As Integer = Me.IndexOf(Name)
                If Not index < 0 Then Return DirectCast(List(index), User)
            End Get
            Set(ByVal Value As User)
                Dim index As Integer = Me.IndexOf(Name)
                If Not index < 0 Then list(index) = Value
            End Set
        End Property

        Public Overloads Function Equals(ByVal Users As UserCollection) As Boolean
            If Not Users.Count = list.Count Then Return False

            For index As Integer = 0 To List.Count - 1
                If Not Users(index).Equals(Me(index)) Then Return False
            Next
            Return True
        End Function

        Public Function Add(ByVal Item As User) As Integer
            If Not Me.Contains(Item) Then Return list.Add(Item)
        End Function

        Public Function Contains(ByVal Item As User) As Boolean
            Return list.Contains(Item)
        End Function

        Public Sub CopyTo(ByVal Array As User(), ByVal index As Integer)
            list.CopyTo(Array, index)
        End Sub
        Public Sub CopyTo(ByVal Array As IList, ByVal index As Integer)
            For Each item As User In Me.List
                Array.Add(item)
            Next
        End Sub

        Public Function IndexOf(ByVal Item As User) As Integer
            Return list.IndexOf(Item)
        End Function
        Public Function IndexOf(ByVal Name As String) As Integer
            For index As Integer = 0 To list.Count - 1
                If Name.ToLower.Equals(Me(index).Name.ToLower) Then
                    Return index
                End If
            Next
            Return -1
        End Function

        Public Sub Insert(ByVal Index As Integer, ByVal Item As User)
            list.Insert(Index, Item)
        End Sub

        Public Sub Remove(ByVal Item As User)
            list.Remove(Item)
        End Sub
        Public Sub Remove(ByVal Name As String)
            For index As Integer = 0 To list.Count - 1
                If Me(index).Name.Equals(Name) Then
                    list.RemoveAt(index)
                    Exit For
                End If
            Next
        End Sub

        Public Function Save(ByVal Path As String) As Boolean
            Dim fs As IO.FileStream
            Try
                IO.File.Copy(Path, Path & ".bak")
                fs = IO.File.Open(Path, IO.FileMode.Truncate, IO.FileAccess.Write)
                _Serializer.Serialize(fs, Me)
                IO.File.Delete(Path & ".bak")
                fs.Close()
            Catch
                fs.Close()
                IO.File.Delete(Path)
                IO.File.Move(Path & ".bak", Path)
            End Try
            Return True
        End Function
        Public Sub New(ByVal Path As String)
            Dim fs As IO.FileStream
            Try
                fs = IO.File.Open(Path, IO.FileMode.Open, IO.FileAccess.Read)
                Dim lc As UserCollection = _Serializer.Deserialize(fs)
                lc.CopyTo(Me.List, 0)
            Finally
                fs.Close()
            End Try
        End Sub
        Public Sub New()

        End Sub
    End Class
End Namespace


It's long - but you can edit users, add user, delete users from the UserCollection, and call the save method to save it... [you'd want to update the save routine to meet your specs for the filename etc...] and by calling the overloaded new on UserCollection it will deserialize the file into a collection of your user objects.

XML ftw?
#4
Web Development / Re: Web Security
November 15, 2006, 11:57 PM
You definately want to store the passwords as a stronger hash (SHA-1 or better), why not MD5? http://www.gdataonline.com/

Also, cookies are fine.  But you will want to secure your users from XSS or CSFR attacks.  If there is any action that modifies their account in any way - think about requiring user interaction (CAPTCHA?).  And be sure to sanitize any user input strings. (Definately want to encode <> to say the least)

Its amazing what kind of vulnerabilities are out there....
#5
.NET Platform / Re: [VB] NetworkStream Help
January 17, 2006, 01:15 PM
Quote from: MyndFyre on January 17, 2006, 01:03 PM
See:
Quote from: MSDNRemarks
The Flush method implements the Stream.Flush method; however, because NetworkStream is not buffered, it has no affect on network streams. Calling the Flush method will not throw an exception.

Indulgence, I suggest you take a look at that last sentence before you try to look cool.

Sheesh sorry I edited that part in if you would have noticed - only b/c I, obviously, misread.  My initial statement was that the calls were un-neccessary...
#6
.NET Platform / Re: [VB] NetworkStream Help
January 17, 2006, 12:56 PM
Quote from: MSDNNetworkStream.Flush Method

Flushes data from the stream. This method is reserved for future use.

Remarks

The Flush method implements the Stream.Flush method; however, because NetworkStream is not buffered, it has no affect on network streams. Calling the Flush method will not throw an exception.
    Function Receive() As String
        Dim Bytes(wSock.ReceiveBufferSize) As Byte
        Dim objSR As New System.IO.StreamReader(Stream, Encoding.ASCII)
        Receive = (objSR.ReadToEnd())
    End Function


Maybe loop calls to that looking for a terminator... not really into the "bot" thing
#7
.NET Platform / Re: [C#] Stack overflow - SOLVED
August 25, 2005, 12:36 AM
You are most likely fine with having a public variable - however its not of the object-oriented mentality of encapsulation
#8
Web Development / Re: [JavaScript] Bot?
June 26, 2005, 01:01 PM
Quote from: [Unknown] on June 15, 2005, 11:54 AM
READ THE DATES!!!!!!!!!!!!!!!!!

I realized the difference in dates b/w last post and when i read it.  However,  The thread was still on the first page (and only about halfway down) and not to mention that I actually contributed to the topic instead of just spamming it like you :)
#9
LUA ftw
#10
Web Development / Re: [JavaScript] Bot?
June 14, 2005, 06:28 PM
#11
Excess of Grok / Re: Say hello to...
February 23, 2005, 06:47 PM
Look out in 2007 for Noel Devine out of the sunshine state....
#12
Excess of Grok / Re: Bowl Games
December 13, 2004, 01:36 PM
GMAC Bowl -- Bowling Green vs. Memphis
Hawaii Bowl -- Hawaii vs. UAB
MPC Computers Bowl -- Virginia vs. Fresno State
Independence Bowl -- Miami (Ohio) vs. Iowa State
Insight Bowl -- Notre Dame vs. Oregon State
Alamo Bowl -- Oklahoma State vs. Ohio State
Holiday Bowl -- Texas Tech vs. Cal
Music City Bowl -- Alabama vs. Minnesota
Sun Bowl -- Arizona State vs. Purdue
Liberty Bowl -- Boise State vs. Louisville
Peach Bowl -- Florida vs. Miami
Outback Bowl -- Georgia vs. Wisconsin
Cotton Bowl -- Tennessee vs. Texas A&M
Gator Bowl -- Florida State vs. West Virginia
Capital One Bowl -- LSU vs. Iowa

-BCS-

Rose Bowl -- Texas vs. Michigan
Fiesta Bowl -- Pitt vs. Utah
Sugar Bowl -- Virginia Tech vs. Auburn
Orange Bowl -- USC vs. Oklahoma
#13
I hope Tennessee can nab Patrick Turner
Patrick Turner    6-5, 210,  4.5    Nashville (Goodpasture), Tenn.

He will be a STUD Wide Reciever. Unfortunately USC is one of his favorites, Florida was earlier in the year - hopefully Meyer's system doesn't lure him.  I mean 6-5 and runs a 4.5, this guy could dominate Defensive Backs. He's #2 on Rivals WR list and #4 on ESPN's
#14
Florida was the 1984 SEC Champion, but it was stripped for cheating :x
#15
Warcraft / Re: World of Warcraft
November 22, 2004, 10:52 PM
Ya, the GM's were given carte blanche on the live servers.  They were punting ppl around towns, spawning uber mobs like the infernal, and dropping onyxia spawns all over the place