Author Topic: Brian Smith's IRC Server Program Thing  (Read 1936 times)

Sends a request to blockland auth server with IP and Name, server responds with the BLID of the player. Brian's thing is just a middleman

post or get?

function user_authCheck($name, $ip) {
        if($ip == "") {
                $ip = $_SERVER['REMOTE_ADDR'];
        }
       
        if($ip == "192.168.1.1") {
                $ip = "";
        }
        $server= 'auth.blockland.us';
        $port = 80;
        $url = '/authQuery.php';
        $content = 'NAME=' . $name . '&IP=' . $ip;
        $content_length = strlen($content);
        $headers= "POST $url HTTP/1.0\r\nContent-type: application/x-www-form-urlencoded\r\nHost: $server\r\nContent-length: $content_length\r\n\r\n";
       
        $fp = fsockopen($server, $port, $errno, $errstr);
        if(!$fp)
                return false;
               
        fputs($fp, $headers);
        fputs($fp, $content);
        //echo $headers . "\n" . $content . "\n";
       
        $ret = "";
        while (!feof($fp))
        {
                $ret.= fgets($fp, 1024);
        }
       
        fclose($fp);
        $l = explode("\n", $ret);
        foreach($l as $line) {
                if(strPos($line, "YES") !== false) {
                        $w = explode(" ", $line);
                        return $w[1];
                }
        }
        return false;
}



-snip-

Oh god, just do it like this:


        function send_AuthReq($name, $ip)
        {
                $res = http_post_fields("http://auth.blockland.us/authQuery.php", array(
                        "NAME" => $name,
                        "IP" => $ip
                ));

                $body = http_parse_message($res)->body;
                $explodedBody = explode(' ', $body);
                               
                if($explodedBody[0] == "YES")
                {
                        return $explodedBody[1];
                }
        }

Oh god, just do it like this:


        function send_AuthReq($name, $ip)
        {
                $res = http_post_fields("http://auth.blockland.us/authQuery.php", array(
                        "NAME" => $name,
                        "IP" => $ip
                ));

                $body = http_parse_message($res)->body;
                $explodedBody = explode(' ', $body);
                                
                if($explodedBody[0] == "YES")
                {
                        return $explodedBody[1];
                }
        }


Oh god, just do it like this:

Code: [Select]
def get_auth(name, ip):
    r = requests.post('http://auth.blockland.us/authQuery.php', payload={'NAME': name, 'IP': ip})
    r.raise_for_status()

    if r.text.startswith('YES '):
        return r.text.split(' ')[1:]

;)