...

View Full Version : Banning IPs?



bratzmania
06-10-2005, 04:42 AM
Hi! Is there a way to ban IPs from coming to your site using HTML, Javascript, or CSS?

I need a code where I can ban more then one IP at the same time and when the IP or Ips come to my site, it sends them to a "banned page" or different page (so they can't see mine!)!? I've tried different codes, and one even banned every IP instead of the ones I wanted it to ban :( !

Does anyone know of a good IP banning code? Thanks! :)

_Aerospace_Eng_
06-10-2005, 04:50 AM
You can't do this with html,javascript, or css, what you can do is use .htaccess, here (http://www.depiction.net/?id=ipbanning) is a simple tutorial on how to do this, or if you want you can do it in php as well, another tutorial can be found here (http://www.developerz.com/php_ipbanning.htm).

JamieR
06-10-2005, 08:26 AM
You can do it with .htaccess and also if you want to ban certain IPs from one or two directories/files and if your server supports PHP, you can do it with that. I also know a way of doing it in ASP ;)

bratzmania
06-10-2005, 06:11 PM
Ok :(

How would I be able to put a PHP code on HTML? Something like this:


<script language="PHP" src=".php">
</script>

And please not a PHP code to put a PHP code on HTML! Thankz :D

JamieR
06-10-2005, 06:14 PM
nooooooooo!

You start a php script with:

<?php

and end it with

?>


You server needs to support PHP and you have to save your pages with a .php file extension. You can use .php files as normal html documents with the exception of it being able to run php if your server can.

bratzmania
06-10-2005, 06:17 PM
Yes but then you have to save it .php and everything one my site is .html!!!!
I've tried that and it doesn't work! :(

JamieR
06-10-2005, 06:35 PM
does your server support php?

I think you would have to get your host to allow running of PHP on .html files, although I think you can do it through .htaccess (?)

bratzmania
06-10-2005, 06:38 PM
Yes, but I have a free host and you can't really tell them what to do when it'z free :o ! It doesn't allow .htaccess either! :(

_Aerospace_Eng_
06-10-2005, 08:42 PM
Well then you might be stuck, there is no secure way using javascript to block an ip address. Who is your host? And as they always say, you get what you pay for, in this case nothing. For the javascript method you would still need php. One other thing, php can't be parsed on an html file. It would have to be a .php in order to work.

JamieR
06-10-2005, 08:52 PM
Looks like you need a paid host...:)

bratzmania
06-12-2005, 02:53 AM
Sorry, pay might be easy for you, but not for me!
I have put a php counter on a HTML page and it worked, but it was made for a counter code only! :(

See, you put the code at the top of the .html page and it works:


<!-- Counter/Statistics -->
<script language="PHP" src=.php">
</script>

Now if only I could get it to work for every php code! :D

_Aerospace_Eng_
06-12-2005, 04:56 AM
Sorry, pay might be easy for you, but not for me!
I have put a php counter on a HTML page and it worked, but it was made for a counter code only! :(

See, you put the code at the top of the .html page and it works:


<!-- Counter/Statistics -->
<script language="PHP" src=.php">
</script>

Now if only I could get it to work for every php code! :D
That shouldn't work. Why it works I have no idea. Php goes into pages using <?php your script here?> I'm guessing its just a javascript called .php or something.

JamieR
06-14-2005, 12:30 PM
Exactly..that's weird why that would work. If you are able to run that kind of php in that way then your server must support php.....and if it supports PHP then your server must support *.php files unless that has been turned off somehow.

And paid hosting comes very cheaply nowadays....you can get a basic server plan for about $20 a year or something from some cheap american hosts which run Linux servers.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum