if( !is_dir( $directory ) ) {
return false;
}
- $n = mt_rand( 0, $this->countFiles( $directory ) );
+ $n = mt_rand( 0, $this->countFiles( $directory ) - 1 );
$dir = opendir( $directory );
$count = 0;
$dir = opendir( $dirname );
$count = 0;
while( false !== ($entry = readdir( $dir ) ) ) {
- if( $dir != '.' && $dir != '..' ) {
+ if( $entry != '.' && $entry != '..' ) {
$count++;
}
}
$file = $this->imagePath( $salt, $hash );
if( file_exists( $file ) ) {
- header( 'Content-type: image/png' );
- readfile( $file );
+ global $IP;
+ require_once "$IP/includes/StreamFile.php";
+ wfStreamFile( $file );
return true;
}
}
} # End invocation guard
-?>
+