Sei sulla pagina 1di 2

#include <GUIConstants.

au3>
#Include <String.au3>
$FileUP=@DocumentsCommonDir&"\UserPwd.File"
$AR= GUICreate("Accedi/Registrati", 426, 61, 193, 125)
$Registrati= GUICtrlCreateButton("Registrati", 8, 16, 201, 25, 0)
$Login= GUICtrlCreateButton("Accedi", 212, 17, 201, 25, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg= GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Registrati
GUIDelete($AR)
Registrati()
Case $Login
Login()
EndSwitch
WEnd
Func Registrati()
GUICreate("Registrati", 354, 120, 302, 218)
GUICtrlCreateLabel("Username:", 8, 16, 127, 17)
$User= GUICtrlCreateInput("", 144, 16, 201, 21)
$Pwd= GUICtrlCreateInput("", 144, 48, 201, 21)
GUICtrlCreateLabel("Password:", 8, 48, 133, 17)
$Registrati_= GUICtrlCreateButton("Registrati", 248, 88, 97, 25, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg= GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Registrati_
$User2=GUICtrlRead($User)
$Pwd2=GUICtrlRead($Pwd)
$User3=_StringEncrypt(1, $User2, "ByHaKul", 1)
$Pwd3=_StringEncrypt(1, $Pwd2, "ByHaKul", 1)
If FileExists($FileUP) Then
$Open=FileOpen($FileUP, 0)
$Controllo=FileReadLine($Open)
If @error then ExitLoop
If $Controllo=$User3 Then
MsgBox(64, "Errore", "UserName già usato da un altro utente")
Else
FileWrite($FileUP, $User3 &@CRLF& $Pwd3 &@CRLF )
TrayTip("Attendere","Attendere...", 0)
Sleep(2000)
MsgBox(64, "Completato","Account creato con successo")
Exit
EndIf
Else
FileWrite($FileUP, $User3 &@CRLF& $Pwd3 &@CRLF )
TrayTip("Attendere","Attendere...", 0)
Sleep(2000)
MsgBox(64, "Completato","Account creato con successo")
Exit
EndIf
EndSwitch
WEnd
EndFunc
Func Login()
GUICreate("Accedi", 354, 120, 302, 218)
GUICtrlCreateLabel("Username:", 8, 16, 127, 17)
$User= GUICtrlCreateInput("", 144, 16, 201, 21)
$Pwd= GUICtrlCreateInput("", 144, 48, 201, 21)
GUICtrlCreateLabel("Password:", 8, 48, 133, 17)
$Accedi_= GUICtrlCreateButton("Login", 248, 88, 97, 25, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg= GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Accedi_
$Linea=1
$ReadUser= GUICtrlRead($User)
$ReadPwd= GUICtrlRead($Pwd)
$File = FileOpen($FileUP,0)
While 1
$Log=FileReadLine($File)
if @error then ExitLoop
$LogPwd=FileReadLine($File)
if @error then ExitLoop
If _StringEncrypt(0, $Log, "ByHaKul", 1) = $ReadUser and
_StringEncrypt(0, $LogPwd, "ByHaKul", 1) = $ReadPwd Then
TrayTip("Attendere","Attendere...", 0)
Sleep(2000)
MsgBox(64, "Completato","Accesso completa
to")
Exit
EndIf
WEnd
MsgBox(64, "Errore","Accesso negato")
Exit
EndSwitch
WEnd
EndFunc

Potrebbero piacerti anche