+ // Various extensions may have their own backends that need access.
+ // Check if there is a special backend and storage base path for this file.
+ foreach ( $wgImgAuthUrlPathMap as $prefix => $storageDir ) {
+ $prefix = rtrim( $prefix, '/' ) . '/'; // implicit trailing slash
+ if ( strpos( $path, $prefix ) === 0 ) {
+ $be = FileBackendGroup::singleton()->backendFromPath( $storageDir );
+ $filename = $storageDir . substr( $path, strlen( $prefix ) ); // strip prefix
+ if ( $be->fileExists( array( 'src' => $filename ) ) ) {
+ wfDebugLog( 'img_auth', "Streaming `" . $filename . "`." );
+ $be->streamFile( array( 'src' => $filename ),
+ array( 'Cache-Control: private', 'Vary: Cookie' ) );
+ } else {
+ wfForbidden( 'img-auth-accessdenied', 'img-auth-nofile', $filename );
+ }
+ return;
+ }
+ }
+