Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Version := 1.0
- SendMode Input
- #SingleInstance force
- #NoTrayIcon
- setworkingdir, %a_scriptdir%
- ListLines Off
- #include mysql.ahk ; pull from local directory
- mysql := new mysql ; instantiates an object using this class
- db := mysql.connect("host,"user","password","database")
- if db =
- return
- _serial = 0
- IniRead, _V1remember, Settings.ini, LoginData, _remember
- IniRead, _user_name, Settings.ini, LoginData, _user_name
- IniRead, _password, Settings.ini, LoginData, _password
- ;===========================================
- ; LOGIN TO APP
- ;===========================================
- ;-----------------------
- ; Create LOGIN gui
- ;-----------------------
- Gui, Add, Text, x2 y3 w80 h20 , Username
- Gui, Add, Edit, x82 y3 w130 h20 Limit12 vUser_name
- Gui, Add, Text, x2 y30 w80 h20 , Password
- Gui, Add, Edit, x82 y30 w130 h20 Limit20 vPassword
- Gui, Add, CheckBox, x90 y60 w130 h20 v_1remember g_RememberLoginData, Remember Me
- Gui, Add, Picture, x2 y50 w80 h40 , C:\Users\Zielu\Desktop\icon.png
- Gui, Add, Button, x2 y90 w90 h20 g_Login , Login
- Gui, Add, Button, x112 y90 w100 h20 g_Register , Register
- Gui, Show, center h112 w217, HeadHunt Login
- GuiControl,, _1remember, %_V1remember%
- If _V1remember = 1
- GuiControl,, User_name, %_user_name%
- GuiControl,, Password, %_password%
- sql =
- (
- SELECT version
- FROM versions
- WHERE id = 1
- )
- versionresult := mysql.query(db, sql)
- mysql.lvfill(sql, versionresult)
- if versionresult != %Version%
- {
- MsgBox, Update is available, go to download site.
- }
- Return
- GuiClose:
- ExitApp
- Return
- ;-----------------------
- ; SAVE LOGIN DATA
- ;-----------------------
- _RememberLoginData:
- GuiControlGet, _1remember
- IniWrite, %_1remember%,Settings.ini, LoginData, _remember
- IniRead, _V1remember, Settings.ini, LoginData, _remember
- return
- ;-----------------------
- ; LOGIN BUTTON
- ;-----------------------
- _Login:
- GuiControlGet, User_name
- GuiControlGet, Password
- if _V1remember = 1
- {
- IniWrite, %User_name%,Settings.ini, LoginData, _user_name
- IniWrite, %Password%,Settings.ini, LoginData, _password
- Gosub, _Login2
- }
- else
- {
- Gosub, _Login2
- }
- return
- _Login2:
- gui, submit, nohide
- sql =
- (
- SELECT password
- FROM users
- WHERE user_name = "%User_name%"
- )
- loginresult := mysql.query(db, sql)
- mysql.lvfill(sql, loginresult)
- if loginresult =
- {
- msgbox, Username or password is not correct.
- }
- else
- if loginresult = %Password%
- {
- Gosub, UserHardwareId
- }
- else
- {
- msgbox, Username or password is not correct.
- }
- gui, submit, nohide
- return
- Return
- ;-----------------------
- ; Get hardware id
- ;-----------------------
- UserHardwareId:
- gui, submit, nohide
- windir = %A_WinDir%
- StringMid, Drive, windir,1,2
- DriveGet, fingerprintLOGIN, Serial, %Drive%
- sql =
- (
- SELECT hardID
- FROM users
- WHERE user_name = "%User_name%"
- )
- hardresult := mysql.query(db, sql)
- mysql.lvfill(sql, hardresult)
- if hardresult =
- {
- msgbox, Hardware ID not match.
- }
- else
- if hardresult = %fingerprintLOGIN%
- {
- Gosub, CheckLicenceDays
- }
- else
- {
- msgbox, Hardware ID not match.
- }
- gui, submit, nohide
- return
- ;-----------------------
- ; Check Licence Days
- ;-----------------------
- CheckLicenceDays:
- gui, submit, nohide
- sql =
- (
- SELECT days
- FROM users
- WHERE user_name = "%User_name%"
- )
- daysresult := mysql.query(db, sql)
- mysql.lvfill(sql, daysresult)
- if daysresult <= 0
- {
- msgbox, Your licence expired, purchase application.
- ExitApp
- }
- else
- {
- Gui, 1:Destroy
- MsgBox, Welcome %User_name%! You have %daysresult% days licence.
- Gosub, access
- }
- return
- ;===========================================
- ; REGISTER
- ;===========================================
- _Register:
- Gui, 1:Destroy
- Gui, 2:Add, Text, x2 y0 w240 h40 , Welcome to registration panel! Insert all data carefully. If you have any problems please contact support.
- Gui, 2:Add, Text, x2 y50 w80 h20 , User name
- Gui, 2:Add, Edit, x82 y50 w160 h20 vuser_name
- Gui, 2:Add, Text, x2 y80 w80 h20 , Password
- Gui, 2:Add, Edit, x82 y80 w160 h20 vpassword
- Gui, 2:Add, Text, x2 y105 w80 h28 , Repeat password
- Gui, 2:Add, Edit, x82 y110 w160 h20 vpassword2
- Gui, 2:Add, Text, x2 y140 w80 h20 , Email adress
- Gui, 2:Add, Edit, x82 y140 w160 h20 vmail
- Gui, 2:Add, Text, x2 y170 w80 h20 , Serial
- Gui, 2:Add, Edit, x82 y170 w160 h20 vserial
- Gui, 2:Add, Button, x72 y200 w100 h20 gRegister, Register
- Gui, 2:Show, center h224 w248, Register
- Return
- 2GuiClose:
- ExitApp
- Return
- ;============================================================
- ; rejestracja
- ;============================================================
- Register: ; check username
- gui, submit, nohide
- StringLen, userlength, user_name
- If user_name =
- {
- MsgBox, Username can not be empty.
- }
- else
- if userlength < 5
- {
- MsgBox, Username have to contain at least 5 characters.
- }
- else
- Found := RegExMatch(user_name,"\W",Char)
- If Found <> 0
- {
- MsgBox, Username contain illegal character.
- }
- else
- {
- Gosub, checkpassword
- }
- return
- ;-----------------------
- ; Check passwords
- ;-----------------------
- checkpassword:
- gui, submit, nohide
- StringLen, passlength, password
- if password =
- {
- MsgBox, Password can not be empty.
- }
- else
- if password = %user_name%
- {
- MsgBox, Password can not be the same as the user name.
- }
- else
- if passlength < 8
- {
- MsgBox, Password have to contain at least 8 characters.
- }
- else
- Found := RegExMatch(password,"\W",Char)
- If Found <> 0
- {
- MsgBox, Password contain illegal character.
- }
- else
- if password != %password2%
- {
- MsgBox, Entered passwords do not match.
- }
- else
- if password = %password2%
- {
- Gosub, checklength
- }
- return
- checklength:
- gui, submit, nohide
- StringLen, passlength, password
- if passlength > 7
- Gosub, usercheck
- return
- ;-----------------------
- ; Check username
- ;-----------------------
- usercheck:
- gui, submit, nohide
- sql =
- (
- SELECT COUNT(user_name)
- FROM users
- WHERE user_name = "%user_name%"
- )
- result := mysql.query(db, sql)
- mysql.lvfill(sql, result)
- if result = 1
- {
- MsgBox, Username is currently used.
- }
- else
- {
- Gosub, mailcheck
- }
- gui, submit, nohide
- Return
- ;-----------------------
- ; Check email
- ;-----------------------
- mailcheck:
- gui, submit, nohide
- If mail =
- {
- MsgBox, Your email is required for security reasons.
- }
- else
- IfNotInString, mail, @
- {
- MsgBox, Email adress is not correct.
- }
- else
- {
- Gosub, mailcheckdb
- }
- return
- mailcheckdb:
- gui, submit, nohide
- sql =
- (
- SELECT COUNT(email)
- FROM users
- WHERE email = "%mail%"
- )
- result := mysql.query(db, sql)
- mysql.lvfill(sql, result)
- if result = 1
- {
- MsgBox, Email adress is currently used.
- }
- else
- {
- Gosub, serialcheck
- }
- gui, submit, nohide
- Return
- ;-----------------------
- ; Check serial
- ;-----------------------
- serialcheck:
- gui, submit, nohide
- sql =
- (
- SELECT COUNT(serial)
- FROM licencje
- WHERE serial = "%serial%"
- )
- result := mysql.query(db, sql)
- mysql.lvfill(sql, result)
- if result =
- {
- msgbox, Your serial is not correct or already consumed.
- }
- else
- if result = 1
- {
- Gosub, register_user
- }
- else
- {
- msgbox, Your serial is not correct or already consumed.
- }
- Return
- ;-----------------------
- ; Register user
- ;-----------------------
- register_user:
- windir = %A_WinDir%
- StringMid, Drive, windir,1,2
- DriveGet, fingerprint, Serial, %Drive%
- gui, submit, nohide
- sql =
- (
- SELECT days
- FROM licencje
- WHERE serial = "%serial%"
- )
- days := mysql.query(db, sql)
- mysql.lvfill(sql, days)
- sql =
- (
- INSERT INTO users (
- user_name,
- password,
- serial,
- email,
- hardID,
- days
- `)
- VALUES (
- '%user_name%',
- '%password%',
- '%serial%',
- '%mail%',
- '%fingerprint%',
- '%days%'
- `)
- )
- result := mysql.query(db, sql)
- Sleep 200
- sql =
- (
- DELETE
- FROM licencje
- WHERE serial = "%serial%"
- )
- result := mysql.query(db, sql)
- Sleep 200
- msgbox, Your registration is complete.
- Gui, 2:Destroy
- Reload
- Sleep 1000
- msgbox, ERROR ERROR GRRRR : (
- return
- ;===========================================
- ; ACCESS TO APP
- ;===========================================
- access:
- msgbox, have a nice day
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement