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


    The plugin has been updated to 4.5 and should fix the bugs people have been getting
    dwmcc likes this.
  3. Offline


    Alright so I downloaded the new webfiles and the new netstats jar. Reloaded and edited the netstats_config.php to include my working database info. I tried running chmodd 777 on all files and directories under netstats just to see if it was a permissions issue and it is not the case. Ive removed the new files for now.

    When you say make sure the update variable is something other than *0 what exactly should I change it to? Anything?

    This is running on a Ubuntu 10.10 VPS

    I get HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

    The old include is still working and speaking to the database.

    /* ----------------------------------------------
    File Created by Josh Devecka(Jdev19)
    You may use the code as you wish,
    but please give me some credit.
    ------------------------------------------------- */
    # Netstats Web version (do not alter)
    $version = "2.1";
    # Auto-update the web code for you
    $update = true;
    /* ----------------------------------------------
    Depth options:
        ~ "full" - Replaces old files with new ones
        ~ "default" - Keeps new files in /tmp/
    ------------------------------------------------- */
    $depth = "full";
    # Localization (language).
    # Supported: American English (en_US), German (de_DE), Luxembourgish (lu_LU), Finnish (fi_FI), Norwegian (no_NO)
    # Portuguese (pt_PT), French (fr_FR)
    $language = "en_US";
    # Database connection info
    $mysql = array(
        'host'  => 'localhost',
        'user'  => 'netstats',
        'pass'  => '******',
        'db'    => 'netstats',
        'table' => 'netstats'
    mysql_connect($mysql['host'],$mysql['user'],$mysql['pass']) or die (mysql_error());
    mysql_select_db($mysql['db']) or die (mysql_error());
    # What you want to be shown, change to false if you want it hidden
    $track = array(
        'ip'       => *6, # IP address
        'broken'   => *7, # Number of blocks broken by player
        'placed'   => *8, # Number of blocks placed by player
        'deaths'   => *9, # Number of times player died
        'mobs'     => *0, # Number of Monsters killed by player
        'player'   => *A, # Number of Players killed by player
        'joined'   => *B, # Date of when player first joined the server (with Netstats running)
        'distance' => *C  # Total distance player has traveled
  4. Offline


    It's true or false.
  5. Offline


    Nope, I just upgraded to @755 and all fine.

    // Also, I will implement your NetStats info to DynMap web-side, should be better :)
  6. Offline


    Ok, enjoy :)
  7. Offline


    nevermind, I had to set the last array options as true or false as well. Thank you.
  8. Offline


    Valrix even with the 2.1 update i still get "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/enduranc/public_html/stats/data.php on line 153"

    that line of code is "while ($row = mysql_fetch_array($res)) {"

    Apart from uploading the web files to website and the .jar file to my Minecraft server and creating the database, is there anything else i NEED to do that i haven't done?
  9. Offline


    I'm not sure why it's not working for you because it works fine for me and others.
  10. Offline


    I mean you know how some people have those things in there Signitaurs in forums that say something like this

    Joe's Craft Server

    and it's got banner art and such just been looking for something to do this I suggest u make it easier for people wanting to do this (please :D)
  11. Offline


    That's something way different and would take too much effort.
  12. Chinese Locals

    (LC_TIME'cn_CN'); # Change to match your appropriate locale
    $locale = array(
    'name' => '名称',
    'broken' => '块破碎了',
    'placed' =>'块 置了',
    'deaths' => '死亡自己数',
    'mkilled' => '死亡怪物数',
    'pkilled' => ,'死亡玩家数',
    'distance' => '里程',
    'login' => '过去登录',
    'seen' => '过去看见',
    'total' => '总时间玩',
    'plocale' => '玩家的语言环境',
    'join' => '登记日期',
    'ago' => '之前',
    'online' => '当前线上',
    'unseen' => '看不见',
    # Your way of writing or spelling "meters".
    'meters' => '米',
    # Commonly recognized time format for your locale
    'date'     => '%a, %b %d %l:%M %p',
    # Abbreviations for years, months, weeks, etc.
    'years' => '年',
    'months' => '月',
    'weeks' => '星期',
    'days' => '日',
    'hours' => '小时',
    'minutes' => '分钟',
    'seconds' =>'秒钟',
    Locals by Alexander Neil
  13. Offline


    Thanks, it's been added to the list.
  14. Offline


    I know thats why i was hoping some one else doing it :p
  15. Offline


    How exactly the update for the web will work?

    When I navigate to update.php I get to following error.

    Show Spoiler

    Warning: file_get_contents(/netstats_config.php) [function.file-get-contents]: failed to open stream: No such file or directory in /home/maxautod/public_html/shadecrest/netstats/update.php on line 3

    Warning: Invalid argument supplied for foreach() in /home/maxautod/public_html/shadecrest/netstats/update.php on line 10

    Warning: file_put_contents(/netstats_config.php) [function.file-put-contents]: failed to open stream: Permission denied in /home/maxautod/public_html/shadecrest/netstats/update.php on line 21
  16. Offline


    Val, Im begging you for some help with this DB table naming issue. I can't get it to migrate the data back to a table called netstats. Its throws this error and removes the newtable argument from the config. leaving the oldtable=stats argument in place but no longer writes to it. Just constantly pumps out errors because it has no table to write to.

    # Netstats Error Log
    CraftBukkit Version: git-Bukkit-0.0.0-706-gf53e007-b740jnks (MC: 1.5_02)
    Netstats Version: 4.5
    MySQL Error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Incorrect table name ''
    Stack Trace: [Ljava.lang.StackTraceElement;@224260ab
    Then on the next restart/reload it creates a blank netstats table and writes to that. The only way to avoid it is to set both oldtable=stats and newtable=stats and then reset that in the config between every server reload/restart. Its driving me nuts.

    I realise I could just dump all my player stats and start fresh but I've put so much time into our stats page and my players will be most disappointed. I know you wrote the plugin to facilitate smooth upgrades from the old table to the new, but now I'm stuck with this new tablename that the plugin doesn't want to know about. Please look into making it either use the elected table name. Or at least sort it so I can migrate the data back to the table name it wants to use.

    Please dude please. :S

    Supplementary info: Console output when oldtable=stats and newtable=netstats
    2011-05-04 17:15:51 [SEVERE] [Netstats]: Failed to rename table stats to . Does stats exist?
    2011-05-04 17:15:51 [SEVERE] [Netstats]: Severe database error. Saving error log to plugins/Netstats/logs
    2011-05-04 17:15:52 [SEVERE] [Netstats]: Severe database error. Saving error log to plugins/Netstats/logs
    2011-05-04 17:15:52 [INFO] [Netstats] v4.5 has been enabled.
  17. Offline


    Sorry to bother you again, but I've configured my netstats_config.php, and when I browse to the netstats directory on my website, I get
    Warning: ftp_login() expects parameter 1 to be resource, boolean given in /netstats/updateManager.php on line 4
    Couldn't connect to
  18. Offline


    Well, I updated to Netstats 4.5 and using the latest web information.
    It takes about 10-15 seconds before the stats page comes up. When it does, I get information that tells me some players have a total play time of 55 seconds when they have much more than that, and some players have a total play time of 6 months. Which can't be, because the database hasn't been running that long.
    Also the sorting doesn't seem right. When I sort by "Last Seen", I'll see 14, 15, 16, 17, hours, then it will skip to 1 day, and then go back to 11, 12 hours. It's not sorting the columns for times in cronological order.
    I'm not sure what's going on.... heh
  19. Offline


    I dont get this. So how do you check if someone has played or check stats?
  20. Offline


    Swedish Translation done by Letalis :-P

    setlocale(LC_TIME'se_SE'); # Change to match your appropriate locale
    $locale = array(
    'name'     => 'Namn',
    'broken'   => 'F&ouml;rst&ouml;rda Block',
    'placed'   => 'Placerade Block',
    'deaths'   => 'D&ouml;tt',
    'mkilled'  => 'Monster d&ouml;dade',
    'pkilled'  => 'Spelare d&ouml;dade',
    'distance' => 'Distans',
    'login'    => 'Senast inloggad',
    'seen'     => 'Senast sedd',
    'total'    => 'Speltid',
    'plocale'  => 'Land',
    'join'     => 'F&ouml;rsta g&aring;ngen',
    'ago'      => 'sen',
    'online'   => 'Spelare Online',
    'unseen'   => '&Auml;nnu ej sedd',
    # 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'    => '&aring;r',
    'months'   => 'm',
    'weeks'    => 'v',
    'days'     => 'd',
    'hours'    => 't',
    'minutes'  => 'm',
    'seconds'  => 's'
    Could you add something to skip flags if it cant find a flag so I dont get any error message?
    as of now when it cant find the IP it gives:
    Warning: copy(img/flags/.png) [function.copy]: failed to open stream: No such file or directory in C:\xampp\htdocs\swedroid\netstats\data.php on line 216

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


    Also, the play times seem to reset every time the server restarts.
  22. Offline


    Whee, looks like I have a lot to check on today. Slow down a bit guys, I'll check everything out and get back to you on the problems. At this point it almost seems easier to just migrate the java to v5 so I can remove a lot of code that seems to be causing problems and make things run faster.

    For the web auto-updating, I'm going to work on a progress indicator to let you watch it as it happens and make it so only the admin can run the update.

    I'll try to get back to the few people having issues when I have a solution or I find the problem and can patch it. I think I can quickly fix the table renaming issue and if anyone needs immediate help you can PM me and supply me with FTP and/or database info, if you're comfortable with that, and I can help you personally with your problems. At times I actually prefer to do this than try to explain so I can see what's going on myself and do my best to fix it for you. I can't always do this, but if you ask nicely then chances are I'm willing to help you out one-on-one until I get everything fixed for you.

    If I don't think I can quickly get the current bugs fixed, then I'll upgrade to v5 instead as quickly as I can so most of these issues will just disappear. Until I have anything decided for sure, please wait patiently, I'm working as diligently as I can. Thank you.

    I'll work on that. Should be simple enough.

    That's...unexpected. I'll need to check on that. I probably didn't give it long enough for me to encounter any errors.

    I'm not really sure why that happens to be honest.

    I'll work on this and hopefully get it fixed.

    Some of the symbols don't look like they should really be there. Like the numerous "&" and ";"

    The update progress indicator is basically done, now it just needs to be properly added in and have a way to authenticate the admin so only they can update everything instead of any user. I'll work on making flags easier to deal with and hopefully make it easier to manually set a flag for the user's IP.

    I'm also working on the Java when I happen to get tired of doing PHP. v5 is coming along and may come out sooner than I expected as long as I can get the PHP to play nice.

    As a heads up, if you want your database info to stay safe (assuming that it's not already messed up), back it up. Always keep backups of your data in case something breaks. Usually it's time-based things that are easiest to break, but sometimes other bit of data can get messed up. When the next update comes out, the player data will be handled a bit differently to minimize database calls and speed up all data transfer as well as showing real-time stats. First thing to fix is table re-naming though so that one bug (you know which one) will stop popping up.

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


    are you reffering to &Auml; for ex?
  24. Offline


    Yeah, are those just escaped characters? Like &copy;? ...I think I just answered my own question, haha.

    EDIT: Hahaha, sorry, it's fine. I'm just an idiot :p

    Good news: I've fixed the bug where each reload or server restart would perform the revision on all the players and fixed the bug when trying to name the table something else.

    Bad news: Chances are all total play times are completely screwed up unless you have backups.

    Comforting news: All the other stats are perfectly OK and were not affected at all. There have been code improvements done as well, and future versions will make sure to back up all player data before it tries to do anything to it so you can fix it if/when I mess something up again.

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


    Hey Valrix, thanks for your prompt response and your efforts on this plugin all round. Much appreciated.
  26. Offline


    No problem. I mean, it's a lot of work, but as long as people get good use out of it and enjoy it I'm happy. The donations I've got from people were also really awesome since I'm a college student without an actual job (technically these plugins are my full-time job at the moment), but it's not like I force payments, though I am available for hire.

    Anyway, I'm glad to get some words of support, it really cheers me up. Thanks :)
  27. Offline


    Hmm I just did a database wipe due to error in gametime played-
    And i relogged the server and now it says that I have been playing for 41Y 23m 1v 3d 4t 11m 2s.

    EDIT: I had to empty the database from users to make it work again.

    EDIT2: nm that didnt help.
  28. Offline


    I just changed the auto upgrade code to false, and everything worked perfectly. I now have Netstats working!

    Thanks for a great plugin
  29. Offline


    The next update should fix a bunch of these problems for you. Please hang in there while I work out a few kinks.
  30. Offline


    hi valrix.

    I updated to 4.5 and my "play time" is all showing 0s
    it seems like the total time played is being reset on server restarts?

    also when I try to use the code from extra.php I get this;

    Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/sunwind/ on line 15

    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/sunwind/ on line 15

    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/sunwind/ on line 15

    it's trying to connect to the localhost rather than the database specified in netstat config?
  31. Offline


    ^^ Same exact issue here, CB 740

    I only get the first Warning though.

Share This Page