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'); }
public static function getReport() { $options = Config::get('profiler'); // Calculate the variables. $execTime = microtime(true) - HttpRequest::server('REQUEST_TIME_FLOAT'); $elapsedTime = sprintf("%01.4f", $execTime); $memoryUsage = Number::humanSize(memory_get_usage()); if ($options['withDatabase'] == true) { $connection = DB::connection(); $queries = $connection->getQueryLog(); $totalQueries = count($queries); $queriesStr = $totalQueries == 1 ? __d('nova', 'query') : __d('nova', 'queries'); } else { $totalQueries = 0; $queriesStr = __d('nova', 'queries'); } $estimatedUsers = sprintf("%0d", intval(25 / $execTime)); // $retval = __d('nova', 'Elapsed Time: <b>{0}</b> sec | Memory Usage: <b>{1}</b> | SQL: <b>{2}</b> {3} | UMAX: <b>{4}</b>', $elapsedTime, $memoryUsage, $totalQueries, $queriesStr, $estimatedUsers); return $retval; }
/** * 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; }