Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
List of new members during last 24h Details »»
List of new members during last 24h
Version: 1.02, by Olsufr Olsufr is offline
Developer Last Online: Mar 2005 Show Printable Version Email this Page

Version: 3.0.6 Rating:
Released: 02-12-2005 Last Update: 03-21-2005 Installs: 14
 
No support by the author.

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 - 3* 24 * 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 - 3* 24 * 60 * 60; 

Show Your Support

  • If you like to thanks you by the author -> Click Thanks to the Author
  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 02-13-2005, 04:09 PM
Bolas's Avatar
Bolas Bolas is offline
 
Join Date: Jan 2003
Location: Venice
Posts: 111
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

"Please, can you post some screenshots?"
Reply With Quote
  #3  
Old 02-13-2005, 04:29 PM
Sykoi Sykoi is offline
 
Join Date: Dec 2004
Posts: 60
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 02-13-2005, 04:42 PM
Olsufr Olsufr is offline
 
Join Date: Feb 2003
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm sorry.

There is screenshot already.
Reply With Quote
  #5  
Old 02-13-2005, 05:32 PM
Durtay Durtay is offline
 
Join Date: Feb 2004
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #6  
Old 02-13-2005, 08:56 PM
Olsufr Olsufr is offline
 
Join Date: Feb 2003
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 - 3* 24 * 60 * 60; 
Reply With Quote
  #7  
Old 02-15-2005, 04:36 AM
JC's Avatar
JC JC is offline
 
Join Date: Sep 2002
Location: California, USA
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 02-15-2005, 06:56 AM
JC's Avatar
JC JC is offline
 
Join Date: Sep 2002
Location: California, USA
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got it, sorry.
Reply With Quote
  #9  
Old 02-15-2005, 07:01 AM
Olsufr Olsufr is offline
 
Join Date: Feb 2003
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 02-15-2005, 07:17 AM
Olsufr Olsufr is offline
 
Join Date: Feb 2003
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by js707imports
I got it, sorry.
Good luck, js707imports!
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 03:25 AM.


Powered by vBulletin® Version 3.9.0
Copyright ©2000 - 2017, vBulletin Solutions Inc.