r100179 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100178‎ | r100179 | r100180 >
Date:22:31, 18 October 2011
Author:aaron
Status:ok
Tags:
Comment:
Removed unused code
Modified paths:
  • /trunk/tools/upload-scripts/thumb-handler.php (modified) (history)

Diff [purge]

Index: trunk/tools/upload-scripts/thumb-handler.php
@@ -107,8 +107,6 @@
108108 break;
109109 default:
110110 $host = "$lang.wikipedia.org";
111 -
112 -
113111 }
114112 } else {
115113 $sitelang = str_replace( '-', '.', $lang );
@@ -208,29 +206,7 @@
209207 # Error message, suppress cache
210208 header( 'HTTP/1.1 500 Internal server error' );
211209 header( 'Cache-Control: no-cache' );
212 -}
213 -/* we don't use caching servers any more
214 -else {
215 - # Cache the file locally if this is a cache server
216 - $uname = posix_uname();
217 - $server = $uname['nodename'];
218 - if ( !in_array($server, array('amane.pmtpa.wmnet', 'storage1', 'ms1', 'ms2')) ) {
219 - $dest = pathFromUrl( $uri );
220 - if( $dest ) {
221 - if ( strpos( $dest, '..' ) === false ) {
222 - # Make directory and parents
223 - for ( $i = 0, $path = dirname( $dest ); !file_exists( $path ) && $i < 6; $path = dirname( $path ), $i++ ) {
224 - @mkdir( $path );
225 - }
226 - @file_put_contents( $dest, $text );
227 - }
228 - } else {
229 -
230 - header( "X-Debug: got invalid input path" );
231 - }
232 - }
233210 }
234 -*/
235211
236212 if ( !$contentType ) {
237213 header( 'Content-Type:' );
@@ -239,42 +215,3 @@
240216 }
241217 print $text;
242218 curl_close( $ch );
243 -
244 -function pathFromUrl( $url ) {
245 - if( preg_match( '!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|/temp|)/(\w)/(\w\w)/([^/]*)/([^/]*)$!',
246 - $url, $matches ) ) {
247 - $parts = array_map( 'rawurldecode', $matches );
248 - list( $all, $site, $lang, $archOrTemp, $hash1, $hash2, $filename, $fn2 ) = $parts;
249 -
250 - $md5 = md5( $filename );
251 - if( $hash1 != substr( $md5, 0, 1 ) ) return false;
252 - if( $hash2 != substr( $md5, 0, 2 ) ) return false;
253 -
254 - $testNames = array( $filename, "$filename.png", "$filename.jpg" );
255 - $good = false;
256 - foreach ( $testNames as $testName ) {
257 - if ( substr( $fn2, -strlen( $testName ) ) == $testName ) {
258 - $good = true;
259 - break;
260 - }
261 - }
262 -
263 - if( $good ) {
264 - $thumbPath = array( '', 'export', 'upload', $site, $lang, 'thumb', $archOrTemp, $hash1, $hash2, $filename, $fn2 );
265 - if ( !checkPathComponents( $thumbPath ) ) return false;
266 - return implode( '/', $thumbPath );
267 - }
268 - }
269 - return false;
270 -}
271 -
272 -function checkPathComponents( $components ) {
273 - foreach( $components as $component ) {
274 - if( strpos( $component, '/' ) !== false ) return false;
275 - if( $component == '.' ) return false;
276 - if( $component == '..' ) return false;
277 - }
278 - return true;
279 -}
280 -
281 -?>

Status & tagging log