Teh Mine

From: Drew (X3N0PH0N) 4 Aug 2011 19:46
To: ANT_THOMAS 2804 of 3934
Ahh ok. I think all you'd need there is file() or file_get_contents() and a bit of regex to pull out the actual chat messages. Actually, may as well use file() then recurse through the array (file() puts the lines of a file into an array) for ones which don't start with a chat message character and discard those. Shouldn't even need regex then, just strpos()
From: ANT_THOMAS 4 Aug 2011 19:49
To: Drew (X3N0PH0N) 2805 of 3934
So does that only work for the start of a line?

Because the log looks like this...

code:
2011-08-04 18:22:00 [INFO] <Spooneymania> i mean yes
2011-08-04 18:22:03 [INFO] <Jeesus> :D
2011-08-04 18:22:25 [INFO] <Spooneymania> i started a hangout thingu
2011-08-04 18:26:57 [INFO] [PLAYER_COMMAND] Spooneymania: /time day 
2011-08-04 18:36:27 [INFO] wakeupbomb [/94.193.54.69:57470] logged in with entity id 543938 at ([world] 965.90625, 72.0, 94.53125)
2011-08-04 18:36:31 [INFO] [PLAYER_COMMAND] wakeupbomb: /who  
2011-08-04 18:38:15 [INFO] [PLAYER_COMMAND] Spooneymania: /time day 
2011-08-04 18:42:09 [INFO] [PLAYER_COMMAND] Spooneymania: /weather dry 
2011-08-04 18:44:30 [INFO] chrishigs [/86.154.231.70:51136] logged in with entity id 546382 at ([world] -53.995520489623885, 23.0, 221.17613932596916)
2011-08-04 18:44:30 [INFO] [PLAYER_COMMAND] wakeupbomb: /weather wet 
2011-08-04 18:44:41 [INFO] [PLAYER_COMMAND] chrishigs: /who  
2011-08-04 18:44:54 [INFO] [PLAYER_COMMAND] chrishigs: /home  
2011-08-04 18:44:57 [INFO] [PLAYER_COMMAND] chrishigs: /spawn  
2011-08-04 18:45:19 [INFO] [PLAYER_COMMAND] chrishigs: /home  
2011-08-04 18:45:33 [INFO] <wakeupbomb> test
2011-08-04 18:45:38 [INFO] <Spooneymania> 123
2011-08-04 18:48:29 [INFO] [PLAYER_COMMAND] chrishigs: /time day 
2011-08-04 18:51:20 [INFO] [PLAYER_COMMAND] wakeupbomb: /time day 
2011-08-04 18:57:34 [INFO] [PLAYER_COMMAND] chrishigs: /home  
2011-08-04 18:57:45 [INFO] [PLAYER_COMMAND] chrishigs: /sethome  
2011-08-04 18:57:59 [INFO] [PLAYER_COMMAND] chrishigs: /spawn  
2011-08-04 18:59:09 [INFO] Connection reset
2011-08-04 18:59:09 [INFO] chrishigs lost connection: disconnect.endOfStream
2011-08-04 19:01:38 [INFO] [PLAYER_COMMAND] Spooneymania: /time day 
2011-08-04 19:03:22 [INFO] mjwatmough [/82.38.245.253:54757] logged in with entity id 557366 at ([world] -59.25, 75.0, 249.0)
2011-08-04 19:12:22 [INFO] [PLAYER_COMMAND] Spooneymania: /time day 
2011-08-04 19:13:07 [INFO] Read timed out
2011-08-04 19:13:07 [INFO] Spooneymania lost connection: disconnect.endOfStream
2011-08-04 19:13:27 [INFO] Spooneymania [/80.177.102.181:61709] logged in with entity id 561889 at ([world] 784.40625, 74.0, 585.125)
2011-08-04 19:21:12 [INFO] Connection reset
2011-08-04 19:21:12 [INFO] mjwatmough lost connection: disconnect.quitting
2011-08-04 19:24:25 [INFO] [PLAYER_COMMAND] Spooneymania: /time day 
2011-08-04 19:35:02 [INFO] [PLAYER_COMMAND] Spooneymania: /time day 
2011-08-04 19:45:52 [INFO] [PLAYER_COMMAND] Spooneymania: /time day 


So I'd need it to only pick lines that contain "[INFO] <"
From: Drew (X3N0PH0N) 4 Aug 2011 19:51
To: ANT_THOMAS 2806 of 3934
easy then, gimme a min and I'll whip up something that might work if you want. Or would you rather do it yourself?
From: ANT_THOMAS 4 Aug 2011 19:52
To: Drew (X3N0PH0N) 2807 of 3934
Go for it if you want to :D
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?