removed $SESSION->encoding now replaced by current_charset() and $CFG->unicodedb...
[moodle.git] / fixpix.php
1 <?php
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/fixpix.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();
19 }
21 $matches = array();
23 if (!preg_match('/theme\/[^\/]*\/pix\/(.*)$/',$_SERVER['REDIRECT_URL'],$matches)) {
24     die();
25 }
27 if (file_exists($CFG->dirroot.'/pix/'.$matches[1])) {
28     header("Location: ".$CFG->wwwroot.'/pix/'.$matches[1]);
29 }
31 ?><html>
32 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
33 <HTML><HEAD>
34 <TITLE>404 Not Found</TITLE>
35 </HEAD><BODY>
36 <H1>Not Found</H1>
37 <P><?php echo $_SERVER['REDIRECT_ERROR_NOTES']; ?></P>
38 <HR>
39 </BODY></HTML>