The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Hit Tracker
I want to add a single command that will add stats about people hitting the site. I want it to trigger on ALL activity, and do an insert into the database. I have the command written, and the table created, but I need to locate a proper location in the php files to place it. I've tried global.php but it executes twice. Any suggestions?
Command: $DB_site->query("INSERT INTO " . TABLE_PREFIX . "hit_data (hitid, host, resolvedhost, useragent, port, referer, timestamp) VALUES (NULL, '" . $_SERVER["REMOTE_ADDR"] . "', '" . $_SERVER["RESOLVED_ADDR"] . "', '" . $_SERVER["HTTP_USER_AGENT"] . "', '" . $_SERVER["REMOTE_PORT"] . "', '" . $_SERVER["HTTP_REFERER"] . "', '" . $_SERVER["TIMESTAMP_NOW"] . "')"); |
#2
|
|||
|
|||
I applaud your effort. I too have contemplated such a hack. Just haven't got to it. I find lacking in vB more robust features for understanding what interests site users/visitors. I'll stay tuned for now.
One thing occurs to me is to place the command in the form of a function with appropriate parameters in a 'include' function file. Maybe even global since it will be called globally. |
#3
|
||||
|
||||
I've currently got it running in global. But I'm finding that a single formview will generate 1 - I've seen 9 hits. Global must be used for attachments or some other sub function. I need to find a single location, or a controlling variable. If I could find the place that executes the header template that would do it.
I've further refined the insert to include then username as well, so I can further query the resulting data. My one concern at this point is the additional load on the machine. Any thoughts? |
#4
|
||||
|
||||
Ok. My latest revision. This one seems to be working. But I'm still testing it out. This is placed into the global.php file.
if (!headers_sent()) { $DB_site->query("INSERT INTO " . TABLE_PREFIX . "hit_data (hitid, host, username, useragent, port, referer) VALUES (NULL, '" . $_SERVER["REMOTE_ADDR"] . "', '" . addslashes($bbuserinfo['username']) . "', '" . addslashes($_SERVER["HTTP_USER_AGENT"]) . "', '" . $_SERVER["REMOTE_PORT"] . "', '" . addslashes($_SERVER["HTTP_REFERER"]) . "')"); } |
#5
|
|||
|
|||
global.php is included in various different php files for different functions. I'm a newb myself, but I'm guessing that with more calls to global.php, the number of times the counter increments is also incrementing. My instinct would be to put it in index.php itself since that is the first file being called.
I'm interested in what you are working on because I need to implement a counter (or thread-views type of thing) for calendar events. I need to have this developed and working by the end of this month. Some of the logic I'll be developing may be of use to you and vice-versa. |
#6
|
||||
|
||||
The only problem being is that, if the user goes to a post or a thread directly from the e-mail notification then they bypass the index.php altogether.
Quote:
|
#7
|
|||
|
|||
Quote:
I'm sure some of this logic must exist in vbulletin itself since thread views cannot be artificially inflated by simply hitting refresh. |
#8
|
||||
|
||||
running such a query on a large board can become database and server intensive which is not advised for webmasters who run their forums on shared hosting
|
#9
|
||||
|
||||
I would agree the logic does exist, but I just haven't found it. (I haven't looked in a while either)
Quote:
|
#10
|
||||
|
||||
I do run a large board. I get about 8,500-9,000 posts a day. I did have the previous hit counter script running on the board, but with the duplicate hit problem I wrote another little application that does the hit counting for me. It's more accurate because it's only included in the footer.
The hit counting it intense, but it's worth the trouble and the load because it justifies banner advertising, and it's information that's required to do that. My Linux AMD 3000 is currently running at a top static of a load average of 5-6 as peak times spiking to 12-15 at times. I'm currently in the process of aquiring a SCSI Ultra 320 drive and controller in hopes that it relieves some of the load on the box. If that doesn't work then I need to go with a dual processor box. Quote:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|