Inactive [INFO/WEB] Netstats v5.0.4 - Keeps track of player playtime and online status [RB 1.1-R3]

Discussion in 'Inactive/Unsupported Plugins' started by Valrix, Feb 13, 2011.

  1. Offline

    Valrix

    Netstats v5:
    COMPLETE!
    Keep up with development in BukkitDev!
    Netstats - Player Monitoring Plugin:
    Plugin Version: v5.0
    Web Version: v3.0

    Netstats watches players as they join and leave the server and keeps track of how long they've been logged into the server as well as keeping track of their current online/offline status while using very little system resources. The information is stored in a database which is defined by the user. First time using Netstats it will create the config file then disable itself until you change the config to match your database. Then you can reload or restart the server and it'll start collecting information immediately.
    Source Code: Netstats

    OLD CHANGELOG (open)

    Version 4.7
    • Bug fixes
    • If you don't supply a "database" in the config it will attempt to make it's own database named "NetStats" then create the table "netstats" inside it.
    • Fixed repetitive code and unnecessary MySQL connections when doing multiple queries one-after-another (reduces database calls, speeds up the code, and uses less resources).
    • Reduced code complexity (simplified certain calls and removed hacky functions to improve code performance by around 5-10% in my tests)
    Version 4.6
    • Fixed the bug that happened when trying to change the name of your stats table.
    • Fixed the bug that messed up everyone's total play time (sorry)
    • Code improvements and uses less code for database calls
    Version 4.5
    • Fixed the bug where folders weren't being made.
    Version 4.4
    • Converts the total play time to be saved as seconds instead of milliseconds to increase maximum play time. This will now match the PHP code, so if you changed it, change it back.
    • Now disables and re-enables itself instead of reloading the server when doing a wipe
    • Some code improvements
    Version 4.3
    • No longer requires the /lib/ folder since CB already contains the needed drivers
    • v5 is close to being ready and will bring large speed improvements
    Version 4.2
    • Fixes the bug that creates .stats folders instead of files.
    Version 4.1
    • Many code improvements to improve speed and memory usage.
    • Thanks to @jascotty2 for the code to fix how player and mob kills are handled
    Version 4.0
    • Many bug fixes
    • Changed how total play time was saved to the database
    • Fixed a bug with timed events
    • A new and improved Web update is nearly finished
    Version 3.9
    • Should work with RB 617
    Version 3.8
    • Fixed an issue with how files were handled.
    Version 3.7
    • Fixes issue of logged-in users being shown as offline after a reload
    • Fixed file creation bug where .stat files weren't being made properly
    Version 3.6
    • Fixed a bug where, depending on your region, your IP address was logged twice in the database. This was more of an issue with how the IP address was being grabbed than a problem with how it was stored.
    • Few other small fixes to prevent possible future bugs.
    Version 3.5
    • Changed how paths are managed by the plugin to be more OS-independent, hopefully fixing all "file not found" errors.
    • Removed checking if a database password exists or not.
    Version 3.4
    • Improved error logger that create a special log file with the exact info I'll need to find out what caused the problem.
    • Numerous bug fixes and speed tweaks
    Version 3.3
    • Added tracking of distance traveled
    • Added tracking of number of monsters a player has killed
    • Added tracking of number of other players a player has killed
    • Added the date of when the player first joined the server (after this version of Netstats has been installed, will only be correct after a full wipe of other stats)
    • Database will auto-build if it doesn't exist, otherwise it'll add columns if they're needed (so you don't have to do anything to update your database)
    • Config file now auto-updates and allows for comments (they need their own line however)
    • Many other code improvements and fixes to help it run faster and more efficiently.
    Version 3.2
    • Fixed the problem with saving to the database that everyone's been getting. (Only need the JAR)
    Version 3.1
    • Changed the namespace to com.sparkedia.valrix since I did the Java bit.
    Version 3.0
    • Rebuild of v1 to be more efficient.
    • Customized tracking based on "true" or "false"
    • What you don't want tracked won't be watched which improves performance
    • Timed updates (default is 90 seconds)
    • Fixed updating based on total actions user has done (default is 32)
    • Numerous performance tweaks
    • A "pretty" config file
    • Improved web script performance and added customized tracking (make it match your main config, variables are named the same for simplicity)
    • Web view tells when a player is still online and makes their name green if online, red if offline
    • Uses the "hybrid" method of player data saving like v1 to put less strain on the database
    • When saving to a database it is done dynamically so that only changed things are saved to cut down on the code needed and make smaller, faster calls to the database when saving (this was a big improvement on all previous versions)
    • Table name has been changed to "netstats" to not conflict with any other tables
    • NOTICE: You will need to remove your old data since it is outdated and the table is named differently with a few field name changes so make sure to use the .sql file to add it to your database. Please, before complaining about losing all the old data, realize that there's a 99% chance that it's wrong.
    Version 2.0
    • Complete revamp!
    • Now uses only flatfiles to store data, no more database issues!
    • Lots of code removed and improved for faster speed and less resource use
    • Customizable timed updates (default is every 30 seconds)
    • Customized tracking also reduces resource use by registering (or not registering) events as per your config so it only watches events that you want it to.
    • Web script will search for your CraftBukkit server when you first look at the web page.
    • You can choose where the server will save every player's .stats file by setting the "path" option in the config. The path is relative to your main server folder (where the world folder should be at). So if you set "path=../players/" then the .stats files will be in a folder called "players" in the folder that your server is in.
    • Table of player data is built depending on what your tracking and will change as you change the Netstats config file, nice and easy!
    • There are a few rules to setting paths that are listed above, make sure to read them!
    Version 1.8
    • Various code fixes and changes to improve how it runs.
    • Creates a new blank config file if it can't find one.
    • Only JAR has been changed. Get the newest one above, which I'll just reference from now on since it's faster than posting the same link over and over again.
    Version 1.7
    • Changed how files are accessed which should fix the "Too many files open" bug on Linux machines. Update the [JAR]
    Version 1.6
    • Hopefully fixed bug with connecting multiple times to a property file for each user. Only [JAR] needs updating.
    Version 1.5
    • Fixed a critical bug where user property files (where it saved your data before moving it to the database) wasn't re-defined when the plugin was reloaded. Now it looks for it after everything you do to make sure your data is always being recorded. Only the [JAR] needs to be updated.
    Version 1.4
    • Updated the files to work with the new constructor. You'll need only the [JAR] for this update.
    Version 1.3
    • Fixed a bug with how the plugin saves user data after a server crash
    • Added an Update.sql to add new columns to database table [Web.zip] (only for those upgrading from v1.2)
    Version 1.2
    • Added tracking of blocks broken
    • Added tracking of blocks placed
    • Added tracking of player deaths
    • Added more frequent tracking of total time online
    • Implemented new "safety" storage system
    • New storage system reduces number of database calls
    • Improved the way data is stored to database to take less code
    • The table of data is now ordered by who is online
    Version 1.1
    • Added tracking of player's last used IP address
    Version 1.0
    • Release of Netstats
    WEB CHANGELOG (open)

    Version 2.1
    • Some code cleanup and fixes as well as a better auto-updater that makes sure that the updater is the latest version before doing the actual update process.
    • Localization support for 7 different languages.
    • File name changes to be more netstats-specific which will prevent clashes of CSS and other pages.
    • Better include() and require() calls so a page is only added once which speeds up all the pages and keeps them from destroying each other.
    Version 2.0
    • Improved layout
    • Automatic code updates
    Version 1.0
    • Initial release of web code

    Donations: Don't forget to give amd3th some love too since he helped in making Netstats and came up with the idea (you rock!) as well as @marshall007 since he's been awesome by helping me in his spare time.
     
    Phaedrus, Niemand, D-Lew and 5 others like this.
  2. your welcome i made a css file for all who maybe wanna make diffrent colours without going into the php file so easy edit the css file in the zip
     
  3. Offline

    nakashimakun

    Hehe thanks. Heres how im using it.

    http://94.76.234.218/

    Thought it look snazzy on a page like that ;)
     
  4. Yeah looks cool i find the way you changed "Online" to "Now Playing" totaly great, well i have some more ideas to make it look mor nice, just i need more time cos im not that good in PHP :D
     
  5. Offline

    nakashimakun

    That page on mine isn't php it's just html I just put a php include in and changed the file tyle from html to php and it works fine. That page is pretty much 99% html code (+ css)
     
  6. oh ok, sorry :D but i have a tiny offtopic how oyu made that map?
     
  7. Offline

    Valrix

    Nice job. I don't mind at all. amdeth is the one who did the PHP and I don't think he'd mind since it's just a css edit. Plus the source to everything we made is fully available anyway.
     
  8. Offline

    nakashimakun

    @ItsCriminal. It's another plugin Dynmap

    @Vlrix
    If you want check http://94.76.234.218/ out you can offer them that whole page I can give you all the files for it. as for some people coding a page for it to display within can be a be horrifying.
     
  9. Offline

    Valrix

    It's alright, the css isn't hard at all and if I was bored enough I'd style the table myself, but then that would take away all the work from amdeth and I already told him he would be in charge of the web stuff.
     
  10. Offline

    nakashimakun

    Fair enough it was just a small offer.

    what you going to be added to this plugin? anything like block stats and stuff. Would you make it a fully fledged stats plugin?
     
  11. Offline

    Valrix

    As far as I currently see it, I think it should stay as it is because it wasn't really thought up with that in mind, but like I said before if enough people ask for the same thing then I might add it when things get more stable.
     
  12. Offline

    Bronski

    I got an error in the browser because a semi-colon was missing from this line in get.php (around 80):

    echo "<tr>";

    I'll let you know how it goes when I get a chance to restart the MC server though :D

    Edit: Oh, just to confirm, the sql makes a table called 'players', but the config.php file has:

    $mysql_table = 'TABLE';

    I should change that to 'players' as well, yes?
     
  13. yes you have to change it to 'players'
     
  14. Offline

    Valrix

    The config is a template that you change to fit your database as needed.
     
  15. @Valrix in the get.php you forgot a ; at line 80 after echo "<tr>" so it shoud be:

     
  16. Offline

    Bronski

    That's what I said *bonk* :p

    Thanks for the other tip. Seems to work fine :)
     
  17. i think i jump over that, sorry for that.
     
  18. Offline

    Bronski

    No worries!
     
  19. Offline

    Valrix

    Hey now, don't blame me for the PHP :p, I only wrote the Java.
     
  20. i forgot to say my first uploaded zip was for 1.0
    but now i made a custom of 1.1

    + becouse of the better php file now i got easier true it and commented all i changed :) ( i get totaly into it xD )
    ++ nakashimakun gave me some inspiration, so i added a background to it and swaped Online to Now Playing

    demo: http://sapphira.org/page/?page_id=326

    File is attached and credits stay to Jdev19
     
  21. Offline

    amd3th

    Thanks didn't notice the missing ; it's easy to look over those things especially when no errors pop up from it.
     
  22. Offline

    wolfen

    hi guys,

    just wanted to use this plugin on my server and i keep getting this error message:
    "[Netstats]: Could not set data for mysql: java.sql.SQLException: invalid database address: jdbc:mysql://62.141.38.146/netstats"

    anybody also had this issue?

    thanks in advance

    regards,
     
  23. first of all is your mysql database made and you uploaded the netstats.sql into the database so the tables are created?
    seconde, did you made all edit on the config.php?
     
  24. Offline

    wolfen

    yes of course,database is all setup, with all the needed tables and the configs have the correct values.

    is it possible, that my minecraft server (which is running debian) is missing the jdbc package?

    regards,

    EDIT: Ok it works now, it was a problem with the sql user.
     
  25. Offline

    nakashimakun

    Well I was thinking since its a netstats plugin I do think adding in like how many blocks you dug out and placed would be cool to know.

    But great job with the plugin and glad I could offer you some inspration ItsCriminal
     
  26. Offline

    AreLam

    I notice the playtime doesn't get updated unless the player logs out of the server. Is it possible to have it update on a regular basis as well?

    That being said, in the event of a crash (server side) the values won't get changed at all.

    Thanks for the small plugin ^^
     
  27. Offline

    Valrix

    Haha, seems like more people than I thought want how many blocks were dug out and placed. Well, I think I may add it after all along with the number of deaths, but it will come with a warning that with all the events firing it has potential to slow down your server if a lot of users are building, mining, etc. at the same time since each of those events will do a database call. Though I still need to improve the script a bit and I may come up with a way to temporarily store user data to a flat file until they rack up a total of 50-100 actions (not sure exactly how much yet). Meaning each user will have a ".stat" file that will record the number of blocks broken, placed, and how long they've been in until they reach a total of 100 blocks placed and broken; then the data will be written to the database. This will ensure that the data is kept safe even if the server crashes. This also helps keep from having it save after time-based events which is a lot easier on the server.

    Recap:
    1. I will be adding an improved save function to ensure better data saving.
    2. Block break/place will be added to stat list.
    3. Player data is saved based on their activity (more active = more saves).
    4. Code will be shrunk to be slightly faster to reduce server stress. (Even if the code is already 99% lean)

    Hopefully this is satisfactory for everyone. :)
     
  28. Offline

    AreLam

    You could always make the action number a config option :)

    Looking forward to next release!

    Edit:
    Could you make the plugin reset the online status (of users) when the server is started? After a crash it's not that fun to see people who aren't online set to online in the database :p
     
  29. Offline

    maxsteele

    Alright, I have the plugin installed. I have the config.txt all set up:
    Code:
    #Minecraft Properties File
    #Tue Feb 08 08:49:41 PST 2011
    host=localhost
    database=netstats
    username=root
    password=XXXXXXXX
    I have looked at my netstats database in phpmyadmin and it has player entries.

    I have a directory called netstats in /var/www/ . The full path is /var/www/netstats/ . That is where I have the php files.

    Here is my config.php file:
    Code:
    <?php
    /* ----------------------------------------------
    File Created by Josh Devecka(Jdev19)
    You may use the code as you wish,
    but please give me some credit.
    ------------------------------------------------- */
    $mysql_host = 'localhost';
    $mysql_user = 'root';
    $mysql_pass = 'XXXXXXXXXX';
    $mysql_db = 'netstats';
    $mysql_table = 'TABLE';
    ?>
    When I go to http://craftersrealm.com/netstats/get.php , I get:

    "The website cannot display the page".

    Any ideas?
     
  30. Offline

    amd3th

    @maxsteele "The website cannot display the page" shouldn't be coming from the PHP code but if it is since Err. 500 is kind of a catch all for Apache, it might be. I notice that you have the $mysql_table = 'TABLE'; still set as the default. Is the name of the table in your database actually TABLE? otherwise you'll need to change that. I don't know if it will fix the Internal Server Error, but it's definitely worth looking at.
     
  31. Offline

    maxsteele

    Looking at the database, it looks like there's only one table, named players. I'll edit that now.

    EDIT:

    I edited that and it's still giving the HTTP 500 error. I'm using the default get.php file. I'll paste it here though so you can take a look:
    Code:
    <?php
    /* ----------------------------------------------
    File Created by Josh Devecka(Jdev19)
    You may use the code as you wish,
    but please give me some credit.
    -------------------------------------------------*/
    
    include("config.php");
    
    date_default_timezone_set(date_default_timezone_get());
    
    mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die (mysql_error());
    mysql_select_db($mysql_db) or die (mysql_error());
    
    $res = mysql_query("SELECT * from $mysql_table");
    
    //Start Table
    echo "<table border ='1'>";
    echo "<tr><th width=192px>Name</th>";
    echo "<th width=130px>Last Login</th>";
    echo "<th width=130px>Last Seen</th>";
    echo "<th width=80px>Play Time</th>";
    echo "<th width=50px>Status</th>";
    /* Uncomment (remove //) to include Player IP in table, scroll down and uncomment below as well. */
    //echo "<th>Player IP</th>";
    echo "</tr>";
    
    while($row = mysql_fetch_array($res)){
            $name = $row['name'];
            $login = $row['enter'];
            $logout = $row['logout'];
            $total = $row['total'];
            $status = $row['status'];
        $ip = $row['ip'];
    
    //Gather milliseconds from timestamp and convert to human readable time
    $inSeconds = $login / 1000;
    $inDate = date("D M/d G:i", $inSeconds);
    
    $outSeconds = $logout / 1000;
    $outDate = date("D M/d G:i", $outSeconds);
    
    //Convert Total Playtime into readable time.
    $total = floor($total / 1000);
    $seconds = $total % 60;
    
    $total = floor($total / 60);
    $minutes = $total % 60;
    
    $total = floor($total / 60);
    $hours = $total % 24;
    
    //calculate how long ago player was on
    $etime = time() * 1000;
    $ago = ($etime - $logout);
    
    $ago = floor($ago /1000);
    $psec = $ago % 60;
    
    $ago = floor($ago /60);
    $pmin = $ago % 60;
    
    $ago = floor($ago / 60);
    $phr = $ago %24;
    
    $ago = floor($ago / 24);
    $pday = $ago %24;
    
    $longago = $pday . "d " . $phr . "h " . $pmin . "m " . $psec . "s";
    
    //put in readable format
    $playtime = $hours . "h " . $minutes . "m " . $seconds . "s";
    
    if($status == 1){
        $status2 = "Online";
        } else {
        $status2 = "Offline";
        }
    echo "<tr>"
    echo "<td>" . $name . "</td>";
    echo "<td>" . $inDate . "</td>";
    echo "<td>" . $longago . " ago</td>";
    echo "<td>" . $playtime . "</td>";
    echo "<td>" . $status2 . "</td>";
    /* Uncomment line below to include IP data in table */
    //echo "<td>" . $ip . "</td>";
    echo "</tr>";
    }
    
    echo "</table>";
    ?>
    I don't know anything about php. But this is the get.php that comes with the whole plugin package, so if there's an error, it's part of the release.

    I also know that php is working, because I have phpBB3 all set up. :)
     

Share This Page