Typo in comment of Html::radio()
[lhc/web/wiklou.git] / thumb.php
1 <?php
2 /**
3 * PHP script to stream out an image thumbnail.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Media
22 */
23
24 define( 'MW_NO_OUTPUT_COMPRESSION', 1 );
25 require __DIR__ . '/includes/WebStart.php';
26
27 // Don't use fancy MIME detection, just check the file extension for jpg/gif/png
28 $wgTrivialMimeDetection = true;
29
30 if ( defined( 'THUMB_HANDLER' ) ) {
31 // Called from thumb_handler.php via 404; extract params from the URI...
32 wfThumbHandle404();
33 } else {
34 // Called directly, use $_GET params
35 wfStreamThumb( $_GET );
36 }
37
38 $mediawiki = new MediaWiki();
39 $mediawiki->doPostOutputShutdown( 'fast' );
40
41 // --------------------------------------------------------------------------
42
43 /**
44 * Handle a thumbnail request via thumbnail file URL
45 *
46 * @return void
47 */
48 function wfThumbHandle404() {
49 global $wgArticlePath;
50
51 # Set action base paths so that WebRequest::getPathInfo()
52 # recognizes the "X" as the 'title' in ../thumb_handler.php/X urls.
53 # Note: If Custom per-extension repo paths are set, this may break.
54 $repo = RepoGroup::singleton()->getLocalRepo();
55 $oldArticlePath = $wgArticlePath;
56 $wgArticlePath = $repo->getZoneUrl( 'thumb' ) . '/$1';
57
58 $matches = WebRequest::getPathInfo();
59
60 $wgArticlePath = $oldArticlePath;
61
62 if ( !isset( $matches['title'] ) ) {
63 wfThumbError( 404, 'Could not determine the name of the requested thumbnail.' );
64 return;
65 }
66
67 $params = wfExtractThumbRequestInfo( $matches['title'] ); // basic wiki URL param extracting
68 if ( $params == null ) {
69 wfThumbError( 400, 'The specified thumbnail parameters are not recognized.' );
70 return;
71 }
72
73 wfStreamThumb( $params ); // stream the thumbnail
74 }
75
76 /**
77 * Stream a thumbnail specified by parameters
78 *
79 * @param array $params List of thumbnailing parameters. In addition to parameters
80 * passed to the MediaHandler, this may also includes the keys:
81 * f (for filename), archived (if archived file), temp (if temp file),
82 * w (alias for width), p (alias for page), r (ignored; historical),
83 * rel404 (path for render on 404 to verify hash path correct),
84 * thumbName (thumbnail name to potentially extract more parameters from
85 * e.g. 'lossy-page1-120px-Foo.tiff' would add page, lossy and width
86 * to the parameters)
87 * @return void
88 */
89 function wfStreamThumb( array $params ) {
90 global $wgVaryOnXFP;
91
92 $headers = array(); // HTTP headers to send
93
94 $fileName = isset( $params['f'] ) ? $params['f'] : '';
95
96 // Backwards compatibility parameters
97 if ( isset( $params['w'] ) ) {
98 $params['width'] = $params['w'];
99 unset( $params['w'] );
100 }
101 if ( isset( $params['width'] ) && substr( $params['width'], -2 ) == 'px' ) {
102 // strip the px (pixel) suffix, if found
103 $params['width'] = substr( $params['width'], 0, -2 );
104 }
105 if ( isset( $params['p'] ) ) {
106 $params['page'] = $params['p'];
107 }
108
109 // Is this a thumb of an archived file?
110 $isOld = ( isset( $params['archived'] ) && $params['archived'] );
111 unset( $params['archived'] ); // handlers don't care
112
113 // Is this a thumb of a temp file?
114 $isTemp = ( isset( $params['temp'] ) && $params['temp'] );
115 unset( $params['temp'] ); // handlers don't care
116
117 // Some basic input validation
118 $fileName = strtr( $fileName, '\\/', '__' );
119
120 // Actually fetch the image. Method depends on whether it is archived or not.
121 if ( $isTemp ) {
122 $repo = RepoGroup::singleton()->getLocalRepo()->getTempRepo();
123 $img = new UnregisteredLocalFile( null, $repo,
124 # Temp files are hashed based on the name without the timestamp.
125 # The thumbnails will be hashed based on the entire name however.
126 # @todo fix this convention to actually be reasonable.
127 $repo->getZonePath( 'public' ) . '/' . $repo->getTempHashPath( $fileName ) . $fileName
128 );
129 } elseif ( $isOld ) {
130 // Format is <timestamp>!<name>
131 $bits = explode( '!', $fileName, 2 );
132 if ( count( $bits ) != 2 ) {
133 wfThumbError( 404, wfMessage( 'badtitletext' )->parse() );
134 return;
135 }
136 $title = Title::makeTitleSafe( NS_FILE, $bits[1] );
137 if ( !$title ) {
138 wfThumbError( 404, wfMessage( 'badtitletext' )->parse() );
139 return;
140 }
141 $img = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $title, $fileName );
142 } else {
143 $img = wfLocalFile( $fileName );
144 }
145
146 // Check the source file title
147 if ( !$img ) {
148 wfThumbError( 404, wfMessage( 'badtitletext' )->parse() );
149 return;
150 }
151
152 // Check permissions if there are read restrictions
153 $varyHeader = array();
154 if ( !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) ) {
155 if ( !$img->getTitle() || !$img->getTitle()->userCan( 'read' ) ) {
156 wfThumbError( 403, 'Access denied. You do not have permission to access ' .
157 'the source file.' );
158 return;
159 }
160 $headers[] = 'Cache-Control: private';
161 $varyHeader[] = 'Cookie';
162 }
163
164 // Check if the file is hidden
165 if ( $img->isDeleted( File::DELETED_FILE ) ) {
166 wfThumbErrorText( 404, "The source file '$fileName' does not exist." );
167 return;
168 }
169
170 // Do rendering parameters extraction from thumbnail name.
171 if ( isset( $params['thumbName'] ) ) {
172 $params = wfExtractThumbParams( $img, $params );
173 }
174 if ( $params == null ) {
175 wfThumbError( 400, 'The specified thumbnail parameters are not recognized.' );
176 return;
177 }
178
179 // Check the source file storage path
180 if ( !$img->exists() ) {
181 $redirectedLocation = false;
182 if ( !$isTemp ) {
183 // Check for file redirect
184 // Since redirects are associated with pages, not versions of files,
185 // we look for the most current version to see if its a redirect.
186 $possRedirFile = RepoGroup::singleton()->getLocalRepo()->findFile( $img->getName() );
187 if ( $possRedirFile && !is_null( $possRedirFile->getRedirected() ) ) {
188 $redirTarget = $possRedirFile->getName();
189 $targetFile = wfLocalFile( Title::makeTitleSafe( NS_FILE, $redirTarget ) );
190 if ( $targetFile->exists() ) {
191 $newThumbName = $targetFile->thumbName( $params );
192 if ( $isOld ) {
193 /** @var array $bits */
194 $newThumbUrl = $targetFile->getArchiveThumbUrl(
195 $bits[0] . '!' . $targetFile->getName(), $newThumbName );
196 } else {
197 $newThumbUrl = $targetFile->getThumbUrl( $newThumbName );
198 }
199 $redirectedLocation = wfExpandUrl( $newThumbUrl, PROTO_CURRENT );
200 }
201 }
202 }
203
204 if ( $redirectedLocation ) {
205 // File has been moved. Give redirect.
206 $response = RequestContext::getMain()->getRequest()->response();
207 $response->statusHeader( 302 );
208 $response->header( 'Location: ' . $redirectedLocation );
209 $response->header( 'Expires: ' .
210 gmdate( 'D, d M Y H:i:s', time() + 12 * 3600 ) . ' GMT' );
211 if ( $wgVaryOnXFP ) {
212 $varyHeader[] = 'X-Forwarded-Proto';
213 }
214 if ( count( $varyHeader ) ) {
215 $response->header( 'Vary: ' . implode( ', ', $varyHeader ) );
216 }
217 $response->header( 'Content-Length: 0' );
218 return;
219 }
220
221 // If its not a redirect that has a target as a local file, give 404.
222 wfThumbErrorText( 404, "The source file '$fileName' does not exist." );
223 return;
224 } elseif ( $img->getPath() === false ) {
225 wfThumbErrorText( 400, "The source file '$fileName' is not locally accessible." );
226 return;
227 }
228
229 // Check IMS against the source file
230 // This means that clients can keep a cached copy even after it has been deleted on the server
231 if ( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
232 // Fix IE brokenness
233 $imsString = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
234 // Calculate time
235 MediaWiki\suppressWarnings();
236 $imsUnix = strtotime( $imsString );
237 MediaWiki\restoreWarnings();
238 if ( wfTimestamp( TS_UNIX, $img->getTimestamp() ) <= $imsUnix ) {
239 HttpStatus::header( 304 );
240 return;
241 }
242 }
243
244 $rel404 = isset( $params['rel404'] ) ? $params['rel404'] : null;
245 unset( $params['r'] ); // ignore 'r' because we unconditionally pass File::RENDER
246 unset( $params['f'] ); // We're done with 'f' parameter.
247 unset( $params['rel404'] ); // moved to $rel404
248
249 // Get the normalized thumbnail name from the parameters...
250 try {
251 $thumbName = $img->thumbName( $params );
252 if ( !strlen( $thumbName ) ) { // invalid params?
253 throw new MediaTransformInvalidParametersException(
254 'Empty return from File::thumbName'
255 );
256 }
257 $thumbName2 = $img->thumbName( $params, File::THUMB_FULL_NAME ); // b/c; "long" style
258 } catch ( MediaTransformInvalidParametersException $e ) {
259 wfThumbError(
260 400,
261 'The specified thumbnail parameters are not valid: ' . $e->getMessage()
262 );
263 return;
264 } catch ( MWException $e ) {
265 wfThumbError( 500, $e->getHTML() );
266 return;
267 }
268
269 // For 404 handled thumbnails, we only use the base name of the URI
270 // for the thumb params and the parent directory for the source file name.
271 // Check that the zone relative path matches up so squid caches won't pick
272 // up thumbs that would not be purged on source file deletion (bug 34231).
273 if ( $rel404 !== null ) { // thumbnail was handled via 404
274 if ( rawurldecode( $rel404 ) === $img->getThumbRel( $thumbName ) ) {
275 // Request for the canonical thumbnail name
276 } elseif ( rawurldecode( $rel404 ) === $img->getThumbRel( $thumbName2 ) ) {
277 // Request for the "long" thumbnail name; redirect to canonical name
278 $response = RequestContext::getMain()->getRequest()->response();
279 $response->statusHeader( 301 );
280 $response->header( 'Location: ' .
281 wfExpandUrl( $img->getThumbUrl( $thumbName ), PROTO_CURRENT ) );
282 $response->header( 'Expires: ' .
283 gmdate( 'D, d M Y H:i:s', time() + 7 * 86400 ) . ' GMT' );
284 if ( $wgVaryOnXFP ) {
285 $varyHeader[] = 'X-Forwarded-Proto';
286 }
287 if ( count( $varyHeader ) ) {
288 $response->header( 'Vary: ' . implode( ', ', $varyHeader ) );
289 }
290 return;
291 } else {
292 wfThumbErrorText( 404, "The given path of the specified thumbnail is incorrect;
293 expected '" . $img->getThumbRel( $thumbName ) . "' but got '" .
294 rawurldecode( $rel404 ) . "'." );
295 return;
296 }
297 }
298
299 $dispositionType = isset( $params['download'] ) ? 'attachment' : 'inline';
300
301 // Suggest a good name for users downloading this thumbnail
302 $headers[] =
303 "Content-Disposition: {$img->getThumbDisposition( $thumbName, $dispositionType )}";
304
305 if ( count( $varyHeader ) ) {
306 $headers[] = 'Vary: ' . implode( ', ', $varyHeader );
307 }
308
309 // Stream the file if it exists already...
310 $thumbPath = $img->getThumbPath( $thumbName );
311 if ( $img->getRepo()->fileExists( $thumbPath ) ) {
312 $starttime = microtime( true );
313 $success = $img->getRepo()->streamFile( $thumbPath, $headers );
314 $streamtime = microtime( true ) - $starttime;
315
316 if ( !$success ) {
317 wfThumbError( 500, 'Could not stream the file' );
318 } else {
319 RequestContext::getMain()->getStats()->timing( 'media.thumbnail.stream', $streamtime );
320 }
321 return;
322 }
323
324 $user = RequestContext::getMain()->getUser();
325 if ( !wfThumbIsStandard( $img, $params ) && $user->pingLimiter( 'renderfile-nonstandard' ) ) {
326 wfThumbError( 429, wfMessage( 'actionthrottledtext' )->parse() );
327 return;
328 } elseif ( $user->pingLimiter( 'renderfile' ) ) {
329 wfThumbError( 429, wfMessage( 'actionthrottledtext' )->parse() );
330 return;
331 }
332
333 list( $thumb, $errorMsg ) = wfGenerateThumbnail( $img, $params, $thumbName, $thumbPath );
334
335 /** @var MediaTransformOutput|MediaTransformError|bool $thumb */
336
337 // Check for thumbnail generation errors...
338 $msg = wfMessage( 'thumbnail_error' );
339 $errorCode = 500;
340 if ( !$thumb ) {
341 $errorMsg = $errorMsg ?: $msg->rawParams( 'File::transform() returned false' )->escaped();
342 if ( $errorMsg instanceof MessageSpecifier &&
343 $errorMsg->getKey() === 'thumbnail_image-failure-limit'
344 ) {
345 $errorCode = 429;
346 }
347 } elseif ( $thumb->isError() ) {
348 $errorMsg = $thumb->getHtmlMsg();
349 } elseif ( !$thumb->hasFile() ) {
350 $errorMsg = $msg->rawParams( 'No path supplied in thumbnail object' )->escaped();
351 } elseif ( $thumb->fileIsSource() ) {
352 $errorMsg = $msg
353 ->rawParams( 'Image was not scaled, is the requested width bigger than the source?' )
354 ->escaped();
355 $errorCode = 400;
356 }
357
358 if ( $errorMsg !== false ) {
359 wfThumbError( $errorCode, $errorMsg );
360 } else {
361 // Stream the file if there were no errors
362 $success = $thumb->streamFile( $headers );
363 if ( !$success ) {
364 wfThumbError( 500, 'Could not stream the file' );
365 }
366 }
367 }
368
369 /**
370 * Actually try to generate a new thumbnail
371 *
372 * @param File $file
373 * @param array $params
374 * @param string $thumbName
375 * @param string $thumbPath
376 * @return array (MediaTransformOutput|bool, string|bool error message HTML)
377 */
378 function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath ) {
379 global $wgMemc, $wgAttemptFailureEpoch;
380
381 $key = wfMemcKey( 'attempt-failures', $wgAttemptFailureEpoch,
382 $file->getRepo()->getName(), $file->getSha1(), md5( $thumbName ) );
383
384 // Check if this file keeps failing to render
385 if ( $wgMemc->get( $key ) >= 4 ) {
386 return array( false, wfMessage( 'thumbnail_image-failure-limit', 4 ) );
387 }
388
389 $done = false;
390 // Record failures on PHP fatals in addition to caching exceptions
391 register_shutdown_function( function () use ( &$done, $key ) {
392 if ( !$done ) { // transform() gave a fatal
393 global $wgMemc;
394 // Randomize TTL to reduce stampedes
395 $wgMemc->incrWithInit( $key, 3600 + mt_rand( 0, 300 ) );
396 }
397 } );
398
399 $thumb = false;
400 $errorHtml = false;
401
402 // guard thumbnail rendering with PoolCounter to avoid stampedes
403 // expensive files use a separate PoolCounter config so it is possible
404 // to set up a global limit on them
405 if ( $file->isExpensiveToThumbnail() ) {
406 $poolCounterType = 'FileRenderExpensive';
407 } else {
408 $poolCounterType = 'FileRender';
409 }
410
411 // Thumbnail isn't already there, so create the new thumbnail...
412 try {
413 $work = new PoolCounterWorkViaCallback( $poolCounterType, sha1( $file->getName() ),
414 array(
415 'doWork' => function () use ( $file, $params ) {
416 return $file->transform( $params, File::RENDER_NOW );
417 },
418 'getCachedWork' => function () use ( $file, $params, $thumbPath ) {
419 // If the worker that finished made this thumbnail then use it.
420 // Otherwise, it probably made a different thumbnail for this file.
421 return $file->getRepo()->fileExists( $thumbPath )
422 ? $file->transform( $params, File::RENDER_NOW )
423 : false; // retry once more in exclusive mode
424 },
425 'fallback' => function () {
426 return wfMessage( 'generic-pool-error' )->parse();
427 },
428 'error' => function ( Status $status ) {
429 return $status->getHTML();
430 }
431 )
432 );
433 $result = $work->execute();
434 if ( $result instanceof MediaTransformOutput ) {
435 $thumb = $result;
436 } elseif ( is_string( $result ) ) { // error
437 $errorHtml = $result;
438 }
439 } catch ( Exception $e ) {
440 // Tried to select a page on a non-paged file?
441 }
442
443 /** @noinspection PhpUnusedLocalVariableInspection */
444 $done = true; // no PHP fatal occured
445
446 if ( !$thumb || $thumb->isError() ) {
447 // Randomize TTL to reduce stampedes
448 $wgMemc->incrWithInit( $key, 3600 + mt_rand( 0, 300 ) );
449 }
450
451 return array( $thumb, $errorHtml );
452 }
453
454 /**
455 * Convert pathinfo type parameter, into normal request parameters
456 *
457 * So for example, if the request was redirected from
458 * /w/images/thumb/a/ab/Foo.png/120px-Foo.png. The $thumbRel parameter
459 * of this function would be set to "a/ab/Foo.png/120px-Foo.png".
460 * This method is responsible for turning that into an array
461 * with the folowing keys:
462 * * f => the filename (Foo.png)
463 * * rel404 => the whole thing (a/ab/Foo.png/120px-Foo.png)
464 * * archived => 1 (If the request is for an archived thumb)
465 * * temp => 1 (If the file is in the "temporary" zone)
466 * * thumbName => the thumbnail name, including parameters (120px-Foo.png)
467 *
468 * Transform specific parameters are set later via wfExtractThumbParams().
469 *
470 * @param string $thumbRel Thumbnail path relative to the thumb zone
471 * @return array|null Associative params array or null
472 */
473 function wfExtractThumbRequestInfo( $thumbRel ) {
474 $repo = RepoGroup::singleton()->getLocalRepo();
475
476 $hashDirReg = $subdirReg = '';
477 $hashLevels = $repo->getHashLevels();
478 for ( $i = 0; $i < $hashLevels; $i++ ) {
479 $subdirReg .= '[0-9a-f]';
480 $hashDirReg .= "$subdirReg/";
481 }
482
483 // Check if this is a thumbnail of an original in the local file repo
484 if ( preg_match( "!^((archive/)?$hashDirReg([^/]*)/([^/]*))$!", $thumbRel, $m ) ) {
485 list( /*all*/, $rel, $archOrTemp, $filename, $thumbname ) = $m;
486 // Check if this is a thumbnail of an temp file in the local file repo
487 } elseif ( preg_match( "!^(temp/)($hashDirReg([^/]*)/([^/]*))$!", $thumbRel, $m ) ) {
488 list( /*all*/, $archOrTemp, $rel, $filename, $thumbname ) = $m;
489 } else {
490 return null; // not a valid looking thumbnail request
491 }
492
493 $params = array( 'f' => $filename, 'rel404' => $rel );
494 if ( $archOrTemp === 'archive/' ) {
495 $params['archived'] = 1;
496 } elseif ( $archOrTemp === 'temp/' ) {
497 $params['temp'] = 1;
498 }
499
500 $params['thumbName'] = $thumbname;
501 return $params;
502 }
503
504 /**
505 * Convert a thumbnail name (122px-foo.png) to parameters, using
506 * file handler.
507 *
508 * @param File $file File object for file in question
509 * @param array $params Array of parameters so far
510 * @return array Parameters array with more parameters
511 */
512 function wfExtractThumbParams( $file, $params ) {
513 if ( !isset( $params['thumbName'] ) ) {
514 throw new InvalidArgumentException( "No thumbnail name passed to wfExtractThumbParams" );
515 }
516
517 $thumbname = $params['thumbName'];
518 unset( $params['thumbName'] );
519
520 // Do the hook first for older extensions that rely on it.
521 if ( !Hooks::run( 'ExtractThumbParameters', array( $thumbname, &$params ) ) ) {
522 // Check hooks if parameters can be extracted
523 // Hooks return false if they manage to *resolve* the parameters
524 // This hook should be considered deprecated
525 wfDeprecated( 'ExtractThumbParameters', '1.22' );
526 return $params; // valid thumbnail URL (via extension or config)
527 }
528
529 // FIXME: Files in the temp zone don't set a MIME type, which means
530 // they don't have a handler. Which means we can't parse the param
531 // string. However, not a big issue as what good is a param string
532 // if you have no handler to make use of the param string and
533 // actually generate the thumbnail.
534 $handler = $file->getHandler();
535
536 // Based on UploadStash::parseKey
537 $fileNamePos = strrpos( $thumbname, $params['f'] );
538 if ( $fileNamePos === false ) {
539 // Maybe using a short filename? (see FileRepo::nameForThumb)
540 $fileNamePos = strrpos( $thumbname, 'thumbnail' );
541 }
542
543 if ( $handler && $fileNamePos !== false ) {
544 $paramString = substr( $thumbname, 0, $fileNamePos - 1 );
545 $extraParams = $handler->parseParamString( $paramString );
546 if ( $extraParams !== false ) {
547 return $params + $extraParams;
548 }
549 }
550
551 // As a last ditch fallback, use the traditional common parameters
552 if ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) {
553 list( /* all */, /* pagefull */, $pagenum, $size ) = $matches;
554 $params['width'] = $size;
555 if ( $pagenum ) {
556 $params['page'] = $pagenum;
557 }
558 return $params; // valid thumbnail URL
559 }
560 return null;
561 }
562
563
564 /**
565 * Output a thumbnail generation error message
566 *
567 * @param int $status
568 * @param string $msgText Plain text (will be html escaped)
569 * @return void
570 */
571 function wfThumbErrorText( $status, $msgText ) {
572 wfThumbError( $status, htmlspecialchars( $msgText ) );
573 }
574
575 /**
576 * Output a thumbnail generation error message
577 *
578 * @param int $status
579 * @param string $msgHtml HTML
580 * @return void
581 */
582 function wfThumbError( $status, $msgHtml ) {
583 global $wgShowHostnames;
584
585 header( 'Cache-Control: no-cache' );
586 header( 'Content-Type: text/html; charset=utf-8' );
587 if ( $status == 400 || $status == 404 || $status == 429 ) {
588 HttpStatus::header( $status );
589 } elseif ( $status == 403 ) {
590 HttpStatus::header( 403 );
591 header( 'Vary: Cookie' );
592 } else {
593 HttpStatus::header( 500 );
594 }
595 if ( $wgShowHostnames ) {
596 header( 'X-MW-Thumbnail-Renderer: ' . wfHostname() );
597 $url = htmlspecialchars(
598 isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : ''
599 );
600 $hostname = htmlspecialchars( wfHostname() );
601 $debug = "<!-- $url -->\n<!-- $hostname -->\n";
602 } else {
603 $debug = '';
604 }
605 $content = <<<EOT
606 <!DOCTYPE html>
607 <html><head>
608 <meta charset="UTF-8" />
609 <title>Error generating thumbnail</title>
610 </head>
611 <body>
612 <h1>Error generating thumbnail</h1>
613 <p>
614 $msgHtml
615 </p>
616 $debug
617 </body>
618 </html>
619
620 EOT;
621 header( 'Content-Length: ' . strlen( $content ) );
622 echo $content;
623 }