Ejemplo n.º 1
0
 public function postValidate()
 {
     $validator = $this->validator->make($this->input->all(), array('recaptcha_response_field' => 'required|recaptcha'));
     if ($validator->fails()) {
         return $this->response->json(array('result' => 'failed'));
     }
     $this->session->put('captcha.passed.time', $this->mockably->microtime());
     return $this->response->json(array('result' => 'success'));
 }
Ejemplo n.º 2
0
 /**
  * Get the time difference of a time record compared to the present
  *
  * @param float $time_record A record of microtime(true) in the past
  * @param string $unit Can be either 'ms', 's' or 'm' (milliseconds, seconds, minutes)
  * @return int Returns the time difference in the given unit
  * @throws BadMethodCallException
  */
 public function getCurrentTimeDifference($time_record, $unit = 'm')
 {
     $current_time = $this->mockably->microtime();
     switch ($unit) {
         case 'ms':
             $difference = round(($current_time - $time_record) * 1000);
             break;
         case 's':
             $difference = round($current_time - $time_record);
             break;
         case 'm':
             $difference = floor(round($current_time - $time_record) / 60);
             break;
         default:
             throw new BadMethodCallException();
     }
     return (int) $difference;
 }