User Online Time And Shop

Started on the old forum in May 2007 · view the original in the archive · old links redirect here

17 replies · 2,645 views · started 19 years ago · 1 min read

TL;DR · summary of 17 replies
  • - - User wanted to know how to track how long users spend on site.
  • - - Code for tracking idle time was provided, but not for total time spent on site.
  • - - A suggestion was made to add two new columns (totaltime and temptime) in the database to track user activity duration.
  • - - A guest provided a code snippet for calculating idle time based on last active timestamp.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

5 participants
Megabrain #1

Hi, how do i code the user online time eg:

In User Profile

Member's ID: Status: A/S/L: Topics: Posts: PMs IN: OUT: Credits: Chat Posts: User Time: 1 day, 23 hours, 7 minutes, 56seconds Battle Points: Shouts: Joined M: Last Active: Last Visit: Browser: Martial Status: E-mail: Site: Signature: IP: Buddies:


i also want to know the codes of the shop to buy items and send via a pm

eg: BUY FLOWERS

Then i want to send it to a user

linkrx7 #2

replace this with the gettimemsg() function

function gettimemsg($sec)
{
//////////////
$years=0;
$months=0;
$weeks=0;
$days=0;
$mins=0;
$hours=0;
if ($sec>60)
{
$secs=$sec%60;
$mins=$sec/60;
$mins=(integer)$mins;
}

if ($mins>60)
{
$hours=$mins/60;
$hours=(integer)$hours;
$mins=$mins%60;
}

if ($hours>24)
{
$days=$hours/24;
$days=(integer)$days;
$hours=$hours%24;
}

if ($days>7)
{
$weeks=$days/7;
$weeks=(integer)$weeks;
$days=$days%7;
}

if ($weeks>4)
{
$months=$weeks/4;
$months=(integer)$months;
$weeks=$weeks%4;
}

if ($months>12)
{
$years=$months/12;
$years=(integer)$years;
$months=$months%12;
}

if($years>0)
{
if($years==1){$yearmsg="year";}else{$yearmsg="years";}
if($months==1){$monthsmsg="month";}else{$monthsmsg="months";}
if($days==1){$daysmsg="day";}else{$daysmsg="days";}
if($hours==1){$hoursmsg="hour";}else{$hoursmsg="hours";}
if($mins==1){$minsmsg="minute";}else{$minsmsg="minutes";}
if($secs==1){$secsmsg="second";}else{$secsmsg="seconds";}

if($months!=0){$monthscheck="$months $monthsmsg ";}else{$monthscheck="";}
if($days!=0){$dayscheck="$days $daysmsg ";}else{$dayscheck="";}
if($hours!=0){$hourscheck="$hours $hoursmsg ";}else{$hourscheck="";}
if($minutes!=0){$minscheck="$mins $minsmsg ";}else{$minscheck="";}
if($secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

return "$years $yearmsg $monthscheck$dayscheck$hourscheck$minscheck$secscheck";
}

if(($years<1)&&($months>0))
{
if($months==1){$monthsmsg="month";}else{$monthsmsg="months";}
if($days==1){$daysmsg="day";}else{$daysmsg="days";}
if($hours==1){$hoursmsg="hour";}else{$hoursmsg="hours";}
if($mins==1){$minsmsg="minute";}else{$minsmsg="minutes";}
if($secs==1){$secsmsg="second";}else{$secsmsg="seconds";}

if($days!=0){$dayscheck="$days $daysmsg ";}else{$dayscheck="";}
if($hours!=0){$hourscheck="$hours $hoursmsg ";}else{$hourscheck="";}
if($minutes!=0){$minscheck="$mins $minsmsg ";}else{$minscheck="";}
if($secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

return "$months $monthsmsg $dayscheck$hourscheck$minscheck$secscheck";
}

if(($months<1)&&($weeks>0))
{
if($weeks==1){$weeksmsg="week";}else{$weeksmsg="weeks";}
if($days==1){$daysmsg="day";}else{$daysmsg="days";}
if($hours==1){$hoursmsg="hour";}else{$hoursmsg="hours";}
if($mins==1){$minsmsg="minute";}else{$minsmsg="minutes";}
if($secs==1){$secsmsg="second";}else{$secsmsg="seconds";}

if($days!=0){$dayscheck="$days $daysmsg ";}else{$dayscheck="";}
if($hours!=0){$hourscheck="$hours $hoursmsg ";}else{$hourscheck="";}
if($minutes!=0){$minscheck="$mins $minsmsg ";}else{$minscheck="";}
if($secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

return "$weeks $weeksmsg $dayscheck$hourscheck$minscheck$secscheck";
}

if(($weeks<1)&&($days>0))
{
if($days==1){$daysmsg="day";}else{$daysmsg="days";}
if($hours==1){$hoursmsg="hour";}else{$hoursmsg="hours";}
if($mins==1){$minsmsg="minute";}else{$minsmsg="minutes";}
if($secs==1){$secsmsg="second";}else{$secsmsg="seconds";}

if($hours!=0){$hourscheck="$hours $hoursmsg ";}else{$hourscheck="";}
if($minutes!=0){$minscheck="$mins $minsmsg ";}else{$minscheck="";}
if($secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

return "$days $daysmsg $hourscheck$minscheck$secscheck";
}

if(($days<1)&&($hours>0))
{
if($hours==1){$hoursmsg="hour";}else{$hoursmsg="hours";}
if($mins==1){$minsmsg="minute";}else{$minsmsg="minutes";}
if($secs==1){$secsmsg="second";}else{$secsmsg="seconds";}

if($minutes!=0){$minscheck="$mins $minsmsg ";}else{$minscheck="";}
if($secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

return "$hours $hoursmsg $minscheck$secscheck";
}

if(($hours<1)&&($mins>0))
{
if($mins==1){$minsmsg="minute";}else{$minsmsg="minutes";}
if($secs==1){$secsmsg="second";}else{$secsmsg="seconds";}

if($secs!=0){$secscheck="$secs $secsmsg";}else{$secscheck="";}

return "$mins $minsmsg $secscheck";
}

if(($mins<1)&&($sec>0))
{
if($sec==1){$secsmsg="second";}else{$secsmsg="seconds";}

if($sec!=0){$secscheck="$sec $secsmsg";}else{$secscheck="";}

return "$secscheck";
}
}

then add this to profiles code

$noi = mysql_fetch_array(mysql_query("SELECT lastact FROM ibwf_users WHERE id='".$who."'"));
$var1 = date("His",$noi[0]);
$var2 = time();
$var21 = date("His",$var2);
$var3 = $var21 - $var1;
$var4 = date("s",$var3);
echo "[b]Idle For:[/b] ";
$remain = time() - $noi[0];
$idle = gettimemsg($remain);
echo "$idle
";

then that should be it

Megabrain #3

Where is gettimemsg() function

alesh Lead · 604 posts #4

Where is gettimemsg() function

its in the core....

btw linkrx7 thanx 4 tht but thts just 4 idle time...... cn it b used 4 how many time user spend at site??????

eeeeerrr....

WhiteWarrior Principal · 1,419 posts #5

idle time is how long they been on the site....

alesh Lead · 604 posts #6

idle time is how long they been on the site....

ur wrong..... this code makes u c how long user is not active..... im nt tht stupid u knw......

look at the code ... it say IDLE......

eeeeerrr....

FlareX #7

YEP Alesh ryt

alesh Lead · 604 posts #8

YEP Alesh ryt

LOL i knw my english sux a lil bit but if they understood me at california, then they'll understand me here 2 lmao....

ANYWAY IDLE TIME WORKS BUT WHTS THE CODE 4 HOW ANY TIME USER SPEND AT SITE....???????

ANY1 SO GOOD AND SHARE IT PLS

eeeeerrr....

FlareX #9

I Also Want That Code

WhiteWarrior Principal · 1,419 posts #10

how long they spent at the site?.. you dont make sence mate lol how long they been registered is how long they been at the site for! if you explane what you mean maybe people would help!!! you mean how long they been "ONLINE" for?..

alesh Lead · 604 posts #11

how long they spent at the site?.. you dont make sence mate lol how long they been registered is how long they been at the site for! if you explane what you mean maybe people would help!!! you mean how long they been "ONLINE" for?..

well fkn yes!!!! wht doesnt make any sence?????????????? how long they spent at site yes..... or if u prefer ONLINE FOR

eeeeerrr....

linkrx7 #12

thats quite pointless when u got registered time and idle time aint they enough? lol

alesh Lead · 604 posts #13

thats quite pointless when u got registered time and idle time aint they enough? lol

no its not lol

i removed reg time, last act and last visit and i got just idle time.... so now i wanna put excatly how many time they spent at site or like DrugsBunny prefer ONLINE FOR:!!!!!!!!!

but i cnt figure it out the code......

eeeeerrr....

hellspawn #14

hmmm ....

there is a way.

Ive put me head to it, the best way is to add 2 new colums to ibwf_users eg. totaltime and temptime.

then at the top of each page where it updates the users session, add a function to update the users temptime from last login to that specific time.

Then whenever a user logs in, the script should add the temptime to the totaltime and start the temptime process over again?

Just a thought, it will work -tea- lol

Guest #15

My code for Idle:

$noi = mysql_fetch_array(mysql_query("SELECT lastact FROM ibwf_users WHERE id='".$who."'")); $remain = time() - $noi[0];

$num = $remain/86400; $days = intval($num); $num2 = ($num - $days)*24; $hours = intval($num2); $num3 = ($num2 - $hours)*60; $mins = intval($num3); $num4 = ($num3 - $mins)*60; $secs = intval($num4);

echo "Idle For: "; if(($days==0) and ($hours==0) and ($mins==0)){ echo "$secs seconds "; }else if(($days==0) and ($hours==0)){ echo "$mins mins, "; echo "$secs seconds "; }else if(($days==0)){ echo "$hours hours, "; echo "$mins mins, "; echo "$secs seconds "; }else{ echo "$days days, "; echo "$hours hours, "; echo "$mins mins, "; echo "$secs seconds "; }

alexism Developer · 136 posts #16

can anybody give me the total online code for funmobile??thanks all..

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close