vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Visitor Totals Last 24hrs (https://vborg.vbsupport.ru/showthread.php?t=100671)

tcs 11-12-2005 10:00 PM

Visitor Totals Last 24hrs
 
ported for 3.5.x.

It's a cool hack if you like to look at your total hits in a 24hr day from both members and guests.

1 PHP Modification to includes/cleanup.php
1 Template Mod. to Forumhome
1 Product Pluggin

Instructions and XML are in the zip.

I will support this hack but should be much trouble with it. Been running it since vB 2.2 I think.

When you first install this hack it will only track from the time the last sessions cleanup was completed. After a sessions cleanup it will start over or reset to 1hr again. Then track the hours in increments for 24hrs. Then clean out the sessions table and start over again. Sessions cleanups should normally occur at midnight.

This hack works if you remove the old code in the cleanup.php and replace it with the new information in the readme.

For information cleanout2.php dose not run hourly like implied in the cron tab. It is set for 5 min after midnight. Jelsoft set it that way and not sure why it is titled a hourly cleanup in the scheduled task. In any event it is needed to reset the script for the next day.

Good luck and I will do my best to answer any questions.

Thanks to Paul M. for pointing out a bug I kept overlooking.

donBLACK 11-13-2005 12:01 AM

nice

Makaveli105 11-13-2005 12:15 AM

very nice, thank you :D

TTG 11-13-2005 12:16 AM

Simple but effective .. thanks
Clicked install

GamerJunk.net 11-13-2005 01:34 AM

I forced an Hourly CleanUp and got this error...

Parse error: parse error, unexpected ']' in /home/gsnforce/public_html/forum/includes/cron/cleanup.php on line 26

GamerJunk.net 11-13-2005 01:45 AM

How do I edit it to say 24 hours rather than 1hrs?

It works even with that error.

tcs 11-13-2005 01:51 AM

Not an error. It counts up to 24 hrs. Check it in another hour.

caliman 11-13-2005 02:03 AM

I've been waiting for this! Thanks..
Does this use cookies? IP checks? Just curious...

tcs 11-13-2005 10:19 AM

It uses sessions table in the mysql. It changes the cleanup.php to leave the sessions table alone for 24hrs to collect the data. Then counts userid's and totals them up. Guests are assigned a userid of 0 by vB to be able to separate them from members.

No cookies (Although cookies are made with sessions information) and no IP checks.

bspiller82 11-13-2005 11:12 AM

Quote:

Originally Posted by RasMasta
I forced an Hourly CleanUp and got this error...

Parse error: parse error, unexpected ']' in /home/gsnforce/public_html/forum/includes/cron/cleanup.php on line 26

I got that error to. Are you saying if you wait an hour then run it, the error will not happen?

Is there a way to change the time from saying last 1 hours to last 24 if it logs the last 24 why have it say last hour?

Snake 11-13-2005 11:48 AM

Thanks!

lexx27 11-13-2005 12:47 PM

It worked for the 2 first hours. No it hasnt changed for 2 or 3 hours.

Paul M 11-13-2005 01:34 PM

Quote:

Originally Posted by tcs
It uses sessions table in the mysql. It changes the cleanup.php to leave the sessions table alone for 24hrs to collect the data.

Will this screw-up the who's online displays then ?

JTyson 11-13-2005 01:36 PM

Quote:

Originally Posted by Paul M
Will this screw-up the who's online displays then ?

Doesnt seem to, http://www.fuo-motorsports.com/forum/

I had to change cleanup2.php aswell

tcs 11-13-2005 02:26 PM

Quote:

Originally Posted by Paul M
Will this screw-up the who's online displays then ?

No it will not. Online Sessions are closed and changed by the timeout settings in you admincp.


Quote:

Originally Posted by bspiller82
I got that error to. Are you saying if you wait an hour then run it, the error will not happen?

Is there a way to change the time from saying last 1 hours to last 24 if it logs the last 24 why have it say last hour?


The script will count up to 24hrs. It will track visitor throughout the day.

You change the code to do an hourly cleanup? Leave the cleanup.php original and it will do an hourly cleanup with no additional code changes.

I have never had to mess with cleanup2.php. When you first install this hack it will only track the time from the last sessions cleanup. After a cleanup it will start over or reset to 1hr again.

caliman 11-13-2005 02:36 PM

tcs ... is there a fix for this? i am holding off because of this error.

Quote:

Parse error: parse error, unexpected ']' in /home/gsnforce/public_html/forum/includes/cron/cleanup.php on line 26

tcs 11-13-2005 03:34 PM

Lines 24 to 28 should look like this:
Code:

$vbulletin->db->query_write("
        DELETE FROM " . TABLE_PREFIX . "session
        WHERE lastactivity < " . intval((TIMENOW - 86400]) . "
        ### Delete stale sessions ###
");

You are looking for a ] extra, missing or out if place.

Post you lines and I will see if I can find it.

JTyson 11-13-2005 11:45 PM

Quote:

Originally Posted by tcs
Lines 24 to 28 should look like this:
Code:

$vbulletin->db->query_write("
        DELETE FROM " . TABLE_PREFIX . "session
        WHERE lastactivity < " . ntval((TIMENOW - 86400]) . "
        ### Delete stale sessions ###
");

You are looking for a ] extra, missing or out if place.

Post you lines and I will see if I can find it.

Might want to update your readme file as the error is in the code. :)

Code:

$vbulletin->db->query_write("
        DELETE FROM " . TABLE_PREFIX . "session
        WHERE lastactivity < " . intval((TIMENOW - 86400]) . "
        ### Delete stale sessions ###


tcs 11-14-2005 02:50 AM

The one in the readme is the correct one. The code on my test site was wrong and had an error I missed.

The code you posted should work fine.

caliman 11-14-2005 04:41 AM

tcs -

Is this mod compatible with 'who has visited today?'

https://vborg.vbsupport.ru/showthread.php?t=82769

bspiller82 11-14-2005 05:45 AM

How do I fix mine?

Code:

$vbulletin->db->query_write("
        DELETE FROM " . TABLE_PREFIX . "cpsession
        WHERE dateline < " . intval(TIMENOW - 3600) . "
        ### Delete stale cpsessions ###

Is giving me this error
Code:

Parse error: parse error, unexpected ']' in /home/a247xtre/public_html/forums/includes/cron/cleanup.php on line 26

Paul M 11-14-2005 09:31 AM

Quote:

Originally Posted by caliman
Is this mod compatible with 'who has visited today?'

https://vborg.vbsupport.ru/showthread.php?t=82769

I can't see any reason that this would intefere with my hack. :)

caliman 11-14-2005 12:42 PM

Thanks Paul.

caliman 11-14-2005 12:48 PM

Hey, mine doesn't seem to work right... if you stay on the site for a while it keeps recounting you as a member and it doesn't seem to go over 1 hour (it's been on past midnight now):

Total users last 1hrs : 13 (10 members and 3 guests)

Any ideas?

lexx27 11-14-2005 12:58 PM

I have the same problem.

TTG 11-14-2005 02:06 PM

Quote:

Originally Posted by caliman
Hey, mine doesn't seem to work right... if you stay on the site for a while it keeps recounting you as a member and it doesn't seem to go over 1 hour (it's been on past midnight now):

Total users last 1hrs : 13 (10 members and 3 guests)

Any ideas?

Same problem on mine !?

mclark2112 11-14-2005 06:50 PM

Still a problem in IE in the Dark Blue style...Map is all over the place.

tcs 11-14-2005 08:05 PM

Code:

$vbulletin->db->query_write("
        DELETE FROM " . TABLE_PREFIX . "session
        WHERE lastactivity < " . intval((TIMENOW - 86400]) . "
        ### Delete stale sessions ###

Is the code to use in cleanup.php only. Do not change what is in cleanup2.php.

I run "who was online today" and have had no issues or conflicts with them working together.

I just installed this on 3 other boards in an attempt to duplicate this problem. So far they are working fine.

Check your cleanup2.php and make sure you did not change the original code. This is the only hack I know that changes the cleanup.php you can re upload a new copy and try again to see if that fixes it.

amykhar 11-14-2005 08:33 PM

Typo in the install file.

Code:

$vbulletin->db->query_write("
        DELETE FROM " . TABLE_PREFIX . "session
        WHERE lastactivity < " . intval((TIMENOW - 86400]) . "
        ### Delete stale sessions ###

Should be
Code:

$vbulletin->db->query_write("
        DELETE FROM " . TABLE_PREFIX . "session
        WHERE lastactivity < " . intval((TIMENOW - 86400)) . "
        ### Delete stale sessions ###


amykhar 11-14-2005 08:47 PM

I have NOT been able to test this fully. Or even more than making sure it has no parse errors and the numbers add up. But, here is the plugin code for this mod for those of you using my spider's on the forumhome page.

The forumhome template code needs to change as well. My target audience will know how to do that ;)

Code:

    $datecut24 = TIMENOW - 86400;
        $numberregistered24 = 0;
        $numberguest24 = 0;
        $numberspiders24 = 0;

        $forumusers24 = $vbulletin->db->query("
                SELECT userid, lastactivity, useragent FROM " . TABLE_PREFIX . "session
                WHERE lastactivity > $datecut24
        ");

        $time24 = TIMENOW ;
        while ($loggedin24 = $vbulletin->db->fetch_array($forumusers24))
        {
                $userid24 = $loggedin24['userid'];
                if (!$userid24)
                {        // Guest or spider
                  if (!empty($vbulletin->wol_spiders))
            {
                      if (preg_match('#(' . $vbulletin->wol_spiders['spiderstring'] . ')#si', $loggedin24['useragent'], $agent))
                      {
                        $numberspiders24++;
                      }
                      else
                      {
                              $numberguest24++;
                          }
                        }
                }
                else
                {
                        $numberregistered24++;
                }
                if ($loggedin24['lastactivity'] < $time24)
                {
                        $time24 = $loggedin24['lastactivity'];
                }
        }
        $time24 = TIMENOW - $time24;
        $time24 = floor($time24 / 3600) + (($time24 % 3600) ? 1 : 0);

        $numbertotal24 = $numberregistered24 + $numberguest24 +$numberspiders24;

        unset($loggedin24);
        $vbulletin->db->free_result($forumusers24);


tcs 11-14-2005 11:22 PM

Quote:

Originally Posted by amykhar
Typo in the install file.

Code:

$vbulletin->db->query_write("
        DELETE FROM " . TABLE_PREFIX . "session
        WHERE lastactivity < " . intval((TIMENOW - 86400]) . "
        ### Delete stale sessions ###

Should be
Code:

$vbulletin->db->query_write("
        DELETE FROM " . TABLE_PREFIX . "session
        WHERE lastactivity < " . intval((TIMENOW - 86400)) . "
        ### Delete stale sessions ###


Thanks, There was a typo on my part. If you have the final spider code input let me know and I will add it and your credits to the install.

Zip file is updated.

amykhar 11-14-2005 11:54 PM

With this code running, I am having the same error others are reporting. The results are for one hour, even though it's been running for several. I am at work right now and won't be able to analyze the code till later. If I figure out what's amiss, I'll let y'all know.

JTyson 11-15-2005 12:15 AM

Ive said it before but cleanup2.php also has the same delete statement in it that needs to be modified.

caliman 11-15-2005 12:16 AM

Quote:

Originally Posted by JTyson
Ive said it before but cleanup2.php also has the same delete statement in it that needs to be modified.

So is it working for you JTyson?

Paul M 11-15-2005 12:41 AM

Quote:

Originally Posted by tcs
Thanks, There was a typo on my part. If you have the final spider code input let me know and I will add it and your credits to the install.

Zip file is updated.

This bit
Code:

intval((TIMENOW - 86400))
only needs one bracket each side. :)

caliman 11-15-2005 01:26 AM

So does this thing work for you Paul? Anybody? Seems like the behavior I described earlier is still happening for a few people here.

tcs 11-15-2005 01:36 AM

Quote:

Originally Posted by Paul M
This bit
Code:

intval((TIMENOW - 86400))
only needs one bracket each side. :)


Thanks, Fixed it in the zip file. Also added to change cleanup2.php. I can concede that this might need to be changed even though it works fine on my site without this additional change.

For those that don't wish to download the zip again this is the code. If you don't wish to change it the (( is fine too.

Code:

$vbulletin->db->query_write("
        DELETE FROM " . TABLE_PREFIX . "session
        WHERE lastactivity < " . intval(TIMENOW - 86400) . "
        ### Delete stale sessions ###

Chuck

amykhar 11-15-2005 02:30 AM

I'm not so sure about the quality of the data. Right now, it's saying I've had 59 members on in the last 3 hours - but my Total Members that have visited the site today says only 46 have logged in today.

Amy

tcs 11-15-2005 10:33 AM

Quote:

Originally Posted by amykhar
I'm not so sure about the quality of the data. Right now, it's saying I've had 59 members on in the last 3 hours - but my Total Members that have visited the site today says only 46 have logged in today.

Amy

No it is doing what it is meant to do. It is a Hit counter for a day. Counts all the visitors to your site. If you visit your site twice then that is 2 registered members hit's.

Now it has a error, it didn't clean out at midnight last night and I need to figure out why, I am pulling the hack till I get it back to the way I intended it to work.

COBRAws 11-15-2005 03:56 PM

Quote:

Originally Posted by amykhar
With this code running, I am having the same error others are reporting. The results are for one hour, even though it's been running for several. I am at work right now and won't be able to analyze the code till later. If I figure out what's amiss, I'll let y'all know.

same here, more than 36hrs running and only see the last hour stats.

Will wait till tcs works on the redo :D


All times are GMT. The time now is 03:00 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01361 seconds
  • Memory Usage 1,837KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (14)bbcode_code_printable
  • (15)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete