WebChatLog

WebChatLog

294 Downloads

Sends chat messages to a {administrator defined URL.}
for every {administrator defined value} chat messages.

sends data in POST,

sends remaining chat messages on plugin stop.

administrator must have server side script to catch the chat messages.

To install:

Add ChatLog.jar to plugins folder.

restart the server.

This will create a config file, you can edit this config file in Notepad ++ in order to change the URL and frequency between sending the messages to the webserver.

Potential easy web interface may come soon.

Simple log data to file:

<?php 
 $link=mysqli_connect("localhost", "root", "root", "chatmessages");
if (mysqli_connect_error($link)) {
print 'Connect Error: ' . mysqli_connect_error($link);
}
if (isset($_POST['jsonArry'])){
$myfile = fopen("logs.txt", "a") or die("Unable to open file!");
$jsonData = json_decode($_POST['jsonArry'], true);
fwrite($myfile, "\n\n\n". print_r($jsonData ,true));//log the json
foreach ($jsonData as $v){
//print $v["datetime"];
print $v["username"];
print " - ";
print $v["message"];
$clean['username']=mysqli_real_escape_string($link, $v['username']);//escape username
$clean['message']=mysqli_real_escape_string($link, $v['message']); //escape message
$date = (new \DateTime($v["datetime"]))->modify('-1 hour');//reduce time by an hour.
$q=mysqli_query($link, "insert into chatmessages (`datetime`, `message`, `username`) VALUES ('{$date}', '{$clean['message']}', '{$clean['username']}')");
if(!$q){
fwrite($myfile, "\n\n\n". mysqli_error($link));//log the error like a boss
}
print mysqli_error($link);//display error.
print "\n";
}
fclose($myfile);
}

Credits to mspaint for the amazing logo.