Teh Mine

From: Drew (X3N0PH0N) 4 Aug 2011 20:18
To: ANT_THOMAS 2812 of 3934
Oh that'll do every chat message in the log though so...

PHP code:
<?
 
$things = file('server.log');
$chats = Array();
 
foreach ($things as $thing) {
	if (strpos($thing, "[INFO] <")) {
		$chats[] = htmlspecialchars(substr($thing, 27));
	}
}
 
$chatt = implode("<br />", array_slice($chats, -30));
echo $chatt;
 
?>


That'll get the last 30. Change the -30 on line 12 to adjust.
From: Drew (X3N0PH0N) 4 Aug 2011 20:19
To: Drew (X3N0PH0N) 2813 of 3934
(I left $chatt as a variable so you can regex some styling into it if you want)
From: Ken (SHIELDSIT) 4 Aug 2011 20:44
To: Drew (X3N0PH0N) 2814 of 3934
You are such a hard core haxor!
From: ANT_THOMAS 4 Aug 2011 20:46
To: Drew (X3N0PH0N) 2815 of 3934
Give it a try on the mini-site. It's not linking to the live server.log, but just want to see if everyone else can see it.
From: JonCooper 4 Aug 2011 20:49
To: Drew (X3N0PH0N) 2816 of 3934
can you make it not include all the bollocks where people turn on the sun or turn off the rain etc?
From: Drew (X3N0PH0N) 4 Aug 2011 20:49
To: ANT_THOMAS 2817 of 3934
Works for me.
From: ANT_THOMAS 4 Aug 2011 20:51
To: JonCooper 2818 of 3934
He's already done that.
From: JonCooper 4 Aug 2011 20:51
To: ANT_THOMAS 2819 of 3934
I can see that too
From: JonCooper 4 Aug 2011 20:52
To: ANT_THOMAS 2820 of 3934
he is such a clever dude :)
From: ANT_THOMAS 4 Aug 2011 20:52
To: JonCooper 2821 of 3934
Good stuff. I wasn't sure if PHP could link to a local IP.
From: Mouse 4 Aug 2011 20:54
To: ALL2822 of 3934
Hard Work has made me the most amazing entrance system to my soon to be built scuplture gallery from the painting gallery. I will soon me accepting commissions for sculptures (modestly sized only) .
From: Radio 4 Aug 2011 20:56
To: ALL2823 of 3934
Where's this mini site then?
From: ANT_THOMAS 4 Aug 2011 21:00
To: Radio 2824 of 3934

It's on the first post of the thread (I try to keep post 1 updated)

 

http://mine.tehforum.co.uk/site/

From: Matt 4 Aug 2011 21:32
To: Drew (X3N0PH0N) 2825 of 3934
Seeing as you asked so nicely.

php code:
 
<?php echo nl2br(htmlentities(`tail -n 30 server.log | grep '\[INFO\] <' | cut -b 28-`));


Also, Andy?! Did you just wake from a coma?
From: Chris (CHRISSS) 4 Aug 2011 21:34
To: ANT_THOMAS 2826 of 3934
Would that not just be the number of lines the client shows, so not a server thing? I'm not that bothered if it's not an easy fix. Would be nice in the browser for the text to show for longer though, and be able to bring up recent messages like bringing up the chat windows in game.
EDITED: 4 Aug 2011 21:34 by CHRISSS
From: Drew (X3N0PH0N) 4 Aug 2011 21:34
To: Matt 2827 of 3934
Andy Caer.

And thanks :D
From: ANT_THOMAS 4 Aug 2011 21:56
To: Drew (X3N0PH0N) 2828 of 3934

How do I reverse the output so the newest is at the top?

 

I've tried "array_reverse" in various places with no luck yet.

From: Drew (X3N0PH0N) 4 Aug 2011 22:00
To: ANT_THOMAS 2829 of 3934
$things = array_reverse(file('server.log'));

Should do it?
From: ANT_THOMAS 4 Aug 2011 22:01
To: Drew (X3N0PH0N) 2830 of 3934

I've sorted it anyway

 

There was once place I hadn't tried :)

From: Matt 4 Aug 2011 22:02
To: Drew (X3N0PH0N) 2831 of 3934
But, but! Caer is Caer, and he'd probably write it in Ruby or something.

To be fair, Andy would probably right it in ActionScript.