Login Guest
Feb 23, 2012, 2:00 am UTCHome arrow Code Chunks arrow Get Online Status
header image
Home
Downloads
Menu Overview
Coding
Polls
The most influential person in technology in the last 25 years is...
  
Get Online Status
Written by Dream Dancer   
Sep 04, 2010 at 12:02 AM
' online checker
 
$onlineserver = "on.furcadia.com"
$agentname = "FauxPawn 1.1"
GLOBAL ServerIndex  AS LONG
 
FUNCTION GetOnlineStatus(NamesIn AS STRING) AS STRING
LOCAL NamesOut, Domain  AS STRING
LOCAL Url, sPacket      AS STRING
LOCAL rPacket           AS STRING ' asciiz * 32768
LOCAL hPort             AS LONG
 
    Domain = $onlineserver
    IF ServerIndex > 1 THEN
        REPLACE "on." WITH "on"& FORMAT$(ServerIndex) &"." IN Domain
    END IF
    INCR ServerIndex
    IF ServerIndex > 4 THEN ServerIndex = 1
    Url = "/q/?"& NamesIn
    sPacket = "GET " & URL & " HTTP/1.1" & $CRLF & _
                "Host: "& Domain & $CRLF & _
                "User-Agent: "& $agentname & $CRLF & _
                "Accept: text/*, text/html, */*" & $CRLF & _
                "Accept-Encoding: " & $CRLF & _
                "Content-Type: application/x-www-form-urlencoded" & $CRLF & _
                "Content-Length: 0" & $CRLF & _
                $CRLF '// End of header
 
    ON ERROR GOTO Whoops
    hPort = FREEFILE
    TCP OPEN PORT 80 AT Domain AS hPort TIMEOUT 60000
    TCP SEND hPort, sPacket
    DO ' UNTIL EOF(hPort)
        TCP RECV hPort, 32768, rPacket
        IF rPacket = "" THEN EXIT DO
        NamesOut = NamesOut & rPacket
    LOOP
    CLOSE hPort
    REPLACE $CRLF WITH $LF IN NamesOut
 
Whoops:
    IF ERR > 0 THEN
        INCR FetchError
        NamesOut = FORMAT$(ERR)
        ERRCLEAR
    ELSE
        INCR FetchSuccess
    END IF
 
    GetOnlineStatus = NamesOut
END FUNCTION
 

GeSHi parsed in 0.232849836349 seconds.

header image