Esempio n. 1
0
 /**
  * @phutil-external-symbol class PhabricatorStartup
  */
 public function getCSRFToken()
 {
     $salt = PhabricatorStartup::getGlobal('csrf.salt');
     if (!$salt) {
         $salt = Filesystem::readRandomCharacters(self::CSRF_SALT_LENGTH);
         PhabricatorStartup::setGlobal('csrf.salt', $salt);
     }
     // Generate a token hash to mitigate BREACH attacks against SSL. See
     // discussion in T3684.
     $token = $this->getRawCSRFToken();
     $hash = PhabricatorHash::digest($token, $salt);
     return 'B@' . $salt . substr($hash, 0, self::CSRF_TOKEN_LENGTH);
 }
Esempio n. 2
0
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();
$show_unexpected_traces = false;
try {
    PhabricatorStartup::loadCoreLibraries();
    PhabricatorEnv::initializeWebEnvironment();
    $show_unexpected_traces = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
    // This is the earliest we can get away with this, we need env config first.
    PhabricatorAccessLog::init();
    $access_log = PhabricatorAccessLog::getLog();
    PhabricatorStartup::setGlobal('log.access', $access_log);
    $access_log->setData(array('R' => AphrontRequest::getHTTPHeader('Referer', '-'), 'r' => idx($_SERVER, 'REMOTE_ADDR', '-'), 'M' => idx($_SERVER, 'REQUEST_METHOD', '-')));
    DarkConsoleXHProfPluginAPI::hookProfiler();
    DarkConsoleErrorLogPluginAPI::registerErrorHandler();
    $sink = new AphrontPHPHTTPSink();
    $response = PhabricatorSetupCheck::willProcessRequest();
    if ($response) {
        PhabricatorStartup::endOutputCapture();
        $sink->writeResponse($response);
        return;
    }
    $host = AphrontRequest::getHTTPHeader('Host');
    $path = $_REQUEST['__path__'];
    switch ($host) {
        default:
            $config_key = 'aphront.default-application-configuration-class';