snyperj
asked on
Help me to modify this code and to (more importantly) to understand how...
Hello- we have a small PHP/MySQL forum. I have installed some 3rd party code (hack) that shows a list of users who have visited the forum in the last day. When you hover your mouse over one of the visitors names, it displays a tiny pop-up that shows the time that the user was active. For example, I just hovered over my name and the window said 4:55 PM. Very cool.
The code as it is, is shown below. Here is what I hope someone can help me with.
1.) I would like to know what part of it actually triggers the little pop-up window to fire with the time.
2.) I would like to know how I could add the date to the pop-up window. So in the case of my example above, it would then say 10/24/2006 4:55 PM instead of just 4:55 PM.
The reason for number 2 is that I would like to implement this code in another area of the forum where the date will be necessary. THANKS for any help. I am very new to PHP- though I am eager to dive in!
The code:
-----Start------
if ($show['wvt'])
{
if ($vbulletin->options['wvt2 4'])
{
$cutoff = TIMENOW - 86400;
$whodesc = $vbphrase['visited_today_2 4'];
}
else
{
$whodesc = $vbphrase['visited_today'] ;
$tnow = date('YmdHis',TIMENOW - intval($vbulletin->options ['hourdiff ']));
$cutoff = TIMENOW - (substr($tnow,8,2)*3600 + substr($tnow,10,2)*60 + substr($tnow,12,2));
}
$todaysusers = $vbulletin->db->query_read ("
SELECT userid, lastactivity, options, username, user.usergroupid, displaygroupid,
groupa.opentag as opentaga, groupa.closetag as closetaga,
groupb.opentag as opentagb, groupb.closetag as closetagb
FROM " . TABLE_PREFIX . "user as user
LEFT JOIN " . TABLE_PREFIX . "usergroup as groupa ON(user.usergroupid = groupa.usergroupid)
LEFT JOIN " . TABLE_PREFIX . "usergroup as groupb ON(user.displaygroupid = groupb.usergroupid)
WHERE lastactivity > " .$cutoff. " ORDER BY username
");
$totaltoday = 0;
unset ($whotoday);
while ($today = $vbulletin->db->fetch_arra y($todaysu sers))
{
$totaltoday += 1;
if ($vbulletin->options['wvtn ames'])
{
$today['opentag'] = $today['opentaga'] ;
$today['closetag'] = $today['closetaga'] ;
if ($today['displaygroupid'])
{
$today['opentag'] = $today['opentagb'] ;
$today['closetag'] = $today['closetagb'] ;
}
$today[visible] = 1 ;
if ($today['options'] & $vbulletin->bf_misc_userop tions['inv isible'])
{
$today['visible'] = 0 ;
if (($vbulletin->userinfo['pe rmissions' ]['generic permission s']
& $vbulletin->bf_ugp_generic permission s['canseeh idden'])
OR $today['userid'] == $vbulletin->userinfo['user id'])
{
$today['visible'] = 2 ;
}
}
if ($today['visible'])
{
$wrdate = vbdate($vbulletin->options ['timeform at'], $today['lastactivity']);
$whotoday .= "<a rel=\"nofollow\" href='member.php?u=$today[ userid]' title='$wrdate' >";
if ($today['visible'] == 2)
{
$whotoday .= $today['opentag'].$today[' username'] .$today['c losetag']. "</a>*, ";
}
else
{
$whotoday .= $today['opentag'].$today[' username'] .$today['c losetag']. "</a>, ";
}
}
}
}
if ($whotoday)
{
$whotoday = substr($whotoday, 0, strlen($whotoday)-2);
}
else
{
$whotoday = $vbphrase['no_visitors'];
}
if (!$vbulletin->options['wvt names'])
{
$whotoday = $vbphrase['no_visitors_dis play'];
}
if ($vbulletin->options['wvtc ol'])
{
$show['wvt1']= '<a style="float:'.$stylevar[r ight].'" href="#top" onclick="return toggle_collapse(\'forumhom e_todayuse rs\')"><im g id="collapseimg_forumhome_ todayusers " src="'.$stylevar[imgdir_bu tton].'/co llapse_the ad_collaps ed.gif" alt="" border="0" /></a>';
$show['wvt2']= '<tbody id="collapseobj_forumhome_ todayusers " style="display:none;">';
}
else
{
$show['wvt1']= '<a style="float:'.$stylevar[r ight].'" href="#top" onclick="return toggle_collapse(\'forumhom e_todayuse rs\')"><im g id="collapseimg_forumhome_ todayusers " src="'.$stylevar[imgdir_bu tton].'/co llapse_the ad'.$vbcol lapse[coll apseimg_fo rumhome_to dayusers]. '.gif" alt="" border="0" /></a>';
$show['wvt2']= '<tbody id="collapseobj_forumhome_ todayusers " style="'.$vbcollapse[colla pseobj_for umhome_tod ayusers].' ">';
}
$ftotaltoday = vb_number_format($totaltod ay);
$search_text = '<!-- end logged-in users -->';
$vbulletin->templatecache[ 'FORUMHOME '] = str_replace($search_text,
$search_text.fetch_templat e('Display _Visitors' ),$vbullet in->templa tecache['F ORUMHOME'] );
}
-----End-----
The code as it is, is shown below. Here is what I hope someone can help me with.
1.) I would like to know what part of it actually triggers the little pop-up window to fire with the time.
2.) I would like to know how I could add the date to the pop-up window. So in the case of my example above, it would then say 10/24/2006 4:55 PM instead of just 4:55 PM.
The reason for number 2 is that I would like to implement this code in another area of the forum where the date will be necessary. THANKS for any help. I am very new to PHP- though I am eager to dive in!
The code:
-----Start------
if ($show['wvt'])
{
if ($vbulletin->options['wvt2
{
$cutoff = TIMENOW - 86400;
$whodesc = $vbphrase['visited_today_2
}
else
{
$whodesc = $vbphrase['visited_today']
$tnow = date('YmdHis',TIMENOW - intval($vbulletin->options
$cutoff = TIMENOW - (substr($tnow,8,2)*3600 + substr($tnow,10,2)*60 + substr($tnow,12,2));
}
$todaysusers = $vbulletin->db->query_read
SELECT userid, lastactivity, options, username, user.usergroupid, displaygroupid,
groupa.opentag as opentaga, groupa.closetag as closetaga,
groupb.opentag as opentagb, groupb.closetag as closetagb
FROM " . TABLE_PREFIX . "user as user
LEFT JOIN " . TABLE_PREFIX . "usergroup as groupa ON(user.usergroupid = groupa.usergroupid)
LEFT JOIN " . TABLE_PREFIX . "usergroup as groupb ON(user.displaygroupid = groupb.usergroupid)
WHERE lastactivity > " .$cutoff. " ORDER BY username
");
$totaltoday = 0;
unset ($whotoday);
while ($today = $vbulletin->db->fetch_arra
{
$totaltoday += 1;
if ($vbulletin->options['wvtn
{
$today['opentag'] = $today['opentaga'] ;
$today['closetag'] = $today['closetaga'] ;
if ($today['displaygroupid'])
{
$today['opentag'] = $today['opentagb'] ;
$today['closetag'] = $today['closetagb'] ;
}
$today[visible] = 1 ;
if ($today['options'] & $vbulletin->bf_misc_userop
{
$today['visible'] = 0 ;
if (($vbulletin->userinfo['pe
& $vbulletin->bf_ugp_generic
OR $today['userid'] == $vbulletin->userinfo['user
{
$today['visible'] = 2 ;
}
}
if ($today['visible'])
{
$wrdate = vbdate($vbulletin->options
$whotoday .= "<a rel=\"nofollow\" href='member.php?u=$today[
if ($today['visible'] == 2)
{
$whotoday .= $today['opentag'].$today['
}
else
{
$whotoday .= $today['opentag'].$today['
}
}
}
}
if ($whotoday)
{
$whotoday = substr($whotoday, 0, strlen($whotoday)-2);
}
else
{
$whotoday = $vbphrase['no_visitors'];
}
if (!$vbulletin->options['wvt
{
$whotoday = $vbphrase['no_visitors_dis
}
if ($vbulletin->options['wvtc
{
$show['wvt1']= '<a style="float:'.$stylevar[r
$show['wvt2']= '<tbody id="collapseobj_forumhome_
}
else
{
$show['wvt1']= '<a style="float:'.$stylevar[r
$show['wvt2']= '<tbody id="collapseobj_forumhome_
}
$ftotaltoday = vb_number_format($totaltod
$search_text = '<!-- end logged-in users -->';
$vbulletin->templatecache[
$search_text.fetch_templat
}
-----End-----
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i think this part shows the popup window
if ($vbulletin->options['wvtc
{
$show['wvt1']= '<a style="float:'.$stylevar[r
$show['wvt2']= '<tbody id="collapseobj_forumhome_
}
else
{
$show['wvt1']= '<a style="float:'.$stylevar[r
$show['wvt2']= '<tbody id="collapseobj_forumhome_
}