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 04-21-2001, 10:58 PM
SystemLogic SystemLogic is offline
 
Join Date: Nov 2001
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there anyway that I can put some sort of code on the pages of my actual site (not the message boards) so that it adds each person to the # of users online? And then put something on each page of my site:

"XXX Users Currently Online"

I think it would be pretty easy to do something like this, but if anybody can let me know, I would appreciate it a lot.
Reply With Quote
  #2  
Old 04-22-2001, 06:15 AM
JamesUS's Avatar
JamesUS JamesUS is offline
 
Join Date: Oct 2001
Posts: 347
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I believe to do this all you need to do is do:
PHP Code:
require("./forums/global.php"); 
And to add it to your own page just look at how it is done in index.php
Reply With Quote
  #3  
Old 04-22-2001, 04:31 PM
SystemLogic SystemLogic is offline
 
Join Date: Nov 2001
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just tried that and it's not working.....Is it just me, or does that not work?
Reply With Quote
  #4  
Old 04-22-2001, 05:15 PM
JamesUS's Avatar
JamesUS JamesUS is offline
 
Join Date: Oct 2001
Posts: 347
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What doesn't work about it?
Reply With Quote
  #5  
Old 04-22-2001, 05:19 PM
Wayne Luke's Avatar
Wayne Luke Wayne Luke is offline
Senior Member
 
Join Date: Jan 2002
Location: Southern California
Posts: 1,694
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

We include a pseudo-total on many of our pages at SitePoint. We do it by running a cron job every 5 minutes and putting the results into a text file. We then include that text file where ever we want the information to display. Mainly in the various active topic sections throughout the network. This text file is stored in our admin directory as is the code to generate it.

Here is the script we use:
PHP Code:
// Now Online - copyright 2001 SitePoint Pty. Ltd. All Rights Reserved.
<?
chdir("..");
include("global.php");
chdir("admin");

$datecut=time()-$cookietimeout;

$loggedins=$DB_site->query_first("SELECT COUNT(*) AS sessions FROM session WHERE userid=0 AND lastactivity>$datecut");
$numberguest=$loggedins['sessions'];

$numbervisible=0;
$numberregistered=0;
$loggedins=$DB_site->query("SELECT DISTINCT session.userid,username,invisible
                            FROM session
                            LEFT JOIN user ON (user.userid=session.userid)
                            WHERE session.userid<>0 AND session.lastactivity>$datecut
                            ORDER BY invisible ASC, username ASC");
while ($loggedin=$DB_site->fetch_array($loggedins)) {
  $numberregistered++;
}
$DB_site->free_result($loggedins);

$totalonline=$numberregistered+$numberguest;

($numberregistered > 1) ? ($membertext = "members")   : ($membertext = "member");
($numberguest > 1)  ? ($guesttext = "guests")   : ($guesttext = "guest");


$fp = fopen ("nowonline.txt", "w");
fwrite
(
  $fp,
  "There are currently $numberregistered $membertext and $numberguest $guesttext on the forums.<br>"
);
fclose ($fp);

?>
Feel free to use it as long as the copyright remains.
Reply With Quote
  #6  
Old 04-22-2001, 06:25 PM
SystemLogic SystemLogic is offline
 
Join Date: Nov 2001
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wluke, thanks for that script, but that is not exactly what I was looking for, although part of it. Let me give an example.

Say you head to my site, systemlogic.net to read a review. That user is not in the forums, but I would like them to be added to the online list (so if they are not registered or logged on they are guests). So basically to add the users online functionality to the actual site. And then with that, do what you did to include the total number of users online.

This seems like it would be possible by just doing whatever kind PHP code or cookie code onto each page that I want to be included, right?
Reply With Quote
  #7  
Old 04-22-2001, 09:21 PM
Fred
Guest
 
Posts: n/a
Default

James gave you the code to do it.

I need to know how do you put a PHP code such as James of Luke's, into a .shtml file?
Reply With Quote
  #8  
Old 04-22-2001, 09:30 PM
SystemLogic SystemLogic is offline
 
Join Date: Nov 2001
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Alright well I added global.php and saw no difference. And then I tried putting some stuff from index.php in but I kept getting errors. So I have no clue what sort of PHP code to put, so if anybody that knows how to code, could you help me out?

Also, I don't think it's possible to parse PHP in a .shtml file right?
Reply With Quote
  #9  
Old 04-22-2001, 09:49 PM
tubedogg's Avatar
tubedogg tubedogg is offline
 
Join Date: Oct 2001
Location: Medina, OH
Posts: 785
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<!--#include file="file.php"-->

That will include the file.php and parse whatever is in file.php. (you would put this in a .shtm or .shtml file).
Reply With Quote
  #10  
Old 04-23-2001, 03:14 PM
SystemLogic SystemLogic is offline
 
Join Date: Nov 2001
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Alright I put this on some pages:

PHP Code:
<?

require("$abspath/boards/global.php");

if ($displayloggedin) {
  $datecut=time()-$cookietimeout;

  //$loggedins=$DB_site->query_first("SELECT COUNT(*) AS sessions FROM session WHERE lastactivity>$datecut");
  //$totalonline=$loggedins['sessions'];
  $loggedins=$DB_site->query_first("SELECT COUNT(*) AS sessions FROM session WHERE userid=0 AND lastactivity>$datecut");
  $numberguest=$loggedins['sessions'];
  //$numberregistered=$totalonline-$numberguest;

  $numbervisible=0;
  $numberregistered=0;
  //$loggedins=$DB_site->query("SELECT DISTINCT user.userid,username FROM user,session WHERE session.userid=user.userid AND session.userid<>0 AND invisible=0 AND session.lastactivity>$datecut ORDER BY username");
  $loggedins=$DB_site->query("SELECT DISTINCT session.userid,username,invisible
                              FROM session
                              LEFT JOIN user ON (user.userid=session.userid)
                              WHERE session.userid>0 AND session.lastactivity>$datecut
                              ORDER BY invisible, username");
  if ($loggedin=$DB_site->fetch_array($loggedins)) {
    $numberregistered++;
    if ($loggedin['invisible']==0 or $bbuserinfo['usergroupid']==6) {
      $numbervisible++;
      $userid=$loggedin['userid'];
      if ($loggedin['invisible']==1) { // Invisible User but show to Admin
        $username=$loggedin['username'];
        $invisibleuser = '*';
      } else {
        $username=$loggedin['username'];
        $invisibleuser = '';
      }
      $location=$loggedin['location'];
      eval("\$activeusers = \"".gettemplate('forumhome_loggedinuser')."\";");
    }

    while ($loggedin=$DB_site->fetch_array($loggedins)) {
      $numberregistered++;
      $invisibleuser = '';
      if ($loggedin['invisible']==1 and $bbuserinfo['usergroupid']!=6) {
        continue;
      }
      $numbervisible++;
      $userid=$loggedin['userid'];
      if ($loggedin['invisible']==1) { // Invisible User but show to Admin
        $username=$loggedin['username'];
        $invisibleuser = '*';
      } else {
        $username=$loggedin['username'];
      }
      $location=$loggedin['location'];
      eval("\$activeusers .= \", ".gettemplate('forumhome_loggedinuser')."\";");
    }
  }
  $DB_site->free_result($loggedins);

  $totalonline=$numberregistered+$numberguest;
  $numberinvisible=$numberregistered-$numbervisible;

  $maxusers=explode(" ", gettemplate('maxloggedin',0,0));
  if ((int)$maxusers[0] <= $totalonline) {
    $time = time();
    $maxloggedin = "$totalonline " . $time;
    $DB_site->query("UPDATE template SET template='$maxloggedin' WHERE title='maxloggedin'");
    $maxusers[0] = $totalonline;
    $maxusers[1] = $time;
  }
  $recordusers = $maxusers[0];
  $recorddate = vbdate($dateformat,$maxusers[1]);
  $recordtime = vbdate($timeformat,$maxusers[1]);
  eval("\$loggedinusers = \"".gettemplate('forumhome_loggedinusers')."\";");
}

?>
Note for VB guys, if this is against the VB license posting that much code, let me know and I'll delete it.

Is this wrong? Because it still doesn't show all the other users on the main page of the forum.
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 11:26 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.17040 seconds
  • Memory Usage 2,270KB
  • 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
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (9)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete