PDA

View Full Version : List of new members during last 24h


Olsufr
02-12-2005, 10:00 PM
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:

// ###################### 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:

// ###################### 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:

// 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:

// ### 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: Welcome to our newest members


Step 4

Add new template (Title: forumhome_regnewuser):

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


Step 5

FORUMHOME template modification

Find:

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


and replace with:

<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):$cattime24 = TIMENOW - 24 * 60 * 60;to $cattime24 = TIMENOW - 3* 24 * 60 * 60;

and

2) to change line of this hack for index.php (see step 2 of installation):$cattime24 = TIMENOW - 24 * 60 * 60;to $cattime24 = TIMENOW - 3* 24 * 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:
$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:

$cattime24 = TIMENOW - 24 * 60 * 60;

write this line:

$cattime24 = TIMENOW - 3* 24 * 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
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
I got it, sorry.Good luck, js707imports!

JC
02-15-2005, 07:46 AM
Thank you, worked out great! :)

Olsufr
02-15-2005, 06:25 PM
There is a little modification of hack's code.

v.1.01
Install instructions and downloaded file at first post in this topic is renewed.

Modification is in index.php:

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

$lastregusers24 = $userstats['lastregusers24h'];
$numbernewregusers24 = 0;
$newusers24 = '';
if (is_array($lastregusers24) && count($lastregusers24) > 0)
{
foreach($lastregusers24 AS $regjoindate => $regnewuser)
{
$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 #############

change to:
// ### 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 #############


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):$cattime24 = TIMENOW - 24 * 60 * 60;to $cattime24 = TIMENOW - 3* 24 * 60 * 60;

and

2) to change line of this hack for index.php (see step 2 of installation):$cattime24 = TIMENOW - 24 * 60 * 60;to $cattime24 = TIMENOW - 3* 24 * 60 * 60;

Rick Sample
02-15-2005, 08:52 PM
awesome hack, but is their anyway the counter can reset at midnight instead of the last 24h after you install it?

THANKS :)

WreckRman2
02-17-2005, 05:07 AM
Question you set up a condition "<if condition="$numbernewregusers24">" but how to you set that condition as on?

neocorteqz
02-17-2005, 07:41 AM
Question you set up a condition "<ifcondition="$numbernewregusers24">" but how to you set that conditionas on?

what exactly do you want to know?

xtreme-mobile
02-23-2005, 07:31 PM
ive just installed this but it doesnt show the 8 members that i have had register? or will it start from when the next member signs up?

Olsufr
02-23-2005, 10:48 PM
ive just installed this but it doesnt show the 8 members that i have had register? or will it start from when the next member signs up?xtreme-mobile, this statistics is updated when new member registers.

xtreme-mobile
02-24-2005, 02:52 PM
yep all working now

great hack

Q-v-n-s-Q
03-07-2005, 11:42 AM
Nice hacks

TLCanna
03-07-2005, 04:55 PM
I added this hack and it's working fine, but now my latest new member isn't there (at the top). It says 'Welcome to our newest member, " but no name. How can I get that added back AND have this hack show at the bottom?

http://www.javajane.com/images/GAGscreen.gif

If the link doesn't work the first time clicking it, refresh and it should show up. It's just an image of the area I'm talking about.

Thanks

TLCanna
03-10-2005, 09:39 AM
I added this hack and it's working fine, but now my latest new member isn't there (at the top). It says 'Welcome to our newest member, " but no name. How can I get that added back AND have this hack show at the bottom?

http://www.javajane.com/images/GAGscreen.gif

If the link doesn't work the first time clicking it, refresh and it should show up. It's just an image of the area I'm talking about.

Thanks
Hello... Hello... Echo }} Echo }}

Anyone? Anyone?

Can anyone answer my question above? Pretty please?

:)

TLCanna
03-18-2005, 10:27 PM
Hello... Hello... Echo }} Echo }}

Anyone? Anyone?

Can anyone answer my question above? Pretty please?

:)
Nobody? :(

Aw well...

Olsufr
03-22-2005, 10:09 PM
There is new version of this hack 1.02.

I added this hack and it's working fine, but now my latest new member isn't there (at the top). It says 'Welcome to our newest member, " but no name. How can I get that added back AND have this hack show at the bottom?

TLCanna, this error is fixed now and
if you want to have statistics of latest new member and statistics by this hack at the same time
instead of step 5 you have to do next:

FORUMHOME template modification

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


And insert this below:

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

TLCanna
03-29-2005, 04:28 PM
<if condition="$numbernewregusers24"><div>$vbphrase[welcome_to_our_newest_members]: ($numbernewregusers24) $newusers24</div></if>


This didn't work. :(

ma7room
08-20-2005, 11:35 PM
me too. i can't see any change after install this hack. is it working with 3.07?

Socomjunky.com
08-21-2005, 02:43 AM
me too. i can't see any change after install this hack. is it working with 3.07?


same happend to me

xtreme-mobile
09-16-2005, 07:15 PM
ive installed this on my second board and all i get is loads of , , , , , ,, like that with no names in between

any ideas what ive done?

regards

dean

Thug
09-21-2005, 01:29 AM
i installed it at http://www.oh-twadi.com/forum/index.php?styleid=63
and well it doesnt reset at 12 midnight uk time
can anyone help

Paul M
09-21-2005, 03:04 AM
i installed it at http://www.oh-twadi.com/forum/index.php?styleid=63
and well it doesnt reset at 12 midnight uk time
can anyone help
Well since the hack says "List of new members during last 24h" its not likely to reset at midnight ....

Thug
09-21-2005, 10:27 AM
why not
from 12oclock to 12oclock is 24hours do ur maths mate
ok so looks like we are back at school rnt we
from 11:59pm on the 20th to 11:59pm on the 21st
how many hours is that mate 24

how many hours are in a day 24 mate,so why doesnt it reset after 24hours at midnight
from midnight to midnight it should count

hbalagh1
09-21-2005, 06:35 PM
Great little mod, ive been having alot of new users these days... great to see the new members names

swa
10-23-2005, 12:54 AM
Very nice! working on my site!

dknelson
11-01-2005, 08:59 PM
Any chance of this being ported to 3.5? Really enjoyed it.