TomT Posted February 24, 2009 Share Posted February 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/ Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770322 Share on other sites More sharing options...
TomT Posted February 24, 2009 Author Share Posted February 24, 2009 Fantastic. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770342 Share on other sites More sharing options...
TomT Posted February 24, 2009 Author Share Posted February 24, 2009 One quick question. How would I change one line bold if a specific email address is shown ? eg: if $user CONTAINS <apache@phpfreaks.serverpowered.net> the BOLD ?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770345 Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770349 Share on other sites More sharing options...
TomT Posted February 24, 2009 Author Share Posted February 24, 2009 Thanks again.. That worked well. Last question - is it possible to specify multiple email addresses ?? eg: email = email@here.com OR email@domain.com etc ?? Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770356 Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770389 Share on other sites More sharing options...
TomT Posted February 24, 2009 Author Share Posted February 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770406 Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 Try removing the !== false. Both the usernames should appear, just the ones specified should be red colored. Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770408 Share on other sites More sharing options...
TomT Posted February 24, 2009 Author Share Posted February 24, 2009 Hmm. Still not working ?? $addresses = array('user@domain1.com', 'user@domain2.com'); if (in_array($user, $addresses)) Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770416 Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770426 Share on other sites More sharing options...
TomT Posted February 24, 2009 Author Share Posted February 24, 2009 Thanks again that fixed it !! Could you point me in the right direction for doing it via the array. I may do that later Thanks Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770433 Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 <?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>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770437 Share on other sites More sharing options...
TomT Posted February 24, 2009 Author Share Posted February 24, 2009 Thanks again I will play with that over the next few evenings Thanks Quote Link to comment https://forums.phpfreaks.com/topic/146727-solved-displaying-text-file-entries-missing/#findComment-770440 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.