Other language versions of this PHP script...

Status
Not open for further replies.

enlivenit

Solid State Member
Messages
8
I have a DNSBL server hosted at www.mailer.mobi and a script on my web server written in PHP that checks the DNSBL to see if a visitor's IP is blacklisted and returns 0 or 1 accordingly. So you can put the following line of PHP code at the very start of your web site to return a 404 Error "Page Not Found" if it's visited by a computer on a blacklisted IP.


<?php if (@file_get_contents("https://mailer.mobi/?guard=".$_SERVER['REMOTE_ADDR']) == "1") { header("HTTP/1.0 404 Not Found"); die(); } ?>


What I'm after is the same functionality as the above line, but just in other dynamic languages, ie. ASP, JSP, Perl (CGI), Python, Coldfusion etc, so I can put them on the www.mailer.mobi site for people who have sites in those languages.


If you know how to do the above in another language, can you help me?
 
pick a language and i think we can help. this is going to be different for each language.

the code you posted is using functions native to php. we would have to find equivlant functions in other languages.

What the code is doing is sending a http request to mail.mobi with the remote server address and checking the http header of the response.
 
Sort of, it's reading the contents returned by a script on a remote server, and if the contents equals simply "1" it returns locally a 404 error header.

I think the main other language that I'd like to post the script on my site in would be ASP, since PHP and ASP seem to be the most common two dynamic languages. I guess I could stop being so lazy and just google a few things about ASP, lol, but I'm not sure if the learning curve would be worth it as I only really want one line of code. I love PHP and think it's the best one out there, and only develop in it, but I know a lot of people started out on something else and I'd like to support that.
 
so far for asp i have this:
but i'm not sure if it's correct

<%
Option Explicit
Dim UserIPAddress
UserIPAddress = Request.ServerVariables("REMOTE_ADDR")
Const REMOTE_FILE_URL = "http://mailer.mobi/?guard=" & UserIPAddress
Call ShowRemoteFile
Sub ShowRemoteFile
Dim objXML, strContents, arrLines
Dim x
Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET", REMOTE_FILE_URL, False
objXML.Send
strContents = objXML.ResponseText
Set objXML = Nothing
If strContents = "1" Then
throw new HttpException(404, "Not found");
Response.End
End If
End Sub
%>
 
i think you're going to have a issue with the following line

throw new HttpException(404, "Not found");


i dont think vbscript has throw as a keyword. i would prolly just redirect to a page that doesn't exist.
 
i think you're going to have a issue with the following line

throw new HttpException(404, "Not found");


i dont think vbscript has throw as a keyword. i would prolly just redirect to a page that doesn't exist.

yes, see I have no idea about asp
but hey, that's a good idea to redirect, that's easier for me to understand
would it look like this? :

Response.Redirect "http://page/that/doesnt/exist/"
 
Status
Not open for further replies.
Back
Top Bottom