Forum Moderators: coopster

Message Too Old, No Replies

Add Ip Field to Mysql Data Base

Add Ip Feild

         

joe da laidoff plumr

1:54 am on Nov 2, 2008 (gmt 0)

10+ Year Member



I have a link dump site running a very simple mysql script... no spam protection... anyways I have one user that repeatedly spams even after warnings. I want to block spammers based on the IP used to send the spam. Currently the link dump script grabs the Title of the link, the link url, and the link date... I want it to also grap the IP when the link is submitted... very new to mysql, looking for a point in the right direction as far as coding to add ip feild to the data base

php code for the script:
------------------------

<?
include("dbConfig.php");
$x = 0;
$y = 350;

do{

$sql = "SELECT url, title, date, FROM `links` ORDER BY id DESC LIMIT ".$x.", ".$y.";";
$rs = mysql_query($sql);
echo mysql_error();
$nr = mysql_num_rows($rs);

while($row = mysql_fetch_row($rs)){
echo "<a target=\"blank\" href=\"".$row[0]."\">".$row[1]."</a> ".$row[2]."\n<br>\n";
}

if($nr !=0){echo "<p><a href=\"#dump\">DUMP YOUR LINK</a></p>";
}
$x = $x + 350;
$y = $y + 350;
} while($nr!=0);
mysql_close();
?>

mysql:
-------
CREATE TABLE `links` (
`id` int(11) NOT NULL auto_increment,
`url` varchar(160) NOT NULL default '',
`title` varchar(100) NOT NULL default '',
`date` date NOT NULL default '0000-00-00',
PRIMARY KEY (`id`)
) TYPE=MyISAM;

jatar_k

12:56 pm on Nov 2, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld

a couple things

to add a column to a table in mysql you would use ALTER TABLE [dev.mysql.com]

the problem with stopping everything from a certain IP is that an IP does not uniquely identify a single user. The ip could be from AOL and you could ban all of AOL, which would be a fair number of folks.

Some other criteria for identifying "spam" is likely needed.

joe da laidoff plumr

3:28 pm on Nov 2, 2008 (gmt 0)

10+ Year Member



I understand how to add a feild, that I can do via "php myadmin" for mysql data base... and I have actually added the IP feild but it's not grabbing anything... whenever I browse my table, looking at stored links the IP feild is always empty... I couldnt figure out how to make the feild actually work...
--------------------
I probably wont grab the IP as AOL and I am sure that a few others assign same IP to multiple users, I thought IP was like a finger print for your computer.
-------------------
Well is there a way that I could alter the php to block a certain string from being entered onto the form...
on the Php end of the form there is a feild for Title and a feild for Url... possible to block a certain string from being entered in to the url feild... for instance, blocking www.somedomain.com, form wont submit if somedomain.com is entered...
--------------------
right now form wont submit if title or url feild is blank... possible to add a code to block the form from submitting based on a list of banned domains?

jatar_k

12:25 am on Nov 3, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you would need to find the insert query, I don't see it above, and then you would add to that.

You could grab the IP using $_SERVER['REMOTE_ADDR'] and then, as I said, adding that to the insert statement.

You would need to find what is mentioned in the action portion of the form and look in that script for the insert.

joe da laidoff plumr

4:52 pm on Nov 3, 2008 (gmt 0)

10+ Year Member



huh? insert query? Lost me... anyways, I am definitely not at the point to write code. That link dump script was given to me and its my first database... I will just manually delete spam links, no idea how to write strings of functioning code so i'll just delete the spam manually... it's an adult link dump, guess i should have expected spam and shady webmasters.