Merge pull request #8 from radiocontrolled/0004872
[atutor.git] / get_acheck.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12 // $Id$
13
14 /* this file simply gets the AT_CONTENT_DIR/CID.html file that was generated
15  * by the AChecker page of the content editor.
16  * there is no authentication on this page. either the file exists (in which
17  * case it is then quickly deleted after), or it doesn't.
18  */
19
20 $_user_location = 'public';
21
22 define('AT_INCLUDE_PATH', 'include/');
23 require(AT_INCLUDE_PATH . '/vitals.inc.php');
24
25 //get path to file
26 $args = substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME']));
27 $file = AT_CONTENT_DIR . $args;
28
29 //check that this file is within the content directory & exists
30 if (preg_match('/^\/[0-9]+\.html$/', $args) === 1) {
31     $real = realpath($file);
32     if (file_exists($real) && substr($real, 0, strlen(AT_CONTENT_DIR)) == AT_CONTENT_DIR) {
33         header('Content-Type: text/html');
34             echo file_get_contents($real);
35             exit;
36         }
37
38 header('HTTP/1.1 404 Not Found');
39 exit;
40
41
42
43 ?>