Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Attribute VB_Name = "modAccount"
- '**************************************************************************
- 'This program is free software; you can redistribute it and/or modify
- 'it under the terms of the GNU General Public License as published by
- 'the Free Software Foundation; either version 2 of the License, or
- '(at your option) any later version.
- '
- 'This program is distributed in the hope that it will be useful,
- 'but WITHOUT ANY WARRANTY; without even the implied warranty of
- 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 'GNU General Public License for more details.
- '
- 'You should have received a copy of the GNU General Public License
- 'along with this program; if not, write to the Free Software
- 'Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- '**************************************************************************
- '@Module Author: Wolftein
- '@Module Update: 4/7/09
- '@Module Explination: Account Functions
- '@Module Todo:
- Option Explicit
- Public Function accountExist(ByVal Name As String) As Boolean
- '*****************************************************************
- 'Return if the Account Exist or NOT
- 'Author: Wolftein
- '*****************************************************************
- srvDatabase.Open "SELECT * FROM accounts WHERE name='" & UCase$(Name) & "'", , adOpenStatic, adLockOptimistic, adCmdText
- accountExist = (srvDatabase.EOF = False)
- srvDatabase.Close
- End Function
- Public Function accountCreate(ByVal Name As String, ByVal Password As String, ByVal Email As String) As Boolean
- '*****************************************************************
- 'Create a new Account
- 'Author: Wolftein
- '*****************************************************************
- accountCreate = False
- ' if the file create, then exit the function
- If (accountExist(Name) = True) Then Exit Function
- ' create the account to the database
- srvDatabaseConnection.Execute "INSERT INTO accounts VALUES('" & UCase$(Name) & "','" & Password & "','" & Email & "'," & 0 & ",' ')"
- accountCreate = True
- End Function
- Public Function accountCheckPassword(ByVal Name As String, ByVal Password As String) As Boolean
- '*****************************************************************
- 'Return if the password Match or not
- 'Author: Wolftein
- '*****************************************************************
- srvDatabase.Open "SELECT * from accounts WHERE name='" & UCase$(Name) & "'", , adOpenStatic, adLockOptimistic, adCmdText
- accountCheckPassword = (Trim$(srvDatabase!Password) = Password)
- srvDatabase.Close
- End Function
- Public Function accountChangePassword(ByVal Name As String, ByVal Password As String, ByVal newPassword As String) As Boolean
- '*****************************************************************
- 'Change the password of an account
- 'Author: Wolftein
- '*****************************************************************
- accountChangePassword = False
- ' if the account doesn't exist then exit
- If (accountExist(Name) = False) Then Exit Function
- ' Check if the password match
- If (accountCheckPassword(Name, Password) = False) Then Exit Function
- ' get the account row
- srvDatabase.Open "SELECT * from accounts WHERE name='" & UCase$(Name) & "'", , adOpenStatic, adLockOptimistic, adCmdText
- ' change the password
- srvDatabase!Password = newPassword
- ' update and close
- srvDatabase.Update
- srvDatabase.Close
- accountChangePassword = True
- End Function
- Public Function accountDelete(ByVal Name As String, ByVal Password As String) As Boolean
- '*****************************************************************
- 'Delete an Account
- 'Author: Wolftein
- '*****************************************************************
- accountDelete = False
- ' if the account doesn't exist then exit
- If (accountExist(Name) = False) Then Exit Function
- ' Check if the password match
- If (accountCheckPassword(Name, Password) = False) Then Exit Function
- ' delete each character on that account
- ' TODO:
- ' destroy the account
- srvDatabase.Open "SELECT * from accounts WHERE name='" & UCase$(Name) & "'", , adOpenStatic, adLockOptimistic, adCmdText
- srvDatabase.Delete adAffectCurrent
- accountDelete = True
- End Function
- Public Function accountLogin(ByVal Name As String, ByVal Password As String, ByRef List As String) As Boolean
- '*****************************************************************
- 'Login an existing Account, save in @List the list of Characters
- 'Author: Wolftein
- '*****************************************************************
- accountLogin = False
- ' if the file create, then exit the function
- If (accountExist(Name) = False) Then Exit Function
- ' Check if the password match
- If (accountCheckPassword(Name, Password) = False) Then Exit Function
- ' get the list of characters
- srvDatabase.Open "SELECT * from accounts WHERE name='" & UCase$(Name) & "'", , adOpenStatic, adLockOptimistic, adCmdText
- List = srvDatabase!Characters
- ' close the query
- srvDatabase.Close
- accountLogin = True
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement