AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [TF2] Item Logger (With Web Panel) (https://forums.alliedmods.net/showthread.php?t=139492)

Geit 10-01-2010 18:51

[TF2] Item Logger (With Web Panel)
 
3 Attachment(s)
Logs item interactions (finds, crafts, trades, purchases, unboxings, giftings, earnings and refunds) to database for statistical analysis.

Working Examples:
http://items.degree-gaming.com/
http://www.bigbanggamers.com/drops/

Updating to 2.02 from 1.11:
  1. Upload the web panel files
  2. Fill out system/includes/config.php
  3. Run update.php
  4. Run convert.php
  5. Delete update.php and convert.php
  6. Rename the "feedback" database config to "itemlogger2"
  7. Upload a new copy of the plugin
  8. Restart server.

Changelog:

2.04:
  • (Plugin) Made sure FetchRow is called successfully before attempting to retrieve values.
  • (Web) Updated Item Methods
  • (Web) Fixed updater script - thanks PolyQuad!
2.03:
  • (Plugin) Will now attempt to reconnect to the database server if the handle becomes invalid.
  • (Plugin) Removed the use of GetInsertID in favor of just doing another threaded query: as it does not appear to function correctly on local result sets in some cases.
2.02:
  • (Web) Added Pagination
  • (Web) Fixed (X)HTML non-compliance
  • (Web) Escaping output now (Critical)
  • (Web) Updated Jquery to 1.6.4
  • (Plugin) Fixed sourcemod errors on player/server inserts
  • (Plugin) Fixed a required server restart for plugin updates/reloads - still recommended though!
2.01:
  • Rewrote the web panel with numerous improvements
    • Less barebones, comes with dedicated style.
    • Improved Speed
    • Improved update.php
  • Redesigned the database schema to be more efficient
  • Rewrote the plugin from scratch around Valve changes.
  • Changed the database config from "feedback" to "itemlogger2"
  • Probably some other stuff I don't remember.
1.11
  • Added a check to prevent the plugin from logging two sets of item notifications when using my Fast Item Hook plugin
1.1
  • Fixed a UTF-8 Issue with the plugin
  • Numerous web panel fixes
Cvars:
  • sm_item_logger_version - Version
Plugin Installation
  1. Create a configuration named "itemlogger2" in your databases.cfg like so:
    Code:

    "itemlogger2"
        {
            "driver"            "mysql"
            "host"                "localhost"
            "database"            "sourcemod"
            "user"                "user"
            "pass"                "password"
        }

  2. Drop the compiled plugin into your plugins dir
Web Panel Installation
  1. Fill in the variables in system/includes/config.php - You can get an API key from here: http://steamcommunity.com/dev/apikey
  2. Navigate to update.php in your browser, wait for it finish loading (can take up to 2 minutes)
  3. Delete update.php and convert.php
  4. Index.php should now be working.
  5. (When the game is updated with new items, simply rerunning update.php will update your panel with the new items)
Credits
rack_gothroach - Massive amount of help with the web panel :3
Darkimmortal - Daemon and Original Web code
Geit - Updated Plugin/Web code
Nineaxis - Web panel design for >2.0

Troubleshooting:

If you get a table does not exist error upon visiting the web panel, ensure that your database details in config.php match those you set for the plugin then use this query:

Code:

CREATE TABLE IF NOT EXISTS `itemlogger2_finds` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT,`player_id` int(11) unsigned NOT NULL DEFAULT '0',`server_id` int(11) unsigned NOT NULL DEFAULT '0',`player_count` tinyint(3) unsigned NOT NULL DEFAULT '0',`item_index` int(11) NOT NULL DEFAULT '0' COMMENT 'signed int, 32 bit',`method` tinyint(2) NOT NULL DEFAULT '0',`quality` tinyint(2) NOT NULL DEFAULT '0',`time` int(11) unsigned NOT NULL DEFAULT '0',PRIMARY KEY (`id`),KEY `actual_time` (`time`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `itemlogger2_items` (`id` int(11) unsigned NOT NULL DEFAULT '0',`item_name` tinytext,`proper_name` tinyint(1) DEFAULT NULL,`item_slot` varchar(16) DEFAULT NULL,`image_url` tinytext,`material_type` varchar(16) DEFAULT NULL,PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `itemlogger2_players` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT,`steam_id` varchar(25) NOT NULL DEFAULT '',`name` varchar(32) DEFAULT NULL,`avatar` tinytext,`avatar_last_updated` int(11) DEFAULT NULL,PRIMARY KEY (`id`),UNIQUE KEY `steam_id` (`steam_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `itemlogger2_qualities` (`id` tinyint(3) unsigned NOT NULL,`name` varchar(32) DEFAULT '0',`raw_name` varchar(32) DEFAULT '0',PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `itemlogger2_servers` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT,`ip` varchar(16) DEFAULT '127.0.0.1',`port` smallint(5) unsigned DEFAULT '27015',`name` tinytext,PRIMARY KEY (`id`),UNIQUE KEY `ip_port` (`ip`,`port`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;


aRcTiC 10-01-2010 23:57

Re: [TF2] Item Logger (With Web Panel)
 
nice work
drinking_hat.png can't download and you should add pagination to the page

Geit 10-02-2010 03:44

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by aRcTiC (Post 1313522)
nice work
drinking_hat.png can't download and you should add pagination to the page

If anything can't be gotten from the TF2 WebAPI it should be reported here: http://wiki.teamfortress.com/wiki/Talk:WebAPI - I've added it myself now, although there is no mention of the Rimmed Raincatcher on the wiki, and I'll also add pagination & add the "Powered By Steam" text to the footer when I get home.

aRcTiC 10-02-2010 04:10

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in avatars_cron.php on line 10
get that when trying to get profile avatars and also unknown server

Geit 10-02-2010 04:24

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by aRcTiC (Post 1313606)
get that when trying to get profile avatars and also unknown server

Have you filled out the variables at the top of the cron and filled out the servers array correctly (at the top of index.php)?

Geit 10-02-2010 16:33

Re: [TF2] Item Logger (With Web Panel)
 
Updated the web panel:
  • Added "Powered by Steam" text
  • Added pagination, the PERPAGE define at the top of index.php controls how many rows are shown per page
  • Added Search
  • Fixed the cron script reporting invalid resource

aRcTiC 10-02-2010 19:44

Re: [TF2] Item Logger (With Web Panel)
 
you forgot teh function again
Quote:

Fatal error: Call to undefined function steam2friend() in drops\avatars_cron.php on line 12
also i deleted the extra drop in 'drop/index.php' in 3 places i saw in index.php because that produces drop/drop/index.php which didnt work for me

i did add my servers ip address but still unknown server, i check the database and it says the right ports but all localhost:27015(6)(7), i am hosting web, mysql and tf2 on the same pc, maybe i have to use my external ip in database.cfg?

edit:
possible to just view avatars directly from steam instead of downloading them first?

bouncer 10-02-2010 20:20

Re: [TF2] Item Logger (With Web Panel)
 
I can't see anywhere in first post where is the MYSQL Query that needs to be run in order to create the tables/columns??

Also when I go to http://www.brotherhoodofgamers.com/tf2itemlogger/
I get the error: Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/brother6/public_html/tf2itemlogger/index.php on line 45

Geit 10-03-2010 02:27

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by aRcTiC (Post 1314183)
you forgot teh function again
also i deleted the extra drop in 'drop/index.php' in 3 places i saw in index.php because that produces drop/drop/index.php which didnt work for me

i did add my servers ip address but still unknown server, i check the database and it says the right ports but all localhost:27015(6)(7), i am hosting web, mysql and tf2 on the same pc, maybe i have to use my external ip in database.cfg?

edit:
possible to just view avatars directly from steam instead of downloading them first?

Cheers for pointing that out, The way I'm updating this is a that I'm updating our own version of the web panel which hooks into vB, so i end up adding extra stuff that I forget to remove, sorry. :3

What are the Ip's being logged as on your mysql? - The array should match the ones specified there. If it does, can you post up/PM the full array at the top of index.php

It is possible to get steam avatars without first downloading them, but it requires the use of Javascript (or a very long load time), which the in-game browser doesn't support.

@Bouncer: The Tables are created by the plugin when it successfully connects to your database

Anyway, Reuploaded the web panel, sorry for the mistakes :wink:

asherkin 10-03-2010 05:11

Re: [TF2] Item Logger (With Web Panel)
 
Great system, found a few issues though.

Line 189 of index.php needs the / in the beginning of the string removed.

In avatars_cron.php there are a few issues:
$path_to_avatars should have "avatars/" added on directly in the variable.
The first time $xml is set should be removed, as it's switched to use the web api below it.
Then the correct way to get the avatar would be $profile->players->player->avatarmedium.

Geit 10-03-2010 08:00

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by asherkin (Post 1314443)
Great system, found a few issues though.

Line 189 of index.php needs the / in the beginning of the string removed.

In avatars_cron.php there are a few issues:
$path_to_avatars should have "avatars/" added on directly in the variable.
The first time $xml is set should be removed, as it's switched to use the web api below it.
Then the correct way to get the avatar would be $profile->players->player->avatarmedium.

Cheers! Updated the web panel yet again.

(Issues with avatar_cron are purely because I quickly adapted it from our, GamingMaster's, Daemon which is a lot more dated and complicated then what is included)

DeJaDeW 10-03-2010 13:14

Re: [TF2] Item Logger (With Web Panel)
 
Thanks, no major problems yet. Great job.

http://bfused.com/?page_id=272

Now all I need to setup a cron job

aRcTiC 10-06-2010 19:12

Re: [TF2] Item Logger (With Web Panel)
 
nnCron and wget works well for the avatars cron job i set it to 5 minutes
also Geit can you also add item search as well?

DontWannaName 10-07-2010 00:15

Re: [TF2] Item Logger (With Web Panel)
 
Sooo... does this require a lot of constant mysql use or does it send the data on map end so it doesnt lag users during gameplay.

Geit 10-07-2010 03:29

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by aRcTiC (Post 1317440)
nnCron and wget works well for the avatars cron job i set it to 5 minutes
also Geit can you also add item search as well?

Will do.

Quote:

Originally Posted by DontWannaName (Post 1317725)
Sooo... does this require a lot of constant mysql use or does it send the data on map end so it doesnt lag users during gameplay.

It uses threaded queries (minus the connection event) and doesn't process results so there should be no lag at all.

aRcTiC 10-07-2010 03:29

Re: [TF2] Item Logger (With Web Panel)
 
plugin hooks item_found event and logs it instantly when someone finds,crafts,unboxes,trades,earns,gifts,purch ases,refunds something...
so ya it constantly uses your mysql db and not just on map change

edit:
i couldn't wait so i edited a few things and added item search myself
also made it search the whole db not just from midnight of that day

notice ip localhost was related to how you got ip in your plugin, so i changed the ip cvar to my outside ip
all should be better i hope

http://uberz.servegame.com/drops

Skyrider 10-07-2010 09:54

Re: [TF2] Item Logger (With Web Panel)
 
It keeps saying:
Quote:

Table 'my1094_drops.log' doesn't exist
I've edited both index & update.php and also ran it.

EDIT:
I manually ran:
Quote:

CREATE TABLE IF NOT EXISTS `log` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(64) NOT NULL, `steam_id` varchar(25) NOT NULL DEFAULT '0', `time` int(11) NOT NULL DEFAULT '0', `players` int(11) NOT NULL DEFAULT '0', `item` varchar(50) NOT NULL DEFAULT '0', `server` varchar(32) NOT NULL DEFAULT '0', `method` tinyint(2) NOT NULL DEFAULT '0', `quality` tinyint(2) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `actualderptime` (`time`), KEY `Index 3` (`steam_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Through Phpmyadmin. Works good now.

I am getting errors though when using update.php
Quote:

[07-Oct-2010 13:49:46] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so: undefined symbol: sqlite3_libversion in Unknown on line 0
[07-Oct-2010 13:50:07] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so: undefined symbol: sqlite3_libversion in Unknown on line 0
[07-Oct-2010 13:52:06] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so: undefined symbol: sqlite3_libversion in Unknown on line 0
[07-Oct-2010 13:52:11] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so: undefined symbol: sqlite3_libversion in Unknown on line 0
The site doesn't really seem to update though:
http://drops.forcepit.com/

I'm pretty sure everything is set correctly in the database.cfg file. No errors within the sourcemod logs..

Plus,
Number of items found/crafted today: 0
That's 0 per hour!

It's not updating.

Does the plugin show any kind of SQL errors within the error log if it can't connect?

aRcTiC 10-07-2010 11:29

Re: [TF2] Item Logger (With Web Panel)
 
found the rimmed raincatcher (aka drinking_hat.png) lulz
heres the pack for people who couldn't use update.php for whatever reason

Skyrider 10-07-2010 12:59

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by aRcTiC (Post 1318109)
found the rimmed raincatcher (aka drinking_hat.png) lulz
heres the pack for people who couldn't use update.php for whatever reason

File attachment doesn't work.

aRcTiC 10-07-2010 13:58

Re: [TF2] Item Logger (With Web Panel)
 
fixed, here again

Skyrider 10-14-2010 13:53

Re: [TF2] Item Logger (With Web Panel)
 
Who's the owner of http://69.204.254.155/drops/?

Geit 10-14-2010 14:08

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by FF|Skyrider (Post 1324726)

EDIT: Artic owns that one.

Thrawn2 10-17-2010 11:29

Re: [TF2] Item Logger (With Web Panel)
 
thx for this. link.
any idea how to fix the utf8 issue?

jab2000 10-18-2010 15:48

Re: [TF2] Item Logger (With Web Panel)
 
nvm this post

Geit 10-18-2010 15:58

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by jab2000 (Post 1328685)
i get the same thing

It is likely that Valve have messed up their Schema and added a blank entry, which is something the update script doesn't know how to handle (Because I didn't expect it to happen >.>)

jab2000 10-18-2010 17:10

Re: [TF2] Item Logger (With Web Panel)
 
I get a error saying missing "items.php" there's no items.php on the zip file

Skyrider 10-18-2010 20:09

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by jab2000 (Post 1328755)
I get a error saying missing "items.php" there's no items.php on the zip file

did you run update.php? It should create the items file.

Aoxmodeus 10-18-2010 21:41

Re: [TF2] Item Logger (With Web Panel)
 
I'd really like to run this, but am running windows servers. I'm trying to get this to run, and have had mostly success, but I'm getting very odd rendering issues, and can't get the images to display, not having proper variables filled in by php. Should I be able to get this to run on a windows box?

-Aox

Skyrider 10-19-2010 06:52

Re: [TF2] Item Logger (With Web Panel)
 
Can anyone tell me how to disable the daily reset? I want the logs to be kept.

asherkin 10-19-2010 06:54

Re: [TF2] Item Logger (With Web Panel)
 
The data is still in the database, you just need to remove all the checks for the time being later than midnight from the SQL queries.

Skyrider 10-19-2010 07:25

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by asherkin (Post 1329221)
The data is still in the database, you just need to remove all the checks for the time being later than midnight from the SQL queries.

Mind sharing how? I'm not that much advanced. And yea, I noticed that all data is still in the database. I already tried replacing midnight with, but getting a sql error.

EDIT:
Replacing "midnight" with "-1 day" seems to work.. Got anything better though? Or will this work just fine?

EDIT:
Number of items found, traded or crafted in total: 1340

Even when using -1 day, it still display 1340 total.. while it should be much more.

haet 10-19-2010 18:40

Re: [TF2] Item Logger (With Web Panel)
 
woah woah woah...

i want that spray tracker plugin! where can i get this!? :)

Aoxmodeus 10-19-2010 22:00

Re: [TF2] Item Logger (With Web Panel)
 
OK, so I got this working, with some fudgery... Turns out I didn't have "short open tags" enabled in my php config. When I turned this on, it accepted the short tags in the code, and fixed my rendering issues.

On Windows, I still have issues with setting the correct path in the avatar_cron.php file. I can't seem to get a path to work at all. The avatar files ALWAYS end up in the root of the drops site. I ended up modifying the index.php to remove the avatars/ for $av and now everything is working great. I suppose I may have also been able to fix this by running the avatar_cron.php from the avatars directory itself.

I do have one final tuning issue I'd like to fix. Can one of you PHP gurus tell me how I can modify the query in the index.php to give me time -8 hours, to show my west coast USA time zone times properly? I figure it's got to be something simple. I see a $CorrectedTime variable in there, but not sure what I'd change to make it reflect -8 off of GMT.

Also, in windows, is there a way to run the avatars_cron as a schedule task from a command line, without having to set up a scheduled task to actually open up a browser window?

Thanks for any help!

Site is up and online at http://aoxbox.ciscofreak.com/drops/

-Aox

Aoxmodeus 10-20-2010 01:28

Re: [TF2] Item Logger (With Web Panel)
 
Ok, worked around the php windows path issue by setting up a scheduled task to run "cURL" every 5 min to call the avatars_cron.php directly from the avatars folder. I'm not sure why the update.php would work fine with the images/ variable, but in the avatars_cron.php, I couldn't set $path_to_avatars = avatars/ and have it dump the images to avatars/. There must be something else in the code I don't understand that I don't have my server configged properly for, like the short open tag setting, or a path issue that keeps it from dumping to the subdirectory.

Only remaining issue that eludes me is how do I get the page to show server time, and not UCT/GMT?

http://aoxbox.ciscofreak.com/drops/

Thanks again for the cool app! I've learned more about php, apache, and mysql in the past two days than I ever thought a network guy like me would know.

-Aox

ltgenkd 10-20-2010 06:10

Re: [TF2] Item Logger (With Web Panel)
 
Whats the best way to have the web interface not clear @ midnight?
To have multiple pages to view.

Thanks

Skyrider 10-20-2010 08:25

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by ltgenkd (Post 1330052)
Whats the best way to have the web interface not clear @ midnight?
To have multiple pages to view.

Thanks

Change midnight to -1

ltgenkd 10-20-2010 12:06

Re: [TF2] Item Logger (With Web Panel)
 
Quote:

Originally Posted by FF|Skyrider (Post 1330109)
Change midnight to -1

So, change midnight to -1 everywhere it says midnight in index.php?

Aoxmodeus 10-20-2010 14:07

Re: [TF2] Item Logger (With Web Panel)
 
So... I seem to have an odd bug I don't understand.

Randomly, it appears the steam2friend function will generate the TF2items link, OR the avatar image link, with a .0000000000. between the friend code and the .jpg extension of the image file, or will append a ".0000000000" to the end of the TF2 items link.

It happens in the avatars_cron as well. Sometimes it pulls the files down with the proper name of friendcode.jpg, sometimes it re-writes all those files with friendcode.0000000000.jpg, which then causes the avatars in displayed in the index.php to default to that questionmark file, since the if exist can't file the proper filename.

Any ideas why this would be happening?

Anyone?

-Aox

Aoxmodeus 10-20-2010 16:41

Re: [TF2] Item Logger (With Web Panel)
 
Ok, so I re-wrote this function:

This theoretically will strip the weird .tenzeros out of my links/avatars when it happens, I think.

function steam2friend($steam_id){
$steam_id=strtolower($steam_id);
if(substr($steam_id,0,7)=='steam_0'){
$tmp=explode(':',$steam_id);
if((count($tmp)==3) && is_numeric($tmp[1]) && is_numeric($tmp[2])){
$id_fix=bcadd((($tmp[2]*2)+$tmp[1]),'76561197960265728');
$id_fix=str_replace(".0000000000.","",$id_fix );
$id_fix=str_replace(".0000000000","",$id_fix) ;
return $id_fix;

} else {

I know you linux guys probably don't give a sh*t, but maybe this will help some other win-dink XD

-Aox

Aoxmodeus 10-20-2010 17:02

Re: [TF2] Item Logger (With Web Panel)
 
This programming stuff is kind of cool...

It's all working!!!! No more bugs, no issues other than HOW IN THE HECK DO I DISPLAY GMT -8 ON THE PAGE?!??! Hehehhe.

Woot!

http://aoxbox.ciscofreak.com/drops

-Aox


All times are GMT -4. The time now is 15:04.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.