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


    Netstats v5:
    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 [] (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. Offline


    If you'd like I can create a variable for you that's a quick call to the database to count the players that way you can just echo the variable instead.
  3. Offline


    oh that works too I guess :)
  4. Offline


    Okay, I've fixed up the locale page to now translate ANY possible text as well as adding some comments to help you understand what changes what on the page. It will also all locale change for the time and allows you to set the time format.

    (LC_TIME'en_US'); # Change to match your appropriate locale
    $locale = array(
    'name'     => 'Name',
    'broken'   => 'Blocks Broken',
    'placed'   => 'Blocks Placed',
    'deaths'   => 'Deaths',
    'mkilled'  => 'Monsters Killed',
    'pkilled'  => 'Players Killed',
    'distance' => 'Distance Traveled',
    'login'    => 'Last Login',
    'seen'     => 'Last Seen',
    'total'    => 'Play Time',
    'plocale'  => 'Player Locale',
    'join'     => 'Join Date',
    'ago'      => 'ago',
    'online'   => 'Currently Online',
    'unseen'   => 'Not yet seen',
    # Your way of writing or spelling "meters".
    'meters'   => 'meters',
    # Commonly recognized time format for your locale
    'date'     => '%a, %b %d %l:%M %p',
    # Abbreviations for years, months, weeks, etc.
    'years'    => 'y',
    'months'   => 'mo',
    'weeks'    => 'w',
    'days'     => 'd',
    'hours'    => 'h',
    'minutes'  => 'm',
    'seconds'  => 's'
    Welcome. I've already made it and to access it you'll just need to do an include on a specific page and that'll include the $playersOnline variable which is the number of players currently online. I'll push out an update in a few. Just need to clean up some code first.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 8, 2016
  5. German Local

    setlocale(LC_TIME, 'de_DE'); # Change to match your appropriate locale
    $locale = array(
        'name'     => 'Name',
        'broken'   => 'Zerstörte Blöcke',
        'placed'   => 'Plazierte Blöcke',
        'deaths'   => 'Tode',
        'mkilled'  => 'Monster getötet',
        'pkilled'  => 'Spieler getötet',
        'distance' => 'Distanz gelaufen',
        'login'    => 'Letzte Anmeldung',
        'seen'     => 'Zuletzt gesehen',
        'total'    => 'Spielzeit',
        'plocale'  => 'Spieler Ort',
        'join'     => 'Anmeldedatum',
        'ago'      => 'vor',
        'online'   => 'Zurzeit Anwesend',
        'unseen'   => 'Noch nicht gesehen',
        # Your way of writing or spelling "meters".
        'meters'   => 'Meter',
        # Commonly recognized time format for your locale
        'date'     => '%a, %b %d %l:%M %p',
        # Abbreviations for years, months, weeks, etc.
        'years'    => 'J',
        'months'   => 'Mo',
        'weeks'    => 'W',
        'days'     => 'T',
        'hours'    => 'St',
        'minutes'  => 'M',
        'seconds'  => 'Sek'
  6. Offline


    Ok, adding that to the supported locales. Thanks :)
  7. Luxembourgish Locals

    (LC_TIME'lu_LU'); # Change to match your appropriate locale
    $locale = array(
    'name'     => 'Numm',
    'broken'   => 'Zersteiert Bleck',
    'placed'   => 'Plazeiert Bleck',
    'deaths'   => 'Gestuerwen',
    'mkilled'  => 'Monster embruet',
    'pkilled'  => 'Spiller embruet',
    'distance' => 'Distanz gelaaf',
    'login'    => 'Lescht Unmeldung',
    'seen'     => 'Virdlescht gesinn',
    'total'    => 'Spillzait',
    'plocale'  => 'Spiller Hierkunft',
    'join'     => 'Unmelungsdatum',
    'ago'      => 'virdrun',
    'online'   => 'Vir de moment Online',
    'unseen'   => 'Nach net gesinn',
    # Your way of writing or spelling "meters".
    'meters'   => 'Meter',
    # Commonly recognized time format for your locale
    'date'     => '%a, %b %d %l:%M %p',
    # Abbreviations for years, months, weeks, etc.
    'years'    => 'J',
    'months'   => 'Mo',
    'weeks'    => 'W',
    'days'     => 'D',
    'hours'    => 'St',
    'minutes'  => 'M',
    'seconds'  => 'Sek'
  8. Offline


  9. Offline


    Had nothing else to do (except everything else) so I translated too..

    Not that I'd ever get the chance to use it on my site..

    Norwegian locale:
    (LC_TIME'no_NO'); # Change to match your appropriate locale
    $locale = array(
    'name'     => 'Navn',
    'broken'   => 'Blokker ødelagt',
    'placed'   => 'Blokker plassert',
    'deaths'   => 'Dødsfall',
    'mkilled'  => 'Monstre drept',
    'pkilled'  => 'Spillere drept',
    'distance' => 'Distanse reist',
    'login'    => 'Siste pålogging',
    'seen'     => 'Sist sett',
    'total'    => 'Spilletid',
    'plocale'  => 'Nasjonalitet',
    'join'     => 'Dato blitt med',
    'ago'      => 'siden',
    'online'   => 'Pålogget',
    'unseen'   => 'Ikke logget av enda',
    # Your way of writing or spelling "meters". Could be trimmed to just "m".
    'meters'   => 'meter',
    # Commonly recognized time format for your locale
    'date'     => '%a, %d %b  %H:%M',
    # Abbreviations for years, months, weeks, etc.
    'years'    => 'år',
    'months'   => 'md',
    'weeks'    => 'uker',
    'days'     => 'd',
    'hours'    => 't',
    'minutes'  => 'm',
    'seconds'  => 's'
    Kinda fixed death translation.. lol
  10. Offline


    I'm still having to work on auto-updating to make sure the updater also updates itself. Not sure why his data would jump that much.
  11. Offline


    I keep getting players with crazy times too
  12. Finnish Locals

    (LC_TIME'fi_FI'); # Change to match your appropriate locale
    $locale = array(
    'name'     => 'Nimi',
    'broken'   => 'Laattoja Rikottu',
    'placed'   => 'Laattoja Korvattu',
    'deaths'   => 'Kuolemia',
    'mkilled'  => 'Monstereita Tapettu',
    'pkilled'  => 'Pelaajia Tapettu',
    'distance' => 'Matkaa Kuljettu',
    'login'    => 'Viimeinen Sisäänkirjautuminen',
    'seen'     => 'Viimeksi Nähty',
    'total'    => 'Pelattu Aika',
    'plocale'  => 'Pelaajan Tapahtumapaikka',
    'join'     => 'Liittymisen Päivä',
    'ago'      => 'Sitten',
    'online'   => 'Online-Tilassa',
    'unseen'   => 'Ei Vielä Nähty',
    # Your way of writing or spelling "meters".
    'meters'   => 'Metriä',
    # Commonly recognized time format for your locale
    'date'     => '%a, %b %d %l:%M %p',
    # Abbreviations for years, months, weeks, etc.
    'years'    => 'Vu',
    'months'   => 'Ku',
    'weeks'    => 'Vi',
    'days'     => 'Pä',
    'hours'    => 'Tu',
    'minutes'  => 'Mi',
    'seconds'  => 'Sek'
    Credit to a good friend
  13. Offline


    Wow, tons of locales already and the updates not even done yet, haha. I'm adding them in as you guys supply them though, so no worries. I'm just fixing a few bugs and it'll be out. I'll try to see what's wrong with the Java too when I get home.
  14. Portuguese Locals

    (LC_TIME'pt_PT'); # Change to match your appropriate locale
    $locale = array(
    'name'     => 'Nome',
    'broken'   => 'Blocos Destruidos',
    'placed'   => 'Blocos Colocados',
    'deaths'   => 'Mortos',
    'mkilled'  => 'Monstro Matado',
    'pkilled'  => 'Jogador Matado',
    'distance' => 'Distancia Corrida',
    'login'    => 'Ultima Noticia',
    'seen'     => 'Ultima Vista',
    'total'    => 'Tempo de jogada',
    'plocale'  => 'Lugar de onde vem',
    'join'     => 'Data de noticia',
    'ago'      => 'Antes',
    'online'   => 'Ainda Apresentado',
    'unseen'   => 'Ainda nao esta visto',
    # Your way of writing or spelling "meters".
    'meters'   => 'Metros',
    # Commonly recognized time format for your locale
    'date'     => '%a, %b %d %l:%M %p',
    # Abbreviations for years, months, weeks, etc.
    'years'    => 'A',
    'months'   => 'M',
    'weeks'    => 'S',
    'days'     => 'D',
    'hours'    => 'H',
    'minutes'  => 'M',
    'seconds'  => 'Sec'
    Locals by André

    frensh locals

    (LC_TIME'fr_FR'); # Change to match your appropriate locale
    $locale = array(
    'name'     => 'Nome',
    'broken'   => 'casser des blocs',
    'placed'   => 'placer des blocs',
    'deaths'   => 'mort',
    'mkilled'  => 'tué un monstre',
    'pkilled'  => 'tué un joueur',
    'distance' => 'distance couru',
    'login'    => 'dernière inscription',
    'seen'     => 'vu en dernier',
    'total'    => 'temps réglementaire',
    'plocale'  => 'origine du joueur',
    'join'     => 'date de connexion',
    'ago'      => 'avant',
    'online'   => 'présentement',
    'unseen'   => 'pas encore vu',
    # Your way of writing or spelling "meters".
    'meters'   => 'mètre',
    # Commonly recognized time format for your locale
    'date'     => '%a, %b %d %l:%M %p',
    # Abbreviations for years, months, weeks, etc.
    'years'    => 'a',
    'months'   => 'm',
    'weeks'    => 's',
    'days'     => 'j',
    'hours'    => 'h',
    'minutes'  => 'min',
    'seconds'  => 'sec'
    credits to Patty

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 8, 2016
  15. Offline


    Correct French (not Google translate lol)

    (LC_TIME'fr_FR'); # Change to match your appropriate locale
    $locale = array(
    'name'     => 'Nom',
    'broken'   => 'Blocs cassés',
    'placed'   => 'Blocs Placés',
    'deaths'   => 'Morts',
    'mkilled'  => 'Monstres Tués',
    'pkilled'  => 'Joueurs Tués',
    'distance' => 'Distance Parcourue',
    'login'    => 'Dernière Connexion',
    'seen'     => 'Vu la Dernière Fois',
    'total'    => 'Temps de Jeu',
    'plocale'  => 'Pays',
    'join'     => "Date d'inscription",
    'ago'      => '',
    'online'   => 'Actuellement Connecté',
    'unseen'   => 'Pas encore vu',
    # Your way of writing or spelling "meters".
    'meters'   => 'mètres',
    # Commonly recognized time format for your locale
    'date'     => '%A %d %B %G à %H:%M',
    # Abbreviations for years, months, weeks, etc.
    'years'    => 'A',
    'months'   => 'mo',
    'weeks'    => 'S',
    'days'     => 'j',
    'hours'    => 'h',
    'minutes'  => 'mn',
    'seconds'  => 's'
    Only "ago" is not localizable (you say "2 years ago" and in french : "Depuis 2 ans" or "Il y a 2 ans")

    Thanks for providing localization for this plugin, too many devs forget it.
  16. Offline


    Ok, thanks. Once the update is ready and everyone can test out the localizations then I'll be available for any corrections that need to be made to make it sound better when read in-context.

    No problem, I noticed many servers were hosted by non-native English speakers so I figured it would be best to have a way of localizing it so everyone can be happy. In the future it'll remember a user using sessions so if there are users from different countries on the same server they can each see the stats in their own localization.
  17. Offline


    I really want to get this plugin to work but it doesnt! please help.

    I get the error: "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/enduranc/public_html/stats/get.php on line 156"

    website -
  18. Offline


    I've got a new version ready. My next post will have the details along with a link.

    The web code has been updated, you're welcome to use the current auto-update code though there are a few steps you'll have to do to make sure nothing gets destroyed or overwritten by accident. However, if you'd like to just download this version and mix it in yourself to be safe the link is in the first post, you'll notice that link now says "" instead of "". For those who want to try out the auto-update, you'll get an error at first when it's done saying that it couldn't find the config, which is because it's been renamed to "netstats_config.php". Work in the data of the old config into the new one, making sure that you fill in everything and change the version number to 2.1 so it won't try to update again as well as deleting the old "update.php" and replacing it with the new one and adding the "updateManager.php" to the same folder as "update.php". The /locale/ folder has all the localizations and the config has a small list of them for you to easily see what's available without checking the folder. There's an /extra/ folder now that will have extra code bits for PHP devs and for me to use later on, currently it creates a variable called $playersOnline which is a total count of online players. "get.php has no been changed to "data.php" as well.

    If you think I missed anything, please point it out so I can help. Furthermore, the next update will be able to show you the progress of the update and will have a better management system.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 8, 2016
  19. I find it nice you did the correction but i have to say that the person who did it learned french in Luxembourg i noticed already that the french in france is diffrent with the luxembourgish school french xD
  20. Offline


    Even with the update it still says "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/enduranc/public_html/stats/data.php on line 153"

  21. Offline


    which do I download for that thing you added in for me valrix?
  22. Offline


    Download the latest version and get the extra.php file inside the /extra/ folder. That has the code for you to use.
  23. Offline



    Just installed the latest version (first time install, no previous versions). Half of the page loads, and I'm left with the error:
    Warning: copy(img/pflags/ [function.copy]: failed to open stream: Permission denied in /var/www/netstats/data.php on line 216

    at the top of the screen. Here is the address:

    Also the play times seem massively wrong. I installed this mod a few hours ago and it lists some players with 1 month+ play times.

    Any ideas? I'm a complete n00b with php :(
  24. Offline


    Make sure all folders have write access so the flags can be created. What it's trying to do is make flags named after an IP so it doesn't have to do a country lookup for that IP address more than once. Which is weird since it looks like it already did it...

    EDIT: Ah! I see why the flags are still showing, which I'm glad I had it fall back to that, but you still need to make sure there are correct permissions for all the folders to be written to.
  25. Offline


    I get a 500 internal server error on the index...?
  26. Offline


    Awesome! Thats fixed now.

    Any idea about the times? Does Netstats calculate total times based off logs (so it can retrospecitvely calculate user time) or is it only time since Netstats has been installed?

  27. Offline


    Only since the JAR has been installed.

    That could be due to the config not being set up right so it'll cause the page to die.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 8, 2016
  28. Offline



    Does anyone have any ideas on why the 'play times' could be so far out? I installed the JAR maybe 3 - 4 hours ago and the minimum playtime is 5h 7m and then jumps straight up into the weeks and months.

    Its live at if anyone wants a look.
  29. Offline


    Getting a 'couldn't find file config.txt (no file or directory)' error (simply installed JAR in plugin directory). Folder is writeable, and all other plugins create config files perfectly. Then I get the 'created config.txt' message, but when I check, there isn't any Netstats directory or config.txt file.

    Any ideas?

  30. Offline


    For those getting the 500 error and did a fresh install, make sure the $update variable is something besides *0;

    Yeah, I'm fixing that bug now. For some reason the folders weren't being created.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 8, 2016
  31. Offline


    Thanks so much! I can't wait to install this plugin on my server. Let us know when it's updated!


Share This Page