[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/pix/ -> redirect.php (source)

   1  <?php // $Id: redirect.php,v 1.1 2006/04/11 07:53:59 moodler Exp $
   2  
   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:
   6  
   7  <Location /moodle/theme/yourtheme/pix >
   8     ErrorDocument 404 /moodle/pix/redirect.php
   9  </Location>
  10  
  11  **/
  12  
  13  
  14  require_once ('../config.php');
  15  
  16  // obtain the requested path.
  17  if (!array_key_exists('REDIRECT_STATUS',$_SERVER) || $_SERVER['REDIRECT_STATUS'] != 404) {
  18      die();
  19  }
  20  
  21  $matches = array();
  22  
  23  if (!preg_match('/theme\/[^\/]*\/pix\/(.*)$/',$_SERVER['REDIRECT_URL'],$matches)) {
  24      die();
  25  }
  26  
  27  if (file_exists($CFG->dirroot.'/pix/'.$matches[1])) {
  28      header("Location: ".$CFG->wwwroot.'/pix/'.$matches[1]);
  29  }
  30  
  31  ?>
  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>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7