Committing current progress, can't afford to lose this again
This commit is contained in:
parent
9ce7b25482
commit
54157024f7
35
Plugins/Mineplex.ChatSnapManager/web/Player.php
Normal file
35
Plugins/Mineplex.ChatSnapManager/web/Player.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php class Player
|
||||
{
|
||||
/** @var String */
|
||||
private $uuid;
|
||||
|
||||
/** @var String */
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* Player constructor.
|
||||
* @param String $uuid
|
||||
* @param String $username
|
||||
*/
|
||||
function Player($uuid, $username)
|
||||
{
|
||||
$this->uuid = $uuid;
|
||||
$this->username = $username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getUUID()
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
}
|
5
Plugins/Mineplex.ChatSnapManager/web/jquery.atooltip.min.js
vendored
Normal file
5
Plugins/Mineplex.ChatSnapManager/web/jquery.atooltip.min.js
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
/*Plugin by: Ara Abcarians: http://ara-abcarians.com License: http://creativecommons.org/licenses/by/3.0/ */
|
||||
(function($){$.fn.aToolTip=function(options){var defaults={closeTipBtn:'aToolTipCloseBtn',toolTipId:'aToolTip',fixed:false,clickIt:false,inSpeed:200,outSpeed:100,tipContent:'',toolTipClass:'defaultTheme',xOffset:5,yOffset:5,onShow:null,onHide:null},settings=$.extend({},defaults,options);return this.each(function(){var obj=$(this);if(obj.attr('title')){var tipContent=obj.attr('title');}else{var tipContent=settings.tipContent;}
|
||||
var buildaToolTip=function(){$('body').append("<div id='"+settings.toolTipId+"' class='"+settings.toolTipClass+"'><p class='aToolTipContent'>"+tipContent+"</p></div>");if(tipContent&&settings.clickIt){$('#'+settings.toolTipId+' p.aToolTipContent').append("<a id='"+settings.closeTipBtn+"' href='#' alt='close'>close</a>");}},positionaToolTip=function(){$('#'+settings.toolTipId).css({top:(obj.offset().top-$('#'+settings.toolTipId).outerHeight()-settings.yOffset)+'px',left:(obj.offset().left+obj.outerWidth()+settings.xOffset)+'px'}).stop().fadeIn(settings.inSpeed,function(){if($.isFunction(settings.onShow)){settings.onShow(obj);}});},removeaToolTip=function(){$('#'+settings.toolTipId).stop().fadeOut(settings.outSpeed,function(){$(this).remove();if($.isFunction(settings.onHide)){settings.onHide(obj);}});};if(tipContent&&!settings.clickIt){obj.hover(function(){$('#'+settings.toolTipId).remove();obj.attr({title:''});buildaToolTip();positionaToolTip();},function(){removeaToolTip();});}
|
||||
if(tipContent&&settings.clickIt){obj.click(function(el){$('#'+settings.toolTipId).remove();obj.attr({title:''});buildaToolTip();positionaToolTip();$('#'+settings.closeTipBtn).click(function(){removeaToolTip();return false;});return false;});}
|
||||
if(!settings.fixed&&!settings.clickIt){obj.mousemove(function(el){$('#'+settings.toolTipId).css({top:(el.pageY-$('#'+settings.toolTipId).outerHeight()-settings.yOffset),left:(el.pageX+settings.xOffset)});});}});};})(jQuery);
|
0
Plugins/Mineplex.ChatSnapManager/web/main.js
Normal file
0
Plugins/Mineplex.ChatSnapManager/web/main.js
Normal file
61
Plugins/Mineplex.ChatSnapManager/web/message.php
Normal file
61
Plugins/Mineplex.ChatSnapManager/web/message.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php class Message
|
||||
{
|
||||
/** @var Player */
|
||||
private $sender;
|
||||
|
||||
/** @var Player[] */
|
||||
private $recipients;
|
||||
|
||||
/** @var Int */
|
||||
private $timestamp;
|
||||
|
||||
/** @var String */
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* Message constructor.
|
||||
* @param Player $sender
|
||||
* @param Player[] $recipients
|
||||
* @param Int $timestamp
|
||||
* @param String $message
|
||||
*/
|
||||
function Message($sender, $recipients, $timestamp, $message)
|
||||
{
|
||||
$this->sender = $sender;
|
||||
$this->recipients = $recipients;
|
||||
$this->timestamp = $timestamp;
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getSender()
|
||||
{
|
||||
return $this->sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getRecipients()
|
||||
{
|
||||
return $this->recipients;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Int
|
||||
*/
|
||||
public function getTimestamp()
|
||||
{
|
||||
return $this->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
}
|
@ -1,34 +1,27 @@
|
||||
<?php
|
||||
|
||||
require_once('snapshot.php');
|
||||
require_once('message.php');
|
||||
require_once('player.php');
|
||||
|
||||
$dataDir = 'data/';
|
||||
|
||||
// ID corresponds to the Report ID
|
||||
if (!isset($_GET['id']) || empty($_GET['id'])) {
|
||||
echo 'No identifier supplied.';
|
||||
return;
|
||||
if (!isset($_GET['identifier']) || empty($_GET['identifier'])) {
|
||||
exit('No identifier supplied.');
|
||||
}
|
||||
|
||||
$id = removeNonAlphaNumeric($_GET['id']); // prevents escaping
|
||||
$filePath = $dataDir . $id . '.json';
|
||||
$identifier = removeBadCharacters($_GET['identifier']); // prevents escaping
|
||||
$reportNumber = explode("-", $identifier)[0];
|
||||
$filePath = $dataDir . $identifier . '.json';
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
displayMessages(toDataArray($filePath));
|
||||
} else {
|
||||
echo 'Invalid identifier.';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $dataArray root JSON data array.
|
||||
*/
|
||||
function displayMessages($dataArray)
|
||||
if (!file_exists($filePath))
|
||||
{
|
||||
$snapshot = toSnapshot($dataArray);
|
||||
|
||||
foreach ($snapshot->getMessages() as $message) {
|
||||
echo getMessageLine($message);
|
||||
echo '<br \>';
|
||||
}
|
||||
exit('Invalid identifier.');
|
||||
}
|
||||
|
||||
$snapshot = toSnapshot($identifier, toDataArray($filePath));
|
||||
|
||||
/**
|
||||
* @param String $filename
|
||||
* @return array JSON data array.
|
||||
@ -39,24 +32,41 @@ function toDataArray($filename)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Message $message
|
||||
* @return string
|
||||
* @param String $identifier
|
||||
* @param Snapshot $snapshot
|
||||
*/
|
||||
function getMessageLine($message)
|
||||
function displayMessages($identifier, $snapshot)
|
||||
{
|
||||
return $message->getSender()->getUsername() . ' - ' . $message->getMessage();
|
||||
echo '<p>';
|
||||
|
||||
foreach ($snapshot->getMessages() as $message) {
|
||||
echo getMessageHTML($message) . "<br />\n";
|
||||
}
|
||||
|
||||
echo '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Message $message
|
||||
* @return string
|
||||
*/
|
||||
function getMessageHTML($message)
|
||||
{
|
||||
$sender = $message->getSender();
|
||||
return '<span data-uuid=\"' . $sender->getUUID() . '\">' . $sender->getUsername() . '</span> - ' . $message->getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param String $identifier
|
||||
* @param array $snapshotData Snapshot data array.
|
||||
* @return Snapshot
|
||||
*/
|
||||
function toSnapshot($snapshotData)
|
||||
function toSnapshot($identifier, $snapshotData)
|
||||
{
|
||||
$identifier = $snapshotData['token'];
|
||||
$players = getPlayers($snapshotData['usernames']);
|
||||
$messages = getMessages($players, $snapshotData['snapshots']);
|
||||
return new Snapshot($identifier, $messages, $players);
|
||||
$players = toPlayers($snapshotData['usernames']);
|
||||
$messages = toMessages($players, $snapshotData['snapshots']);
|
||||
$timeGenerated = $snapshotData["time_generated"];
|
||||
return new Snapshot($identifier, $messages, $players, $timeGenerated);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +74,7 @@ function toSnapshot($snapshotData)
|
||||
* @param array $messagesData Messages data array.
|
||||
* @return Message[]
|
||||
*/
|
||||
function getMessages($players, $messagesData)
|
||||
function toMessages($players, $messagesData)
|
||||
{
|
||||
$messages = array();
|
||||
|
||||
@ -112,7 +122,7 @@ function getPlayersFromUUIDs($players, $uuidArray)
|
||||
* @param Player[] $playersArray
|
||||
* @return Player[]
|
||||
*/
|
||||
function getPlayers($playersArray) // String UUID as Key
|
||||
function toPlayers($playersArray) // String UUID as Key
|
||||
{
|
||||
$players = array();
|
||||
|
||||
@ -147,154 +157,30 @@ function getPlayer($players, $uuid)
|
||||
* @param String $input
|
||||
* @return String
|
||||
*/
|
||||
function removeNonAlphaNumeric($input)
|
||||
function removeBadCharacters($input)
|
||||
{
|
||||
return preg_replace('/[^A-Za-z0-9_\-]/', '_', $input);
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title>Snapshot for Report #<?php echo $reportNumber ?></title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
class Snapshot {
|
||||
displayMessages($identifier, $snapshot);
|
||||
|
||||
/** @var String */
|
||||
private $identifier;
|
||||
// convert to friendly date time
|
||||
$seconds = $snapshot->getTimeGenerated() / 1000;
|
||||
$friendlyDateTime = date('m/d/y \a\t h:ia', $seconds);
|
||||
|
||||
/** @var Message[] */
|
||||
private $messages;
|
||||
echo '<p>';
|
||||
echo 'Snapshot taken at: ' . $friendlyDateTime;
|
||||
echo '<br />';
|
||||
echo 'Player names were valid at this time.';
|
||||
echo '</p>';
|
||||
|
||||
/** @var Player[] */
|
||||
private $players; // String UUID as Key
|
||||
|
||||
/**
|
||||
* Snapshot constructor.
|
||||
* @param String $identifier
|
||||
* @param Message[] $messages
|
||||
* @param Player[] $players
|
||||
*/
|
||||
function Snapshot($identifier, $messages, $players)
|
||||
{
|
||||
$this->identifier = $identifier;
|
||||
$this->messages = $messages;
|
||||
$this->players = $players;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Message[]
|
||||
*/
|
||||
public function getMessages()
|
||||
{
|
||||
return $this->messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getPlayers()
|
||||
{
|
||||
return $this->players;
|
||||
}
|
||||
}
|
||||
|
||||
class Message
|
||||
{
|
||||
/** @var Player */
|
||||
private $sender;
|
||||
|
||||
/** @var Player[] */
|
||||
private $recipients;
|
||||
|
||||
/** @var Int */
|
||||
private $timestamp;
|
||||
|
||||
/** @var String */
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* Message constructor.
|
||||
* @param Player $sender
|
||||
* @param Player[] $recipients
|
||||
* @param Int $timestamp
|
||||
* @param String $message
|
||||
*/
|
||||
function Message($sender, $recipients, $timestamp, $message)
|
||||
{
|
||||
$this->sender = $sender;
|
||||
$this->recipients = $recipients;
|
||||
$this->timestamp = $timestamp;
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getSender()
|
||||
{
|
||||
return $this->sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getRecipients()
|
||||
{
|
||||
return $this->recipients;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Int
|
||||
*/
|
||||
public function getTimestamp()
|
||||
{
|
||||
return $this->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
}
|
||||
|
||||
class Player
|
||||
{
|
||||
/** @var String */
|
||||
private $uuid;
|
||||
|
||||
/** @var String */
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* Player constructor.
|
||||
* @param String $uuid
|
||||
* @param String $username
|
||||
*/
|
||||
function Player($uuid, $username)
|
||||
{
|
||||
$this->uuid = $uuid;
|
||||
$this->username = $username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getUUID()
|
||||
{
|
||||
return $this->uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
59
Plugins/Mineplex.ChatSnapManager/web/snapshot.php
Normal file
59
Plugins/Mineplex.ChatSnapManager/web/snapshot.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php class Snapshot
|
||||
{
|
||||
|
||||
/** @var String */
|
||||
private $identifier;
|
||||
|
||||
/** @var Message[] */
|
||||
private $messages;
|
||||
|
||||
/** @var Player[] */
|
||||
private $players; // String UUID as Key
|
||||
|
||||
/** @var Int */
|
||||
private $timeGenerated;
|
||||
|
||||
/**
|
||||
* Snapshot constructor.
|
||||
* @param String $identifier
|
||||
* @param Message[] $messages
|
||||
* @param Player[] $players
|
||||
* @param Int $timeGenerated
|
||||
*/
|
||||
function Snapshot($identifier, $messages, $players, $timeGenerated)
|
||||
{
|
||||
$this->identifier = $identifier;
|
||||
$this->messages = $messages;
|
||||
$this->players = $players;
|
||||
$this->timeGenerated = $timeGenerated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
*/
|
||||
public function getIdentifier()
|
||||
{
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Message[]
|
||||
*/
|
||||
public function getMessages()
|
||||
{
|
||||
return $this->messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getPlayers()
|
||||
{
|
||||
return $this->players;
|
||||
}
|
||||
|
||||
public function getTimeGenerated()
|
||||
{
|
||||
return $this->timeGenerated;
|
||||
}
|
||||
}
|
@ -114,6 +114,7 @@ public class MessageSnapshotManager
|
||||
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("token", token);
|
||||
jsonObject.addProperty("time_generated", System.currentTimeMillis());
|
||||
jsonObject.add("snapshots", GSON.toJsonTree(snapshots));
|
||||
jsonObject.add("usernames", GSON.toJsonTree(uuidUsernameMap));
|
||||
String json = GSON.toJson(jsonObject);
|
||||
|
Loading…
Reference in New Issue
Block a user