Teh Mine

From: Drew (X3N0PH0N) 4 Aug 2011 20:05
To: ANT_THOMAS 2808 of 3934
Ok well this should work. It's no doubt poor code and PB or Matt or Andy will be along to betterise it but it works...

PHP code:
<?
 
$things = file('server.log');
$chats = "";
 
foreach ($things as $thing) {
	if (strpos($thing, "[INFO] <")) {
		$chats .= htmlspecialchars(substr($thing, 27)) . "<br />";
	}
}
 
echo $chats;
 
?>
EDITED: 4 Aug 2011 20:06 by X3N0PH0N
From: af (CAER) 4 Aug 2011 20:07
To: ANT_THOMAS 2809 of 3934
Looking at the map.js source, there's an option 'messagettl' that seems to be the delay before messages are hidden. You should be able to edit config.js and add

messagettl: 10000

(I'm assuming it's measured in milliseconds)
From: ANT_THOMAS 4 Aug 2011 20:07
To: Drew (X3N0PH0N) 2810 of 3934
:D I shall put that into use!
From: ANT_THOMAS 4 Aug 2011 20:16
To: af (CAER) 2811 of 3934
I think it's in seconds because it's currently "5" so I'll increase that too.
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