Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Xchange
- #include <ButtonConstants.au3>
- #include <EditConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <StaticConstants.au3>
- #include<mysql.au3>
- #include <WindowsConstants.au3>
- #include<guiconstants.au3>
- #include<INetSmtpMailCom.au3>
- global $UserNamesql = "xchange123" ;MySQL User
- global $Passwordsql = "mendax123" ;MySQL Passwort
- global $Databasesql = "xchange123" ;Database
- global $MySQLServerNamesql = "db4free.net" ;Hostname oder IP
- global $key
- $Login = GUICreate("Login", 316, 205, 378, 183, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_POPUP, $WS_GROUP, $WS_CLIPSIBLINGS))
- $Label1 = GUICtrlCreateLabel("Xchange Login", 0, 0, 312, 36, $SS_CENTER)
- GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
- $Benutzername = GUICtrlCreateInput("", 115, 66, 148, 21)
- $aPassword = GUICtrlCreateInput("", 115, 93, 148, 21, $ES_PASSWORD)
- $Label2 = GUICtrlCreateLabel("Benutzername:", 1, 66, 106, 20, $SS_CENTER)
- $Passwort = GUICtrlCreateLabel("Passwort:", -13, 94, 113, 17, $SS_CENTER)
- $Login = GUICtrlCreateButton("Login", 12, 120, 253, 24, $WS_GROUP)
- $Registrierung = GUICtrlCreateButton("Registrierung", 12, 147, 253, 24, $WS_GROUP)
- GUISetState(@SW_SHOW)
- While 1
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $GUI_EVENT_CLOSE
- GUISetState(@SW_HIDE, $createaccount)
- GUISetState(@SW_ENABLE, $Login)
- Case $Login
- sqlcheck()
- Case $Registrierung
- GUISetState(@SW_DISABLE, $Login)
- $createaccount = GUICreate("Registrierung für Xchange", 498, 376, 205, 164)
- $aLabel1 = GUICtrlCreateLabel("Registrierung für Xchange", 1, 0, 496, 56, $SS_SUNKEN)
- GUICtrlSetFont(-1, 35, 400, 0, "MS Sans Serif")
- $aInput1 = GUICtrlCreateInput("Gewünschter Username", 13, 80, 345, 21)
- $aMail = GUICtrlCreateInput("Deine Mailadresse", 14, 108, 344, 21)
- $aPW = GUICtrlCreateInput("Gewünschtes Passwort", 16, 135, 344, 21)
- $bPw = GUICtrlCreateInput("Passwort wiederholen", 15, 165, 344, 21)
- $aCheckbox1 = GUICtrlCreateCheckbox("Ja, ich will den Newsletter erhalten", 16, 193, 243, 21)
- $aCheckbox2 = GUICtrlCreateCheckbox("Ja, mir ist bewusst, dass es verboten ist, urheberrechtlich geschütztes Material zu verbreiten,", 17, 215, 387, 36)
- $aButton1 = GUICtrlCreateButton("Anmeldung abschicken", 16, 255, 341, 26, $WS_GROUP)
- $aInput2 = GUICtrlCreateInput("Aktivierungscode", 18, 289, 343, 21)
- GUICtrlSetState(-1, $gui_disable)
- GUISetState(@SW_SHOW, $createaccount)
- While WinExists("Registrierung für Xchange")
- $msg = GUIGetMsg($createaccount)
- Switch $msg
- case $GUI_EVENT_CLOSE
- guisetstate(@SW_show,$login)
- guidelete($createaccount)
- Case $aButton1
- Msgbox(0, "", "")
- If GUICtrlRead($aButton1) = "Anmeldung abschicken" and stringlen(guictrlread($ainput1))>4 and stringlen(guictrlread($ainput1))<30 and stringlen(guictrlread($amail))>4 and stringlen(guictrlread($amail))<30 and stringlen(guictrlread($apw))>4 _
- and stringlen(guictrlread($apw))<30 and guictrlread($apw)=guictrlread($bpw) and guictrlread($acheckbox2)= $gui_checked Then
- MsgBox(0, "Anmeldung abgeschickt", "Deine Anmeldung wurde abgeschickt. Dir wurde eine Email mit einem Aktivierungscode gesendet. Gib diesen Aktivierungscode im unteren Feld ein")
- GUICtrlSetState($aInput1, $gui_disable)
- GUICtrlSetState($aMail, $gui_disable)
- GUICtrlSetState($aPW, $gui_disable)
- GUICtrlSetState($bPw, $gui_disable)
- GUICtrlSetState($aCheckbox1, $gui_disable)
- GUICtrlSetState($aCheckbox2, $gui_disable)
- GUICtrlSetState($aInput2, $gui_enable)
- GUICtrlSetData($aButton1, "Account aktivieren")
- _registerinsql()
- _sendemail(guictrlread($amail))
- else
- Msgbox(0, "Fehler", "Der Benutzername darf min. 5 und max 30 Zeichen haben." &@crlf& "Die Emailadresse darf max 30 Zeichen haben."&@crlf& "Das Passwort darf min. 5 und max. 30 Zeichen haben."&@crlf& "Die zwei Passwörter müssen übereinstimmen und du musst die 'Mini-AGBs' akzeptieren")
- EndIf
- If Guictrlread($abutton1)= "Account aktivieren" then
- $SQLconnect = _MySQLConnect($UserNamesql,$Passwordsql,$Databasesql,$MySQLServerNamesql)
- $SQLCode = "SELECT Aktivierungsnummer FROM Members WHERE Aktivierungsnummer='" & GUICtrlRead($aInput1) & "'"
- $TableContents = _Query($SQLconnect, $SQLCode)
- With $TableContents
- While Not .EOF
- $aktivierungscode &= .Fields("Aktivierungsnummer" ).value & @CRLF
- .MoveNext
- WEnd
- EndWith
- endif
- If guictrlread($aInput2)= $aktivierungscode Then
- Msgbox(0, "Aktivierung erfolgreich", "Deine Anmeldung war erfolgreich. Der Account ist nun freigeschalten und du kannst dich einloggen")
- Else
- Msgbox(0, "Fehler", "Falscher Aktivierungscode")
- endif
- EndSwitch
- WEnd
- EndSwitch
- WEnd
- Func sqlcheck()
- If not (GUICtrlRead($aPassword)) = 0 Then
- Local $pw
- $SQLCode = "SELECT Passwort FROM Members WHERE Benutzername ='" & GUICtrlRead($Benutzername) & "'"
- $TableContents = _Query($SQLconnect, $SQLCode)
- With $TableContents
- While Not .EOF
- $pw &= .Fields("Passwort" ).value & @CRLF
- .MoveNext
- WEnd
- EndWith
- $readinput = GUICtrlRead($aPassword)
- If $pw = $readinput Then
- MsgBox(0, "Login erfolgreich", "Du wurdest erfolgreich angemeldet")
- Else
- MsgBox(0, "Fehler", "Der Login-Vorgang war nicht erfolgreich")
- EndIf
- EndIf
- EndFunc ;==>sqlcheck
- Func _registerinsql()
- $SQLconnect = _MySQLConnect($UserNamesql, $Passwordsql, $Databasesql, $MySQLServerNamesql)
- Dim $ColumnNames[5]
- $ColumnNames[0] = "Benutzername"
- $ColumnNames[1] = "Passwort"
- $ColumnNames[2] = "Email"
- $ColumnNames[3] = "Aktivierungsnummer"
- $ColumnNames[4] = "activated"
- Dim $Newaccount[5]
- $Newaccount[0] = GUICtrlRead($aInput1)
- $Newaccount[1] = GUICtrlRead($aMail)
- $Newaccount[2] = GUICtrlRead($aPW)
- $Key = Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1) & Random(0, 9, 1)
- $Newaccount[3] = $Key
- $Newaccount[4] = 0
- _AddRecord($SQLconnect, "Members", $ColumnNames, $Newaccount)
- EndFunc ;==>_registerinsql
- Func _SendEmail($sEmail)
- $SmtpServer = "smtp.web.de" ; address for the smtp-server to use - REQUIRED
- $FromName = "Xchange" ; name from who the email was sent
- $FromAddress = "" ; address from where the mail should come
- $ToAddress = $sEmail; destination address of the email - REQUIRED
- $Subject = "Registrierungs Bestätigung" ; subject from the email - can be anything you want it to be
- $Body = "Zur Bestätigung ihrer Angaben übernehmen Sie bitte den unten stehenden Code und melden Sie sich an." & @CRLF & "Code: " & $Key & @CRLF & "Vielen Dank" & @CRLF & "Das Xchange Team" ; the messagebody from the mail - can be left blank but then you get a blank mail
- $AttachFiles = "" ; the file you want to attach- leave blank if not needed
- $CcAddress = "" ; address for cc - leave blank if not needed
- $BccAddress = "" ; address for bcc - leave blank if not needed
- $Importance = "Normal" ; Send message priority: "High", "Normal", "Low"
- $UserName = "x_change" ; username for the account used from where the mail gets sent - REQUIRED
- $Password = "mendax123" ; password for the account used from where the mail gets sent - REQUIRED
- $IPPort = 587 ; port used for sending the mail normaly 25
- $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS
- $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $UserName, $Password, $IPPort, $ssl)
- Return ($Key)
- EndFunc ;==>_SendEmail
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement