Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Chat Logger v2.1a PHP Script | Awesome Cars + Fun Maps
<!doctype html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css">
<link href="https://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<title>Chat</title>
<style type="text/css">
body {
background-color: #111111;
width: 100%;
margin: 0px auto;
color: gray;
font-family: 'Verdana';
font-size: 14px;
}
h1 {
color: #DADADA;
margin: 0px 0px 20px 0px;
padding: 0px;
font-size: 50px;
text-align: center;
}
.chat-row {
margin: 0 10px;
}
.player-name-red {
color: #D81001;
}
.player-name-blue {
color: #2593E6;
}
.player-name-yellow {
color: #FED524;
}
.player-message {
color: #25A51F;
}
.message-date {
font-size: 10px;
color: gray;
padding-left: 5px;
}
/* formstyles */
.form {
text-align: center;
margin: 0 10px 20px 10px;
}
input[type=text] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid gray;
border-radius: 4px;
box-sizing: border-box;
background: #111111;
color: #dadada;
}
input[type=submit] {
width: 100%;
background-color: #25A51F;;
color: white;
padding: 14px 20px;
margin: 8px 0;
margin-top: 0px;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=submit]:hover {
background-color: #45a049;
}
/* scrollcontrols */
#return-to-top {
position: fixed;
bottom: 75px;
right: 20px;
background: rgb(0, 0, 0);
background: rgba(0, 132, 255, 0.7);
width: 50px;
height: 50px;
display: block;
text-decoration: none;
-webkit-border-radius: 35px;
-moz-border-radius: 35px;
border-radius: 35px;
display: none;
-webkit-transition: all 0.3s linear;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
opacity: 0.5;
}
#return-to-top i {
color: #fff;
margin: 0;
position: relative;
left: 16px;
top: 13px;
font-size: 19px;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
}
#return-to-top:hover {
background: rgba(0, 0, 0, 0.9);
}
#return-to-top:hover i {
color: #fff;
top: 5px;
}
/* Bottom Arrow Style */
#return-to-bottom {
position: fixed;
bottom: 20px;
right: 20px;
background: rgb(0, 0, 0);
background: rgba(0, 132, 255, 0.7);
width: 50px;
height: 50px;
display: block;
text-decoration: none;
-webkit-border-radius: 35px;
-moz-border-radius: 35px;
border-radius: 35px;
display: block;
-webkit-transition: all 0.3s linear;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
opacity: 0.5;
}
#return-to-bottom i {
color: #fff;
margin: 0;
position: relative;
left: 16px;
top: 13px;
font-size: 19px;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
}
#return-to-bottom:hover {
background: rgba(0, 0, 0, 0.9);
}
#return-to-bottom:hover i {
color: #fff;
top: 20px;
}
</style><!-- your html stuff -->
<meta charset="UTF-8">
</head>
<body>
<h1>Chat - Awesome Cars</h1>
<div class="form">
<form action="chat.php" method="get">
<input type="text" name="password" placeholder="Enter password..."><br>
<input type="submit" value="Show IPs">
</form>
</div>
<?php
$ftp_ip = ""; //
$ftp_user = ""; //
$ftp_pass = ""; //
$ftp_log_path = "cstrike/addons/amxmodx/logs/ChatLog.htm";
$temporary_file = "chat.htm";
$conn_id = ftp_connect($ftp_ip);
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
$local = fopen($temporary_file, "w");
$result = ftp_fget($conn_id, $local, $ftp_log_path, FTP_ASCII);
ftp_close($conn_id);
$myFile = $temporary_file;
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
$lines = file($myFile);
// readfile($myFile);
array_splice($lines, 0, 3);
$messages = $lines;
$password = null;
if (!empty($_GET)) {
$password = $_GET["password"];
}
for ($i = 0; $i < count($messages); $i++) {
$message = $messages[$i];
$steamIdAndIp = null;
$playerName = null;
$playerNameAndMessage = null;
$steamIdAndIPRegex = '/(?<=&lt;).*?(?=&gt;)/';
$playerNameAndMessageRegex = '/<font color=.*?>(.*?)(?=<\/font>)/';
preg_match_all($steamIdAndIPRegex, $message, $steamIdAndIp);
preg_match_all($playerNameAndMessageRegex, $message, $playerNameAndMessage);
$date = substr($message, 0, 21);
$steamId = $steamIdAndIp[0][0];
$playerIp = $steamIdAndIp[0][1];
$playerName = $playerNameAndMessage[1][0];
$playerNameWithMeta = $playerNameAndMessage[0][0];
$playerMessage = $playerNameAndMessage[1][1];
$passwordSecret = '';
if (substr_compare($playerMessage, '!', 0, strlen('!')) === 0) {
continue;
}
if (substr_compare($playerMessage, '/', 0, strlen('/')) === 0) {
continue;
}
echo "<div class=\"chat-row\">";
if ($password === $passwordSecret) {
echo "<span>";
echo ($steamId);
echo " | ";
echo ($playerIp);
echo "&nbsp;&nbsp;";
echo "</span>";
}
if (strpos($playerNameWithMeta, 'red') !== false) {
echo "<span class=\"player-name-red\">";
echo htmlspecialchars($playerName);
echo "</span>";
} else if (strpos($playerNameWithMeta, 'blue') !== false) {
echo "<span class=\"player-name-blue\">";
echo htmlspecialchars($playerName);
echo "</span>";
} else if (strpos($playerNameWithMeta, 'gray') !== false) {
echo "<span class=\"player-name-yellow\">";
echo htmlspecialchars($playerName);
echo "</span>";
}
echo " : ";
echo "<span class=\"player-message\" title=\"";
echo $date;
echo "\">";
echo htmlspecialchars($playerMessage);
echo "</div>";
}
?>
<!-- Return to Top -->
<a href="javascript:" id="return-to-top">
<i class="icon-chevron-up"></i>
</a>
<a href="javascript:" id="return-to-bottom">
<i class="icon-chevron-down"></i>
</a>
<script>
// ===== Scroll to Top ====
$(window).scroll(() => {
if ($(this).scrollTop() >= 300) { // If page is scrolled more than 50px
$('#return-to-top').fadeIn(500) // Fade in the arrow
} else {
$('#return-to-top').fadeOut(500) // Else fade out the arrow
}
})
$('#return-to-top').click(() => { // When arrow is clicked
$('body, html').animate({
scrollTop: 0 // Scroll to top of body
}, 500)
})
// ===== Scroll to Bottom ====
let height = $(document).height()
let maxScrollBottom = height - $(window).height()
$(window).scroll(() => {
if ($(this).scrollTop() == maxScrollBottom) {
$('#return-to-bottom').fadeOut(500)
} else {
$('#return-to-bottom').fadeIn(500)
}
})
$('#return-to-bottom').click(() => {
$('html, body').animate({
scrollTop: height
}, 700)
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.