vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Total Time Online Hack v1.0 (https://vborg.vbsupport.ru/showthread.php?t=42864)

Dark Shogun 09-20-2002 09:08 AM

Does anyone know how to get rid of this error when viewing the leader board? Warning: Division by zero in /web/blarg/public_html/testvb/timeonline.php on line 42

Dark Shogun

bouncer18 09-20-2002 04:10 PM

Quote:

Originally posted by Dark Shogun
Does anyone know how to get rid of this error when viewing the leader board? Warning: Division by zero in /web/blarg/public_html/testvb/timeonline.php on line 42


Dark Shogun

check his first post

Bison 09-20-2002 07:49 PM

Quote:

Originally posted by bouncer18
im an idiot

post removed cause you answered it 532895934 times now

"NO Comment!"

NSeXcellent 09-20-2002 10:27 PM

Hi guys... I got it working fine except for one thing. I'm really not in need of the leader list, but a few members requested it. I was getting the 'Division by Zero' error, but edited the 'timeonline.php' with the fix. Now when I click on the link in postbit, it opens up the timeonline.php link, but i'm getting a blank page. This could have possibly been covered already, but i dont remember seeing a fix or solution. Any help? Thanks!

xevito 09-21-2002 12:36 AM

Can someone write an idiots guide and post an updated file - this thread is getting confusing now.

GoTTi 09-21-2002 09:43 PM

I am having slight problem with this hack

The Time Online is not being displayed in the user threads, which I assume is the postbit templates.

Attached is SS of what it is doing.

Neo 09-22-2002 12:21 AM

Why did you incert a new row for this?

You dont need to do any database edits to make this hack.

TECK 09-22-2002 07:43 PM

should i say it's a great one... you hack, still?? :)

btw, i use a very light part of you hack,
i mod it to give me only the online hours spent.. in the post only.
here it is a little piece my postbit, with the activity online:

GoTTi 09-23-2002 01:08 AM

Neo what do u mean?

TECK 09-23-2002 03:03 AM

Quote:

Originally posted by Neo
Why did you incert a new row for this?

You dont need to do any database edits to make this hack.

yes you do.

TECK 09-23-2002 01:31 PM

hmm g-force, i just realised that the hack it's adding a query everywhere, in all pages. i really dont like that because i'm trying to stay with an average of max 18queries on my forums.

and you should use in your sessions.php something like:
Code:

$timeactive = time() - $bbuserinfo['lastactivity'];
if ($bbuserinfo['userid'] != 0 and $timeactive < (5 * 60)) {
  $DB_site->query("UPDATE user SET timeactivity=timeactivity+$timeactive WHERE userid='$bbuserinfo[userid]'");
}

so it doesnt perform a query also for quests. it will save you some serverload.

UPDATE :)
check below how to optimise the code and eliminate the extra query...
wait for g-force to update his files... or do it yourself if your belt is strong enough.

g-force2k2 09-23-2002 03:51 PM

NSeXcellent:

make sure that the link is this:

PHP Code:

<a href='timeonline.php?s=$session[sessionhash]&action=view_leader'>Time Online:</a

xevito:

everything is included in the zip file, other changes are just custom ones nothing necessary

Da GoTTi:

did you include the $post[onlinetime] variable in the postbit?

Neo:

how would you do it?

TECK:

thanks for the addition :) i will add the link to the first post ;)

regards...

g-force2k2

TECK 09-23-2002 04:37 PM

ok, g-force i found a way to dont load any query at all. you can update your code if you want... is your hack and it's a great tool.
now let's optimise shall we? :)

here it is what i did, step by step (keep in mind i used my own terms, change them to yours):
run this query:
[sql]ALTER TABLE user ADD timeactivity int(10) unsigned DEFAULT '0' NOT NULL AFTER posts[/sql]
in /admin/functions.php find:
Code:

$post[joindate]=vbdate($registereddateformat,$post[joindate]);
replace it with:
Code:

    $post[joindate]=vbdate($registereddateformat,$post[joindate]);

    // activity time
    $post[activity] = floor($post[timeactivity] / 3600);
    if ($post[activity] <> 1) {
      $pluralhour = 's';
    } else {
      $pluralhour = '';
    }

in /admin/sessions.php find:
Code:

  if ($ourtimenow - $bbuserinfo['lastactivity'] > $cookietimeout) {
    if (!isset($bypass)) {
      if ($noshutdownfunc) {
        $DB_site->query("UPDATE user SET lastvisit=lastactivity,lastactivity=$ourtimenow".iif($showforumusers,",inforum='0' ","")." WHERE userid='$bbuserinfo[userid]'");
      } else {
        $shutdownqueries[99]="UPDATE user SET lastvisit=lastactivity,lastactivity=$ourtimenow".iif($showforumusers,",inforum='0'","")." WHERE userid='$bbuserinfo[userid]'";
      }
    }
    $bbuserinfo['lastvisit'] = $bbuserinfo['lastactivity'];
  } else {
    if (!isset($bypass)) {
      if ($noshutdownfunc) {
        $DB_site->query("UPDATE user SET lastactivity=$ourtimenow".iif($showforumusers,",inforum='0' ","")." WHERE userid='$bbuserinfo[userid]'");
      } else {
        $shutdownqueries[99]="UPDATE user SET lastactivity=$ourtimenow".iif($showforumusers,",inforum='0' ","")." WHERE userid='$bbuserinfo[userid]'";
        // This update will be done in the doshutdownfunction automatically, but the old method was doing screwy things!!
      }
    }
    $bbuserinfo['lastvisit'] = $bbuserinfo['lastvisit'];
  }

replace it with:
Code:

  $timeactive = time() - $bbuserinfo['lastactivity'];
  if ($ourtimenow - $bbuserinfo['lastactivity'] > $cookietimeout) {
    if (!isset($bypass)) {
      if ($noshutdownfunc) {
        $DB_site->query("UPDATE user SET ".iif($bbuserinfo['userid']!=0 and $timeactive<(1*60),"timeactivity=timeactivity+$timeactive,","")."lastvisit=lastactivity,lastactivity=$ourtimenow".iif($showforumusers,",inforum='0' ","")." WHERE userid='$bbuserinfo[userid]'");
      } else {
        $shutdownqueries[99]="UPDATE user SET ".iif($bbuserinfo['userid']!=0 and $timeactive<(1*60),"timeactivity=timeactivity+$timeactive,","")."lastvisit=lastactivity,lastactivity=$ourtimenow".iif($showforumusers,",inforum='0'","")." WHERE userid='$bbuserinfo[userid]'";
      }
    }
    $bbuserinfo['lastvisit'] = $bbuserinfo['lastactivity'];
  } else {
    if (!isset($bypass)) {
      if ($noshutdownfunc) {
        $DB_site->query("UPDATE user SET ".iif($bbuserinfo['userid']!=0 and $timeactive<(1*60),"timeactivity=timeactivity+$timeactive,","")."lastactivity=$ourtimenow".iif($showforumusers,",inforum='0' ","")." WHERE userid='$bbuserinfo[userid]'");
      } else {
        $shutdownqueries[99]="UPDATE user SET ".iif($bbuserinfo['userid']!=0 and $timeactive<(1*60),"timeactivity=timeactivity+$timeactive,","")."lastactivity=$ourtimenow".iif($showforumusers,",inforum='0' ","")." WHERE userid='$bbuserinfo[userid]'";
        // This update will be done in the doshutdownfunction automatically, but the old method was doing screwy things!!
      }
    }
    $bbuserinfo['lastvisit'] = $bbuserinfo['lastvisit'];
  }

in postbit template, add:
Code:

Activity Online: <font color="#E4630A">$post[activity]</font> hour$pluralhour
anywhere you like... voila, no queries loaded and also the event time is set to 1, so no more limits and worries about the exact time...

as i said before, i did it this way because all i wanted to have is the time in postbit.
the results? a screenshot is here...

go ahead and update your cool hack now. :)
thanks for letting me aport a small contribution to it.

cheers.
floren. :)

monitox 09-23-2002 06:01 PM

Great great HACK ! :classic:

Thank YOU very much man !
I use it on a (mutilated :) ) 2.2.2 board and works PERFECT !

Have A Cool Day !

monitox 09-23-2002 07:15 PM

TECK > your modification is NOT working for me :glasses:
Give me MySQL error :(

PS: esti cumva Roman ? :D

TECK 09-23-2002 07:21 PM

monitox, it doesnt work because the params and variables are not identical. this is a custom install for my forum, not the original hack. just wait for g-force to customize it, because you add an extra query on the process with his current hack...

and yes i'm romanian.. you can tell by the name. :)

GoTTi 09-23-2002 09:47 PM

g-force =

Yes the code is in the postbit, here is what I got in there:

<p align="right"><smallfont><a href="javascript:openeditsigwindow(490,320,'$session[sessionhash]','$post[userid]')">Edit Sig</a> | <a href="report.php?s=$session[sessionhash]&postid=$post[postid]">Report this post to a moderator</a> | $post[iplogged] | <a href='timeonline.php?s=$session[sessionhash]&action=view_leader'>Time Online:</a>$post[onlinetime]</smallfont></p>

anything wrong?

g-force2k2 09-24-2002 01:52 PM

Da_GoTTi: did you make the admin/functions.php file edit? regards...

g-force2k2

NSeXcellent 09-24-2002 02:43 PM

Quote:

Originally posted by g-force2k2
NSeXcellent:

make sure that the link is this:

PHP Code:

<a href='timeonline.php?s=$session[sessionhash]&action=view_leader'>Time Online:</a


Its identical to that. It just brings up a blank page.

GoTTi 09-24-2002 10:39 PM

yes the modification is on the functions....

all of it is in correctly, i dunno what is causing it.

groovesalad 09-24-2002 11:35 PM

Da Gotti - I'm having the same issue. Just comes up not finding the page.

groovesalad 09-24-2002 11:56 PM

I get a division by zero error when I click on the Time Online link. I've looked at the zero.php file, but it looks like a lot of computer garble. Am I supposed to upload this .php file? I can't decipher directions from it.

groovesalad 09-25-2002 12:05 AM

Quote:

Originally posted by g-force2k2
aight... for all the ppl that feel cheated... here's a code i devised for ya...no the counter isn't buggy because it uses the joindate :p but here's a little code i whipped up for ppl like you that feel cheated :p regards...

open timeonline.php

find:

PHP Code:

            $daysregs floor((time() - $lead[2]) / 86400); 

replace with:

PHP Code:

        // Time Online Hack Addon (fair time per day?) g-force2k2
        
$fairtime 1030505285;
        if(
$joindate $fairtime) {
          
$daysregs floor((time() - $fairtime) /86400);
            } else {
            
$daysregs floor((time() - $lead[2]) / 86400); 
            } 
        
// Time Online Hack Addon (fair time per day?) g-force2k2 

should really change those values up for ya now ;) regards...

g-force2k2

This didn't change anything unfortunately.

groovesalad 09-29-2002 05:10 PM

Anyone know how to make it so regular users can't see how long the Admins have been online?

410 09-30-2002 12:06 AM

Any possible way to like reset the time after each month? So I can create like a "Loser of the month" award or something :) ... and maybe add some sort of log of each month...

Thanks!

\ \ - Speedy - / / 10-14-2002 01:30 PM

ok I have that Profile Change Thingy installed that changes it . .. then when I did what it said in for getinfo template it showed up like this . .

Can someone post a fix for this? Thankx

\ \ - Speedy - / /

NTLDR 10-14-2002 06:47 PM

You need to make sure that the bgcolor is set correctly for the <td> tags in the getinfo_timeone (I think?) template. They should be either { firstaltcolor } or { secondaltcolor } without the spaces.

maverick1969 10-18-2002 04:48 AM

Merci pour ce hack car je vien de le mettre et il est geniel

Sc0rp 10-18-2002 10:13 AM

nice hack..:D installed it and working.. one prob when I click time online though :(

Fatal error: Call to undefined function: dotimeonline() in c:\www\apache\htdocs\zforce\timeonline.php on line 39

whats wrong there?

and is there any way I can show the total time online of the user?

thanx mate :)

N9ne 10-18-2002 06:51 PM

g-force, a tiny request: maybe you could optimize TECK's code on page 15? It reduces queries :) [I dont know about the params and variables so I can't use it...]

BlueVoltage 10-19-2002 12:16 AM

Yes, Please update TECK's code! :(

Bison 10-19-2002 03:05 PM

Quote:

Originally posted by groovesalad
Anyone know how to make it so regular users can't see how long the Admins have been online?
This will remove the Admin Time Online everywhere BUT the threads.... you' still be able to record the admin's time but it won't show in the "View Leaders" and "User Profile" ...

Open your timeonline.php and search for:

WHERE userid !=0 AND timeonline > 0

Change it to:

WHERE userid > 1 AND timeonline > 0

open up member.php ans search for:

$userinfo[onlinetime] = dotimeonline($userinfo[timeonline]);
if($userinfo[timeonline] > 0) {
eval("\$getinfo_timeonline = \"".gettemplate('getinfo_timeonline')."\";");
} else {
$getinfo_template = "";
}

Replace it with:

if ($userinfo[userid] != 1){
$userinfo[onlinetime] = dotimeonline($userinfo[timeonline]);
if($userinfo[timeonline] > 0) {
eval("\$getinfo_timeonline = \"".gettemplate('getinfo_timeonline')."\";");
} else {
$getinfo_template = "";
}
// +++++++ Start Time Online Hack [ g-force2k2 ] +++++++
}

Bison 10-19-2002 05:42 PM

g-force2k2 ...

I would be nice if you modified your code in the zip file to include Teck's additional fixes. I just applied one (To settings.php) and it automatically removed one query from all of my pages.

You've served us well in the past, and personally have done a lot for me behind the scenes.

Everyone (Including the non-coders) here would appreciate it!

Regards,
Rolodex! :)

xevito 10-20-2002 06:52 AM

Quote:

Originally posted by Rolodex


This will remove the Admin Time Online everywhere BUT the threads.... you' still be able to record the admin's time but it won't show in the "View Leaders" and "User Profile" ...

Open your timeonline.php and search for:

WHERE userid !=0 AND timeonline > 0

Change it to:

WHERE userid > 1 AND timeonline > 0

open up member.php ans search for:

$userinfo[onlinetime] = dotimeonline($userinfo[timeonline]);
if($userinfo[timeonline] > 0) {
eval("\$getinfo_timeonline = \"".gettemplate('getinfo_timeonline')."\";");
} else {
$getinfo_template = "";
}

Replace it with:

if ($userinfo[userid] != 1){
$userinfo[onlinetime] = dotimeonline($userinfo[timeonline]);
if($userinfo[timeonline] > 0) {
eval("\$getinfo_timeonline = \"".gettemplate('getinfo_timeonline')."\";");
} else {
$getinfo_template = "";
}
// +++++++ Start Time Online Hack [ g-force2k2 ] +++++++
}



What other mods have you installed as my file doesnt contain the same as yours..

groovesalad 10-20-2002 12:21 PM

Quote:

Originally posted by Rolodex


This will remove the Admin Time Online everywhere BUT the threads.... you' still be able to record the admin's time but it won't show in the "View Leaders" and "User Profile" ...

Open your timeonline.php and search for:

WHERE userid !=0 AND timeonline > 0

Change it to:

WHERE userid > 1 AND timeonline > 0

open up member.php ans search for:

$userinfo[onlinetime] = dotimeonline($userinfo[timeonline]);
if($userinfo[timeonline] > 0) {
eval("\$getinfo_timeonline = \"".gettemplate('getinfo_timeonline')."\";");
} else {
$getinfo_template = "";
}

Replace it with:

if ($userinfo[userid] != 1){
$userinfo[onlinetime] = dotimeonline($userinfo[timeonline]);
if($userinfo[timeonline] > 0) {
eval("\$getinfo_timeonline = \"".gettemplate('getinfo_timeonline')."\";");
} else {
$getinfo_template = "";
}
// +++++++ Start Time Online Hack [ g-force2k2 ] +++++++
}

Yeah, I don't seem to have that either. Here's what I have:

Quote:


if($action == "view_leader") {
$perpage = $usersperpage;
$totalusers = $DB_site->query_first("
SELECT COUNT(*) AS users
FROM user");
$totalpages = ceil($totalusers[0] / $perpage);
if($page == "") {
$page = 1;
}
$startat = ($page-1)*$perpage;
$leadtime = $DB_site->query("
SELECT userid, username, joindate, timeonline
FROM user
WHERE userid!=0
ORDER by timeonline DESC LIMIT $startat,$perpage");
while($lead = $DB_site->fetch_array($leadtime)) {
$userid = $lead[0]; $username = $lead[1]; $joindate = vbdate($dateformat,$lead[2]); $timeonline = dotimeonline($lead[3]);
$daysregs = floor((time() - $lead[2]) / 86400);
if($daysregs == 0) { // checking to see if not registered for more then a day to prevent division by zero
$daysreg = 1;
} else {
$daysreg = $daysregs;
}
$dotimeperday = floor($lead[3] / $daysreg);
$timeperday = dotimeonline($dotimeperday);
eval("\$time_leader.= \"".gettemplate("time_leader")."\";");
}
if($page!=1) {
$prv = $page - 1;
$firstpage = "<a href='timeonline.php?s=$session[sessionhash]&action=view_leader&perpage=$perpage&page=1'\">[ First Page ]</a>";
$prevpage = "<a href='timeonline.php?s=$session[sessionhash]&action=view_leader&perpage=$perpage&page=$prv' \">[ Previous Page ]</a>";
}
if ($page!=$totalpages) {
$nxt = $page+1;
$nextpage = "<a href='timeonline.php?s=$session[sessionhash]&action=view_leader&perpage=$perpage&page=$nxt' \">[ Next Page ]</a>";
$lastpage = "<a href='timeonline.php?s=$session[sessionhash]&action=view_leader&perpage=$perpage&page=$totalpa ges'\">[ Last Page ]</a>";
}
eval("dooutput(\"".gettemplate("time")."\");");
}

and

Quote:


// +++++++ Start Time Online Hack [ g-force2k2 ] +++++++
$userinfo[onlinetime] = dotimeonline($userinfo[timeonline]);
eval("\$getinfo_timeonline = \"".gettemplate('getinfo_timeonline')."\";");
// +++++++ Start Time Online Hack [ g-force2k2 ] +++++++



So, maybe you've got other hacks you're working around?

Bison 10-20-2002 08:21 PM

Can't you see the similarities?

Change this "WHERE userid!=0"

to:

WHERE userid > 1

We all don't have the same hacks on our boards so that may answer your question. Like I did, you have to learn to improvise from others code to get yours to work the way you want.

Peace!

Bison 10-20-2002 08:24 PM

Place the condition around the code you showed me ....

if ($userinfo[userid] != 1){

// +++++++ Start Time Online Hack [ g-force2k2 ] +++++++
$userinfo[onlinetime] = dotimeonline($userinfo[timeonline]);
eval("\$getinfo_timeonline = \"".gettemplate('getinfo_timeonline')."\";");
// +++++++ Start Time Online Hack [ g-force2k2 ] +++++++
}

N9ne 10-21-2002 04:58 PM

Bump for optimized version :(

N9ne 10-21-2002 06:16 PM

A Question: TECK, maybe you can answer this, how many queries does this hack add, and on what pages, w/o your modification?

Also, someone please modify TECK's code so it works, pwease :D

N9ne 10-22-2002 03:00 PM

...bump...


All times are GMT. The time now is 06:31 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.02083 seconds
  • Memory Usage 1,866KB
  • 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
  • (6)bbcode_code_printable
  • (4)bbcode_php_printable
  • (10)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)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