#include<Array.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
_Cache("url", "http://www.lowadi.com/site/doLogIn")
_Cache("useragent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16")
$Form1 = GUICreate("Лошади бот", 210, 179, 466, 366)
$Label1 = GUICtrlCreateLabel("Логин:", 29, 18, 38, 17)
$Input1 = GUICtrlCreateInput("chika72rus", 67, 16, 121, 21)
$Label2 = GUICtrlCreateLabel("Пароль:", 22, 43, 45, 17)
$Input2 = GUICtrlCreateInput("ganja2013", 67, 41, 121, 21)
$Button1 = GUICtrlCreateButton("Авторизация", 67, 70, 121, 25)
$Label3 = GUICtrlCreateLabel("ЭКЮ:", 37, 122, 30, 17)
$Label4 = GUICtrlCreateLabel("", 67, 122, 121, 17)
$Label5 = GUICtrlCreateLabel("Лошади:", 20, 146, 47, 17)
$Label6 = GUICtrlCreateLabel("", 67, 146, 121, 17)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_Authorization($Input1, $Input2)
GUICtrlSetData($Label4, _ECU(_Request()))
EndSwitch
WEnd
Func _Authorization($sLogin, $sPassw)
Local $sPostData = StringFormat("&login=%s&password=%s&redirection=http%3A%2F%2Fwww.lowadi.com%2Fjeu%2F%3Fidentification%3D1&isBoxStyle=&1cf7cf527e=", GUICtrlRead($sLogin), GUICtrlRead($sPassw))
_Cache("login", $sLogin)
_Cache("passw", $sPassw)
$oHTTP.Open("POST", _Cache("url"), false)
$oHTTP.SetRequestHeader("User-Agent", _Cache("useragent"))
$oHTTP.SetRequestHeader("Host", "www.lowadi.com")
$oHTTP.SetRequestHeader("Origin", "http://www.lowadi.com")
$oHTTP.SetRequestHeader("Accept", "text/html, */*; q=0.01")
$oHTTP.SetRequestHeader("Content-Length", StringLen($sPostData))
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
$oHTTP.SetRequestHeader("Connection", "keep-alive")
$oHTTP.Send($sPostData)
If StringInStr($oHTTP.responseText, 'redirection') Then
_Cache("url", StringRegExpReplace(StringReplace($oHTTP.responseText, "\", ""), '{"redirection":"(.*)"}', "$1"))
_Cache("cookie", $oHTTP.getResponseHeader("Set-Cookie"))
Return 1
Else
Return 0
EndIf
EndFunc ;==>_Authorization
Func _Cache($sKey, $sValue = "")
If Not IsDeclared("Cache") Then
Assign("Cache", ObjCreate("Scripting.Dictionary"), 2)
Local $oCache = Eval("Cache")
Else
Local $oCache = Eval("Cache")
EndIf
If $sValue = "" Then
If $oCache.Exists($sKey) Then
$sRet = $oCache.Item($sKey)
Return $sRet
EndIf
Else
If $oCache.Exists($sKey) Then
$oCache.Item($sKey) = $sValue
Else
$oCache.Add($sKey, $sValue)
EndIf
EndIf
EndFunc ;==>_Cache
Func _Request()
$oHTTP.Open("GET", _Cache("url"), false)
$oHTTP.SetRequestHeader("User-Agent", _Cache("useragent"))
$oHTTP.SetRequestHeader("Host", "www.lowadi.com")
$oHTTP.SetRequestHeader("Origin", "http://www.lowadi.com")
$oHTTP.SetRequestHeader("Accept", "text/html, */*; q=0.01")
$oHTTP.SetRequestHeader("Cookie", _Cache("cookie"))
$oHTTP.SetRequestHeader("Connection", "keep-alive")
$oHTTP.Send()
$sHTML = $oHTTP.responseText
Return $sHTML
EndFunc ;==>_Request
Func _ECU($sData)
$aECU = StringRegExp($sData, 'id="reserve".*?>([\d|\s]+)', 3)
Return $aECU[0]
EndFunc ;==>_ECU