getNsText( NS_IMAGE ) . ":" . wfBaseName( $_SERVER['PATH_INFO'] ); # Check if the filename is in the correct directory if ( substr( $filename, 0, strlen( $realUploadDirectory ) ) != $realUploadDirectory ) { wfDebugLog( 'img_auth', "requested path not in upload dir: $filename" ); wfForbidden(); } if ( is_array( $wgWhitelistRead ) && !in_array( $imageName, $wgWhitelistRead ) && !$wgUser->getID() ) { wfDebugLog( 'img_auth', "not logged in and requested file not in whitelist: $imageName" ); wfForbidden(); } if( !file_exists( $filename ) ) { wfDebugLog( 'img_auth', "requested file does not exist: $filename" ); wfForbidden(); } if( is_dir( $filename ) ) { wfDebugLog( 'img_auth', "requested file is a directory: $filename" ); wfForbidden(); } # Write file wfDebugLog( 'img_auth', "streaming file: $filename" ); wfStreamFile( $filename ); wfLogProfilingData(); function wfForbidden() { header( 'HTTP/1.0 403 Forbidden' ); header( 'Content-Type: text/html; charset=utf-8' ); print "
You need to log in to access files on this server
"; wfLogProfilingData(); exit; } ?>