SimpleSAML\Utils\HTTP::getSelfURLNoQuery PHP Method

getSelfURLNoQuery() public static method

Retrieve the current URL using the base URL in the configuration, without the query parameters.
Author: Andreas Solberg, UNINETT AS ([email protected])
Author: Jaime Perez, UNINETT AS ([email protected])
public static getSelfURLNoQuery ( ) : string
return string The current URL, not including query parameters.
    public static function getSelfURLNoQuery()
    {
        $url = self::getSelfURL();
        $pos = strpos($url, '?');
        if (!$pos) {
            return $url;
        }
        return substr($url, 0, $pos);
    }

Usage Example

Example #1
0
 /**
  * Save an error report.
  *
  * @return array  The array with the error report data.
  */
 protected function saveError()
 {
     $data = $this->format();
     $emsg = array_shift($data);
     $etrace = implode("\n", $data);
     $reportId = bin2hex(openssl_random_pseudo_bytes(4));
     SimpleSAML_Logger::error('Error report with id ' . $reportId . ' generated.');
     $config = SimpleSAML_Configuration::getInstance();
     $session = SimpleSAML_Session::getSessionFromRequest();
     if (isset($_SERVER['HTTP_REFERER'])) {
         $referer = $_SERVER['HTTP_REFERER'];
         // remove anything after the first '?' or ';', just in case it contains any sensitive data
         $referer = explode('?', $referer, 2);
         $referer = $referer[0];
         $referer = explode(';', $referer, 2);
         $referer = $referer[0];
     } else {
         $referer = 'unknown';
     }
     $errorData = array('exceptionMsg' => $emsg, 'exceptionTrace' => $etrace, 'reportId' => $reportId, 'trackId' => $session->getTrackID(), 'url' => \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(), 'version' => $config->getVersion(), 'referer' => $referer);
     $session->setData('core:errorreport', $reportId, $errorData);
     return $errorData;
 }
All Usage Examples Of SimpleSAML\Utils\HTTP::getSelfURLNoQuery