MDL-15942 - separate data escaped for database entry from unescaped data
[moodle-linuxchix.git] / pix / redirect.php
blob80b7badeef001196d298ea1fb52ef344047fbce7
1 <?php // $Id$
3 /**
4 If you're using custompix in your theme, but you don't want to have to copy every pix from /pix into /theme/yourtheme/pix, use this as a 404 handler.
5 You need to put a snippet like the following into your apacheconfig:
7 <Location /moodle/theme/yourtheme/pix >
8 ErrorDocument 404 /moodle/pix/redirect.php
9 </Location>
11 **/
14 require_once('../config.php');
16 // obtain the requested path.
17 if (!array_key_exists('REDIRECT_STATUS',$_SERVER) || $_SERVER['REDIRECT_STATUS'] != 404) {
18 die();
21 $matches = array();
23 if (!preg_match('/theme\/[^\/]*\/pix\/(.*)$/',$_SERVER['REDIRECT_URL'],$matches)) {
24 die();
27 if (file_exists($CFG->dirroot.'/pix/'.$matches[1])) {
28 header("Location: ".$CFG->wwwroot.'/pix/'.$matches[1]);
32 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
33 <html><head>
34 <title>404 Not Found</title>
35 </head>
36 <body>
37 <h1>Picture not found</h1>
38 <p><?php echo $_SERVER['REDIRECT_ERROR_NOTES']; ?></p>
39 </body>
40 </html>