Jump to content

[SOLVED] anti-spam function help needed


Pastulio

Recommended Posts

Ok, so I was writing an anti-spam function that looked a little bit like this:

 

// Anti-Spam function
function antiSpam ($passedDay, $passedHour, $passedMinutes, $passedSeconds){

  $currentHour = date ("H");
  $currentMinutes = date ("i");
  $currentSeconds = date ("s")
  $currentTimeSeconds = ($currentHour * 3600) + ($currentMinutes * 60) + $currentSeconds;
  $passedTimeSeconds = ($passedHour *3600) + ($passedMinuts * 60) + $passedSeconds;
  $intervalPP = 120; //interval in seconds

  $totalTime = $currentTimeSeconds - $passedTimeSeconds;

  if ($totalTime >= $intervalPP){

	$_SESSION['antispam'] = "on";
	$_SESSION['time_day'] = date ("d")
	$_SESSION['time_hour'] = date ("H");
	$_SESSION['time_minutes'] = date ("i");
	$_SESSION['time_seconds'] = date ("s");
	return 1;

  }
  
}

 

 

And I though... Well what if somebody happens to post at 23:59  (11:59 PM) and again at 00:00 (12 AM).

Then the function wouldn't live up to it's cause.

 

Can anybody help me with this because if I do this for another day, the bug will just scoop over to month and year =/.

 

Thanks a lot guys

 

 

Edit: just saw I didn't even use the $intervalPP variable fixed in the code now :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.