vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   List of new members during last 24h (https://vborg.vbsupport.ru/showthread.php?t=76249)

Olsufr 02-12-2005 10:00 PM

List of new members during last 24h
 
Simple hack to display new registered members during last 24 hours.

A very simple display of all members who have registered in the forum during last 24 hours.

It displays statistics and the list of new registered members (last 24h) on Forum Home
under the "Users online" display.

The list is now in chronological order (newest first, oldest last).

example:
" Welcome to our newest members: (18) name18, name17, name16, name15, name14, name13, name12, name11, name10, name9, name8, name7, name6, name5, name4, name3, name2, name1 "

There is no additional SQL query.

----------------------------------

Installation (there is in attached file)

Step 1

In includes/functions_databuild.php

Find:

PHP Code:

// ###################### Start saveuserstats #######################
// Save user count & newest user into template
function build_user_statistics()
{
    global 
$vboptions$DB_site;

    
// get total members
    
$members $DB_site->query_first("SELECT COUNT(*) AS users, MAX(userid) AS max FROM " TABLE_PREFIX "user");

    
// get newest member
    
$newuser $DB_site->query_first("SELECT userid, username FROM " TABLE_PREFIX "user WHERE userid = $members[max]");

    
// make a little array with the data
    
$values = array(
        
'numbermembers' => $members['users'],
        
'newusername' => $newuser['username'],
        
'newuserid' => $newuser['userid']
    );

    
// update the special template
    
build_datastore('userstats'serialize($values));



And replace by this code:

PHP Code:

// ###################### Start saveuserstats #######################
// Save user count & newest user into template
// Function is modified by Oleg Subel for STATISTICS AND LIST OF NEW REGISTERED MEMBERS 24h
function build_user_statistics()
{
    global 
$vboptions$DB_site;

    
// get total members
    
$members $DB_site->query_first("SELECT COUNT(*) AS users, MAX(userid) AS max FROM " TABLE_PREFIX "user");

    
// get last newest members 24h
    
$cattime24 TIMENOW 24 60 60;
    
$newusers $DB_site->query("SELECT joindate, userid, username FROM " TABLE_PREFIX "user WHERE joindate > $cattime24");
//    $newuser = $DB_site->query_first("SELECT userid, username FROM " . TABLE_PREFIX . "user WHERE userid = $members[max]");

    
$newusers24 = array();
    while (
$newuser $DB_site->fetch_array($newusers))
    {
        
$newusers24["{$newuser['joindate']}"] = array('id' => $newuser['userid'], 'name' => $newuser['username']);
    }
    
// reverse sort keys
    
krsort($newusers24);

    if (empty(
$newusers24[0]))
    {
        
$lastnewuser $DB_site->query_first("SELECT userid, username FROM " TABLE_PREFIX "user WHERE userid = $members[max]");
    }

    
// make a little array with the data
    
$values = array(
        
'numbermembers' => $members['users'],
        
'newusername' => ( (empty($newusers24[0])) ? $lastnewuser['username'] : $newusers24[0]['name'] ),
        
'newuserid' => ( (empty($newusers24[0])) ? $lastnewuser['userid'] : $newusers24[0]['id'] ),
        
'lastregusers24h' => $newusers24
    
);

    
// update the special template
    
build_datastore('userstats'serialize($values));



Step 2

In index.php

Find:

PHP Code:

// get total members and newest member from template
$userstats unserialize($datastore['userstats']);
$numbermembers vb_number_format($userstats['numbermembers']);
$newusername $userstats['newusername'];
$newuserid $userstats['newuserid']; 

And insert this code below:

PHP Code:

// ### STATISTICS AND LIST OF NEW REGISTERED MEMBERS 24h by Oleg Subel ####################

$lastregusers24 $userstats['lastregusers24h'];
$numbernewregusers24 0;
$newusers24 '';
$cattime24 TIMENOW 24 60 60;
if (
is_array($lastregusers24) && count($lastregusers24) > 0)
{
    foreach(
$lastregusers24 AS $regjoindate => $regnewuser)
    {
        if (
$regjoindate $cattime24)
        {
            
$numbernewregusers24++;
            eval(
'$newusers24 .= ", ' fetch_template('forumhome_regnewuser') . '";');
        }
    }
}
$newusers24 substr($newusers24 2); // get rid of initial comma

// ### End of STATISTICS AND LIST OF NEW REGISTERED MEMBERS 24h by Oleg Subel ############# 

Step 3

Add new phrase

Phrase Type: GLOBAL
Varname: welcome_to_our_newest_members
Text:
Code:

Welcome to our newest members

Step 4

Add new template (Title: forumhome_regnewuser):

Code:

<a href="member.php?$session[sessionurl]u=$regnewuser[id]">$regnewuser[name]</a>
Step 5

FORUMHOME template modification

Find:

Code:

                        <div><phrase 1="member.php?$session[sessionurl]u=$newuserid" 2="$newusername">$vbphrase[welcome_to_our_newest_member_x]</phrase></div>
and replace with:

Code:

                        <if condition="$numbernewregusers24"><div>$vbphrase[welcome_to_our_newest_members]: ($numbernewregusers24) $newusers24</div></if>

END

Now, if you want to have statistics more than for 24 hours (for example - 3 days)
you need:

1) to change line of this hack for includes/functions_databuild.php (see step 1 of installation):
PHP Code:

$cattime24 TIMENOW 24 60 60

to
PHP Code:

$cattime24 TIMENOW 324 60 60

and

2) to change line of this hack for index.php (see step 2 of installation):
PHP Code:

$cattime24 TIMENOW 24 60 60

to
PHP Code:

$cattime24 TIMENOW 324 60 60


Bolas 02-13-2005 04:09 PM

Why? Why the first reply to a new hack MUST EVERY BE:

"Please, can you post some screenshots?"

Sykoi 02-13-2005 04:29 PM

Why must the second reply always back up the first?

I wouldn't mind seeing some screens either, because it sounds like a great hack.

Olsufr 02-13-2005 04:42 PM

I'm sorry.

There is screenshot already.

Durtay 02-13-2005 05:32 PM

if alter the line:
Code:

$cattime24 = TIMENOW - 24 * 60 * 60;
and change the 24 to another number, will that change the whole hack?

As my forums aren't that active yet and I'd rather have it display the newest users of the past 3 days (72 hours).

Olsufr 02-13-2005 08:56 PM

Yes, Durtay, you are right.

In your case
in includes/functions_databuild.php:

instead of this line:

PHP Code:

$cattime24 TIMENOW 24 60 60

write this line:

PHP Code:

$cattime24 TIMENOW 324 60 60


JC 02-15-2005 04:36 AM

I hate to ask but how do I "ADD A NEW PHRASE" ? Is that just adding it to the index.php anywhere ? Thanks for the help :(

JC 02-15-2005 06:56 AM

I got it, sorry.

Olsufr 02-15-2005 07:01 AM

Quote:

Originally Posted by jc707imports
how do I "ADD A NEW PHRASE" ?

jc707imports,

1) Admin Panel -> Languages & Phrases -> Phrase Manager
2) Set "Phrase Type" to "GLOBAL"
3) Click button "Add New Phrase"
4) Write "Varname:" and "Text:" fields as it says install instruction.

Olsufr 02-15-2005 07:17 AM

Quote:

Originally Posted by js707imports
I got it, sorry.

Good luck, js707imports!


All times are GMT. The time now is 08:22 AM.

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.01244 seconds
  • Memory Usage 1,793KB
  • 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
  • (5)bbcode_code_printable
  • (10)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (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