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
https://forums.phpfreaks.com/topic/55875-solved-anti-spam-function-help-needed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.