Topic: [Request] Online Today

I think that such of extension would be useful not only for me. Analogue of mod Online Today for 1.2.x. I think it can be written in five minutes, but I don't have enough knowledge of PHP. Therefore, all hope for community smile

Re: [Request] Online Today

I like that idea.
Better yet, list the username AND optional avatar.

3 (edited by padizar 2009-01-27 07:03)

Re: [Request] Online Today

I found a forum PunBB 1.3 (http://flazy.ru/), and there are all the needed restrictions, "who was online" is among of them. Lets ask the developer to share his developments.

P.s. Russians do not surrender! big_smile

Re: [Request] Online Today

i realy need this extension smile

Re: [Request] Online Today

did any one maked this extension

MyFootballCafe.com  is Now Online!

Re: [Request] Online Today

$result = $forum_db->query("SELECT id,username FROM pun_users WHERE last_visit>'".strtotime(gmdate("M d Y"))."' ORDER BY last_visit DESC");
while(list($id, $username) = $forum_db->fetch_row($result)) $todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.$username.'</a>';
echo "Today's users: ".implode(', ', $todays_users);

Now just find a place to put that.

Re: [Request] Online Today

I can do this extension, but really don't have time now. I must first fix 2 my extensions first.
Maybe in next week.

YonasH's repository + Extensions Directory = PunBB Extensions Online Library (in progress....)

Away. I will be back soon.

Re: [Request] Online Today

Garciat wrote:
$result = $forum_db->query("SELECT id,username FROM pun_users WHERE last_visit>'".strtotime(gmdate("M d Y"))."' ORDER BY last_visit DESC");
while(list($id, $username) = $forum_db->fetch_row($result)) $todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.$username.'</a>';
echo "Today's users: ".implode(', ', $todays_users);

Now just find a place to put that.

i want to post show that after (Currently online) stuff.
in this method: Online Today: XXX, XXX, XXX.

any tips how to do that.

MyFootballCafe.com  is Now Online!

Re: [Request] Online Today

Find

($hook = get_hook('in_new_online_data')) ? eval($hook) : null;

on 'index.php' and paste the code next to it.

$result = $forum_db->query("SELECT id,username FROM pun_users WHERE last_visit>'".strtotime(gmdate("M d Y"))."' ORDER BY last_visit DESC");
while(list($id, $username) = $forum_db->fetch_row($result)) $todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.$username.'</a>';
echo '<h3 class="hn"><span>Today\'s users: '.implode(', ', $todays_users).'</span></h3>';

Re: [Request] Online Today

oh i got this error:

Notice: Undefined variable: todays_users in /home2/supermag/public_html/forum/index.php on line 356 Warning: implode() [function.implode]: Invalid arguments passed in /home2/supermag/public_html/forum/index.php on line 356

here is my index.php:

//It is not needed

MyFootballCafe.com  is Now Online!

11

Re: [Request] Online Today

Use this instead:

$todays_users = array();
$result = $forum_db->query("SELECT id,username FROM pun_users WHERE last_visit>'".strtotime(gmdate("M d Y"))."' ORDER BY last_visit DESC");
while(list($id, $username) = $forum_db->fetch_row($result)) $todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.$username.'</a>';
if(!empty($todays_users))
echo '<h3 class="hn"><span>Today\'s users: '.implode(', ', $todays_users).'</span></h3>';

Re: [Request] Online Today

Does not work.

13

Re: [Request] Online Today

Well, I think the problem is that the last_visit value is updated only when you log in (not when you visit the site).

Re: [Request] Online Today

YonasH wrote:

I can do this extension, but really don't have time now ... Maybe in next week.

We can wait for you, YonasH!

15 (edited by allineer 2009-02-02 06:58)

Re: [Request] Online Today

$todays_users = array();
$result = $forum_db->query("SELECT id,username FROM users WHERE last_visit>'".strtotime(gmdate("M d Y"))."' ORDER BY username");
while(list($id, $username) = $forum_db->fetch_row($result))
{
 if (!$forum_user['is_guest'])
 {
  $todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.$username.'</a>';
 }
 else
 {
  $todays_users[] = $username;
 }
}
if (!empty($todays_users))
{
?>
<div id="brd-online" class="gen-content">
    <h3 class="hn"><span>
<?
 echo $lang_index['Today online'] . implode(', ', $todays_users);
?>
    </span></h3>
</div>
<?
}

http://umix.no-ip.biz:8080/forum/index.php

look in table name in your forum`s database: "pun_users" or "users"...

16

Re: [Request] Online Today

You do realize that by just getting that info from the database you're not changing the $forum_user variable at all, don't you? There's only one guest user account and its last_visit is never updated, so there's no need to add a check for $forum_user['is_guest'].

Also, not everyone has $lang_index['Today online'], so they're gonna get "Undefined index".

The only thing wrong with my code would be the table prefix. And here it's fixed:

$todays_users = array();
$result = $forum_db->query("SELECT id,username FROM ".$db_prefix."users WHERE last_visit>'".strtotime(gmdate("M d Y"))."' ORDER BY last_visit DESC");
while(list($id, $username) = $forum_db->fetch_row($result)) $todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.$username.'</a>';
if(!empty($todays_users))
echo '<h3 class="hn"><span>Online today: '.implode(', ', $todays_users).'</span></h3>';

Re: [Request] Online Today

Garciat wrote:

You do realize that by just getting that info from the database you're not changing the $forum_user variable at all, don't you? There's only one guest user account and its last_visit is never updated, so there's no need to add a check for $forum_user['is_guest'].

Also, not everyone has $lang_index['Today online'], so they're gonna get "Undefined index".

The only thing wrong with my code would be the table prefix. And here it's fixed

$todays_users = array();
$result = $forum_db->query("SELECT id,username FROM ".$db_prefix."users WHERE last_visit>'".strtotime(gmdate("M d Y"))."' ORDER BY last_visit DESC");
while(list($id, $username) = $forum_db->fetch_row($result)) $todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.$username.'</a>';
if(!empty($todays_users))
echo '<h3 class="hn"><span>Online today: '.implode(', ', $todays_users).'</span></h3>';

                        [url="garciat.org/">Garciat - Die hard

Some info about me

i putted that code in my index file and nothing is showing, just normal statics.

MyFootballCafe.com  is Now Online!

Re: [Request] Online Today

Garciat, it works. How can I add a separating line over the line "Today's online"?

Re: [Request] Online Today

ah its working now, i think it was not showing because of cache. thanks. but it would be bitter if it was converted to extension.

MyFootballCafe.com  is Now Online!

20 (edited by allineer 2009-02-02 16:58)

Re: [Request] Online Today

You can use AnyCode Tool:

solution name - today_users
hook - in_info_end

code if you want to Guests can see links to user-profiles:

$todays_users = array();
$query = array(
    'SELECT'    =>    'id, username',
    'FROM'       =>    'users',
    'WHERE'    =>    'last_visit>"'.strtotime(gmdate("M d Y")).'"',
    'ORDER BY'   =>    'username'
);
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);

while(list($id, $username) = $forum_db->fetch_row($result))
{
  $todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.forum_htmlencode($username).'</a>';
}
if (!empty($todays_users))
{
?>
    <div id="brd-todayonline" class="gen-content">
        <h3 class="hn"><span>
<?
 echo $lang_index['Today online'] . implode(', ', $todays_users);
?>
        </span></h3>
    </div>
<?
}

code if you don`t want to Guests can see links to user-profiles:

$todays_users = array();
$query = array(
    'SELECT'    =>    'id, username',
    'FROM'       =>    'users',
    'WHERE'    =>    'last_visit>"'.strtotime(gmdate("M d Y")).'"',
    'ORDER BY'   =>    'username'
);
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);

while(list($id, $username) = $forum_db->fetch_row($result))
{
 if (!$forum_user['is_guest'])
 {
  $todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.forum_htmlencode($username).'</a>';
 }
 else
 {
  $todays_users[] = forum_htmlencode($username);
 }
}
if (!empty($todays_users))
{
?>
    <div id="brd-todayonline" class="gen-content">
        <h3 class="hn"><span>
<?
 echo $lang_index['Today online'] . implode(', ', $todays_users);
?>
        </span></h3>
    </div>
<?
}

if you don`t want to edit lang-pack - just replace "$lang_index['Today online']" on "Today\`s online:"


Fixed by punbb.ru forum users.


but it would be bitter if it was converted to extension.

I can`t do this - I`m a noob:)

Sorry for my English roll

21

Re: [Request] Online Today

replace

$todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.$username.'</a>';

to

$todays_users[] = '<a href="'.forum_link($forum_url['user'], $id).'">'.forum_htmlencode($username).'</a>';

22 (edited by padizar 2009-02-03 08:56)

Re: [Request] Online Today

We have been discussing this extension for so much days but we have not still released it. Who will be the first? smile As I understood many people are waiting for it.

23

Re: [Request] Online Today

There you go http://punbb.informer.com/forums/topic/ … ine-today/