D: my first Itopic XD hope this helps!
I know this is only one method out of many, PLEASE DO NOT POST OTHER METHODS AS I WILL CLASS THEM AS SPAM
You don't need this to get accepted, but it is a good idea
If you want to get your website verified by ST so you can post links to it from the scratch website, then i'ts a good idea, but not a necessity to be able to block ip addresses or in other words people.
Why block Ip's?
If you can block ip's then you can keep you site safe by keeping people who don't follow the rules, or who spam.
What is an IP
An Ip address is a string of numbers, every device that can go on the internet has to use one.
How do I block them
[If your website editor or provider provides it, then use that method]
[If your website editor doesn't provide it, then use this, or any other you like, I'm just trying to help with this]
It's actually not that hard, first use a website editor that allows you to edit the <head> tag, it's also a good idea to use one that lets you see ip addresses like this one that gives you the ip whenever they fill out a form, then copy this code after <head> but before</head>
<!--ban Ip start-->
<script type="text/javascript">
//Enter list of banned ips, each separated with a comma:
var bannedips=["111.111.1.11","111.111.1.11]
var ip = '<!--#echo var="REMOTE_ADDR"-->'
var handleips=bannedips.join("|")
handleips=new RegExp(handleips, "i")
if (ip.search(handleips)!=-1){
alert("Sorry, this computer has been banned, one moment...")
window.location.replace("http://www.yourwebsite.com/banned.html")
}
</script>
<!--ban ip end-->This java script will redirect the computer to /banned.html, you must create this page or enter a random web address like google.co.uk
That's it when you have put the ip's in you want to block they will start being led away! [It's a good idea to have this on every page]
Thanks for reading, and good luck with your website!
A very good point made by blob8108
They would have to have java script enabled to get banned, but if you use mostly java script on your site (as I do) then they wont be able to really access anything.
Another very good point
you must have at least one ip on the list or it bans all ip addresses, so I recommend adding when you need to.
Note from Paddle2see-Scratch team
The Scratch Team does not require that you use this on your site. If your site does allow visitors to add stuff to it (forum posts, comments) it's a really good idea to make sure that you do have a way to block IP's. Many sites have that feature built-in - but if they don't, this approach could be very helpful.
Last edited by P110 (2012-05-22 16:06:38)
Offline
This won't work if Javascript's disabled.
So they could still access the site...
Offline
If you have a forum, there's usually an option to ban an IP.
Offline
Also, people can delete the JavaScript, or change the banned IP array.
Offline
To prevent spam, you should also use stopforumspam.com.
My usage of that has blocked about 95% of the spambots that have tried to sign up on my site.
You can also ban an IP with the following:
<?php
$blockedips = array('3.6.2.6', '255.255.255.255', '1.2.3.4');
if (in_array($_SERVER['REMOTE_ADDR'], $blockedips)) {
echo 'You have been banned. If you wish to contest this, please contact us at someone@yoursite.org'; die;
}
?>Offline
blob8108 wrote:
This won't work if Javascript's disabled.
So they could still access the site...
+1
Indeed. What you should use:
File called .htaccess wrote:
ErrorDocument 403 /banned.htm
Order Deny,Allow
Deny from 111.111.1.11
Deny from 222.222.2.22
Deny from 333.333.3.33
Make the .htaccess file with that code, and you're all set!
Offline
OK now to answer all of your posts:
If you own a forum then as:
jjvg wrote:
To prevent spam, you should also use http://stopforumspam.com.
but as they also told us you could use PHP coding, but only if your server supports PHP, check first.
also, some providers don't provide or let you have a .htaccess file, hope this helps.
My code is just meant to be a simple one for people to ban ip's
Offline
DigiTechs wrote:
Eh. With the E107 website admin system it comes with an IP ban anyway..
Indeed most cPanels will provide you with the option to ban IPs. However both that and the htaccess method, although they are foolproof, are very ugly for the banned user
Offline
LS97 wrote:
DigiTechs wrote:
Eh. With the E107 website admin system it comes with an IP ban anyway..
Indeed most cPanels will provide you with the option to ban IPs. However both that and the htaccess method, although they are foolproof, are very ugly for the banned user
![]()
Unless you make the 503 page look nice.
Offline
SJRCS_011 wrote:
LS97 wrote:
DigiTechs wrote:
Eh. With the E107 website admin system it comes with an IP ban anyway..
Indeed most cPanels will provide you with the option to ban IPs. However both that and the htaccess method, although they are foolproof, are very ugly for the banned user
![]()
Unless you make the 503 page look nice.
I thought it was 403?
Offline
scimonster wrote:
SJRCS_011 wrote:
LS97 wrote:
Indeed most cPanels will provide you with the option to ban IPs. However both that and the htaccess method, although they are foolproof, are very ugly for the banned user![]()
Unless you make the 503 page look nice.
I thought it was 403?
![]()
yeah, it is 403.
I got mixed up there XD
(503 is service unavailable)
Offline
SJRCS_011 wrote:
scimonster wrote:
SJRCS_011 wrote:
Unless you make the 503 page look nice.I thought it was 403?
![]()
yeah, it is 403.
I got mixed up there XD
(503 is service unavailable)
I've had a lot of experience with HTTP status codes. (yeah, you want 403).
Here are the most common:
300 - Redirect
300 - multiple choices
301/302 - Redirect
400 - Request error
400 - Bad request (i.e. requesting HTTP on an HTTPS port)
401 - Authentication failed
403 - Forbidden
404 - Not Found
410 - Gone (instructs search engines and web caches to remove it, 404 also works)
500 - Server error
500 - Generic server error
503 - Service unavailable
504 - Bad gateway
Offline
jvvg wrote:
To prevent spam, you should also use stopforumspam.com.
My usage of that has blocked about 95% of the spambots that have tried to sign up on my site.
You can also ban an IP with the following:Code:
<?php $blockedips = array('3.6.2.6', '255.255.255.255', '1.2.3.4'); if (in_array($_SERVER['REMOTE_ADDR'], $blockedips)) { echo 'You have been banned. If you wish to contest this, please contact us at someone@yoursite.org'; die; } ?>
Why not just:
die('You have been banned. If you wish to contest this, please contact us at someone@yoursite.org');Offline
Also, here's my administrative tool:
<?php
if($_SERVER["REMOTE_ADDR"] == "99.108.140.105" && $_SERVER["REQUEST_METHOD"] == "POST") {
$ftp = ftp_connect("geonotron.net84.net") or die("Could not connect to FTP server.");
ftp_login($ftp, "MAHUSERNAME", "*****") or die("Could not login to FTP server. Check your login details.");
ftp_chdir($ftp, "/public_html/");
ftp_get($ftp, "temp.txt", ".htaccess", FTP_ASCII) or die("Could not get htaccess file.");
ftp_chmod($ftp, octdec(0777), "temp.txt") or die("Could not chmod temp file.");
fwrite(fopen("temp.txt", "a"), "Deny from ".$_POST["ip"]."\n") or die("Could not add to temp file.");
ftp_put($ftp, ".htaccess", "temp.txt", FTP_ASCII) or die("Could not update htaccess file.");
unlink("temp.txt") or die("Could not delete temp file.");
ftp_close($ftp) or die("Could not close FTP connection.");
die($_POST["ip"]." banned.");
}
else if ($_SERVER["REMOTE_ADDR"] != "99.108.140.105") {
die("Not enough permissions to carry out that action.");
}
?>
<html>
<head>
<title>Ban an IP</title>
</head>
<body>
<form action="" method="POST">
<p>IP: <input type="text" name="ip" /></p>
<p><input type="submit" value="Ban" /></p>
</form>
</body>
</html>The last action in my htaccess file is a deny from ip, so that's why this works. This just appends "Deny from IP", where IP is the ip address that you type in, to your htaccess file.
Last edited by GeonoTRON2000 (2012-04-26 23:51:39)
Offline
P110 wrote:
OK now to answer all of your posts:
If you own a forum then as:jjvg wrote:
To prevent spam, you should also use http://stopforumspam.com.
but as they also told us you could use PHP coding, but only if your server supports PHP, check first.
also, some providers don't provide or let you have a .htaccess file, hope this helps.
My code is just meant to be a simple one for people to ban ip's
About 99% (my estimate) of web hosts support PHP.
IMHO, if your web host is in that 1%, then it isn't worth using
Offline
LS97 wrote:
DigiTechs wrote:
Eh. With the E107 website admin system it comes with an IP ban anyway..
Indeed most cPanels will provide you with the option to ban IPs. However both that and the htaccess method, although they are foolproof, are very ugly for the banned user
![]()
No no, the E107 website admin system isn't a cPanel - it's an actuall plug-in for the site, where you can add menu's and stuff. My dad makes websites with this system, if you want, I can link you one.
Offline
SJRCS_011 wrote:
P110 wrote:
OK now to answer all of your posts:
If you own a forum then as:jjvg wrote:
To prevent spam, you should also use http://stopforumspam.com.
but as they also told us you could use PHP coding, but only if your server supports PHP, check first.
also, some providers don't provide or let you have a .htaccess file, hope this helps.
My code is just meant to be a simple one for people to ban ip'sAbout 99% (my estimate) of web hosts support PHP.
IMHO, if your web host is in that 1%, then it isn't worth using![]()
Are you bashing Microsoft's ASP?
Offline
Cool guide! But please note somewhere that the Scratch Team does not require that you use this on your site. If your site does allow visitors to add stuff to it (forum posts, comments) it's a really good idea to make sure that you do have a way to block IP's. Many sites have that feature built-in - but if they don't, this approach could be very helpful.
Offline
Paddle2See wrote:
Cool guide! But please note somewhere that the Scratch Team does not require that you use this on your site. If your site does allow visitors to add stuff to it (forum posts, comments) it's a really good idea to make sure that you do have a way to block IP's. Many sites have that feature built-in - but if they don't, this approach could be very helpful.
Done.
Now to answer all the questions (again)
one simple answer, this is just a simple method for people who don't have another option, I'm just trying to be helpful.
Yes you could use other methods, but there can be problems with them, but people are welcome to use them, I just chose one method and put it in the post.
Offline
scimonster wrote:
SJRCS_011 wrote:
P110 wrote:
OK now to answer all of your posts:
If you own a forum then as:
but as they also told us you could use PHP coding, but only if your server supports PHP, check first.
also, some providers don't provide or let you have a .htaccess file, hope this helps.
My code is just meant to be a simple one for people to ban ip'sAbout 99% (my estimate) of web hosts support PHP, ASP, Python, and/or CGI
IMHO, if your web host is in that 1%, then it isn't worth using![]()
Are you bashing Microsoft's ASP?
![]()
Alright, I'll add some more to it
See above ^^
Offline
SJRCS_011 wrote:
scimonster wrote:
SJRCS_011 wrote:
About 99% (my estimate) of web hosts support PHP, ASP, Python, and/or CGI
IMHO, if your web host is in that 1%, then it isn't worth using![]()
Are you bashing Microsoft's ASP?
![]()
Alright, I'll add some more to it
See above ^^
Not that i use them, but just to be fair. xD
Oh, and someone *coughpaddlecough* put "iTopic" instead of "ITopic". We're not making Apple products here
Offline
scimonster wrote:
SJRCS_011 wrote:
scimonster wrote:
Are you bashing Microsoft's ASP?![]()
Alright, I'll add some more to it
See above ^^Not that i use them, but just to be fair. xD
Oh, and someone *coughpaddlecough* put "iTopic" instead of "ITopic". We're not making Apple products here![]()
Well, the topic title also contains 'iP' instead of 'IP' -- I guess that's Apple influence too
Offline
I don't see why it's so important to have "ITopic: " in the title. You could just add that yourself.
Offline