hot202 Posted August 27, 2009 Share Posted August 27, 2009 (edited) hey i have this udf script it works great but i wanted to know how i would be able to change it so it reads the ini from a website so it dont have it on the computer. The reason i want it on a website is that i want to be able to shange the passwords and be able to add usernames and passwords when i need to. Thanks in advance. expandcollapse popup#include <GUIConstants.au3> #include <String.au3> ; $login = _Login(@ScriptDir & '\Login.lin', "{11B614C8-240D-4A0D-8A8A-660CFFEAB439}") ; #FUNCTION# ==================================================================================================================== ; Name...........: _Login() ; Description ...: Creates a custom GUI to have the user login. ; Syntax.........: _Login($INIFileLocation, $EncryptionPassword [, $EncryptionLevel = 3 [, $LockoutTime = 5]]) ; Parameters ....: $INIFileLocation - Where the login information is saved. ; $EncryptionPassword - Additional security password. ; $EncryptionLevel - Optional: How many layers of encryption. ; $LockoutTime - Optional: Time (in seconds) the user has to wait after entering an invalid user/pass. ; ; Return values .: Success - Sets @Error to 0 and returns an array containing: ; [0] = Name the user logged in with. ; [1] = Password the user logged in with. ; ; Failure - Sets @Error to 1 and returns 0 ; ; Author ........: Szhlopp ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; =============================================================================================================================== Func _Login($INIFileLocation, $EncryptionPassword, $EncryptionLevel = 3, $LockoutTime = 5) Local $loginSuccess = False Local $aRet[2] $aRet[0] = 0 $aRet[1] = 0 Local $LoginGUI, $loginusername, $loginpassword, $loginlogin, $logincreate, _ $warnicon1, $warnicon2, $warnicon3, $statuslabel, $loggedinName, $loggedinPassword ; ------- Default Username ------ $defusername = IniRead($INIFileLocation, "Defaults", "Username", "") If $defusername = "" Then IniWrite($INIFileLocation, "Defaults", "Username", "") $defusername = @UserName EndIf ; ------------------------------- ; ------- GUI create ------------ $LoginGUI = GUICreate("Login", 302, 135) $loginusername = GUICtrlCreateCombo($defusername, 102, 21, 165, 21) GUICtrlCreateLabel("Username:", 30, 22, 55, 17) $loginpassword = GUICtrlCreateInput("", 102, 55, 165, 21, 32) GUICtrlCreateLabel("Password:", 30, 56, 53, 17) GUICtrlCreateGroup("Credentials", 6, 1, 286, 86) GUICtrlSetColor(-1, 0x0000ff) GUICtrlCreateGroup("", -99, -99, 1, 1) $loginlogin = GUICtrlCreateButton("Login", 5, 105, 88, 25, 0) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUICtrlSetTip(-1, "Click here to login") $logincreate = GUICtrlCreateButton("Create", 206, 105, 88, 25, 0) GUICtrlSetTip(-1, "Don't have an account? Click here to create one!") ; ------------------------------- ; Default User ------------------------------------------------ $Usernames = IniReadSection($INIFileLocation, "Usernames") If @error <> 1 Then $Usernames_Length = UBound($Usernames) - 1 For $I = 1 To $Usernames_Length $split = StringSplit($Usernames[$I][1], "|") GUICtrlSetData($loginusername, _StringEncrypt(0, $split[1], $EncryptionPassword, $EncryptionLevel)) Next EndIf ; Icon/notifications ----------------------------------------------- $warnicon1 = GUICtrlCreateIcon("Shell32.dll", -132, 270, 22, 15, 15) GUICtrlSetState(-1, $GUI_HIDE) $warnicon2 = GUICtrlCreateIcon("Shell32.dll", -132, 270, 58, 15, 15) GUICtrlSetState(-1, $GUI_HIDE) $warnicon3 = GUICtrlCreateIcon("Shell32.dll", -145, 145, 95, 15, 15) GUICtrlSetState(-1, $GUI_HIDE) $statuslabel = GUICtrlCreateLabel("Successfully created!", 95, 118) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState(-1, $GUI_HIDE) GUISetState(@SW_SHOW) While 1 Sleep(20) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $logincreate GUICtrlSetState($warnicon1, $GUI_HIDE) GUICtrlSetState($warnicon2, $GUI_HIDE) GUICtrlSetState($warnicon3, $GUI_HIDE) GUICtrlSetState($statuslabel, $GUI_HIDE) $loginUN = GUICtrlRead($loginusername) $loginPS = GUICtrlRead($loginpassword) If $loginUN = "" Then GUICtrlSetData($statuslabel, " Username is blank") GUICtrlSetState($statuslabel, $GUI_SHOW) GUICtrlSetState($warnicon1, $GUI_SHOW) ElseIf $loginPS = "" Then GUICtrlSetData($statuslabel, " Passsword is blank") GUICtrlSetState($statuslabel, $GUI_SHOW) GUICtrlSetState($warnicon2, $GUI_SHOW) Else $Usernames = IniReadSection($INIFileLocation, "Usernames") $Usernames_Length = UBound($Usernames) - 1 $I = 1 $error = 0 If $Usernames_Length >= 1 Then For $I = 1 To $Usernames_Length $split = StringSplit($Usernames[$I][1], "|") If $loginUN == _StringEncrypt(0, $split[1], $EncryptionPassword, $EncryptionLevel) Then $error = 1 ExitLoop EndIf Next EndIf If $error = 0 Then IniWrite($INIFileLocation, "Usernames", "Username" & Int($Usernames_Length) + 1, _StringEncrypt(1, $loginUN, $EncryptionPassword, $EncryptionLevel) & "|" & _StringEncrypt(1, $loginPS, $loginUN & $EncryptionPassword & $loginPS, $EncryptionLevel)) GUICtrlSetState($warnicon3, $GUI_SHOW) GUICtrlSetData($statuslabel, " Successfully created!") GUICtrlSetState($statuslabel, $GUI_SHOW) Else GUICtrlSetState($warnicon1, $GUI_SHOW) GUICtrlSetState($loginusername, $GUI_FOCUS) GUICtrlSetData($statuslabel, " Username in use!") GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf EndIf Case $loginlogin $loginSuccess = False GUICtrlSetState($warnicon1, $GUI_HIDE) GUICtrlSetState($warnicon2, $GUI_HIDE) GUICtrlSetState($warnicon3, $GUI_HIDE) GUICtrlSetState($statuslabel, $GUI_HIDE) $loginUN = GUICtrlRead($loginusername) $loginPS = GUICtrlRead($loginpassword) $Usernames = IniReadSection($INIFileLocation, "Usernames") $Usernames_Length = UBound($Usernames) - 1 For $I = 1 To $Usernames_Length $split = StringSplit($Usernames[$I][1], "|") If $split[2] == _StringEncrypt(1, $loginPS, $loginUN & $EncryptionPassword & $loginPS, $EncryptionLevel) Then ; MsgBox(0, "", "Now logged in") GUICtrlSetState($warnicon3, $GUI_SHOW) GUICtrlSetData($statuslabel, " Now logged in") GUICtrlSetState($statuslabel, $GUI_SHOW) $loggedinName = $loginUN $loggedinPassword = $loginPS $loginSuccess = True Sleep(500) ExitLoop EndIf Next If $loginSuccess = False Then GUICtrlSetState($warnicon1, $GUI_SHOW) GUICtrlSetState($warnicon2, $GUI_SHOW) GUICtrlSetState($statuslabel, $GUI_SHOW) If $LockoutTime >=1 Then GUICtrlSetState($loginpassword, $GUI_DISABLE) GUICtrlSetState($loginusername, $GUI_DISABLE) For $I = 0 To $LockoutTime - 1 GUICtrlSetData($statuslabel, "Invalid User/Pass! - " & $LockoutTime - $I) Sleep(1000) Next GUICtrlSetState($loginpassword, $GUI_ENABLE) GUICtrlSetState($loginusername, $GUI_ENABLE) EndIf GUICtrlSetData($statuslabel, " Invalid User/Pass!") EndIf EndSwitch If $loginSuccess = True Then GUIDelete($LoginGUI) $aRet[0] = $loggedinName $aRet[1] = $loggedinPassword ExitLoop EndIf WEnd If $loginSuccess = True Then SetError(0) Return $aRet Else SetError(1) Return 0 EndIf EndFunc ;==>Login Edited August 27, 2009 by hot202 Link to comment Share on other sites More sharing options...
nathanjess Posted August 27, 2009 Share Posted August 27, 2009 That's what i want to be able to do with this code to. I have tryed but cant work it out. Is there anyone that can help us? Link to comment Share on other sites More sharing options...
Developers Jos Posted August 27, 2009 Developers Share Posted August 27, 2009 Are you being serious here or is this your way of trying to speed up things? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
hot202 Posted August 27, 2009 Author Share Posted August 27, 2009 Are you being serious here or is this your way of trying to speed up things?what u mean? cos i asked about this in another topic ages ago? Link to comment Share on other sites More sharing options...
Developers Jos Posted August 27, 2009 Developers Share Posted August 27, 2009 what u mean? cos i asked about this in another topic ages ago?I hate when people play dummy knowingly:Creating and using multiple accounts is against forum policies and you clearly created both posts.Clear enough for you?You get a posting ban of 1 week for this and one account will be banned.*click* SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts