Jump to content

[SOLVED] Displaying Text File. - Entries Missing. !


TomT

Recommended Posts

Hi.

I'm using a simple php script to display a text log file.

This seems to work.. But some entries are missing on screen, but shown if I view the page source. !!

 

<?php
$file = "c:\Logs\LogFile.txt";
$users = file($file);
echo "<table border='0' width='95%'>";
echo "<font face='Verdana' size='2'><b>$file</b><br><br>";
	foreach ($users as $user) {
echo "<tr>";
echo "<td align='left'><font face='Verdana' size='2'>$user</td></tr>";
	$result = count($users);
	}
echo "</table><br><font face='Verdana' size='2'>Number of Entries : <b>" .$result ."</b><br>";
echo "Last Updated: <b>" . date('D jS M \'y H:i:s') . "</b>";
?>

 

The one screen output of the log file shows:

T 20090224 183809 4995898c EHLO phpfreaks.serverpowered.net
T 20090224 183809 4995898c MAIL From: SIZE=1834
T 20090224 183810 4995898c RCPT To:
T 20090224 183811 4995898c DATA
T 20090224 183811 4995898c DATA - 46 lines, 1856 bytes.

 

Yet the Source Code for the same page shows:

T 20090224 183809 4995898c EHLO phpfreaks.serverpowered.net
T 20090224 183809 4995898c MAIL From:<[email protected]> SIZE=1834
T 20090224 183810 4995898c RCPT To:<user@domain_removed.com>
T 20090224 183811 4995898c DATA
T 20090224 183811 4995898c DATA - 46 lines, 1856 bytes.
T 20090224 183811 4995898c QUIT

 

As you can see both of the email addresses are missing from the results but show in the html source !!

It appears not to be showing anything within <> !

 

Can Anyone help ?

Thanks

htmlentities

 

<?php
$file = "c:\Logs\LogFile.txt";
$users = file($file);
   echo "<table border='0' width='95%'>";
   echo "<font face='Verdana' size='2'><b>" . $file . "</b><br><br>";
      foreach ($users as $user) {
   echo "<tr>";
   echo "<td align='left'><font face='Verdana' size='2'>" . htmlentities($user) . "</td></tr>";
      }
      $result = count($users);
   echo "</table><br><font face='Verdana' size='2'>Number of Entries : <b>" .$result ."</b><br>";
   echo "Last Updated: <b>" . date('D jS M \'y H:i:s') . "</b>";
?>

stristr

 

if (stristr($user, "[email protected]") !== false)
         echo "<td align='left'><font face='Verdana' size='2'><b>" . htmlentities($user) . "</b></td></tr>";
else
         echo "<td align='left'><font face='Verdana' size='2'>" . htmlentities($user) . "</td></tr>";

in_array

 

$adresses = array('[email protected]', '[email protected]');
if (in_array($user, $addresses) !== false)
         echo "<td align='left'><font face='Verdana' size='2'><b>" . htmlentities($user) . "</b></td></tr>";
else
         echo "<td align='left'><font face='Verdana' size='2'>" . htmlentities($user) . "</td></tr>";

 

 

Hmm.

That didn't work. :(

 

This is what I've got:

$addresses = array('[email protected]', '[email protected]');
if (in_array($user, $addresses) !== false)
         echo "<td align='left'><font face='Verdana' size='2' color='red'>" . htmlentities($user) . "</font></td></tr>";
else
         echo "<td align='left'><font face='Verdana' size='2'>" . htmlentities($user) . "</td></tr>";

 

both of the usernames appear in the log !!

Any Ideas ?

 

Thanks

Eh I am a moron. Sorry about that, my mind is completely podged today.

 

if (stristr($user, '[email protected]') !== false || stristr($user, '[email protected]')) {
         echo "<td align='left'><font face='Verdana' size='2'><b>" . htmlentities($user) . "</b></td></tr>";
else
         echo "<td align='left'><font face='Verdana' size='2'>" . htmlentities($user) . "</td></tr>";

 

You can use the array, you would just have to loop through it. It depends on how many exemptions you want to add, if it would be worth doing. If it is just these 2, it would not be worth it 4+ I would say it would.

<?php
$addresses = array('user1', 'user2', 'user3');
$inArray = false;
foreach ($addresses as $address) {
	if (stristr($user, $address) !== false) {
		$inArray = true;
		break;
	}
}

if ($inArray)
		 echo "<td align='left'><font face='Verdana' size='2'><b>" . htmlentities($user) . "</b></td></tr>";
else
		 echo "<td align='left'><font face='Verdana' size='2'>" . htmlentities($user) . "</td></tr>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.