Raised This Month: $ Target: $400
 0% 

Auth check


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mazmaajinsh
Senior Member
Join Date: Apr 2005
Location: Latvia
Old 08-19-2010 , 09:35   Auth check
Reply With Quote #1

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?
__________________
Ahujena
mazmaajinsh is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-19-2010 , 19:03   Re: Auth check
Reply With Quote #2

sockets. (probably)
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-19-2010 , 19:26   Re: Auth check
Reply With Quote #3

Do you need to read contents of the file or just check if the file exists? Either way you will be using sockets.
__________________
Bugsy is offline
mazmaajinsh
Senior Member
Join Date: Apr 2005
Location: Latvia
Old 08-19-2010 , 19:34   Re: Auth check
Reply With Quote #4

i guess check if the file exists would be enough.
__________________
Ahujena
mazmaajinsh is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-19-2010 , 20:03   Re: Auth check
Reply With Quote #5

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 );
        }
    }

__________________
Bugsy is offline
mazmaajinsh
Senior Member
Join Date: Apr 2005
Location: Latvia
Old 08-19-2010 , 20:43   Re: Auth check
Reply With Quote #6

Great! Appreciate this ;)
__________________
Ahujena
mazmaajinsh is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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