Kom ihåg mig?
Home Menu

Menu


Blockera IP

 
Ämnesverktyg Visningsalternativ
Oläst 2007-09-16, 04:35 #1
pokerstjärnas avatar
pokerstjärna pokerstjärna är inte uppkopplad
Klarade millennium-buggen
 
Reg.datum: Aug 2007
Inlägg: 2 138
pokerstjärna pokerstjärna är inte uppkopplad
Klarade millennium-buggen
pokerstjärnas avatar
 
Reg.datum: Aug 2007
Inlägg: 2 138
Hej.

Driver en mindre community sida och denna + två veckor tillbaka har den varit utsatt för många spammare.

Dom verkar ta sig förbi captchen också.

Finns det ingen kod man kan lägga till i scriptet på index filen så att dom inte kommer in alls?
Jag har då IP-adresserna listade.

Väldigt tacksam för hjälp. :unsure:
pokerstjärna är inte uppkopplad   Svara med citatSvara med citat
Oläst 2007-09-16, 05:00 #2
gsocs avatar
gsoc gsoc är inte uppkopplad
Mycket flitig postare
 
Reg.datum: Jun 2007
Inlägg: 568
gsoc gsoc är inte uppkopplad
Mycket flitig postare
gsocs avatar
 
Reg.datum: Jun 2007
Inlägg: 568
Kod:
<?
$bannad[0]="1.1.1.1";
$bannad[1]="2.1.1.1";
$bannad[2]="3.1.1.1";
$bannad[3]="4.1.1.1";
$bannad[4]="5.1.1.1";

if (in_array($_SERVER['REMOTE_ADDR'],$bannad))
{
header("HTTP/1.1 403 Forbidden");
exit;
}
?>
Borde fungera för vad du är ute efter?

Edit1: Kom ihåg att du kan faktiskt använda wildcards om du vill blockera tex ett c-nät, 1.1.1.*

Edit2: Om du vill kan du ju använda htaccess till det också:

Kod:
Order Allow,Deny
Deny From 1.1.1.1
Deny From 2.1.1.1
Deny From 3.1.1.1
Allow From All
gsoc är inte uppkopplad   Svara med citatSvara med citat
Oläst 2007-09-16, 06:29 #3
pokerstjärnas avatar
pokerstjärna pokerstjärna är inte uppkopplad
Klarade millennium-buggen
 
Reg.datum: Aug 2007
Inlägg: 2 138
pokerstjärna pokerstjärna är inte uppkopplad
Klarade millennium-buggen
pokerstjärnas avatar
 
Reg.datum: Aug 2007
Inlägg: 2 138
Citat:
Originally posted by gsoc@Sep 16 2007, 05:00
Kod:
<?
$bannad[0]="1.1.1.1";
$bannad[1]="2.1.1.1";
$bannad[2]="3.1.1.1";
$bannad[3]="4.1.1.1";
$bannad[4]="5.1.1.1";

if (in_array($_SERVER['REMOTE_ADDR'],$bannad))
{
header("HTTP/1.1 403 Forbidden");
exit;
}
?>
Borde fungera för vad du är ute efter?

Edit1: Kom ihåg att du kan faktiskt använda wildcards om du vill blockera tex ett c-nät, 1.1.1.*

Edit2: Om du vill kan du ju använda htaccess till det också:

Kod:
Order Allow,Deny
Deny From 1.1.1.1
Deny From 2.1.1.1
Deny From 3.1.1.1
Allow From All
Provade med att blockera min IP-adress och det fungerade utmärkt, Tack.

Om det finns andra sätt som är avancerade tekniskt sätt så får ni gärna posta
pokerstjärna är inte uppkopplad   Svara med citatSvara med citat
Oläst 2007-09-16, 06:40 #4
gsocs avatar
gsoc gsoc är inte uppkopplad
Mycket flitig postare
 
Reg.datum: Jun 2007
Inlägg: 568
gsoc gsoc är inte uppkopplad
Mycket flitig postare
gsocs avatar
 
Reg.datum: Jun 2007
Inlägg: 568
Citat:
Hello,

Well I for one am tired of fraudulent orders from the same old countries and I want to educate as many people as possible about stopping or at least lowering such orders on the internet. So here goes my first How-To :-)

Okay lets start.

Step 1 - Obtaining the country codes

Firstly, lets download the database of countries to IP address (which is provided courtesy of webhosting.info):

http://ip-to-country.webhosting.info/node/view/6

Download the zip file, extract it and then upload it to your server.

Step 2 - Setting up the database

Now create two MySQL tables using the following:

CREATE TABLE `country_list` (
`IP_FROM` double NOT NULL default '0',
`IP_TO` double NOT NULL default '0',
`country_code` char(2) NOT NULL default '',
`country_code2` char(3) NOT NULL default '',
`country_name` varchar(50) NOT NULL default ''
) TYPE=MyISAM;

CREATE TABLE country_blocks (
id int(5) NOT NULL auto_increment,
country_code char(2) NOT NULL default '',
KEY id (id)
) TYPE=MyISAM;

Okay now we want to load all the data into the country_list table. It's very quick if you can run this command from a MySQL prompt:

LOAD DATA INFILE '/directory/ip-to-country.csv' INTO
TABLE `country_list` FIELDS TERMINATED BY ',' ENCLOSED BY '"'
ESCAPED BY '\\' LINES TERMINATED BY '\r\n'

Lets also load some countries that have high fraud stats:

INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (1, 'AF');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (2, 'DZ');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (3, 'BD');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (4, 'BG');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (5, 'CN');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (6, 'HR');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (7, 'ID');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (8, 'JP');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (9, 'MY');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (10, 'NG');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (11, 'RO');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (12, 'SG');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (13, 'TW');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (14, 'VN');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (15, 'EG');

Blocks access from these countries:
AFGHANISTAN, ALGERIA, BANGLADESH, BULGARIA, CHINA, CROATIA, EGYPT, INDONESIA, JAPAN, MALAYSIA, NIGERIA, ROMANIA, SINGAPORE, TAIWAN, VIET NAM.

Step 3 - Doin the PHP

Great, that's that hard stuff! Now lets do the PHP stuff - its pretty easy!

Usually all sites created from php have a common.php or a file that is loaded before anything else if yours is like this then add the following function into that file:

function ip_access_check($ip)
{
$result = mysql_query("SELECT country_code FROM country_list WHERE IP_FROM <= inet_aton('" . $ip . "') AND IP_TO >= inet_aton('" . $ip . "')") or mysql_err();
$row = mysql_fetch_array($result);

$result = mysql_query("SELECT country_code FROM country_blocks WHERE country_code = '" . $row["country_code"] . "'") or mysql_err();

if ($row = mysql_fetch_array($result))
{
header("Location: /blocked.html");
exit;
}
}


If you don't have a common.php or similar then simply create a file called common.php with the function in it and include it in every page that you want using the include(); function.

Notice the "header("Location: /blocked.html");" in the above php function, well you can change this to point to a page that displays a message saying why you have blocked the page.

Now in your index.php and any other pages add the following just after calling the common.php file:

<?
ip_access_check($REMOTE_ADDR);
?>

Step 3 - Testing it

Test by adding your country into the country_blocks and then access that page which you have added the php code to.

Conclusion

I do hope this does lower any fraudulent orders you may get.. Good Luck with your endeavors and please let me know how it goes for you!

-Phil
Om du vill banna länder, gör en sökning på google så skall du ser att du finner svar, finns väldigt många olika metoder och verktyg för att banna folk, bästa vore väll om du använde dig av captcha så slipper du banna folk?
gsoc är inte uppkopplad   Svara med citatSvara med citat
Oläst 2007-09-16, 06:54 #5
pokerstjärnas avatar
pokerstjärna pokerstjärna är inte uppkopplad
Klarade millennium-buggen
 
Reg.datum: Aug 2007
Inlägg: 2 138
pokerstjärna pokerstjärna är inte uppkopplad
Klarade millennium-buggen
pokerstjärnas avatar
 
Reg.datum: Aug 2007
Inlägg: 2 138
Citat:
Originally posted by gsoc@Sep 16 2007, 06:40
Citat:
Hello,

Well I for one am tired of fraudulent orders from the same old countries and I want to educate as many people as possible about stopping or at least lowering such orders on the internet. So here goes my first How-To :-)

Okay lets start.

Step 1 - Obtaining the country codes

Firstly, lets download the database of countries to IP address (which is provided courtesy of webhosting.info):

http://ip-to-country.webhosting.info/node/view/6

Download the zip file, extract it and then upload it to your server.

Step 2 - Setting up the database

Now create two MySQL tables using the following:

CREATE TABLE `country_list` (
`IP_FROM` double NOT NULL default '0',
`IP_TO` double NOT NULL default '0',
`country_code` char(2) NOT NULL default '',
`country_code2` char(3) NOT NULL default '',
`country_name` varchar(50) NOT NULL default ''
) TYPE=MyISAM;

CREATE TABLE country_blocks (
id int(5) NOT NULL auto_increment,
country_code char(2) NOT NULL default '',
KEY id (id)
) TYPE=MyISAM;

Okay now we want to load all the data into the country_list table. It's very quick if you can run this command from a MySQL prompt:

LOAD DATA INFILE '/directory/ip-to-country.csv' INTO
TABLE `country_list` FIELDS TERMINATED BY ',' ENCLOSED BY '"'
ESCAPED BY '\\' LINES TERMINATED BY '\r\n'

Lets also load some countries that have high fraud stats:

INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (1, 'AF');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (2, 'DZ');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (3, 'BD');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (4, 'BG');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (5, 'CN');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (6, 'HR');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (7, 'ID');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (8, 'JP');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (9, 'MY');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (10, 'NG');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (11, 'RO');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (12, 'SG');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (13, 'TW');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (14, 'VN');
INSERT INTO `country_blocks` (`id`, `country_code`) VALUES (15, 'EG');

Blocks access from these countries:
AFGHANISTAN, ALGERIA, BANGLADESH, BULGARIA, CHINA, CROATIA, EGYPT, INDONESIA, JAPAN, MALAYSIA, NIGERIA, ROMANIA, SINGAPORE, TAIWAN, VIET NAM.

Step 3 - Doin the PHP

Great, that's that hard stuff! Now lets do the PHP stuff - its pretty easy!

Usually all sites created from php have a common.php or a file that is loaded before anything else if yours is like this then add the following function into that file:

function ip_access_check($ip)
{
$result = mysql_query("SELECT country_code FROM country_list WHERE IP_FROM <= inet_aton('" . $ip . "') AND IP_TO >= inet_aton('" . $ip . "')") or mysql_err();
$row = mysql_fetch_array($result);

$result = mysql_query("SELECT country_code FROM country_blocks WHERE country_code = '" . $row["country_code"] . "'") or mysql_err();

if ($row = mysql_fetch_array($result))
{
header("Location: /blocked.html");
exit;
}
}


If you don't have a common.php or similar then simply create a file called common.php with the function in it and include it in every page that you want using the include(); function.

Notice the "header("Location: /blocked.html");" in the above php function, well you can change this to point to a page that displays a message saying why you have blocked the page.

Now in your index.php and any other pages add the following just after calling the common.php file:

<?
ip_access_check($REMOTE_ADDR);
?>

Step 3 - Testing it

Test by adding your country into the country_blocks and then access that page which you have added the php code to.

Conclusion

I do hope this does lower any fraudulent orders you may get.. Good Luck with your endeavors and please let me know how it goes for you!

-Phil
Om du vill banna länder, gör en sökning på google så skall du ser att du finner svar, finns väldigt många olika metoder och verktyg för att banna folk, bästa vore väll om du använde dig av captcha så slipper du banna folk?
Det där är precis vad jag behövde, borde tänka på att googla mer
Grejen är att jag använder captcha men dom har tagit sig förbi det på något sätt :unsure: :blink:

men ska prova detta tack så mycket
pokerstjärna är inte uppkopplad   Svara med citatSvara med citat
Oläst 2007-09-16, 09:27 #6
melin melin är inte uppkopplad
Har WN som tidsfördriv
 
Reg.datum: Jul 2003
Inlägg: 1 396
melin melin är inte uppkopplad
Har WN som tidsfördriv
 
Reg.datum: Jul 2003
Inlägg: 1 396
Captcha är långt från perfekt tyvärr, det har funnits så länge så spammers har lärt sig hur dom ska göra
melin är inte uppkopplad   Svara med citatSvara med citat
Oläst 2007-09-17, 03:02 #7
pokerstjärnas avatar
pokerstjärna pokerstjärna är inte uppkopplad
Klarade millennium-buggen
 
Reg.datum: Aug 2007
Inlägg: 2 138
pokerstjärna pokerstjärna är inte uppkopplad
Klarade millennium-buggen
pokerstjärnas avatar
 
Reg.datum: Aug 2007
Inlägg: 2 138
gsoc: provade det du klistra in... well done! fungerar utmärkt.
pokerstjärna är inte uppkopplad   Svara med citatSvara med citat
Oläst 2007-09-17, 07:37 #8
crazzys avatar
crazzy crazzy är inte uppkopplad
Har WN som tidsfördriv
 
Reg.datum: Aug 2007
Inlägg: 1 089
crazzy crazzy är inte uppkopplad
Har WN som tidsfördriv
crazzys avatar
 
Reg.datum: Aug 2007
Inlägg: 1 089
ska slänga upp det på en sida som har en gästbok.. den fylls med ryska..
crazzy är inte uppkopplad   Svara med citatSvara med citat
Oläst 2007-09-17, 08:10 #9
gsocs avatar
gsoc gsoc är inte uppkopplad
Mycket flitig postare
 
Reg.datum: Jun 2007
Inlägg: 568
gsoc gsoc är inte uppkopplad
Mycket flitig postare
gsocs avatar
 
Reg.datum: Jun 2007
Inlägg: 568
Ryska är väll chill, synd att jag varken pratar eller förstår
gsoc är inte uppkopplad   Svara med citatSvara med citat
Oläst 2007-09-17, 16:39 #10
eliasson eliasson är inte uppkopplad
Bara ett inlägg till!
 
Reg.datum: Dec 2005
Inlägg: 1 863
eliasson eliasson är inte uppkopplad
Bara ett inlägg till!
 
Reg.datum: Dec 2005
Inlägg: 1 863
Citat:
Originally posted by melin@Sep 16 2007, 09:27
Captcha är långt från perfekt tyvärr, det har funnits så länge så spammers har lärt sig hur dom ska göra
Tycker det är märkligt att dom kan skapa sådana program som analyzerar CAPTCHA som även har mycket "garbarge" som ska störa den mekaniska faktorn, otroligt.
eliasson är inte uppkopplad   Svara med citatSvara med citat
Svara


Aktiva användare som för närvarande tittar på det här ämnet: 1 (0 medlemmar och 1 gäster)
 

Regler för att posta
Du får inte posta nya ämnen
Du får inte posta svar
Du får inte posta bifogade filer
Du får inte redigera dina inlägg

BB-kod är
Smilies är
[IMG]-kod är
HTML-kod är av

Forumhopp


Alla tider är GMT +2. Klockan är nu 11:24.

Programvara från: vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Svensk översättning av: Anders Pettersson
 
Copyright © 2017