Raised This Month: $12 Target: $400
 3% 

ChatLog v1.3.7 (Extended)


Post New Thread Reply   
 
Thread Tools Display Modes
Simca
Senior Member
Join Date: Feb 2012
Old 05-16-2015 , 03:49   Re: ChatLog v1.3.7 (Extended)
Reply With Quote #181

Hi how do i get it to show steamid? I tried doing what u said but couldn't figure it out.

Code:
<?php
/*
 * =============================================================================
 * SourceMod Extended ChatLog v1.3.5 WebUI Example
 * Reads a chatlog database for sourcemod and prints the sauce, in ajaxxx!
 *
 * (C)2009 [email protected]
 * =============================================================================
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
*/

//
// This is a SIMPLE example. Modify it as you wish. Keep in mind that it is GPL
// Licensed.
//
$START_ROWS = 100; // How many lines of chat we should display to start.

// $DB_HOST [$DB_PORT] $DB_USER $DB_PASS $DB_DATABASE
$DB_HOST = "";
$DB_PORT = "3306";
$DB_USER = "";
$DB_PASS = "";
$DB_DATABASE = "";

// Gives a nicer back-end ID for the javascript.
function cleanId($in)
{
	return preg_replace("/[^0-9a-zA-Z]/", "_", $in);
}
function formatRow($R)
{
	$class;
	if ($R['team'] == 3)
		$class = "bluename";
	elseif ($R['team'] == 2)
		$class = "redname";
	elseif ($R['team'] == 10)
		$class = "violetname";
	else
		$class = "greyname";

	$team = "";
	$dead = "";
	$name = $R['name'];
	if($name)
                    $name = htmlspecialchars("(" . $R['steamid'] . ") " . $name, ENT_QUOTES);
	$text = htmlspecialchars($R['text'], ENT_QUOTES);  
	

	if ($R['type'] >= 0)
	{
		if ($R['type'] & 2)
			$team = "[TEAM] ";
		if ($R['type'] & 1)
			$dead = "<span class=\"deadname\">*DEAD*</span> ";

		$name = "$dead<span class=\"$class\">$team$name: </span>";
	}
	else
	{
		if($R['team'] == 10)
		{
			$team = "[ADMIN] ";
			$name = "<span class=\"$class\">$team$name: </span>";
		}
		else
			$text = "<span class=\"servermsg\">$text</span>";
	}



	// Hours modifier
	$hoursmod = 0;

	// http://fi2.php.net/manual/en/function.date.php
	// European timestamp
	//$date = date("j.m.y H:i:s", $R['date'] + ($hoursmod * 3600));
	$date = date("n/j g:i:sa", $R['date'] + ($hoursmod * 3600));
	
	$id = cleanId($R['srvid']);
	return "$id\x01<span class=\"line\"><span class=\"timestamp\">$date </span>$name$text</span><br />";
}

$SQL = @mysql_connect($DB_PORT ? "$DB_HOST:$DB_PORT" : $DB_HOST, $DB_USER, $DB_PASS);
if (!$SQL) die("Failed to connect to MySQL Database");
@mysql_select_db($DB_DATABASE) or die("MySQL Failure: " . mysql_error());

// Set output encoding to UTF-8
mysql_query('SET NAMES utf8', $SQL) or die("MySQL Failure: " . mysql_error());

	if ($mark == -1)
		$Q = "SELECT name,seqid,type,srvid,team,text,UNIX_TIMESTAMP(`date`) AS `date` FROM `chatlogs` ORDER BY `seqid` DESC LIMIT $START_ROWS";
	else
		$Q = "SELECT name,seqid,type,srvid,team,text,UNIX_TIMESTAMP(`date`) AS `date` FROM `chatlogs` WHERE `seqid` > $mark ORDER BY `seqid` DESC";

	$Q = @mysql_query($Q, $SQL) or die("MySQL Failure: " . mysql_error());
	$ar = array();
	$R = mysql_fetch_array($Q);
	if (!$R)
	{
		// No new data, echo same mark back
		echo($mark);
		exit();
	}
	$newmark = $R['seqid'];
	do
	{
		array_push($ar, formatRow($R));
	} while ($R = mysql_fetch_array($Q));
	array_push($ar, $newmark); // Add mark to bottom (top once reversed)
	$ar = array_reverse($ar);// Query selects rows in reverse order, and mark is on bottom
	echo(implode("\n", $ar));
else:
	$Q = "SELECT DISTINCT `srvid` FROM `chatlogs`";
	$Q = @mysql_query($Q, $SQL) or die("MySQL Failure: " . mysql_error());
	$PB = "";
	$PS = "";
	while ($R = mysql_fetch_row($Q))
	{
		$id = cleanId($R[0]);
		$PB .= "<div class=\"dat\">
				<div class=\"dhead\">Server \"$R[0]\"</div>
				<div class=\"dbody\" id=\"dbody_$id\">
					<div class=\"dtext\" id=\"dat_$id\"></div>
					<div id=\"dscrollto_$id\"></div>
				</div>
			</div>\n";
		$PS .= "srvz.push(\"$id\");\n";
	}
	echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>ChatLog Simple WebUI</title>
		<script type="text/javascript" src="./jquery-1.3.min.js"></script>
		<script type="text/javascript">
			var srvz = new Array();
			var mark = -1;
			var loading = 1;
			<?php echo($PS); ?>
			function dead(wat)
			{
				alert("Server side error. Dying:" + wat);
			}
			function cback(data, textStatus)
			{
				if (textStatus == "success")
				{
					var lines = data.split("\n");
					mark = lines[0];
					if (mark + 0 == 0) die(3);
					var line;
					var scrollme = new Array();
					for(var i = 1; i < lines.length; i++)
					{
						line = lines[i].split("\x01");
						// 0 srvid
						// 1 string
						// Formatted serverside
						if ($("#dscrollto_" + line[0]).offset().top <= $("#dbody_" + line[0]).height() + $("#dbody_" + line[0]).offset().top)
							if (!scrollme[line[0]]) scrollme[line[0]] = true;
						if (line.length != 2) return dead("1");
						var box = $("#dat_" + line[0]);
						if (!box) return dead("2");
						for(var j = i + 1; j < lines.length; j++)
						{
							if(lines[j].split("\x01").length != 1) break;
							line[1] += "<br />" + lines[j];
							i = j;
						}
						if (loading)
						{
							box.html(line[1]);
							loading = 0;
						}
						else
						{
							box.append(line[1]);
						}
						box.children(".line:last").fadeIn(500);
					}
					for (var sid in scrollme)
					{
						// Scroll it, thanks to learningjquery.com!
						var divOffset = $("#dbody_" + sid).offset().top;
						var endOffset = $("#dscrollto_" + sid).offset().top;
						var Scroll = endOffset - divOffset;
						$("#dbody_" + sid).animate({scrollTop: '+=' + Scroll + 'px'}, 500);
					}
				}
				window.setTimeout("proc()", 2000);
			}
			function proc()
			{
				$.get("<?php echo($_SERVER["PHP_SELF"]); ?>?mark=" + mark, cback);
			}
		</script>
		<style>
			body
			{
				background-color: #333;
				font-family: verdana, arial;
				font-size: 12px;
			}
			.dat
			{
				border: 1px solid #000;
				background-color: #EEE;
				padding: 10px;
				margin: 10px;
				width: 700px;
				margin-left: auto;
				margin-right: auto;
			}
			.dbody
			{
				height: 250px;
				width: 700px;
				overflow: auto;
			}
			.dhead
			{
				font-weight: bold;
				font-size: 150%;
			}
			.dtext
			{
				padding-left: 7em;
			}
			.line
			{
				position: relative;
				margin-left: -7em;
				display: none;
			}
			.redname
			{
				color: red;
				font-weight: bold;
			}
			.bluename
			{
				color: blue;
				font-weight: bold;
			}
			.greyname
			{
				color: grey;
				font-weight: bold;
			}
			.violetname
			{
				color: #aa00b7;
				font-weight: bold;
			}
			.deadname
			{
				color: grey;
				font-weight: bold;
				font-style: italic;
			}
			.servermsg
			{
				color: grey;
				font-style: italic;
			}
			.timestamp
			{
				font-size: 80%;
				font-color: black;
				font-style: italic;
			}
		</style>
	</head>
	<body onload="javascript:proc()">
	<?php echo($PB); ?>
	</body>
	</html>
<?php endif; ?>
Simca is offline
Schpraaankiii
Veteran Member
Join Date: Dec 2009
Location: Sweden Norrköping
Old 05-17-2015 , 16:42   Re: ChatLog v1.3.7 (Extended)
Reply With Quote #182

Here a small update:
* Added different colorized output messages for steamid, name, text and date/time
* Enlarged fonts and window size
* Removed the [TEAM] prefix (the blue/red color already tells what team players are in)
* Added Search for SteamID, Name and Text

I'm working on a more advance search function where you could specify what servers and what type (name, text or steamid) you want to search for but I'm not so good at PHP :p

EDIT: I've noticed one really wierd issue. The text stored in my DB and my WebUI output does not support swedish chars, even tho the db is set to UTF8 (tried UTF8_swedish and Latin1_swedish). The issue must be somewhere in the .smxx file when sending the date to the DB ... ?
EDIT2 It seams to work now after a server restart. lets se if it lasts...

UPDATE [2015-05-18]
* Fixed all search functions
* Added search for date/time
* Added option to chose what to search for
* Added server id to be shown when accessing logs from search
Attached Thumbnails
Click image for larger version

Name:	index.gif
Views:	452
Size:	50.4 KB
ID:	145088   Click image for larger version

Name:	search.gif
Views:	361
Size:	48.8 KB
ID:	145112  
Attached Files
File Type: zip chatlogex.zip (4.8 KB, 310 views)
__________________
CAOSK-ESPORTS.COM

Last edited by Schpraaankiii; 05-18-2015 at 11:22.
Schpraaankiii is offline
Send a message via Skype™ to Schpraaankiii
Stylee32
AlliedModders Donor
Join Date: Nov 2014
Old 05-22-2015 , 16:34   Re: ChatLog v1.3.7 (Extended)
Reply With Quote #183

Quote:
Originally Posted by Schpraaankiii View Post
Here a small update:
* Added different colorized output messages for steamid, name, text and date/time
* Enlarged fonts and window size
* Removed the [TEAM] prefix (the blue/red color already tells what team players are in)
* Added Search for SteamID, Name and Text

I'm working on a more advance search function where you could specify what servers and what type (name, text or steamid) you want to search for but I'm not so good at PHP :p

EDIT: I've noticed one really wierd issue. The text stored in my DB and my WebUI output does not support swedish chars, even tho the db is set to UTF8 (tried UTF8_swedish and Latin1_swedish). The issue must be somewhere in the .smxx file when sending the date to the DB ... ?
EDIT2 It seams to work now after a server restart. lets se if it lasts...

UPDATE [2015-05-18]
* Fixed all search functions
* Added search for date/time
* Added option to chose what to search for
* Added server id to be shown when accessing logs from search
This is great, could you make it so that the scroll bar stays at the bottom? It doesn't stick with logs coming from 8 servers
Stylee32 is offline
Schpraaankiii
Veteran Member
Join Date: Dec 2009
Location: Sweden Norrköping
Old 05-23-2015 , 14:12   Re: ChatLog v1.3.7 (Extended)
Reply With Quote #184

Quote:
Originally Posted by Stylee32 View Post
This is great, could you make it so that the scroll bar stays at the bottom? It doesn't stick with logs coming from 8 servers
Hm, what do you mean? I scroll bars are fixed on the bottom at my page... Maybe I don't understand you, could you send a picture of something.
__________________
CAOSK-ESPORTS.COM
Schpraaankiii is offline
Send a message via Skype™ to Schpraaankiii
Stylee32
AlliedModders Donor
Join Date: Nov 2014
Old 05-23-2015 , 15:08   Re: ChatLog v1.3.7 (Extended)
Reply With Quote #185

Quote:
Originally Posted by Schpraaankiii View Post
Hm, what do you mean? I scroll bars are fixed on the bottom at my page... Maybe I don't understand you, could you send a picture of something.
It's only when you scroll up, it doesn't stay fixed.
Is it possible to change the order of the servers? I use TEXT ids.

I take that back, I've just refreshed the page and some stay - some don't
At the moment, 1/8 stay fixed at the bottom, the others don't

The scroll bar goes up as the data is coming through.

Last edited by Stylee32; 05-23-2015 at 15:20.
Stylee32 is offline
Parallax83
Junior Member
Join Date: Jun 2015
Old 07-10-2015 , 14:29   Re: ChatLog v1.3.7 (Extended)
Reply With Quote #186

Hello.I put this plug everything works but the logs displays eror how to fix? it please help.

L 07/10/2015 - 21:16:55: [SM] Displaying call stack trace for plugin "chatlogex.smx":
L 07/10/2015 - 21:16:55: [SM] [0] Line 499, /home/forums/content/files/5/2/0/8/2/47687.attach::LogPlayerConnect()
L 07/10/2015 - 21:16:55: [SM] Native "GetEventString" reported: Invalid game event handle 6780660 (error 2)
L 07/10/2015 - 21:16:55: [SM] Displaying call stack trace for plugin "chatlogex.smx":
L 07/10/2015 - 21:16:55: [SM] [0] Line 499, /home/forums/content/files/5/2/0/8/2/47687.attach::LogPlayerConnect()
L 07/10/2015 - 21:256: Error log file session closed.
Parallax83 is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 07-10-2015 , 21:17   Re: ChatLog v1.3.7 (Extended)
Reply With Quote #187

Quote:
Originally Posted by Parallax83 View Post
Hello.I put this plug everything works but the logs displays eror how to fix? it please help.

Code:
L 07/10/2015 - 21:16:55: [SM] Displaying call stack trace for plugin "chatlogex.smx":
L 07/10/2015 - 21:16:55: [SM]   [0]  Line 499, /home/forums/content/files/5/2/0/8/2/47687.attach::LogPlayerConnect()
L 07/10/2015 - 21:16:55: [SM] Native "GetEventString" reported: Invalid game event handle 6780660 (error 2)
L 07/10/2015 - 21:16:55: [SM] Displaying call stack trace for plugin "chatlogex.smx":
L 07/10/2015 - 21:16:55: [SM]   [0]  Line 499, /home/forums/content/files/5/2/0/8/2/47687.attach::LogPlayerConnect()
L 07/10/2015 - 21:25:36: Error log file session closed.
First: Surround your error logs and other "code" into [CODE] tags on the forum to keep the readability!

Next, your issue appears to have be explained in the first post of this thread if you care to read that..
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Parallax83
Junior Member
Join Date: Jun 2015
Old 07-11-2015 , 10:41   Re: ChatLog v1.3.7 (Extended)
Reply With Quote #188

Explain how to make that in a chat would be in Russian? when you write in game.
though there is also a base too in utf-8

PHP Code:
chatlogex.php
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
Parallax83 is offline
Grainz
Junior Member
Join Date: Jan 2016
Old 05-13-2016 , 18:56   Re: ChatLog v1.3.7 (Extended)
Reply With Quote #189

Does this plugin write to the a db in utf8mb4? Some characters do not get saved properly.
Grainz is offline
deville
AlliedModders Donor
Join Date: Oct 2016
Old 01-12-2017 , 06:08   Re: ChatLog v1.3.7 (Extended)
Reply With Quote #190

edit: nvm, fixed

Last edited by deville; 06-01-2017 at 09:25.
deville is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode