Realtime Web Site Server Info

TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
edited December 2012 in Modding
<div class="IPBDescription">PHP Script with player list, server info, etc.</div>Features:

2 modes of operation:
1. Display server info (name, map, performance, time on map, total players, marines, aliens, steam CONNECT NOW link, etc.)
2. Display formatted player list (Pop-up with formatted list of players shows, teams, commanders, name, score, kills and ping, rr players, spectators, etc. ).

CSS driven (embedded in page)
You can fully edit the CSS, change colors, fonts, backgrounds, widths, heights, link styles, etc.
Supports standard or digest authentication.

Setup requires very little time and it's done by adding the following code to your web site to load the script:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><iframe src="http://www.yoursite.com/scriptname.php?view=server" frameborder="0" scrolling="no" width="258" height="235"></iframe><!--c2--></div><!--ec2-->

UPDATE: To see it in action: <a href="http://www.nationalgaming.org" target="_blank">http://www.nationalgaming.org</a> -> Look on the right side of the page!

Make sure to click "View Players" at the bottom to see the list. (hopefully someone's on haha).

Best way to see how easy it is to setup, here's the file header:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->//*     ===========================================================================
==============
    
    Natural Selection 2 Server Information Box and Pop-up Player List

    Developed by: TechnIckS - www.nationalgaming.org
    Contact email: ***censored for forums***
    
    You are free to use this software as you wish, as long as proper credit is given.
    By using this script, either original or modified, I (TechnIckS) am not to be held
    liable for anything that might go wrong. This script is offered without warranty
    of any kind.
    
    ===========================================================================
==============

    Quick start guide:
    
    Start by editing variables in the "START USER SETTINGS" section.
    
    $LOGINURL is the admin interface address. Make sure you include the port! (www.yoursite.com:1234)
    $username and $password are for your user interface.
    $server_address is the "connect to" address of the server. This may be a domain or an IP Address.
    $server_port is the port players use to connect to. Default is 27015.
    $max_players set the maximum players your server supports. I'm still trying to find a way to extract this automatically but the web interface doesn't return it in the default file.
    $use_digest_output needs to be set to TRUE if using digest authentication, FALSE otherwise. See dedicated server wiki for more info on web authentication.
    $box_height and $box_width are the sizes of the box that will be generated when embeding the script in your page. These are the same dimensions you define in your html <iframe> tab. See a few rows down how to embed in your page.
    $link_to_page should NOT be edited UNLESS your PHP does not return the page to current URL successfuly.
    
    That's it with the settings!
    
    Now copy the file (THIS FILE YOU ARE READING NOW) to a public HTML location accessible from the web.
    
    TO embed in a page use the following code, and make sure the URL is correct. Edit arguments as necessary:
    
    <iframe src="http://www.myserver.com/thisfile.php?view=server" frameborder="0" scrolling="no" width="258" height="235"></iframe>
    

    Finally, if you want to make multiple boxes, simply make multiple copies of the file and adjust server settings in each file.
    Duplicate the <iframe> code for each file as well.    
    
*/<!--c2--></div><!--ec2-->


And finally, download here:

<a href="http://www.nationalgaming.org/php_server_info.zip" target="_blank">http://www.nationalgaming.org/php_server_info.zip</a>


Enjoy, and as usual, any questions are welcome!

12-8-12 UPDATE: Edited instructions to avoid preg_split errors. Updated zip file to latest version.

Comments

  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    Also added a refresh and close links at the bottom of the player list.
  • RothgarRothgar Join Date: 2009-11-13 Member: 69372Members
    It would be nice if there was an Open Source Project or similar and centralized (Single Host) for running the Serverlist

    <a href="http://ns2servers.devicenull.org/index.php" target="_blank">http://ns2servers.devicenull.org/index.php</a>

    That one from Devicenull is good but having some basic information sometimes rather than graphs is a nice addition.
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    Well the main reason I made the script is because I could not find a way to pull players using any other method.

    Tonight ill be wrapping up the formatting and I'm adding ready room and spectators to the player list. Once its done I'm releasing the source.

    Soon ill be adding an optional feature to work together with my other script (forum-game link) that will show connected admins, vips etc.
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    Well i thought i'd be done today, but code cleanup took forever.

    Completed formatting, cleaned up code, embedded in a sample page, moved all user-defined variables at the top, verified functionality on: full server, active server, loading server, empty server.

    To do:
    1. add the how-to :) - hopefully done by tomorrow night sometime.
    2. release code!
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
  • SoulfighterSoulfighter Join Date: 2012-11-05 Member: 167432Members
    Thank you very much for this script, it works great but i had to delete the "link to this page" part because it returned me this error:

    Warning: preg_split(): Compilation failed: nothing to repeat at offset 0 in C:\xampp\htdocs\OMG\server_info.php on line 68
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    edited December 2012
    Did you follow my instructions (see below) or did you do something else?
    Please let me know in case I need to update the instructions.

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->//Link to this page (make sure to use full URL) - DO NOT MODIFY UNLESS THE "VIEW PLAYERS" LINK DOES NOT WORK. If it doesn't work, make $link_to_page = "http://www.yourserver.com/thispage.php";

    $this_page = preg_split( "/?/", $_SERVER["REQUEST_URI"]);
    $link_to_page = $this_page[0];<!--c2--></div><!--ec2-->

    What is the exact modification you did?

    Basically preg_split takes the current page url and divides it at the "?", then takes the first half of the link, basically the url without the ? after it and stores it in $this_page.

    What are the two variables above in your page set to?
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    I figured it out. If $_SERVER["REQUEST_URI"] doesnt work on your site it errors it out when preg_split is trying to run. (either no results or invalid variable passed).
    Therefore, if you type $link_to_page manually, you MUST comment out $this_page line so it won't even run.

    Removing it should not cause any problems either.
  • SoulfighterSoulfighter Join Date: 2012-11-05 Member: 167432Members
    edited December 2012
    i did not modify these 2 lines but it still printed this error (everything else worked fine)

    great code though, it works like a charm ! thanks again :)
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    I'm planning on adding a chat ability where you can talk to players on the server.

    However, I'd like some ideas on to how to proceed in order to avoid spam.
    Some sort of user system? Maybe a permission based forum linked system (I.e. If user is part of x group on the forums allow ability to chat)? Or a secret password or something?

    I'm open to suggestions. Let me know your ideas!
  • HarK0nNeNHarK0nNeN Join Date: 2012-11-20 Member: 172666Members
    <!--quoteo(post=2042980:date=Dec 10 2012, 09:04 AM:name=wireaudio)--><div class='quotetop'>QUOTE (wireaudio @ Dec 10 2012, 09:04 AM) <a href="index.php?act=findpost&pid=2042980"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I'm planning on adding a chat ability where you can talk to players on the server.

    However, I'd like some ideas on to how to proceed in order to avoid spam.
    Some sort of user system? Maybe a permission based forum linked system (I.e. If user is part of x group on the forums allow ability to chat)? Or a secret password or something?

    I'm open to suggestions. Let me know your ideas!<!--QuoteEnd--></div><!--QuoteEEnd-->

    Love the idea, hopefully will implement and test it out :)

    In regards to chat system, fairly good idea, i mean sure can integrate a registered user option. Possibly add a particular "rank" on the forum board before posting such as if a person had just sign up just to chat, they have to meet certain post requirements before using the chat feature, like 10 posts, have to post in particular thread etc. Also might want to add anti-flooding detection such as a buffer before sending to RCON to prevent like trolololol comments and what not. Timer inactivity?

    Just my 2cents! ^_^
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    That's a great idea.
    I'm also going to implement is to automatically use person's name in the chat, and limit max sentance length to however much server can take.
    Also, im working on a logging feature so all chat will be logged to a database (only web-> server chat, not server->web). Optional off course, but hightly recommended. This way you can track people if they spam.

    I'll start with IP Board first since that's what we use and i'll add PHPbb3 support as well (currently wrapping up phpbb3->game server admin management - see my other thread if interested).

    Are there any other forum systems anyone might be interested in?

    Honestly, i'd love to make a server to server chat. Basically if someone types a chat command with a ! in front (i.e. ! How's everyone doing?) it will send that to all servers. (We have 2 servers and 2-4 more coming soon). I think that would be awesome!
  • HarK0nNeNHarK0nNeN Join Date: 2012-11-20 Member: 172666Members
    edited December 2012
    <!--quoteo(post=2043392:date=Dec 10 2012, 09:26 PM:name=wireaudio)--><div class='quotetop'>QUOTE (wireaudio @ Dec 10 2012, 09:26 PM) <a href="index.php?act=findpost&pid=2043392"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->That's a great idea.
    I'm also going to implement is to automatically use person's name in the chat, and limit max sentance length to however much server can take.
    Also, im working on a logging feature so all chat will be logged to a database (only web-> server chat, not server->web). Optional off course, but hightly recommended. This way you can track people if they spam.

    I'll start with IP Board first since that's what we use and i'll add PHPbb3 support as well (currently wrapping up phpbb3->game server admin management - see my other thread if interested).

    Are there any other forum systems anyone might be interested in?

    Honestly, i'd love to make a server to server chat. Basically if someone types a chat command with a ! in front (i.e. ! How's everyone doing?) it will send that to all servers. (We have 2 servers and 2-4 more coming soon). I think that would be awesome!<!--QuoteEnd--></div><!--QuoteEEnd-->

    The logging is good should be mandatory especially for admins to back track records for proof/banning purposes. I mean, servers should have MOTD saying they shouldn't be doing anything to breech code of conduct and that chat will be monitored. That is just an opinion.

    *its okay im blind didn't realise you add IP board there*

    Also, I feel you don't want to add "too" much features for the chat I mean sure its just harmless chatting right, but its like how much text do you really want to fill up the screen with. For reference, this isn't like World of Warcraft where you can have cross realm teams playing each other or even talking to each other in that fact. I think keep the script simple first and see how things go then develop from there, might not even need the server to server feature as I think will cause more issues then it really is or not be used at all.
  • TechnIckSTechnIckS Join Date: 2007-01-14 Member: 59616Members
    hit a few roadblocks but I'm still working on it! it's very difficult to work backwards from devicenull's code for the web interface...
Sign In or Register to comment.