Webmaster-Showcase.net IE Problem

Using Microsoft Internet Explorer to Display Log Files

What is the problem?

Some versions of Microsoft Internet Explorer (IE) are configured to handle files with names that end in ".log" in a special way. So, even though the web server tells the browser that the file is "text/plain", IE insist on saving it on a local disk drive before showing it. Normal browser behavoir for "text/plain" files is to just display the data. (Microsoft thinks it knows better.)

To overcome this problem the simplest solution is - don't use a Microsoft browser... Since that is not always practical I wrote two PHP scripts to assist me in viewing the log files. The first one, "listlogs.php", just presents a list of clickable log files in the current directory. The second one, "showlog.php", shows the contents of the clicked log file. Place both of them in your "/logs" directory.

Here is the source of each:


listlogs.php

<html>
<head>
        <title>List Log Files</title>
</head>
<body>

<?
  $dh
= opendir(".");
  while (
$file = readdir($dh)) {
    if (
substr($file,0,1) != ".") {
      if (
preg_match("/\.log$/",$file,$match)) {
        print(
"<a href=\"showlog.php/$file\">$file</a><br />");
      }
    }
  }


?>

</body>
</html>





showlog.php

<html>
<head>
        <title>Show a file</title>
</head>
<body>

<?
  $file
= $_SERVER["PATH_INFO"];
  
highlight_file("./$file");
?>

</body>
</html>




Home
Show Me How Feedback
Last updated: Mon Sep 30 18:28:14 2002