AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Auth check (https://forums.alliedmods.net/showthread.php?t=135749)

mazmaajinsh 08-19-2010 09:35

Auth check
 
Hello.
Could you tell me how to make authorization check to work like this.

So if on adress http://lalala.com/auth.txt it says "OK" , the plugin continues working fine, but if it says something else, or the file doesnt load at all, the plugin shuts down?

fysiks 08-19-2010 19:03

Re: Auth check
 
sockets. (probably)

Bugsy 08-19-2010 19:26

Re: Auth check
 
Do you need to read contents of the file or just check if the file exists? Either way you will be using sockets.

mazmaajinsh 08-19-2010 19:34

Re: Auth check
 
i guess check if the file exists would be enough.

Bugsy 08-19-2010 20:03

Re: Auth check
 
HTTP?
PHP Code:

#include <amxmodx>
#include <sockets>

#define TASK_RECV 12345
new g_iSocket

// HTTP server responses:
// - File does not exist on server: HTTP/1.1 404 Not Found
// - File does exist on server: HTTP/1.1 200 OK

public plugin_init()
{
    
register_concmd"sock" "CreateSocket" );
}

public 
CreateSocket()
{
    static 
iError szData256 ];
    
g_iSocket socket_open"www.google.com" 80 SOCKET_TCP iError );
    
    
//To see this work, change the name of index.html to something random
    //so see a 'FILE DOES NOT EXIST' response.
    
copyszData charsmaxszData ) , "GET /index.html HTTP/1.1^r^nHost:www.google.com^r^nConnection: close^r^n^r^n" );
    
    
socket_sendg_iSocket szData sizeofszData ) );
    
    
set_task0.5 "CheckForData" TASK_RECV __"b" );
}

public 
CheckForData()
{
    static 
Data32 ];
    if ( 
socket_changeg_iSocket ) )
    {
        
socket_recvg_iSocket Data sizeofData ) );
        {
            
server_print( ( containiData "HTTP/1.1 200 OK" ) != -1) ? "FILE EXISTS" "FILE DOES NOT EXIST" );
            
remove_taskTASK_RECV );
        }
    }



mazmaajinsh 08-19-2010 20:43

Re: Auth check
 
Great! Appreciate this ;)


All times are GMT -4. The time now is 21:59.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.