\r
/**\r
* Returns the image directory of an image\r
- * If the directory does not exist, it is created.\r
* The result is an absolute path.\r
*\r
* This function is called from thumb.php before Setup.php is included\r
if (!$wgHashedUploadDirectory) { return $wgUploadDirectory; }\r
\r
$hash = md5( $fname );\r
- $oldumask = umask(0);\r
- $dest = $wgUploadDirectory . '/' . $hash{0};\r
- if ( ! is_dir( $dest ) ) { mkdir( $dest, 0777 ); }\r
- $dest .= '/' . substr( $hash, 0, 2 );\r
- if ( ! is_dir( $dest ) ) { mkdir( $dest, 0777 ); }\r
+ $dest = $wgUploadDirectory . '/' . $hash{0} . '/' . substr( $hash, 0, 2 );\r
\r
- umask( $oldumask );\r
return $dest;\r
}\r
\r
/**\r
* Returns the image directory of an image's thubnail\r
- * If the directory does not exist, it is created.\r
* The result is an absolute path.\r
*\r
* This function is called from thumb.php before Setup.php is included\r
$base = wfImageArchiveDir( $fname, 'thumb', $shared );\r
if ( Image::isHashed( $shared ) ) {\r
$dir = "$base/$fname";\r
-\r
- if ( !is_dir( $base ) ) {\r
- $oldumask = umask(0);\r
- @mkdir( $base, 0777 );\r
- umask( $oldumask );\r
- }\r
-\r
- if ( ! is_dir( $dir ) ) {\r
- if ( is_file( $dir ) ) {\r
- // Old thumbnail in the way of directory creation, kill it\r
- unlink( $dir );\r
- }\r
- $oldumask = umask(0);\r
- @mkdir( $dir, 0777 );\r
- umask( $oldumask );\r
- }\r
} else {\r
$dir = $base;\r
}\r
\r
/**\r
* Returns the image directory of an image's old version\r
- * If the directory does not exist, it is created.\r
* The result is an absolute path.\r
*\r
* This function is called from thumb.php before Setup.php is included\r
$hashdir = $shared ? $wgHashedSharedUploadDirectory : $wgHashedUploadDirectory;\r
if (!$hashdir) { return $dir.'/'.$subdir; }\r
$hash = md5( $fname );\r
- $oldumask = umask(0);\r
-\r
- # Suppress warning messages here; if the file itself can't\r
- # be written we'll worry about it then.\r
- wfSuppressWarnings();\r
-\r
- $archive = $dir.'/'.$subdir;\r
- if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); }\r
- $archive .= '/' . $hash{0};\r
- if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); }\r
- $archive .= '/' . substr( $hash, 0, 2 );\r
- if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); }\r
-\r
- wfRestoreWarnings();\r
- umask( $oldumask );\r
- return $archive;\r
+\r
+ return $dir.'/'.$subdir.'/'.$hash[0].'/'.substr( $hash, 0, 2 );\r
}\r
\r
\r
*/\r
function wfIsBadImage( $name ) {\r
static $titleList = false;\r
- \r
- if( !$titleList ) {\r
- # Build the list now\r
- $titleList = array();\r
- $lines = explode( "\n", wfMsgForContent( 'bad_image_list' ) );\r
- foreach( $lines as $line ) {\r
- if( preg_match( '/^\*\s*\[\[:?(.*?)\]\]/i', $line, $matches ) ) {\r
- $title = Title::newFromText( $matches[1] );\r
- if( is_object( $title ) && $title->getNamespace() == NS_IMAGE )\r
- $titleList[ $title->getDBkey() ] = true;\r
+ wfProfileIn( __METHOD__ );\r
+ $bad = false;\r
+ if( wfRunHooks( 'BadImage', array( $name, &$bad ) ) ) {\r
+ if( !$titleList ) {\r
+ # Build the list now\r
+ $titleList = array();\r
+ $lines = explode( "\n", wfMsgForContent( 'bad_image_list' ) );\r
+ foreach( $lines as $line ) {\r
+ if( preg_match( '/^\*\s*\[\[:?(.*?)\]\]/i', $line, $matches ) ) {\r
+ $title = Title::newFromText( $matches[1] );\r
+ if( is_object( $title ) && $title->getNamespace() == NS_IMAGE )\r
+ $titleList[ $title->getDBkey() ] = true;\r
+ }\r
}\r
}\r
+ wfProfileOut( __METHOD__ );\r
+ return array_key_exists( $name, $titleList );\r
+ } else {\r
+ wfProfileOut( __METHOD__ );\r
+ return $bad;\r
}\r
- return array_key_exists( $name, $titleList );\r
}\r
\r
/**\r