![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
Need a quick php line
Hostgator shutdown my script for www.whatstheirip.com since some nithead abused it and it was sending out more than 500 emails an hour which is their limit. I am trying to put an anti-abuse script into place. I made a table called antiabuse with an id, sentmail, and timestamp field. Before sending an email, it inserts a 1 into antiabuse field. If lets say 300 1's are in the antiabuse table within the last hour, I want it to not send any more emails out.
Basically here is what i have = //anti abuse - makes sure no more than 250 emails are sent out in one hour mysql_query("INSERT INTO antiabuse (emailsent) VALUES ('1')"); Next I need an if statement which is what I am having problems with. Here is it in laymans terms: Count the number of 1's in antiabuse table emailssent field within the last hour, if the number is greater than 250 echo "Sorry please wait" else (i'll insert the the email script here to proceed with emailing) Hope someone can help, this is a free script I made a year ago on my free time and a lot of people seem to be relying on it :/ |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
So Fucking Banned
Industry Role:
Join Date: Jul 2010
Location: ☣
Posts: 9,327
|
The script above doesn't made since.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
i just need to count the number of antiabuse=1 (field) within the last hour
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
what is the timestamp column called in your table?
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
<&(©¿©)&>
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
|
Sounds like you are doing it wrong...
hit me up, icq: 33375924, and I'll solve this for you for a few bucks...
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000 Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager ![]() Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
Code:
$result = mysql_query('select count(*) from antiabuse where `ts` > curtime() - interval 1 hour'); $row = mysql_fetch_row($result); $count = $row[0]; if ($count > 250) { die('Sorry, please wait and try again in a few minutes.'); }
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 | |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
Quote:
![]()
__________________
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
thanks! timestamp field is called time, I will try this out shortly
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
tested it using a 3 email per hour limit and it didnt seem to end. maybe i need a proper if statement? either that or interval 1 hour isn't recognized. here is the piece of the script:
//anti abuse - makes sure no more than 250 emails are sent out in one hour mysql_query("INSERT INTO antiabuse (emailsent) VALUES ('1')"); $result = mysql_query('select count(*) from antiabuse where `time` > curtime() - interval 1 hour'); $row = mysql_fetch_row($result); $count = $row[0]; if ($count > 3) { die('Sorry, please wait and try again in a few minutes.'); } //then if it doesn't end from the anti abuse script, the send email script starts below $to = "$xemail"; |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#10 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
curtime() is wrong, try
now() - 3600 assuming 'time' is a mysql timestamp value
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#11 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
got it working thanks! had to be 'time' > now() count was 0 when it was 'time < now()
thanks so much |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#12 |
Unregistered Abuser
Industry Role:
Join Date: Oct 2007
Posts: 15,547
|
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#13 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
i just noticed right now that it is counting every single record in the antiabuse table, right now there are 780 records there so the script works when i go > 800 but not when I go > 700
example of my time stamp = 2011-05-18 18:31:25 here is the script i have = Code:
//antiabuse - makes sure no more than 400 emails are sent out in one hour mysql_query("INSERT INTO antiabuse (emailsent) VALUES ('1')"); $result = mysql_query("select count(*) from antiabuse where 'time' < now() - 3600"); $row = mysql_fetch_row($result); $count = $row[0]; if ($count > 400) { die(''); } // end antiabuse for hostgator |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#14 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
maybe i have to use "time" instead of "timestamp" for the table structure?
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#15 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
i guess i can also keep the current script and run a cron job to run a php script every hour that will clear all the data in the antiabuse table. but never did cron jobs before. I am using cpanel
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#16 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
Code:
select count(*) from antiabuse where 'time' < now() - 3600
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#17 |
Confirmed User
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
|
nvm works fine with the cron
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#18 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
I don't know why I bothered.
![]()
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |