Mirage Source
http://web.miragesource.net/forums/

Tutorial - Finished
http://web.miragesource.net/forums/viewtopic.php?f=134&t=1973
Page 1 of 1

Author:  William [ Tue Jun 05, 2007 11:59 am ]
Post subject:  Tutorial - Finished

Decided to make something simple instead since there wont be many anticipants in this contest.

Difficulty: 1/5
Introduction: In case you added email on account creation, this will check if its correct or not. It will check if there is a "@" and a ".", since all emails has those. You can always tweak it to check for .com, .net etc..

In the Create Account Button, add this:
Code:
Dim i As Byte, a As Byte
a = 0
    For i = 1 To Len(Text1.Text)
        If Mid(Text1.Text, i, 1) <> "@" Then
            a = a + 1
            If a = Len(Text1.Text) Then
                MsgBox ("Enter a correct email address!")
                Exit Sub
            End If
        End If
    Next i

a = 0
    For i = 1 To Len(Text1.Text)
        If Mid(Text1.Text, i, 1) <> "." Then
            a = a + 1
            If a = Len(Text1.Text) Then
                MsgBox ("Enter a correct email address!")
                Exit Sub
            End If
        End If
    Next i

I know its pretty simple, but I wanted it for my game cause it makes it look more professional :)

Author:  William [ Mon Jul 16, 2007 6:45 pm ]
Post subject:  Re: Tutorial - Finished

Yeah, very simple. But always something.

Author:  Robin [ Mon Jul 16, 2007 6:47 pm ]
Post subject:  Re: Tutorial - Finished

Or you could add email verification...

Author:  William [ Mon Jul 16, 2007 6:49 pm ]
Post subject:  Re: Tutorial - Finished

Robin wrote:
Or you could add email verification...

How do you do that to a mirage game? If you make that tut I'll probably give you 10bucks cause theres no way you'll manage it.
SPOILER: (click to show)
Wont pay you but hey :P

Author:  Cruzn [ Mon Jul 16, 2007 7:06 pm ]
Post subject:  Re: Tutorial - Finished

Better way to do this would be to check for a period AFTER the @, otherwise "glacier86.99@bellsouth" would return true.

Rough idea:
Code:
Dim i As Byte, a As Byte, c As Byte
   For i = 1 To Len(Text1.Text)
      If Mid(Text1.Text, i, 1) = "@" Then
      'Adding 2 will prevent email@.com
      a = a + 2      
         For c = a To Len(Text1.Text)
                 If Mid(Text1.Text, c, 1) = "." Then
                        Return True
            End If
         Next c
      ' Didn't find the period, return false.
      Return False
      End If
   Next i

Used the PHP "return false," but you get the idea.

Author:  Dragoons Master [ Mon Jul 16, 2007 7:10 pm ]
Post subject:  Re: Tutorial - Finished

I have it on my game. It's all made in PHP. You go to the website, type de name of the account and your e-mail. Then PHP automaticly send's him his password of their account(randomized at run-time), so there is no way they can pass thru it. Actualy, the randomized password is made at the server, here in my house. I have a little program that manages this account creation stuff since all my game is running over the MySQL and this way I can manage this better. There is also a rank system running in Apache here in computer too. Every thing is off since I'm slow with the develop of my game atm, colege is just soo time consuming...
The system it self is very easy and I think I'll post that next year, I realy like things to be tested and I wont post that now...

Author:  Robin [ Mon Jul 16, 2007 7:12 pm ]
Post subject:  Re: Tutorial - Finished

William wrote:
Robin wrote:
Or you could add email verification...

How do you do that to a mirage game? If you make that tut I'll probably give you 10bucks cause theres no way you'll manage it.
SPOILER: (click to show)
Wont pay you but hey :P


Have VB open up outlook or something, send the email to the address. They click the link, this triggers a php file which saves a byte to the account data.

Voila.

Author:  William [ Mon Jul 16, 2007 7:26 pm ]
Post subject:  Re: Tutorial - Finished

Cruzns idea is the best of yours, althouh you will have to loop through a to y.. You guys just makes the smallest thing take time.. xD

Author:  Bradyok [ Thu Aug 02, 2007 8:02 pm ]
Post subject:  Re: Tutorial - Finished

Sorry, slightly old topic, but heres my verification code that works a bit better:

Code:
Public Function ValidateEmail(ByRef sEmail As String) As Boolean

Dim bValid            As Boolean   ' Is email valid?
Dim bFlag             As Boolean   ' Multipurpose boolean value
Dim vntEmail          As Variant   ' Splitted Email
Dim vntDomain         As Variant   ' Splitted Domain
Dim vntValidDomainExt As Variant   ' Valid domain extensions
Dim lCount            As Long      ' Loop variable
Dim lChars            As Long      ' Second loop variable

    ' Validates a email of form "a.bc_123@server.ext"
    ' Insert valid domain extensions in variable
    vntValidDomainExt = Array("no", "com", "edu", "gov", "int", "mil", "net", "org", "info", "biz", "pro", "name", "coop", "museum", _
                              "aero", "af", "al", "dz", "as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "ac", "au", "at", "az", _
                              "bs", "bh", "bd", "bb", "By", "be", "bz", "bj", "bm", "bt", "bo", "ba", "bw", "bv", "br", "io", "bn", _
                              "bg", "bf", "bi", "kh", "cm", "ca", "cv", "ky", "cf", "td", "cs", "cl", "cn", "cx", "cc", "co", "km", _
                              "cg", "ck", "cr", "ci", "hr", "cu", "cy", "cz", "dk", "dj", "dm", "do", "tp", "ec", "eg", "sv", "gq", _
                              "er", "ee", "et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm", "ge", "de", "gh", "gi", _
                              "gr", "gl", "gd", "gp", "gu", "gt", "gg", "gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", _
                              "In", "id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo", "kz", "ke", "ki", "kp", "kr", _
                              "kw", "kg", "la", "lv", "lb", "ls", "lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv", _
                              "ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc", "mn", "ms", "ma", "mz", "mm", "na", _
                              "nr", "np", "nl", "an", "nc", "nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw", "ps", _
                              "pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re", "ro", "ru", "rw", "kn", "lc", "vc", _
                              "ws", "sm", "st", "sa", "sn", "sc", "sl", "sg", "sk", "si", "sb", "so", "za", "gs", "es", "lk", "sh", _
                              "pm", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj", "tz", "th", "tg", "tk", "to", "tt", "tn", _
                              "tr", "tm", "tc", "tv", "ug", "ua", "ae", "gb", "uk", "us", "um", "uy", "su", "uz", "vu", "ve", "vn", _
                              "vg", "vi", "wf", "eh", "ye", "yu", "cd", "zm", "zr", "zw")

    ' Emails are normally composed of only lower-case characters
    ' so lower-case the email and since the parameter is ByRef, the
    ' email will be lower-cased back there.
    sEmail = LCase$(sEmail)
    ' If sEmail contains "@"
    If InStr(sEmail, "@") Then
        ' Split email on "@"
        vntEmail = Split(sEmail, "@")
        ' Asuure only 1 "@"
        If UBound(vntEmail) = 1 Then
            ' Starts with alphanumeric character
            If Left$(vntEmail(0), 1) Like "[a-z]" Or Left$(vntEmail(0), 1) Like "[0-9]" Then
                bFlag = True
                ' Assure all other characters are alphanumeric or "." or "_"
                For lCount = 2 To Len(vntEmail(0))
                    If Not (Mid$(vntEmail(0), lCount, 1) Like "[a-z]" Or Mid$(vntEmail(0), lCount, 1) Like "[0-9]" Or Mid$(vntEmail(0), lCount, 1) = "." Or Mid$(vntEmail(0), lCount, 1) Like "_") Then
                        bFlag = False
                    End If
                Next lCount
                If bFlag Then
                    ' If domain part contains "."
                    If InStr(vntEmail(1), ".") Then
                        ' Split domains on "."
                        vntDomain = Split(vntEmail(1), ".")
                        bFlag = True
                        ' Assure all domains characters are alphanumeric and domain length is over 1 (>= 2)
                        For lCount = LBound(vntDomain) To UBound(vntDomain)
                            If Len(vntDomain(lCount)) < 2 Then
                                bFlag = False
                            End If
                            For lChars = 1 To Len(vntDomain(lCount))
                                If Not (Mid$(vntDomain(lCount), lChars, 1) Like "[a-z]" Or Mid$(vntDomain(lCount), lChars, 1) Like "[0-9]") Then
                                    bFlag = False
                                End If
                                If Not bFlag Then
                                    Exit For
                                End If
                            Next lChars
                            If Not bFlag Then
                                Exit For
                            End If
                        Next lCount
                        If bFlag Then
                            bFlag = False
                            ' Check if email domain extension is valid
                            For lCount = LBound(vntValidDomainExt) To UBound(vntValidDomainExt)
                                If vntDomain(UBound(vntDomain)) = vntValidDomainExt(lCount) Then
                                    bFlag = True
                                    Exit For
                                End If
                            Next lCount
                            If bFlag Then
                                ' If email has passed through all this, it's valid
                                bValid = True
                            End If
                        End If
                    End If
                End If
            End If
        End If
    End If
    ValidateEmail = bValid

End Function

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/