Exemple #1
0
 /**
  * Checks for a honeypot in the request
  *
  * @param   string   $name
  * @param   integer  $delay
  * @return  boolean  True if found and valid, false otherwise.
  */
 public static function checkHoneypot($name = null, $delay = 3)
 {
     $name = $name ?: \Hubzero\Spam\Honeypot::getName();
     if ($honey = self::getVar($name, array(), 'post')) {
         if (!\Hubzero\Spam\Honeypot::isValid($honey['p'], $honey['t'], $delay)) {
             if (\App::has('log')) {
                 $fallback = 'option=' . self::getCmd('option') . '&controller=' . self::getCmd('controller') . '&task=' . self::getCmd('task');
                 $from = self::getVar('REQUEST_URI', $fallback, 'server');
                 $from = $from ?: $fallback;
                 \App::get('log')->logger('spam')->info('spam honeypot ' . self::ip() . ' ' . \User::get('id') . ' ' . \User::get('username') . ' ' . $from);
             }
             return false;
         }
     }
     return true;
 }
Exemple #2
0
 /**
  * Displays an input field that should be left empty by the
  * real users of the application but will most likely be
  * filled out by spam bots.
  *
  * Use in conjunction with Request::checkHoneypot()
  *
  * @param   string   $name
  * @param   integer  $delay
  * @return  string
  */
 public static function honeypot($name = null)
 {
     return \Hubzero\Spam\Honeypot::generate($name);
 }