-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.php
24 lines (20 loc) · 818 Bytes
/
start.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
// Create a Form macro which generates the fake honeypot field
// as well as the time check field
Form::macro('honeypot', function($honey_name, $honey_time)
{
return View::make("honeypot::fields", get_defined_vars());
});
// We add a custom validator to validate the honeypot text and time check fields
Validator::register('honeypot', function($attribute, $value, $parameters)
{
// We want the value to be empty, empty means it wasn't a spammer
return $value == '';
});
Validator::register('honeytime', function($attribute, $value, $parameters)
{
// The timestamp is encrypted so let's decrypt it
$value = Crypter::decrypt($value);
// The current time should be greater than the time the form was built + the speed option
return ( is_numeric($value) && time() > ($value + $parameters[0]) );
});