 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
lance1
Joined: 14 Mar 2008 Posts: 9
|
Posted: Wed Aug 06, 2008 6:17 pm Post subject: Server Query |
|
|
Hello,
I was wondering if it was possible to make a "Server Query" Program like:
http://server.teamhonor.info
it queries the Halo Servers and sees how many players are in it, what map, etc.
Is it possible to make a Program that can use that website, Or a program that depends on its self? |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Aug 06, 2008 6:26 pm Post subject: |
|
|
| Code: | ip=some.ip.for.test
port=2302
httpQuery(Result, "http://server.teamhonor.info/index.php?ip=" . ip . "&port=" port)
VarSetCapacity(Result, -1)
Gui, Add, Edit, w640 h480, %Result%
Gui, Show |
use httpquery() |
|
| Back to top |
|
 |
lance0 Guest
|
Posted: Wed Aug 06, 2008 6:43 pm Post subject: |
|
|
| that does not work |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Aug 06, 2008 6:50 pm Post subject: |
|
|
| i said use httpquery() you didn't even try it properly |
|
| Back to top |
|
 |
lance0 Guest
|
Posted: Wed Aug 06, 2008 6:56 pm Post subject: |
|
|
| well can u HELP me try it properly, i do not understand what i should do |
|
| Back to top |
|
 |
an impostor named lance2 Guest
|
Posted: Wed Aug 06, 2008 7:23 pm Post subject: |
|
|
Let me clarify:
HELP = do it for me.
Now, don't you have something you should be doing?
LOL!  |
|
| Back to top |
|
 |
Slanter
Joined: 28 May 2008 Posts: 397 Location: Minnesota, USA
|
Posted: Wed Aug 06, 2008 7:28 pm Post subject: |
|
|
| Code: | ip=some.ip.for.test ; Try changing this to an IP address that has a server running, post whatever shows up in the edit field and maybe we can help more
port=2302
httpQuery(Result, "http://server.teamhonor.info/index.php?ip=" . ip . "&port=" port)
VarSetCapacity(Result, -1)
Gui, Add, Edit, w640 h480, %Result%
Gui, Show |
_________________ Unless otherwise stated, all code is untested
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination. |
|
| Back to top |
|
 |
neXt
Joined: 18 Mar 2007 Posts: 463
|
Posted: Wed Aug 06, 2008 8:37 pm Post subject: |
|
|
an impostor named lance2, why even post, why not just shut up?
lance1Don't forget to include httpquery in your script. Saying just in case. _________________ simplified csv - easy way to handle csv files. |
|
| Back to top |
|
 |
lance1
Joined: 14 Mar 2008 Posts: 9
|
Posted: Wed Aug 06, 2008 8:44 pm Post subject: |
|
|
| Code: | ; httpQuery-0-3-3.ahk
httpQuery(byref Result, lpszUrl, POSTDATA="", HEADERS="")
{ ; v0.3.3 (w) 27.07.2008 by Heresy & derRaphael / zLib-Style release
; currently the verbs showHeader, storeHeader, and updateSize are supported in httpQueryOps
; in case u need a different UserAgent, Proxy, ProxyByPass, Referrer, and AcceptType just
; specify them as global variables - mind the varname for referrer is httpQueryReferer [sic].
; Also if any special dwFlags are needed such as INTERNET_FLAG_NO_AUTO_REDIRECT or cache
; handling this might be set using the httpQueryDwFlags variable as global
global httpQueryOps, httpAgent, httpProxy, httpProxyByPass, httpQueryReferer, httpQueryAcceptType
, httpQueryDwFlags
; Get any missing default Values
defaultOps =
(LTrim Join|
httpAgent=AutoHotkeyScript|httpProxy=0|httpProxyByPass=0|INTERNET_FLAG_SECURE=0x00800000
SECURITY_FLAG_IGNORE_UNKNOWN_CA=0x00000100|SECURITY_FLAG_IGNORE_CERT_CN_INVALID=0x00001000
SECURITY_FLAG_IGNORE_CERT_DATE_INVALID=0x00002000|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE=0x00000200
INTERNET_OPEN_TYPE_PROXY=3|INTERNET_OPEN_TYPE_DIRECT=1|INTERNET_SERVICE_HTTP=3
)
Loop,Parse,defaultOps,|
{
RegExMatch(A_LoopField,"(?P<Option>[^=]+)=(?P<Default>.*)",http)
if StrLen(%httpOption%)=0
%httpOption% := httpDefault
}
; Load Library
hModule := DllCall("LoadLibrary", "Str", "WinINet.Dll")
; SetUpStructures for URL_COMPONENTS / needed for InternetCrackURL
; http://msdn.microsoft.com/en-us/library/aa385420(VS.85).aspx
offset_name_length:= "4-lpszScheme-255|16-lpszHostName-1024|28-lpszUserName-1024|"
. "36-lpszPassword-1024|44-lpszUrlPath-1024|52-lpszExtrainfo-1024"
VarSetCapacity(URL_COMPONENTS,60,0)
; Struc Size ; Scheme Size ; Max Port Number
NumPut(60,URL_COMPONENTS,0), NumPut(255,URL_COMPONENTS,12), NumPut(0xffff,URL_COMPONENTS,24)
Loop,Parse,offset_name_length,|
{
RegExMatch(A_LoopField,"(?P<Offset>\d+)-(?P<Name>[a-zA-Z]+)-(?P<Size>\d+)",iCU_)
VarSetCapacity(%iCU_Name%,iCU_Size,0)
NumPut(&%iCU_Name%,URL_COMPONENTS,iCU_Offset)
NumPut(iCU_Size,URL_COMPONENTS,iCU_Offset+4)
}
; Split the given URL; extract scheme, user, pass, authotity (host), port, path, and query (extrainfo)
; http://msdn.microsoft.com/en-us/library/aa384376(VS.85).aspx
DllCall("WinINet\InternetCrackUrlA","Str",lpszUrl,"uInt",StrLen(lpszUrl),"uInt",0,"uInt",&URL_COMPONENTS)
; Update variables to retrieve results
Loop,Parse,offset_name_length,|
{
RegExMatch(A_LoopField,"-(?P<Name>[a-zA-Z]+)-",iCU_)
VarSetCapacity(%iCU_Name%,-1)
}
nPort:=NumGet(URL_COMPONENTS,24,"uInt")
; Import any set dwFlags
dwFlags := httpQueryDwFlags
; For some reasons using a selfsigned https certificates doesnt work
; such as an own webmin service - even though every security is turned off
; https with valid certificates works when
if (lpszScheme = "https")
dwFlags |= (INTERNET_FLAG_SECURE|SECURITY_FLAG_IGNORE_CERT_CN_INVALID
|SECURITY_FLAG_IGNORE_CERT_DATE_INVALID|SECURITY_FLAG_IGNORE_UNKNOWN_CA
|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE)
; Check for Header and drop exception if unknown or invalid URL
if (lpszScheme="unknown") {
Result := "ERR: No Valid URL supplied."
Return StrLen(Result)
}
; Initialise httpQuery's use of the WinINet functions.
; http://msdn.microsoft.com/en-us/library/aa385096(VS.85).aspx
hInternet := DllCall("WinINet\InternetOpenA"
,"Str",httpAgent,"UInt"
,(httpProxy != 0 ? INTERNET_OPEN_TYPE_PROXY : INTERNET_OPEN_TYPE_DIRECT )
,"Str",httpProxy,"Str",httpProxyBypass,"Uint",0)
; Open HTTP session for the given URL
; http://msdn.microsoft.com/en-us/library/aa384363(VS.85).aspx
hConnect := DllCall("WinINet\InternetConnectA"
,"uInt",hInternet,"Str",lpszHostname, "Int",nPort
,"Str",lpszUserName, "Str",lpszPassword,"uInt",INTERNET_SERVICE_HTTP
,"uInt",0,"uInt*",0)
; Do we POST? If so, check for header handling and set default
if (Strlen(POSTDATA)>0) {
HTTPVerb:="POST"
if StrLen(Headers)=0
Headers:="Content-Type: application/x-www-form-urlencoded"
} else ; otherwise mode must be GET - no header defaults needed
HTTPVerb:="GET"
; Form the request with proper HTTP protocol version and create the request handle
; http://msdn.microsoft.com/en-us/library/aa384233(VS.85).aspx
hRequest := DllCall("WinINet\HttpOpenRequestA"
,"uInt",hConnect,"Str",HTTPVerb,"Str",lpszUrlPath . lpszExtrainfo
,"Str",ProVer := "HTTP/1.1", "Str",httpQueryReferer,"Str",httpQueryAcceptTypes
,"uInt",dwFlags,"uInt",Context:=0 )
; Send the specified request to the server
; http://msdn.microsoft.com/en-us/library/aa384247(VS.85).aspx
sRequest := DllCall("WinINet\HttpSendRequestA"
, "uInt",hRequest,"Str",Headers, "uInt",Strlen(Headers)
, "Str",POSTData,"uInt",Strlen(POSTData))
VarSetCapacity(header, 2048, 0) ; max 2K header data for httpResponseHeader
VarSetCapacity(header_len, 4, 0)
; Check for returned server response-header (works only _after_ request been sent)
; http://msdn.microsoft.com/en-us/library/aa384238.aspx
Loop, 5
if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest
,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
break
If (headerRequest=1) {
VarSetCapacity(res,headerLength:=NumGet(header_len),32)
DllCall("RtlMoveMemory","uInt",&res,"uInt",&header,"uInt",headerLength)
Loop,% headerLength
if (*(&res-1+a_index)=0) ; Change binary zero to linefeed
NumPut(Asc("`n"),res,a_index-1,"uChar")
VarSetCapacity(res,-1)
} else
res := "timeout"
; Get 1st Line of Full Response
Loop,Parse,res,`n,`r
{
RetValue := A_LoopField
break
}
; No Connection established - drop exception
If (RetValue="timeout") {
html := "Error: timeout"
return -1
}
; Strip protocol version from return value
RetValue := RegExReplace(RetValue,"\Q" ProVer "\E\s+")
; List taken from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
HttpRetCodes := "100=Continue|101=Switching Protocols|102=Processing (WebDAV) (RFC 2518)|"
. "200=OK|201=Created|202=Accepted|203=Non-Authoritative Information|204=No"
. " Content|205=Reset Content|206=Partial Content|207=Multi-Status (WebDAV)"
. "|300=Multiple Choices|301=Moved Permanently|302=Found|303=See Other|304="
. "Not Modified|305=Use Proxy|306=Switch Proxy|307=Temporary Redirect|400=B"
. "ad Request|401=Unauthorized|402=Payment Required|403=Forbidden|404=Not F"
. "ound|405=Method Not Allowed|406=Not Acceptable|407=Proxy Authentication "
. "Required|408=Request Timeout|409=Conflict|410=Gone|411=Length Required|4"
. "12=Precondition Failed|413=Request Entity Too Large|414=Request-URI Too "
. "Long|415=Unsupported Media Type|416=Requested Range Not Satisfiable|417="
. "Expectation Failed|418=I'm a teapot (RFC 2324)|422=Unprocessable Entity "
. "(WebDAV) (RFC 4918)|423=Locked (WebDAV) (RFC 4918)|424=Failed Dependency"
. " (WebDAV) (RFC 4918)|425=Unordered Collection (RFC 3648)|426=Upgrade Req"
. "uired (RFC 2817)|449=Retry With|500=Internal Server Error|501=Not Implem"
. "ented|502=Bad Gateway|503=Service Unavailable|504=Gateway Timeout|505=HT"
. "TP Version Not Supported|506=Variant Also Negotiates (RFC 2295)|507=Insu"
. "fficient Storage (WebDAV) (RFC 4918)|509=Bandwidth Limit Exceeded|510=No"
. "t Extended (RFC 2774)"
; Gather numeric response value
RetValue := SubStr(RetValue,1,3)
; Parse through return codes and set according informations
Loop,Parse,HttpRetCodes,|
{
HttpReturnCode := SubStr(A_LoopField,1,3) ; Numeric return value see above
HttpReturnMsg := SubStr(A_LoopField,5) ; link for additional information
if (RetValue=HttpReturnCode) {
RetMsg := HttpReturnMsg
break
}
}
; Global HttpQueryOps handling
if strlen(HTTPQueryOps)>0 {
; Show full Header response (usefull for debugging)
if (instr(HTTPQueryOps,"showHeader"))
MsgBox % res
; Save the full Header response in a global Variable
if (instr(HTTPQueryOps,"storeHeader"))
global HttpQueryHeader := res
; Check for size updates to export to a global Var
if (instr(HTTPQueryOps,"updateSize")) {
Loop,Parse,res,`n
If RegExMatch(A_LoopField,"Content-Length:\s+?(?P<Size>\d+)",full) {
global HttpQueryFullSize := fullSize
break
}
if (fullSize+0=0)
HttpQueryFullSize := "size unavailable"
}
}
; Check for valid codes and drop exception if suspicious
if !(InStr("100 200 201 202 302",RetValue)) {
Result := RetValue " " RetMsg
return StrLen(Result)
}
VarSetCapacity(BytesRead,4,0)
fsize := 0
Loop ; the receiver loop - rewritten in the need to enable
{ ; support for larger file downloads
bc := A_Index
VarSetCapacity(buffer%bc%,1024,0) ; setup new chunk for this receive round
ReadFile := DllCall("wininet\InternetReadFile"
,"uInt",hRequest,"uInt",&buffer%bc%,"uInt",1024,"uInt",&BytesRead)
ReadBytes := NumGet(BytesRead) ; how many bytes were received?
If ((ReadFile!=0)&&(!ReadBytes)) ; we have had no error yet and received no more bytes
break ; we must be done! so lets break the receiver loop
Else {
fsize += ReadBytes ; sum up all chunk sizes for correct return size
sizeArray .= ReadBytes "|"
}
if (instr(HTTPQueryOps,"updateSize"))
Global HttpQueryCurrentSize := fsize
}
sizeArray := SubStr(sizeArray,1,-1) ; trim last PipeChar
VarSetCapacity(result,fSize) ; reconstruct the result from above generated chunkblocks
Dest := &result ; to a our ByRef result variable
Loop,Parse,SizeArray,|
DllCall("RtlMoveMemory","uInt",Dest,"uInt",&buffer%A_Index%,"uInt",A_LoopField)
, Dest += A_LoopField
DllCall("WinINet\InternetCloseHandle", "uInt", hRequest) ; close all opened
DllCall("WinINet\InternetCloseHandle", "uInt", hInternet)
DllCall("WinINet\InternetCloseHandle", "uInt", hConnect)
DllCall("FreeLibrary", "UInt", hModule) ; unload the library
return fSize ; return the size - strings need update via VarSetCapacity(res,-1)
}
ip=some.ip.for.test ; Try changing this to an IP address that has a server running, post whatever shows up in the edit field and maybe we can help more
port=2302
httpQuery(Result, "http://server.teamhonor.info/index.php?ip=" . ip . "&port=" port)
VarSetCapacity(Result, -1)
Gui, Add, Edit, w640 h480, %Result%
Gui, Show |
k i put the httpquery script, then i put mine at the bottom...
when i run it, i get this:
| Code: |
<html><center>
<head>
<title>Halo Server Query</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="nontent.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="form1" method="get" action="index.php">
There was no Halo server detected at some.ip.for.test on port 2302. <br><br> <table width="470" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <table width="470" border="0" align="left" cellpadding="0" cellspacing="0" class="shadow-outter">
<tr>
<td><table width="470" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><table width="470" border="0" cellspacing="0" cellpadding="0" class="shadow-inner">
<tr>
<td height="23" class="tdbg-and-border">
<div align="center"> </div>
<table width="470" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="10" height="5"></td>
<td height="5"></td>
<td width="10" height="5"></td>
</tr>
<tr>
<td width="10"></td>
<td><div align="center"><a href="index.php"><img src="title_s.gif" width="275" height="35" border="0"></a>
</div>
<table width="450" border="0" cellpadding="0" cellspacing="0">
<tr> <center>Enter the Server IP you wish to query:</center>
<br>
<td width="150"> <div align="center">IP Address</div></td>
<td width="150">
<div align="center">Port
Number</div></td>
<td width="150">
<div align="center">Submit Query </div></td>
</tr>
<tr>
<td width="150" height="20">
<div align="center">
<input name="ip" type="text" size="18">
</div></td>
<td width="150" height="20">
<div align="center">
<input name="port" type="text" value="2302" size="7">
</div></td>
<td width="150" height="20">
<div align="center">
<input type="submit" value="Query Server">
</div></td>
</tr>
</table>
<br>
</td>
<td width="10"></td>
</tr>
<tr>
<td width="10" height="5"></td>
<td height="5"></td>
<td width="10" height="5"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<p> </p>
</form>
</body>
<center>[Query Modded by <a href="http://ismetforumz.info">Sandino</a>and BrandiniMP]
<br>
[»H« Clan Website: <a href="http://www.teamhonor.info">http://www.teamhonor.info]</a> <br>
<a href="http://wiki.teamhonor.info">[Halo Wiki Pages]</a></center>
<a href="http://whos.amung.us/show/xtgpaooc"><img src="http://whos.amung.us/widget/xtgpaooc.png" alt="tracker" width="81" height="29" border="0" /></a>
</html>
|
the html script itsself xD
sry if im doing this worng, imma noob xD trying to learn |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
Posted: Wed Aug 06, 2008 9:46 pm Post subject: |
|
|
There was no Halo server detected at some.ip.for.test on port 2302
you actually have to replace the text "some.ip.for.test " in the script with the actual ip address you want to check
that should have been evident but it seems your not reading a single thing thats being said
oh why do i bother
im goin back to my viliage _________________ Read this
Com
Automate IE7 with Tabs |
|
| Back to top |
|
 |
neXt
Joined: 18 Mar 2007 Posts: 463
|
Posted: Wed Aug 06, 2008 9:46 pm Post subject: |
|
|
I never used this before, so i'll tip you on something else:
instead of placing httpQuery in your script file use include, example:
assuming httpQuery.ahk is in the same directory
| Code: | | #include httpQuery.ahk |
_________________ simplified csv - easy way to handle csv files. |
|
| Back to top |
|
 |
Slanter
Joined: 28 May 2008 Posts: 397 Location: Minnesota, USA
|
Posted: Wed Aug 06, 2008 11:31 pm Post subject: |
|
|
lets try this one more time... | Code: | ; =================================
; TRY CHANGING THE RED TEXT TO AN IP ADDRESS
; =================================
ip=some.ip.for.test
port=2302
httpQuery(Result, "http://server.teamhonor.info/index.php?ip=" . ip . "&port=" port)
VarSetCapacity(Result, -1)
Gui, Add, Edit, w640 h480, %Result%
Gui, Show |
_________________ Unless otherwise stated, all code is untested
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination. |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Aug 07, 2008 12:39 am Post subject: |
|
|
let me try too
CHANGE some.ip.for.test to your desired server's IP Address
CHANGE some.ip.for.test to your desired server's IP Address
CHANGE some.ip.for.test to your desired server's IP Address
CHANGE some.ip.for.test to your desired server's IP Address
CHANGE some.ip.for.test to your desired server's IP Address
CHANGE some.ip.for.test to your desired server's IP Address
CHANGE some.ip.for.test to your desired server's IP Address |
|
| Back to top |
|
 |
an impostor named lance2 Guest
|
Posted: Thu Aug 07, 2008 1:04 am Post subject: |
|
|
Wow, neXt, that was incredibly rude.
At least when I posted, I made my point, unlike your comment, which was just to make an @$$ of yourself I guess.
This kind of thing is why I posted anonymously, and discourages me from posting at all.
But you make a good point. Why am I still here? |
|
| Back to top |
|
 |
lance1
Joined: 14 Mar 2008 Posts: 9
|
Posted: Thu Aug 07, 2008 1:44 am Post subject: |
|
|
so anyways, i did what you guys told me to do,
but i still get the html source which i dont want, now can anyone help me? |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|