View Single Post
  #17 (permalink)  
Old Oct 30th, 2007, 14:37
Rakuli's Avatar
Rakuli Rakuli is offline
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Using standard web logs

That list() call should really be working....

O well, scrap that!...



PHP: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="60" />
<title>Untitled Document</title>
</head>
<body>
<p>This should print the text file</p>
<?php
$filename 
'file.txt';
$fp fopen($filename"r");

// make sure that the file opening was successful
if ($fp)
{
    
// now cycle through one line at a time until we reach the end of the file (feof() checks end of file)
    
while (!feof($fp))
    {
        
$contents fgets($fp);
        
// discard commented links
        
if (strpos($contents'#') === 0)
            continue;
            
        
// Now we'll create the variables to output
        // list will take the keys of an array and read them into the variables as named, the raw output is separated by spaces so we will use explode to split the string into and array
        // on the spaces..... Then you can just echo as required
        
$logBits  explode(' '$contents);
        
        
// cylcle though the bits of the log
        
        
echo '<style="border: 1px; margin: 1em; padding: 1em">';
        
        foreach (
$logBits as $bits)
        {
            echo 
$bits'<br />';
        }
                                echo 
'</div>';
        
        
        
    }
}

fclose($fp);
?>

<script type="text/javascript">
// set the page to reload every 15 minutes
setTimeout('window.location.href = '<?php echo $_SERVER['php_self']; ?>', 900000);
</script>
</body>
</html>
That ^^ Should definitely work..
Reply With Quote