Exemplo n.º 1
0
 public function __construct($connection = null)
 {
     $config = Config::get('profiler');
     if ($config['useForensics'] != true) {
         return;
     }
     if ($connection instanceof Connection) {
         $this->connection = $connection;
     } else {
         if ($config['withDatabase'] == true) {
             $this->connection = DB::connection();
         }
     }
     // Setup the View path.
     $this->viewPath = realpath(__DIR__) . DS . 'Views' . DS . 'Profiler.php';
     // Setup the Start Time.
     $this->startTime = Request::server('REQUEST_TIME_FLOAT');
 }
Exemplo n.º 2
0
 /**
  * Compare given answer against the generated session.
  *
  * @param  string $response
  * @return boolean
  */
 protected function check($response = null)
 {
     if (!$this->isActive()) {
         return true;
     }
     // Get the Http Request instance.
     $request = HttpRequest::instance();
     // Get the recaptcha response value.
     $response = $response ?: $request->input('g-recaptcha-response', '');
     // Build the query string.
     $query = http_build_query(array('secret' => $this->getSecretKey(), 'response' => $response, 'remoteip' => $request->ip()));
     // Calculate the (complete) request URL.
     $url = static::GOOGLEHOST . '?' . $query;
     // Perform the request to Google server.
     $result = file_get_contents($url);
     // Evaluate the Google server response.
     if ($result !== false) {
         $data = json_decode($result, true);
         if (is_array($data)) {
             return $data['success'] === true;
         }
     }
     return false;
 }
Exemplo n.º 3
0
 protected function getElapsedTime()
 {
     $timestamp = microtime(true);
     $requestTime = Request::server('REQUEST_TIME_FLOAT');
     return $timestamp - $requestTime;
 }