Quote:
Originally Posted by Alex_II
I did not play DO since about a year . I dont know how to change server... Im just saying how you can do it. Searching you have to do alone
|
learn/ and some litle exchange
; Авторизация
$sResponse = _HttpRequest('http://darkorbit.bigpoint.com', 'loginForm_default_username=' & $sLogin & '&loginForm_default_password=' & $sPass & '&loginForm_default_login_submit=%D0%92%D1%85%D0%B E%D0%B4')
If StringInStr($sResponse, 'Данное имя пользователя и/или пароль некорректны') Then
MsgBox(16, 'Ошибка', 'Данное имя пользователя и/или пароль некорректны')
Exit
Else
MsgBox(64, 'Внимание', 'Авторизация успешно пройдена')
EndIf
; <== Авторизация
; Выбор сервера
$sServerLink = StringRegExpReplace($sResponse, '(?s)(?i).+?<div id="instance_' & $div & '.+?<a class="verweis" href="(.+?)">.+', '\1')
Sleep(5000)
$sResponse = _HttpRequest($sServerLink, '', 'GET')
If Not StringInStr($sResponse, 'Привет, космический пилот!') Then
MsgBox(16, 'Ошибка', 'Ошибка выбора сервера')
Else
MsgBox(64, 'Внимание', 'Сервер успешно выбран')
EndIf
; <== Выбор сервера
FileOpen("c:\1.txt",2)
FileWrite("c:\1.txt",$sResponse)
FileClose("c:\1.txt")
$File = 'c:\1.txt'
$Text = "dosid"
$FindVar = _FileFindText($File, $Text, 0, 1)
If Not @error Then
For $i = 1 To $FindVar[0][0]
$sstr = $FindVar[$i][1]
Next
ElseIf @error = 1 Then
MsgBox(262144+16, "Error", "Unable to locate the File:" & @LF & "[" & $File & "]")
ElseIf @error > 0 Then
MsgBox(262144+48, "Error", "The Text [" & $Text & "] was not found in file(s):" & @LF & "[" & $File & "]")
EndIf
for $re = 0 to 14
$TStr = StringLeft($sStr, 1 - 1) & StringTrimLeft($sStr, 1)
$sStr = $TStr
Next
FileOpen("c:\2.txt",2)
FileWrite("c:\2.txt",$sStr)
FileClose("c:\2.txt")
$SID = FileRead("c:\2.txt",32)
$oIE =_IECreate ($SERV & '.darkorbit.bigpoint.com/indexInternal.es?action=internalStart&dosid=' & $SID,1,0)
_IELoadWait ($oIE)
_IENavigate($oIE,'http://' & $SERV & '.darkorbit.bigpoint.com/indexInternal.es?&action=internalSkylab&subaction= upgrade&construction=storageModule')
;_IEAction ($oIE, "close")
;$oIE =_IECreate ($SERV & '.darkorbit.bigpoint.com/indexInternal.es?action=internalStart&dosid=' & $SID,1,0)
;_IELoadWait ($oIE)
;_IENavigate($oIE,'http://' & $SERV & '.darkorbit.bigpoint.com/indexInternal.es?&action=internalSkylab&subaction= upgrade&construction=solarModule')
;_IELoadWait ($oIE)
;_IEAction ($oIE, "close")
;$oIE =_IECreate ($SERV & '.darkorbit.bigpoint.com/indexInternal.es?action=internalStart&dosid=' & $SID,1,0)
;_IELoadWait ($oIE)
;_IENavigate($oIE,'http://' & $SERV & '.darkorbit.bigpoint.com/indexInternal.es?&action=internalSkylab&subaction= prometiumCollector')
;_IENavigate($oIE,'http://' & $SERV & '.darkorbit.bigpoint.com/indexInternal.es?&action=internalSkylab&subaction= enduriumCollector')
;_IENavigate($oIE,'http://' & $SERV & '.darkorbit.bigpoint.com/indexInternal.es?&action=internalSkylab&subaction= terbiumCollector')
;_IENavigate($oIE,'http://' & $SERV & '.darkorbit.bigpoint.com/indexInternal.es?&action=internalSkylab&subaction= prometidRefinery')
;_IENavigate($oIE,'http://' & $SERV & '.darkorbit.bigpoint.com/indexInternal.es?&action=internalSkylab&subaction= duraniumRefinery')
;_IENavigate($oIE,'http://' & $SERV & '.darkorbit.bigpoint.com/indexInternal.es?&action=internalSkylab&subaction= xenoModule')
;_IENavigate($oIE,'http://' & $SERV & '.darkorbit.bigpoint.com/indexInternal.es?&action=internalSkylab&subaction= promeriumRefinery')
;_IENavigate($oIE,'http://' & $SERV & '.darkorbit.bigpoint.com/indexInternal.es?&action=internalSkylab&subaction= storageModule')
;_FFConnect()
;_FFStart()
;_FFOpenURL($SERV & '.darkorbit.bigpoint.com/indexInternal.es?action=internalStart&dosid=' & $SID)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd
Func _HttpRequest($sRequestURL, $sSendData, $sType='POST')
If $sType == 'GET' AND $sSendData <> '' Then
$sRequestURL &= '?' & $sSendData
$sSendData = ''
EndIf
Local $oHTTP = ObjCreate('WinHttp.WinHttpRequest.5.1')
$oHTTP.Open($sType, $sRequestURL)
$oHTTP.setTimeouts(5000, 5000, 15000, 15000)
$oHTTP.SetRequestHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
$oHTTP.SetRequestHeader('Accept-Language', 'ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3')
$oHTTP.SetRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
$oHTTP.SetRequestHeader('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13')
$oHTTP.SetRequestHeader('Host', $sRequestURL)
$oHTTP.SetRequestHeader('Connection', 'Keep-alive')
$oHTTP.Send($sSendData)
$oHTTP.WaitForResponse
Return $oHTTP.ResponseText
EndFunc
Func _Notepad($sText)
Local $hWin = WinGetHandle('[CLASS:Notepad]')
If $hWin == '' Then
Run('notepad.exe')
$hWin = WinWait('[CLASS:Notepad]')
EndIf
ControlSetText($hWin, '', 'Edit1', $sText)
WinActivate($hWin)
EndFunc
Func _FileFindText($sFile, $sFindText, $MatchWholeWordFlag = 0, $iCaseSense = 0)
If Not StringInStr($sFile, "|") And Not FileExists($sFile) Then Return SetError(1, 0, -1)
Local $aFilesArr = StringSplit($sFile, "|"), $hFile
Local $iCount = 0, $iLineN = 0, $sCurrentLine, $iMatch = 1, $iStrPos, $aRetArr[1][1]
For $i = 1 To UBound($aFilesArr)-1
If FileExists($aFilesArr[$i]) Then
$hFile = FileOpen($aFilesArr[$i], 0)
While 1
$sCurrentLine = FileReadLine($hFile)
If @error = -1 Then ExitLoop
$iLineN += 1
If StringIsASCII($sFindText) Then
$iStrPos = StringInStr($sCurrentLine, $sFindText)
Else
$sCurrentLine = StringLower($sCurrentLine)
$iStrPos = StringInStr($sCurrentLine, StringLower($sFindText))
$sFindText = StringLower($sFindText)
EndIf
If StringInStr($sCurrentLine, $sFindText, $iCaseSense) Then
If $MatchWholeWordFlag = 1 Then
If StringStripWS(StringMid($sCurrentLine, $iStrPos - 1, 1), 2) = "" And _
StringStripWS(StringMid($sCurrentLine, $iStrPos + StringLen($sFindText), 1), 2) = "" Then
$iMatch = 1
Else
$iMatch = 0
EndIf
EndIf
If $iMatch = 1 Then
$aRetArr[0][0] += 1
ReDim $aRetArr[$aRetArr[0][0]+1][4]
$aRetArr[$aRetArr[0][0]][0] = $aFilesArr[$i]
$aRetArr[$aRetArr[0][0]][1] = $sCurrentLine
$aRetArr[$aRetArr[0][0]][2] = $iLineN
$aRetArr[$aRetArr[0][0]][3] = $iStrPos
EndIf
EndIf
WEnd
FileClose($hFile)
EndIf
Next
If UBound($aRetArr) <= 1 Then Return SetError(2, 0, 0)
Return $aRetArr
EndFunc