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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 05-17-2011, 07:15 PM   #1
mkx
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 :/
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 07:18 PM   #2
marlboroack
So Fucking Banned
 
Industry Role:
Join Date: Jul 2010
Location: ☣
Posts: 9,327
The script above doesn't made since.
marlboroack is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 07:27 PM   #3
mkx
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
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 07:45 PM   #4
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
what is the timestamp column called in your table?
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 07:49 PM   #5
woj
<&(©¿©)&>
 
woj's Avatar
 
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
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 07:50 PM   #6
Brujah
Beer Money Baron
 
Brujah's Avatar
 
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.');
}
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 07:51 PM   #7
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Quote:
Originally Posted by woj View Post
Sounds like you are doing it wrong...
hit me up, icq: 33375924, and I'll solve this for you for a few bucks...
or that.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 07:54 PM   #8
mkx
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
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 07:59 PM   #9
mkx
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";
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 08:12 PM   #10
Brujah
Beer Money Baron
 
Brujah's Avatar
 
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
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 08:24 PM   #11
mkx
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
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-17-2011, 08:27 PM   #12
papill0n
Unregistered Abuser
 
Industry Role:
Join Date: Oct 2007
Posts: 15,547
Quote:
Originally Posted by mkx View Post
got it working thanks! had to be 'time' > now() count was 0 when it was 'time < now()

thanks so much

now move from hostgator and you are all set
papill0n is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-18-2011, 04:52 PM   #13
mkx
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
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-18-2011, 04:53 PM   #14
mkx
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?
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-18-2011, 04:59 PM   #15
mkx
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
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-18-2011, 05:29 PM   #16
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Code:
select count(*) from antiabuse where 'time' < now() - 3600
This query says you want a count of all rows where the datetime is less than 1 hour ago (now-3600 seconds). Don't you want to count all rows in the past 1 hour?
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-18-2011, 05:29 PM   #17
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
nvm works fine with the cron
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-18-2011, 05:54 PM   #18
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Quote:
Originally Posted by mkx View Post
nvm works fine with the cron
I don't know why I bothered. I'll try to remember not to do that in the future.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.