HTTP_GET Access to Password protected File - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: HTTP_GET Access to Password protected File (
/showthread.php?tid=465610)
HTTP_GET Access to Password protected File -
Dragony92 - 23.09.2013
I'm trying to get access to protected file by sending username and password in url, but server is every time returing code 1 (HTTP_ERROR_BAD_HOST).
Example:
pawn Код:
HTTP(playerid, HTTP_GET, "http://user:pass@domain.com/file.txt", "", "MyHttpResponse");
And also can someone explain me how to use 4th param in HTTP function.
Re: HTTP_GET Access to Password protected File -
whatthefuck123 - 23.09.2013
4th param is post.. i dont think u need that for .txt file
What exactly are u trying to do with this? login system?
Re: HTTP_GET Access to Password protected File -
Dragony92 - 23.09.2013
To get data from protected file...
Re: HTTP_GET Access to Password protected File -
Vince - 23.09.2013
I believe you can only structure an FTP URL like that. I also don't think it is even possible to circumvent the authorization with the HTTP() function, because you can't send the required HTTP Authorization headers.
http://en.wikipedia.org/wiki/Basic_a...on#Client_side
I recommend writing a PHP script that can only be accessed from the localhost and the server's IP. This is probably the easiest way to keep unwanted persons out. Replace the x'es with your server IP.
PHP код:
<?php
if($_SERVER['REMOTE_IP'] != '127.0.0.1' && $_SERVER['REMOTE_IP'] != 'x.x.x.x')
{
header('HTTP/1.1 403 Forbidden');
exit();
}
?>
Rest of file here
Re: HTTP_GET Access to Password protected File -
Dragony92 - 23.09.2013
Hmm, is there anyway to allow server ip and other user:pass accs by htaccess?
Re: HTTP_GET Access to Password protected File -
iJumbo - 23.09.2013
Check for htaccess and htpasswd tutorials on web
Re: HTTP_GET Access to Password protected File -
Dragony92 - 23.09.2013
Sloved...
AuthUserFile /path/to/.htpasswd
AuthName "Private"
Authtype Basic
require valid-user
order deny,allow
deny from all
allow from x.x.x.x
allow from 127.0.0.1
Satisfy Any