Link to home
Start Free TrialLog in
Avatar of snyperj
snyperjFlag for United States of America

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['wvt24'])
      {
            $cutoff = TIMENOW - 86400;
            $whodesc = $vbphrase['visited_today_24'];
      }
      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_array($todaysusers))
      {
            $totaltoday += 1;
            if ($vbulletin->options['wvtnames'])
            {
                  $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_useroptions['invisible'])
                  {
                        $today['visible'] = 0 ;
                        if (($vbulletin->userinfo['permissions']['genericpermissions']
                        & $vbulletin->bf_ugp_genericpermissions['canseehidden'])
                        OR $today['userid'] == $vbulletin->userinfo['userid'])
                        {
                              $today['visible'] = 2 ;
                        }
                  }
                  if ($today['visible'])
                  {
                        $wrdate = vbdate($vbulletin->options['timeformat'], $today['lastactivity']);
                        $whotoday .= "<a rel=\"nofollow\" href='member.php?u=$today[userid]' title='$wrdate' >";
                        if ($today['visible'] == 2)
                        {
                              $whotoday .= $today['opentag'].$today['username'].$today['closetag']."</a>*, ";
                        }
                        else
                        {
                              $whotoday .= $today['opentag'].$today['username'].$today['closetag']."</a>, ";
                        }
                  }
            }
      }

      if ($whotoday)
      {
            $whotoday = substr($whotoday, 0, strlen($whotoday)-2);
      }
      else
      {
            $whotoday = $vbphrase['no_visitors'];
      }

      if (!$vbulletin->options['wvtnames'])
      {
            $whotoday = $vbphrase['no_visitors_display'];
      }

      if ($vbulletin->options['wvtcol'])
      {
            $show['wvt1']= '<a style="float:'.$stylevar[right].'" href="#top" onclick="return toggle_collapse(\'forumhome_todayusers\')"><img id="collapseimg_forumhome_todayusers" src="'.$stylevar[imgdir_button].'/collapse_thead_collapsed.gif" alt="" border="0" /></a>';
            $show['wvt2']= '<tbody id="collapseobj_forumhome_todayusers" style="display:none;">';
      }
      else
      {
            $show['wvt1']= '<a style="float:'.$stylevar[right].'" href="#top" onclick="return toggle_collapse(\'forumhome_todayusers\')"><img id="collapseimg_forumhome_todayusers" src="'.$stylevar[imgdir_button].'/collapse_thead'.$vbcollapse[collapseimg_forumhome_todayusers].'.gif" alt="" border="0" /></a>';
            $show['wvt2']= '<tbody id="collapseobj_forumhome_todayusers" style="'.$vbcollapse[collapseobj_forumhome_todayusers].'">';
      }

      $ftotaltoday = vb_number_format($totaltoday);
      $search_text = '<!-- end logged-in users -->';
      $vbulletin->templatecache['FORUMHOME'] = str_replace($search_text,
      $search_text.fetch_template('Display_Visitors'),$vbulletin->templatecache['FORUMHOME']);
}

-----End-----


Avatar of momi_sabag
momi_sabag
Flag of United States of America image

hi

i think this part shows the popup window

     if ($vbulletin->options['wvtcol'])
     {
          $show['wvt1']= '<a style="float:'.$stylevar[right].'" href="#top" onclick="return toggle_collapse(\'forumhome_todayusers\')"><img id="collapseimg_forumhome_todayusers" src="'.$stylevar[imgdir_button].'/collapse_thead_collapsed.gif" alt="" border="0" /></a>';
          $show['wvt2']= '<tbody id="collapseobj_forumhome_todayusers" style="display:none;">';
     }
     else
     {
          $show['wvt1']= '<a style="float:'.$stylevar[right].'" href="#top" onclick="return toggle_collapse(\'forumhome_todayusers\')"><img id="collapseimg_forumhome_todayusers" src="'.$stylevar[imgdir_button].'/collapse_thead'.$vbcollapse[collapseimg_forumhome_todayusers].'.gif" alt="" border="0" /></a>';
          $show['wvt2']= '<tbody id="collapseobj_forumhome_todayusers" style="'.$vbcollapse[collapseobj_forumhome_todayusers].'">';
     }
ASKER CERTIFIED SOLUTION
Avatar of Costaud
Costaud

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial