vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Graveyard (https://vborg.vbsupport.ru/forumdisplay.php?f=224)
-   -   Members who have visited today (with last 24 hours option). (https://vborg.vbsupport.ru/showthread.php?t=71533)

Paul M 01-09-2005 09:43 AM

Quote:

Originally Posted by Mosaicvb
Works like a charm for me. Thanks for your work. I hope I don't offend you by posting what I did.

I would like to know since I dont play in vB a lot whether anything I did would open a security hole.

Well it's a bit of a odd thing to do, but it won't open any security holes. However, you realise that by doing this, you will run the code on every vB page you ever view, not just the forumhome page ?

samael 01-09-2005 11:09 AM

I got this error after editing the files.

Parse error: parse error, unexpected '\"', expecting ']' in /home/rpboards/public_html/forum/index.php(420) : eval()'d code on line 201

Paul M 01-09-2005 01:28 PM

That would suggest you made a mistake in the template update.

good2laugh 01-09-2005 02:54 PM

Installed and working perfectly - thanks, this was one of the easiest modifications/hacks I've used. :D

ericgtr 01-09-2005 03:58 PM

I see someone else has made a variation of this, I did also and I will share it here. Basically, I like the idea of it showing how many users are online today but not the names on my forumhome, I want that in a new page. The other modification for this does this but has never worked on my site, the numbers were different when you clicked on it. So I made it so this will work in a new page.

Create a new php page called online_today.php add all of the following code to it and save:
PHP Code:

<?php
// ####################### SET PHP ENVIRONMENT ########################### 
error_reporting(E_ALL & ~E_NOTICE); 

// #################### DEFINE IMPORTANT CONSTANTS ####################### 
define('NO_REGISTER_GLOBALS'1); 
define('THIS_SCRIPT''online_today'); // change this depending on your filename 

// ################### PRE-CACHE TEMPLATES AND DATA ###################### 
// get special phrase groups 
$phrasegroups = array( 

); 

// get special data templates from the datastore 
$specialtemplates = array( 
     
); 

// pre-cache templates used by all actions 
$globaltemplates = array( 
    
'online_today'
); 

// pre-cache templates used by specific actions 
$actiontemplates = array( 

); 

// ######################### REQUIRE BACK-END ############################ 
require_once('./global.php'); 

// ####################################################################### 
// ######################## START MAIN SCRIPT ############################ 
// ####################################################################### 

$navbits = array(); 
$navbits[$parent] = 'Online Today'
$now TIMENOW ;
require_once(
'./includes/functions_misc.php');
$cutoff vbmktime(000vbdate('m'$nowfalsefalse), vbdate('d'$nowfalsefalse), vbdate('Y'$nowfalsefalse));
//$cutoff = $now - 86400 ;  // Uncomment this line if you don't have vB 3.0.3 and all users are showing.
$todaysusers $DB_site->query("SELECT userid, lastactivity, options, username, opentag, closetag
FROM " 
TABLE_PREFIX "user as user
LEFT JOIN " 
TABLE_PREFIX "usergroup as usergroup ON(user.usergroupid = usergroup.usergroupid)
WHERE lastactivity > " 
.$cutoff" ORDER BY username" ); 

$totaltoday 0;
while (
$today $DB_site->fetch_array($todaysusers))
{
    
$today[visible] = ;
    
$totaltoday += 1;
    if (
$today[options] & $_USEROPTIONS[invisible]) 
    {
        
$today[visible] = ;
        if ((
$permissions['genericpermissions'] & CANSEEHIDDEN) OR $today['userid'] == $bbuserinfo['userid'])
        {
            
$today[visible] = ;
        }
    }
    if (
$today[visible]) 
    {
           
$wrdate vbdate($vboptions['timeformat'], $today['lastactivity']);
        
$whotoday .= "<a 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($whotoday0strlen($whotoday)-2);
}

$navbits construct_navbits($navbits); 
eval(
'$navbar = "' fetch_template('navbar') . '";'); 
eval(
'print_output("' fetch_template('online_today') . '");'); 

?>

Upload to your vb directory


Create a new template called online_today
PHP Code:

$stylevar[htmldoctype]
<
html dir="$stylevar[textdirection]lang="$stylevar[languagecode]">
<
head>
<
title>$vboptions[bbtitle]</title>
$headinclude
</head>
<
body>
$header
$navbar
<!-- Todays active users -->
<
tbody>
    <
tr>
        <
td class="thead" colspan="2">
            <
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>
            
Total users that have visited today$totaltoday
        
</td>
    </
tr>
</
tbody>
<
tbody id="collapseobj_forumhome_todayusers" style="$vbcollapse[collapseobj_forumhome_todayusers]">
    <
tr>
        <
td class="alt2"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="Users online today" border="0" /></td>
        <
td class="alt1" width="100%"><div class="smallfont">$whotoday</div></td>
    </
tr>
</
tbody>
<!-- 
Todays active users -->
</if>
$footer
</body>
</
html

NOTE: This is a change to the existing modification.

Now in your FORUMHOME template find:
PHP Code:

<if condition="$show['loggedinusers']">
<!-- 
logged-in users -->
<
tbody>
    <
tr>
        <
td class="thead" colspan="2">
            <
a style="float:$stylevar[right]href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_activeusers].gif" alt="" border="0" /></a>
            <
a href="online.php?$session[sessionurl]">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
        </
td>
    </
tr>
</
tbody>
<
tbody id="collapseobj_forumhome_activeusers" style="$vbcollapse[collapseobj_forumhome_activeusers]">
    <
tr>
        <
td class="alt2"><a href="online.php?$session[sessionurl]"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="$vbphrase[view_whos_online]border="0" /></a></td>
        <
td class="alt1" width="100%">
            <
div class="smallfont">
                <
div style="white-space: nowrap"><phrase 1="$recordusers2="$recorddate3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
                <
div>$activeusers</div>
            </
div>
        </
td>
    </
tr>
</
tbody>
<!-- 
end logged-in users -->

<!-- 
Todays active users -->
<
tbody>
    <
tr>
        <
td class="thead" colspan="2">
            <
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>
            
Total users that have visited today$totaltoday
        
</td>
    </
tr>
</
tbody>
<
tbody id="collapseobj_forumhome_todayusers" style="$vbcollapse[collapseobj_forumhome_todayusers]">
    <
tr>
        <
td class="alt2"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="Users online today" border="0" /></td>
        <
td class="alt1" width="100%"><div class="smallfont">$whotoday</div></td>
    </
tr>
</
tbody>
<!-- 
Todays active users -->
</if> 

Change to:
PHP Code:

<if condition="$show['loggedinusers']">

<!-- 
Todays active users -->
<
tbody>
    <
tr>
        <
td class="thead" colspan="2">
            <
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>
            <
a href="online_today.php?$session[sessionurl]">Total users that have visited today</a>: $totaltoday
        
</td>
    </
tr>
</
tbody>
<!-- 
Todays active users -->
</if> 


Mosaicvb 01-09-2005 05:17 PM

Quote:

Originally Posted by Paul M
Well it's a bit of a odd thing to do, but it won't open any security holes. However, you realise that by doing this, you will run the code on every vB page you ever view, not just the forumhome page ?


Nope I didn't. Not good.. lol

thanks for the headsup

shadiguy1 01-10-2005 02:51 AM

ERICGTR can u make this into a module for vbadvanced CMPS as i see you make alot of modules for CMPS

Viks 01-10-2005 07:04 AM

Quote:

Originally Posted by shadiguy1
ERICGTR can u make this into a module for vbadvanced CMPS as i see you make alot of modules for CMPS

yes... do it.. do it
:nervous:

BBoo 01-10-2005 08:02 AM

Thanks Paul, just installed works perfect! :)

noppid 01-10-2005 02:03 PM

Quote:

Originally Posted by Mosaicvb
I just installed this mod with vb 3.0.5 and it works great. I made some changes and I am posting what I did if you want to have an option that does not require altering the index.php.

1 : create a php file called whos.online.today.php with the following and upload to the root of the forum. :

PHP Code:

<?php
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

$now TIMENOW ;
require_once(
'./includes/functions_misc.php');
$cutoff vbmktime(000vbdate('m'$nowfalsefalse), vbdate('d'$nowfalsefalse), vbdate('Y'$nowfalsefalse));
//$cutoff = $now - 86400 ;  // Uncomment this line if you don't have vB 3.0.3 and all users are showing.
$todaysusers $DB_site->query("SELECT userid, lastactivity, options, username, opentag, closetag
FROM " 
TABLE_PREFIX "user as user
LEFT JOIN " 
TABLE_PREFIX "usergroup as usergroup ON(user.usergroupid = usergroup.usergroupid)
WHERE lastactivity > " 
.$cutoff" ORDER BY username" ); 

$totaltoday 0;
while (
$today $DB_site->fetch_array($todaysusers))
{
    
$today[visible] = ;
    
$totaltoday += 1;
    if (
$today[options] & $_USEROPTIONS[invisible]) 
    {
        
$today[visible] = ;
        if ((
$permissions['genericpermissions'] & CANSEEHIDDEN) OR $today['userid'] == $bbuserinfo['userid'])
        {
            
$today[visible] = ;
        }
    }
    if (
$today[visible]) 
    {
           
$wrdate vbdate($vboptions['timeformat'], $today['lastactivity']);
        
$whotoday .= "<a 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($whotoday0strlen($whotoday)-2);
}

?>


2: Go to the style manager. Open the style you want to edit.
In the common template section goto the phpinclude_start box and enter :

Code:

ob_start();
include('whos.online.today.php');
ob_end_clean();


3: Follow your instructions for replacing the code in the Forumhome template.

Done.

Works like a charm for me. Thanks for your work. I hope I don't offend you by posting what I did.

I would like to know since I dont play in vB a lot whether anything I did would open a security hole.


You may want to consider adding a conditional to your phpinclude_start template to only run that query when the page selected is forum home or your new WWOL page. As it is that code runs on every page loaded whether it's used or not. Just a little optimization suggestion. :)


All times are GMT. The time now is 03: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.01741 seconds
  • Memory Usage 1,893KB
  • 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
  • (1)bbcode_code_printable
  • (5)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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