Exemplo n.º 1
0
 protected function getRequestUri()
 {
     // separate path and query-string
     $requestUri = explode('?', rawurldecode(Curry_URL::getRequestUri()), 2);
     // remove matching base path
     $baseUrl = Curry_URL::getDefaultBaseUrl();
     $basePath = $baseUrl['path'];
     if ($basePath === $requestUri[0]) {
         $requestUri[0] = '/';
     } else {
         if (Curry_String::startsWith($requestUri[0], $basePath)) {
             $requestUri[0] = substr($requestUri[0], strlen($basePath));
         }
     }
     return join('?', $requestUri);
 }
Exemplo n.º 2
0
 /**
  * Send error notification email.
  *
  * @param Exception $e
  */
 public static function sendErrorNotification(Exception $e)
 {
     try {
         // Create form to recreate error
         $method = strtoupper($_SERVER['REQUEST_METHOD']);
         $hidden = Curry_Html::createHiddenFields($method == 'POST' ? $_POST : $_GET);
         $action = url(Curry_URL::getRequestUri())->getAbsolute();
         $form = '<form action="' . $action . '" method="' . $method . '">' . $hidden . '<button type="submit">Execute</button></form>';
         // Create mail
         $mail = new Curry_Mail();
         $mail->addTo(Curry_Core::$config->curry->adminEmail);
         $mail->setSubject('Error on ' . Curry_Core::$config->curry->name);
         $mail->setBodyHtml('<html><body>' . '<h1>' . get_class($e) . '</h1>' . '<h2>' . htmlspecialchars($e->getMessage()) . '</h2>' . '<p><strong>Method:</strong> ' . $method . '<br/>' . '<strong>URL:</strong> ' . $action . '<br/>' . '<strong>File:</strong> ' . htmlspecialchars($e->getFile()) . '(' . $e->getLine() . ')</p>' . '<h2>Recreate</h2>' . $form . '<h2>Trace</h2>' . '<pre>' . htmlspecialchars($e->getTraceAsString()) . '</pre>' . '<h2>Variables</h2>' . '<h3>$_GET</h3>' . '<pre>' . htmlspecialchars(print_r($_GET, true)) . '</pre>' . '<h3>$_POST</h3>' . '<pre>' . htmlspecialchars(print_r($_POST, true)) . '</pre>' . '<h3>$_SERVER</h3>' . '<pre>' . htmlspecialchars(print_r($_SERVER, true)) . '</pre>' . '</body></html>');
         $mail->send();
         trace_notice('Sent error notification');
     } catch (Exception $e) {
         trace_warning('Failed to send error notification');
     }
 }