Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-30-2002, 12:50 PM
Thomas P's Avatar
Thomas P Thomas P is offline
 
Join Date: Oct 2001
Location: Munich, DE
Posts: 365
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP Mini Hit counter for vB

Hello,

I'm looking for a simple hit counter for my forumhome page.

Currently I use a snippet which breaks every x hours

It is a file based counter I inserted into the phpinclude template and I echo the figures with variables.

What it does is it shows me daily hits, which reset every 24h and total hits with all hits since the beginning.

Does anyone has an alternative to my counter which doesn't break?

Many, many thanks,
-Tom
Reply With Quote
  #2  
Old 09-30-2002, 04:42 PM
g-force2k2 g-force2k2 is offline
 
Join Date: Mar 2002
Location: Everywhere you wanna be..
Posts: 1,608
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what do you mean doesn't break?

If im correct in understanding what you mean... you can use mysql to store the data to get the effect you're looking for...

PHP Code:
CREATE TABLE hits (
  
hitid int(10unsigned NOT NULL DEFAULT '0',
  
hitname varchar(30NOT NULL,
  
hits int(10NOT NULL DEFAULT '0',
  
PRIMARY KEY(hitid)
)

INSERT INTO hits VALUES ('1''index''0'
run those two queries and then open index.php

find:

PHP Code:
eval("dooutput(\"".gettemplate('forumhome')."\");"); 
above it add:

PHP Code:
$DB_site->query("UPDATE hits SET hits=hits+1 WHERE hitname='index'");
$hits $DB_site->query_first("SELECT hits FROM hits WHERE hitname='index'");
$hits $hits['hits']; 
then in your forumhome tempate place $hits whereever you want the hits to show... i doubt this is the most effective way but it should do the trick

regards...

g-force2k2
Reply With Quote
  #3  
Old 10-01-2002, 08:58 AM
Thomas P's Avatar
Thomas P Thomas P is offline
 
Join Date: Oct 2001
Location: Munich, DE
Posts: 365
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks g-force2k2,

I'll try it

Quote:
what do you mean doesn't break?
I don't know why, but my textcounter "breaks" sometimes, i.e. resets all numbers and starts to count from 0

Thank you very much, I think what you posted here is that what I need, but I need one more thing
Is it difficult to add a figure which shows the number of daily users (e.g. $hitsdaily)?

Thanks,
-Tom
Reply With Quote
  #4  
Old 10-02-2002, 06:51 AM
Thomas P's Avatar
Thomas P Thomas P is offline
 
Join Date: Oct 2001
Location: Munich, DE
Posts: 365
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please stay with me

Just this one little addition would make my users happy

Thank you,
-Tom
Reply With Quote
  #5  
Old 10-02-2002, 10:32 AM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why not install vBstats? This has many statistics for you, like hits per day, total, thread views total, users online in a day, posts in the last 24 hrs etc...
Reply With Quote
  #6  
Old 10-02-2002, 12:11 PM
Thomas P's Avatar
Thomas P Thomas P is offline
 
Join Date: Oct 2001
Location: Munich, DE
Posts: 365
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, I know...

I just need to replace my old counter, which'll exist next to vBstats.

http://www.mcseboard.de/ - I have to figures, down to the right, dark shaded is the number of Hits sinc 05/2001 (would be $hits in g-force2k2 hack)

and the number of "guest hits", which is the number of $hits in the last 24h

Thanks anyway,
-Tom
Reply With Quote
  #7  
Old 10-09-2002, 06:34 AM
Thomas P's Avatar
Thomas P Thomas P is offline
 
Join Date: Oct 2001
Location: Munich, DE
Posts: 365
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's the file based counter I use now, which breaks ~3 times a day:

Code:
// ipcounter hack by CX
// config
// create these two files count.txt and ip.txt, chmod them to 777
$count_file = "counter.txt";
$ip_file = "counter_ip.txt";
$userip = getenv('REMOTE_ADDR');  // in some fixed IP server, change this line to $userip = getenv('HTTP_X_FORWARDED_FOR');

$count_temp=file($count_file);
$ip_temp=file($ip_file);

$detail=explode("|",$count_temp[0]);
$count_t=getdate(time());
$count_day=$count_t['mday'];

if ($detail[0]==$count_day) {
    $detail[1]++;
    $detail[2]++;

    $count=count($ip_temp);
    $check=1;
    for ($i=0; $i<$count; $i++) {
        $ip_list=str_replace("\r","",str_replace("\n","",$ip_temp[$i]));
        if ($ip_list==$userip) $check=0;
    }
    if ($check==1) {
        $detail[3]++;
        $detail[4]++;
        $fp=fopen($ip_file,"a");
        flock($fp,3);
        fputs($fp,$userip."\n");
        fclose($fp);
    }
}
else {
    $detail[0]=$count_day;
    $detail[1]=1;
    $detail[3]=1;
    $detail[2]++;
    $detail[4]++;
    $fp=fopen($ip_file,"w");
    flock($fp,3);
    fputs($fp,$userip."\n");
    fclose($fp);
}

$new=implode("|",$detail);
$fp=fopen($count_file,"w");
flock($fp,3);
fputs($fp,$new);
fclose($fp);

// end ipcounter hack

$i = $HTTP_GET_VARS['i'];
Thanks,
-Tom
Reply With Quote
  #8  
Old 10-15-2002, 09:29 AM
Thomas P's Avatar
Thomas P Thomas P is offline
 
Join Date: Oct 2001
Location: Munich, DE
Posts: 365
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, I took a ready made script and integrated it into vB
http://www.needscripts.com/Resource/1447.html

Sad how few support someone can get over here with an easy thing like a counter. I'm not trying to be sarcastic or anything, it's just a fact and I'm curious...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:12 PM.


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.04113 seconds
  • Memory Usage 2,243KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete