Odyssey
tlogs.prg
1 <?php
2 
3 $monLibrary= dirname(__FILE__) . "/../library";
4 require_once("$monLibrary/cu_top.i");
5 require_once("$monLibrary/ck_hticket.i");
6 
7  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
8  // ** Permissions failed
9  // ** redirect to new page
10  header("Location: /hcuadm/hcu_noperm.prg");
11  exit;
12  }
13 
14 
15  $protectdir = "/home";
16 
17  $filepath = $protectdir . $_SERVER['PATH_INFO'];
18  // This filepath will be a directory that has log files, I want
19  // The last file added to the directory, so it does a listing and gets
20  // The last file
21  $fp = popen("ls -r $filepath/*.out | head -1", "r");
22  // Now we have the name, we need to get just the filename
23 
24  $filename = fread($fp, 13000);
25  pclose($fp);
26 
27  // Strip the filepath off the file and the .out off the file to get the filename
28  $filename = str_replace($filepath . "/", "", $filename);
29  $filename = trim(str_replace(".out", "", $filename));
30 
31  // The contents of the out file will be there, so if they aren't then give 404
32  if (is_readable($filepath . "/$filename.out")) {
33  print "<HTML><HEAD><TITLE>Show E-Stmt Log</TITLE></HEAD><BODY>";
34  if (is_readable($filepath . "/$filename.mae")) {
35  print "<b>$filename.mae</b><br><PRE>";
36  readfile($filepath . "/$filename.mae");
37  print "</PRE><p>";
38  }
39  print "<b>$filename.out</b><br><PRE>";
40  readfile($filepath . "/$filename.out");
41  print "</PRE></BODY></HTML>";
42  }
43  else {
44  header("Status: 404 Not Found");
45  print <<<EOF
46  <HTML><HEAD>
47  <TITLE>404 Not Found</TITLE>
48  </HEAD><BODY>
49  <H1>Not Found</H1>
50  The requested URL ${_SERVER['PHP_SELF']} was not found on this server.<P>
51  <HR>
52  <ADDRESS>${_SERVER['SERVER_SIGNATURE']}</ADDRESS>
53  </BODY></HTML>
54 EOF;
55 }
56 ?>