- global $wgUploadDirectory, $wgHashedUploadDirectory;
- if( $wgHashedUploadDirectory ) {
- for( $i = 0; $i < 16; $i++ ) {
- for( $j = 0; $j < 16; $j++ ) {
- $dir = sprintf( '%s%s%01x%s%02x',
- $wgUploadDirectory,
- DIRECTORY_SEPARATOR,
- $i,
- DIRECTORY_SEPARATOR,
- $i * 16 + $j );
- $this->crawlDirectory( $dir );
- }
- }
- } else {
- $this->crawlDirectory( $wgUploadDirectory );
- }
- }
-
- function crawlDirectory( $dir ) {
- if( !file_exists( $dir ) ) {
- return $this->log( "no directory, skipping $dir" );
- }
- if( !is_dir( $dir ) ) {
- return $this->log( "not a directory?! skipping $dir" );
- }
- if( !is_readable( $dir ) ) {
- return $this->log( "dir not readable, skipping $dir" );
- }
- $source = opendir( $dir );
- if( $source === false ) {
- return $this->log( "couldn't open dir, skipping $dir" );
- }
-
- $this->log( "crawling $dir" );
- while( false !== ( $filename = readdir( $source ) ) ) {
- $fullpath = $dir . DIRECTORY_SEPARATOR . $filename;
- if( is_dir( $fullpath ) ) {
- continue;
- }
- if( is_link( $fullpath ) ) {
- $this->log( "skipping symlink at $fullpath" );
- continue;
- }
- $this->checkMissingImage( $filename, $fullpath );
- }
- closedir( $source );