Index: trunk/tools/upload-scripts/thumb-handler.php |
— | — | @@ -11,10 +11,10 @@ |
12 | 12 | } |
13 | 13 | |
14 | 14 | # Is this a thumbnail? |
15 | | -if ( preg_match('!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|)/\w/\w\w/([^/]*)/' . |
| 15 | +if ( preg_match('!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|/temp|)/\w/\w\w/([^/]*)/' . |
16 | 16 | '(page(\d*)-)*(\d*)px-([^/]*)$!', $uri, $matches ) ) |
17 | 17 | { |
18 | | - list( $all, $site, $lang, $arch, $filename, $pagefull, $pagenum, $size, $fn2 ) = $matches; |
| 18 | + list( $all, $site, $lang, $archOrTemp, $filename, $pagefull, $pagenum, $size, $fn2 ) = $matches; |
19 | 19 | $params = array( |
20 | 20 | 'f' => $filename, |
21 | 21 | 'width' => $size |
— | — | @@ -22,8 +22,10 @@ |
23 | 23 | if ( $pagenum ) { |
24 | 24 | $params['page'] = $pagenum; |
25 | 25 | } |
26 | | - if ( $arch ) { |
| 26 | + if ( $archOrTemp == '/archive' ) { |
27 | 27 | $params['archived'] = 1; |
| 28 | + } else if ( $archOrTemp == '/temp' ) { |
| 29 | + $params['temp'] = 1; |
28 | 30 | } |
29 | 31 | } elseif ( preg_match('!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|)/' . |
30 | 32 | '\w/\w\w/([^/]*\.(?:(?i)ogg|ogv|oga))/' . |
— | — | @@ -239,10 +241,10 @@ |
240 | 242 | curl_close( $ch ); |
241 | 243 | |
242 | 244 | function pathFromUrl( $url ) { |
243 | | - if( preg_match( '!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|)/(\w)/(\w\w)/([^/]*)/([^/]*)$!', |
| 245 | + if( preg_match( '!^(?:http://upload.wikimedia.org)?/+([\w-]*)/([\w-]*)/thumb(/archive|/temp|)/(\w)/(\w\w)/([^/]*)/([^/]*)$!', |
244 | 246 | $url, $matches ) ) { |
245 | 247 | $parts = array_map( 'rawurldecode', $matches ); |
246 | | - list( $all, $site, $lang, $arch, $hash1, $hash2, $filename, $fn2 ) = $parts; |
| 248 | + list( $all, $site, $lang, $archOrTemp, $hash1, $hash2, $filename, $fn2 ) = $parts; |
247 | 249 | |
248 | 250 | $md5 = md5( $filename ); |
249 | 251 | if( $hash1 != substr( $md5, 0, 1 ) ) return false; |
— | — | @@ -258,7 +260,7 @@ |
259 | 261 | } |
260 | 262 | |
261 | 263 | if( $good ) { |
262 | | - $thumbPath = array( '', 'export', 'upload', $site, $lang, 'thumb', $arch, $hash1, $hash2, $filename, $fn2 ); |
| 264 | + $thumbPath = array( '', 'export', 'upload', $site, $lang, 'thumb', $archOrTemp, $hash1, $hash2, $filename, $fn2 ); |
263 | 265 | if ( !checkPathComponents( $thumbPath ) ) return false; |
264 | 266 | return implode( '/', $thumbPath ); |
265 | 267 | } |