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:<apache@phpfreaks.serverpowered.net> 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

Link to comment
Share on other sites

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>";
?>

Link to comment
Share on other sites

stristr

 

if (stristr($user, "email@here.com") !== 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>";

Link to comment
Share on other sites

in_array

 

$adresses = array('address1@test.com', 'address2@test.com');
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>";

 

 

Link to comment
Share on other sites

Hmm.

That didn't work. :(

 

This is what I've got:

$addresses = array('user@domain1.com', 'user@domain2.com');
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

Link to comment
Share on other sites

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

 

if (stristr($user, 'user@domain1.com') !== false || stristr($user, 'user@domain2.com')) {
         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.

Link to comment
Share on other sites

<?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>";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.