made a copy
[atutor.git] / admin / error_logging_view.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
6 /* Adaptive Technology Resource Centre / University of Toronto                  */
7 /* http://atutor.ca                                                                                                             */
8 /*                                                                                                                                              */
9 /* This program is free software. You can redistribute it and/or                */
10 /* modify it under the terms of the GNU General Public License                  */
11 /* as published by the Free Software Foundation.                                                */
12 /************************************************************************/
13 // $Id$
14
15 define('AT_INCLUDE_PATH', '../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 admin_authenticate(AT_ADMIN_PRIV_ADMIN);
18
19 if (isset($_POST['back'])) {
20         header('Location: error_logging.php');
21         exit;
22 }
23
24 $files = array();
25 if (isset($_POST['view'])) { // check if a bug was selected
26         foreach($_POST as $elem => $val) {
27                 $str_ = substr($elem, 0, 4);
28                 if ($str_  == 'file') {
29                         $files[] = $elem;
30                 }
31         }
32         if (empty($files)) {
33                 $msg->addError('NO_LOG_SELECTED');
34                 header('Location: error_logging.php');
35                 exit;
36         }
37 }
38
39 $back_ref = $_POST['profile_id'] . ':' . $_POST['profile_date'];
40
41 require(AT_INCLUDE_PATH.'header.inc.php');
42 ?>
43 <form name="form" method="post" action="<?php echo 'admin/error_logging_details.php'; ?>">
44 <input type="hidden" name="data" value="<?php echo $back_ref; ?>" />
45 <input type="hidden" name="view" value="<?php echo ''; ?>" />
46
47 <div class="input-form">
48         <div class="row">
49                 <h3><?php echo _AT('viewing_errors'); ?></h3>
50         </div><?php
51
52         foreach ($files as $file) {
53                 if (isset($_POST[$file])) {
54                         $dump = @file_get_contents(AT_CONTENT_DIR . 'logs/' . $_POST[$file]);   
55                         if ($dump !== false) { ?>
56
57                                 <div class="row">
58                                         <?php echo $dump; ?>
59                                 </div><?php
60
61                         } else {
62                                 $msg->printErrors(array('CANNOT_READ_FILE', AT_CONTENT_DIR . 'logs/' . $_POST[$file]));
63                         }
64                 }       
65         } ?>
66
67         <div class="row buttons">
68                 <input type="submit" name="back" value="<?php echo _AT('back_to_profile'); ?>" />  
69         </div>
70 </div>
71 </form>
72
73 <?php   require(AT_INCLUDE_PATH.'footer.inc.php'); ?>