Scratch made Roster/DB connection

Applications/Tools written to make running DarkStar easier for the rest of us.
Post Reply
User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Scratch made Roster/DB connection

Post by tagban » Sat Oct 19, 2013 6:28 pm

Just started working on this. Could NEVER get the other one to work, so finally gave in, and sat down to learn some basic PHP SQL all over again (its been 10~years since I ever used it..and even then was basic)

This seems to work fine, obviously this is just an output, and can be modified like crazy, can add more info to it, etc. Its fairly easy to tweak once its setup. Enjoy!

Code: Select all

<?php
//use 127.0.0.1 if hosted on same server as ffxi server
//for databasename, by default if you followed instructions, is dspdb
	mysql_connect("yourdatabaseip", "dbusername", "dbpassword") or die(mysql_error());
	mysql_select_db("databasename") or die(mysql_error());
		$query = "SELECT chars.charid, chars.charname, accounts_sessions.charid, zone_settings.zoneid, zone_settings.name, chars.pos_zone FROM accounts_sessions, chars, zone_settings WHERE accounts_sessions.charid = chars.charid AND zone_settings.zoneid = chars.pos_zone";
	 
		$result = mysql_query($query) or die(mysql_error());


		// Print out the contents of each row into a table 
		while($row = mysql_fetch_array($result)){
			echo $row['charname']. " - ". $row['name'];
			echo "<br />";
		}	

?>
The above is for players online, and what zone they're in. THis is EXTREMELY basic but can be built on quite a bit (as I plan to). Another example of this type of connection, which obviously DSP already planned on with the Audit_CHAT function, and could be modified if you dig into the C Headers for yell/shout/etc.

Code: Select all

<?php
	mysql_connect("SERVERIP", "SQLUSER", "SQLPASS") or die(mysql_error());
	mysql_select_db("DATABASENAME") or die(mysql_error());
		$query = "SELECT * FROM audit_chat";
	 
		$result = mysql_query($query) or die(mysql_error());


		// Print out the contents of each row into a table 
		while($row = mysql_fetch_array($result)){
			echo $row['datetime'] . " : " . $row['speaker']. " - ". $row['message'] ." - (" . $row['type'] .")";
			echo "<br />";
		}	

?>
Obviously a stupid sample of really simple code, but more of a proof of concept. Both are live on my site:

http://bnet.cc/ffxi/index.php -- Users Online
http://bnet.cc/ffxi/chat.php -- Chat (Audits only Yell/Shouts for now, manually modified the rest to not display here as I was worried about ballooning the database. Could easily add a script to this to go into the database and delete anything older than say.. 5 days? But thats future. :)

Best Regards,
Tagban

ryce
Posts: 9
Joined: Thu Jul 04, 2013 9:54 am

Re: Scratch made Roster/DB connection

Post by ryce » Fri Nov 15, 2013 9:47 am

Thank you for this. I've been wanting to create a web interface for my server, and this looks like a good place to start. I'm less interested in showing current active status - I've set up some "achievements" for my players (killing certain NMs, finishing certain missions, etc), and I'd like a web app to display that information for others to see. I'll share my implementation if I ever get around to it.

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Scratch made Roster/DB connection

Post by tagban » Wed Dec 04, 2013 5:22 am

Sure. This is extremely basic, but I found it works better than some of the other ones out there, so I've opted to use it.

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Scratch made Roster/DB connection

Post by tagban » Wed Apr 02, 2014 1:54 pm

Decided to update this. Mainly got sick of having a disconnect from my website and my server info. This can be modified to grab any data from the SQL, mainly what you'll see here is an example, which makes it really easy to customize/modify to what you want.

Example: http://www.bnet.cc/ffxi/

Each file for Chat(say), and Online (users), is separate, so you can easily include them elsewhere, image files are included (Height of 12 to match font size), should be pretty simple to integrate if you already have PHP working on a server, make sure your FFXI server and Router (if you host from home) are allowing port 3306 (if you didn't change the default SQL port)

For Chat features, you must edit your CONF files to allow for audit_say, and audit_chat as on. Currently, Yell/Shout/Linkshell don't appear to audit properly (but I'm sure that will be fixed momentarily, and then the script can EASILY be modified to include, or only show, one of those.

Enjoy!
Attachments
FFXI Basic.zip
(8.07 KiB) Downloaded 241 times

Post Reply