Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Global $cookies[1][2]
- Func makeHttpRequest($lnk, $cookie = '', $refer = '', $ignorecookies = 0, $post = 0, $redir = 0)
- $method = "GET"
- $weblink = StringSplit($lnk, '?')
- ;addText($weblink[2],$hListBox)
- If $post = 1 Then
- $method = "POST"
- $linklink = $weblink[1]
- $poststring = $weblink[2]
- Else
- $linklink = $lnk
- EndIf
- $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1")
- If $redir = 0 Then
- $oHTTP.Option(6) = False
- EndIf
- $oHTTP.Open($method, $linklink, False)
- $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0")
- If StringLen($refer) > 1 Then
- $oHTTP.SetRequestHeader("Referer", $refer)
- EndIf
- If StringLen($cookie) > 1 Then
- $oHTTP.SetRequestHeader("Cookie", $cookie)
- EndIf
- If $post = 1 Then
- $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
- $oHTTP.SetRequestHeader("Content-Length", StringLen($poststring))
- $oHTTP.Send($poststring)
- Else
- $oHTTP.Send()
- EndIf
- $oHTTP.WaitForResponse
- $HeaderResponses = $oHTTP.GetAllResponseHeaders()
- If $ignorecookies = 0 Then
- ; Handle Cookies
- $array = StringRegExp($HeaderResponses, 'Set-Cookie: (.+)\r\n', 3)
- ;$cookies = ''
- For $i = 0 To UBound($array) - 1
- ; Add all cookies to a single string, and then clean it up.
- $cook = $array[$i] & ';'
- ; Removing parts we do not use..
- $cook = StringRegExpReplace($cook, "( path| domain| expires)=[^;]+", "")
- $cook = StringRegExpReplace($cook, " HttpOnly", "")
- $cook = StringRegExpReplace($cook, "[;]{2,}", ";")
- $cook1 = StringSplit($cook, ";")
- For $k = 1 To $cook1[0]
- If StringInStr($cook1[$k], "=") Then
- $cook2 = StringSplit(StringReplace($cook1[$k], " ", ""), "=")
- If $cookies[0][0] == "" Then
- $cookies[0][0] = $cook2[1]
- $cookies[0][1] = $cook2[2]
- Else
- $inserted = 0
- For $j = 0 To UBound($cookies) - 1
- If $cook2[1] == $cookies[$j][0] Then
- $cookies[$j][1] = $cook2[2]
- $inserted = 1
- ElseIf ($j == (UBound($cookies) - 1)) And ($inserted == 0) Then
- ReDim $cookies[UBound($cookies) + 1][2]
- $cookies[UBound($cookies) - 1][0] = $cook2[1]
- $cookies[UBound($cookies) - 1][1] = $cook2[2]
- EndIf
- Next
- EndIf
- EndIf
- Next
- Next
- EndIf
- Dim $ret[4]
- If StringInStr($HeaderResponses, "Location:") <> 0 Then
- $ret["0"] = $oHTTP.GetResponseHeader("Location")
- $ret["1"] = 1
- Else
- $ret["0"] = ""
- $ret["1"] = 0
- EndIf
- $ret["2"] = $oHTTP.Responsetext
- ;$ret["method"] = $method
- $ret["3"] = $oHTTP.GetAllResponseHeaders()
- Return $ret
- EndFunc ;==>getHTTP
- ;function to encode url for websurfing
- Func URLEncode($urlText)
- $url = ""
- For $i = 1 To StringLen($urlText)
- $acode = Asc(StringMid($urlText, $i, 1))
- Select
- Case ($acode >= 48 And $acode <= 57) Or _
- ($acode >= 65 And $acode <= 90) Or _
- ($acode >= 97 And $acode <= 122)
- $url = $url & StringMid($urlText, $i, 1)
- Case $acode = 32
- $url = $url & "+"
- Case Else
- $url = $url & "%" & Hex($acode, 2)
- EndSelect
- Next
- Return $url
- EndFunc ;==>URLEncode
- ;function to make cookies from array
- Func mkCookies()
- $rt = ""
- For $j = 0 To UBound($cookies) - 1
- $rt = $rt & $cookies[$j][0] & "=" & $cookies[$j][1]
- If $j <> (UBound($cookies) - 1) Then
- $rt = $rt & "; "
- EndIf
- Next
- Return $rt
- EndFunc ;==>mkCookies
Add Comment
Please, Sign In to add comment