Page 2 of 2

Posted: Fri Aug 26, 2005 4:40 pm
by feyd
yeah, the php error goes away, but the select will never find any records.

Code: Select all

$query = mysql_query("SELECT * FROM `news` WHERE `ip` = '{$ip}' AND `date` > '".(time()-1800)."'") or die(mysql_error());

Posted: Fri Aug 26, 2005 4:55 pm
by Stewsburntmonkey
I just noticed that you are using a unique id that is auto-incremented, so there will never be an update.

Using the id makes things a little bit more difficult. You will probably have to follow the logic I outlined earler. :)

Posted: Fri Aug 26, 2005 4:58 pm
by blacksnday
lol... i mentioned that in my first post...
the very last line says the tables don't update :P

I will check your other stuff out..
having this feature for my submit form is badly needed because
it is the main feature of the script I am making.

Need some kind of spam control other then auth images/etc.
and time based posting per IP (maybe even sessions) is my goal!
Thanks for the help.... i will go back and work on this and
see what happens :)

Posted: Fri Aug 26, 2005 5:07 pm
by s.dot
do you have some sort of login system? where you can log who posted by id or username?

Posted: Fri Aug 26, 2005 5:11 pm
by blacksnday
scrotaye wrote:do you have some sort of login system? where you can log who posted by id or username?
right now nothing from a web base panel.
But all submits do have name/email/ip/date-time inserted to db.
Also I currently do not support a member base.
Just a simple form where anyone can post to.

I plan to eventually make an admin login section to
manage the submissions.

Since all submits do have ip/date-time logged, I figured it wouldn't be to hard
to create a IP based timer to allow or deny new entries
which I prefer to do it that way first, then use secondary measures
to control time based permission.

I would like to add, that the original code suggestion DOES work, when
it see's an IP of a submitter in the DB it stops them from posting again.
I just need to get it to recongize the time from the last IP and realize it's ok
to insert a new submission as long as the last found IP of the user shows a time
being expired of the allowed submit timer.

Posted: Sun Aug 28, 2005 8:39 pm
by blacksnday
Just wanted to update the status of my replies :)

I was searching the net and found someone having a similar problem
and were nice enough to post their solution.

I have edited a tad to better suit my needs.

Code: Select all

$floodTime = "600"; 
$floodQuery = "SELECT * FROM news WHERE ip = '$ip' AND date > (NOW() - INTERVAL '". $floodTime . "' SECOND)";
$flooding = mysql_query($floodQuery);  
while(mysql_fetch_array($flooding))
{
$floodMsg = "Calm Down! Wait to Bash!\n<br />";
$floodMsg .= "<br />You can Bash once every 10 minutes"; 
@mysql_query ("INSERT INTO deny (flood) VALUES ('$ip')");
echo "<center><font color=\"red\" size=\"4\">$floodMsg</font></center>"; 
die(); 
}

Posted: Sun Aug 28, 2005 9:18 pm
by Stewsburntmonkey
Unless I am mistaken that is going to create a new database entry everytime someone fails to submit a page. That seems like a terrible waste of database space. . . It also never seems to update the timestamp in the news table. It doesn't seem like this actually does what you said you wanted it to.

Posted: Sun Aug 28, 2005 9:28 pm
by blacksnday
It only adds a new db entry IF a user tries to submit something
when they are still not allowed too.
And the only thing it adds is their IP address into a seperate table,
to help me see who tries to flood.

and no, it does not update any timestamp.

This does exactly what I was needing.

Since I do not have members, I need a way to control people from
spamming. Just like how shoutboxes can control anoymous submits.

This does just that.
When you make a post, your info is stored in the database.
Then you make a new post the above script checks to see if your ip
is found anywhere in the database and if it is it then checks the
last time available for the last record of your IP.
If the time is to short, it then blocks your submission, and adds your IP
to a seperate table I created just for code like this, So I can see who
abuses and who doesnt.

If your IP is not found, then it updates with your post.
If you IP is found and the time is past the spam time,
then your info gets inserted into a new row just like I want it to be.

Maybe your thinking about a members table, where a new row is NOT created,
rather then the current member row being updated.

The above code is just a snippet of the whole code.
This is just my flood checker :) Not the code that actually does the insertion
of posts.... etc....
Maybe thats how you seemed confused?

Regardless, this does do exactly What I need.
:)