* @file
*/
+use MediaWiki\MediaWikiServices;
use MediaWiki\Session\Session;
use MediaWiki\Session\SessionId;
use MediaWiki\Session\SessionManager;
*/
public static function getPathInfo( $want = 'all' ) {
global $wgUsePathInfo;
- // PATH_INFO is mangled due to http://bugs.php.net/bug.php?id=31892
+ // PATH_INFO is mangled due to https://bugs.php.net/bug.php?id=31892
// And also by Apache 2.x, double slashes are converted to single slashes.
// So we will use REQUEST_URI if possible.
$matches = [];
} elseif ( $wgUsePathInfo ) {
if ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) {
// Mangled PATH_INFO
- // http://bugs.php.net/bug.php?id=31892
+ // https://bugs.php.net/bug.php?id=31892
// Also reported when ini_get('cgi.fix_pathinfo')==false
$matches['title'] = substr( $_SERVER['ORIG_PATH_INFO'], 1 );
* This is for use prior to Setup.php, when no WebRequest object is available.
* At other times, use the non-static function getProtocol().
*
- * @return array
+ * @return string
*/
public static function detectProtocol() {
if ( ( !empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] !== 'off' ) ||
*/
private function getGPCVal( $arr, $name, $default ) {
# PHP is so nice to not touch input data, except sometimes:
- # http://us2.php.net/variables.external#language.variables.external.dot-in-names
+ # https://secure.php.net/variables.external#language.variables.external.dot-in-names
# Work around PHP *feature* to avoid *bugs* elsewhere.
$name = strtr( $name, '.', '_' );
if ( isset( $arr[$name] ) ) {
return $this->sessionId;
}
- /**
- * Returns true if the request has a persistent session.
- * This does not necessarily mean that the user is logged in!
- *
- * @deprecated since 1.27, use
- * \MediaWiki\Session\SessionManager::singleton()->getPersistedSessionId()
- * instead.
- * @return bool
- */
- public function checkSessionCookie() {
- global $wgInitialSessionId;
- wfDeprecated( __METHOD__, '1.27' );
- return $wgInitialSessionId !== null &&
- $this->getSession()->getId() === (string)$wgInitialSessionId;
- }
-
/**
* Get a cookie from the $_COOKIE jar
*
header( 'Content-Type: text/html' );
$encUrl = htmlspecialchars( $url );
echo <<<HTML
+<!DOCTYPE html>
<html>
<head>
<title>Security redirect</title>
# Append XFF
$forwardedFor = $this->getHeader( 'X-Forwarded-For' );
if ( $forwardedFor !== false ) {
- $isConfigured = IP::isConfiguredProxy( $ip );
+ $proxyLookup = MediaWikiServices::getInstance()->getProxyLookup();
+ $isConfigured = $proxyLookup->isConfiguredProxy( $ip );
$ipchain = array_map( 'trim', explode( ',', $forwardedFor ) );
$ipchain = array_reverse( $ipchain );
array_unshift( $ipchain, $ip );
foreach ( $ipchain as $i => $curIP ) {
$curIP = IP::sanitizeIP( IP::canonicalize( $curIP ) );
if ( !$curIP || !isset( $ipchain[$i + 1] ) || $ipchain[$i + 1] === 'unknown'
- || !IP::isTrustedProxy( $curIP )
+ || !$proxyLookup->isTrustedProxy( $curIP )
) {
break; // IP is not valid/trusted or does not point to anything
}
if (
IP::isPublic( $ipchain[$i + 1] ) ||
$wgUsePrivateIPs ||
- IP::isConfiguredProxy( $curIP ) // bug 48919; treat IP as sane
+ $proxyLookup->isConfiguredProxy( $curIP ) // bug 48919; treat IP as sane
) {
// Follow the next IP according to the proxy
$nextIP = IP::canonicalize( $ipchain[$i + 1] );