Changeset View
Changeset View
Standalone View
Standalone View
webroot/index.php
| <?php | <?php | ||||
| require_once dirname(dirname(__FILE__)).'/support/PhabricatorStartup.php'; | $phabricator_root = dirname(dirname(__FILE__)); | ||||
| require_once $phabricator_root.'/support/PhabricatorStartup.php'; | |||||
| // If the preamble script exists, load it. | |||||
| $preamble_path = $phabricator_root.'/support/preamble.php'; | |||||
| if (file_exists($preamble_path)) { | |||||
| require_once $preamble_path; | |||||
| } | |||||
| PhabricatorStartup::didStartup(); | PhabricatorStartup::didStartup(); | ||||
| $show_unexpected_traces = false; | $show_unexpected_traces = false; | ||||
| try { | try { | ||||
| PhabricatorStartup::loadCoreLibraries(); | PhabricatorStartup::loadCoreLibraries(); | ||||
| PhabricatorEnv::initializeWebEnvironment(); | PhabricatorEnv::initializeWebEnvironment(); | ||||
| $show_unexpected_traces = PhabricatorEnv::getEnvConfig( | $show_unexpected_traces = PhabricatorEnv::getEnvConfig( | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | try { | ||||
| $access_log->setData( | $access_log->setData( | ||||
| array( | array( | ||||
| 'c' => $response->getHTTPResponseCode(), | 'c' => $response->getHTTPResponseCode(), | ||||
| 'T' => PhabricatorStartup::getMicrosecondsSinceStart(), | 'T' => PhabricatorStartup::getMicrosecondsSinceStart(), | ||||
| )); | )); | ||||
| DarkConsoleXHProfPluginAPI::saveProfilerSample($access_log); | DarkConsoleXHProfPluginAPI::saveProfilerSample($access_log); | ||||
| // Add points to the rate limits for this request. | |||||
| if (isset($_SERVER['REMOTE_ADDR'])) { | |||||
| $user_ip = $_SERVER['REMOTE_ADDR']; | |||||
| // The base score for a request allows users to make 30 requests per | |||||
| // minute. | |||||
| $score = (1000 / 30); | |||||
| // If the user was logged in, let them make more requests. | |||||
| if ($request->getUser() && $request->getUser()->getPHID()) { | |||||
| $score = $score / 5; | |||||
| } | |||||
| PhabricatorStartup::addRateLimitScore($user_ip, $score); | |||||
| } | |||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| PhabricatorStartup::didEncounterFatalException( | PhabricatorStartup::didEncounterFatalException( | ||||
| 'Core Exception', | 'Core Exception', | ||||
| $ex, | $ex, | ||||
| $show_unexpected_traces); | $show_unexpected_traces); | ||||
| } | } | ||||