Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

Thread: 

An Idea for "Show the users that has been online today" plugin

Ads
banner
banner
banner
Midori Offline referral

Posts: 41
Joined: Apr 2014
Reputation: 1

#1
Junior Member
Hi my friends specially Markus
I have "Show the users that has been online today" Plugin and i want to add something in this plugin .I saw this feature in yaldaram site. How can I add title for members in "whos online ...." section , for example: In mouse over on Midori member , show a title same"Last Visit: 9:40PM"
I added {$onlinetime} and {$onlinedate} for title, but no work for me ,seems that is not enough . please advise me.
please take a look in plugin inside
PHP Code:
<?php
/**
 *    Copyright © 2006-2008 CraKteR, crakter [at] gmail [dot] com
 *
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *    @version $Id: onlinetoday.php 29 2008-08-14 19:00:36Z CraKteR $
 *    @copyright $LastChangedDate: 2008-08-14 21:00:36 +0200 (to, 14 aug 2008) $
 *    @author CraKteR <crakter@gmail.com>
 */

if(!defined("IN_MYBB"))
{
    die(
"This file cannot be accessed directly.");
}

$plugins->add_hook('index_start''add_onlinetoday'1000000);

function 
onlinetoday_info()
{
    return array(
        
"name"            =>    "Show the users that has been online today",
        
"description"    =>    "Shows the users that has been online within 24 hours.",
        
"website"        =>    "",
        
"author"        =>    "CraKteR",
        
"authorsite"    =>    "mailto:crakter@gmail.com",
        
"version"        =>    "2.0",
        
"guid"            =>    "c2f1dd8db9b4f3898cb58f5ed02f9b53",
        
"compatibility" =>    "16*",
    );
}

function 
onlinetoday_activate()
{
    global 
$db;
    
$template = array(
        
"tid"        => NULL,
        
"title"        => "online_today_index",
        
"template"    => "<tr>
    <td class=&#092;"tcat&#092;"><strong>{&#092;$lang->whos_online_today}</strong> [<a href=&#092;"online.php?action=today&#092;">{&#092;$lang->complete_list}</a>]</td>
</tr>
<tr>
    <td class=&#092;"trow1&#092;"><span class=&#092;"smalltext&#092;">{&#092;$lang->online_note_today}<br />{&#092;$onlinemembers}</span></td>
</tr>"
,
        
"sid"        => "-1"
    
);
    
$db->insert_query("templates"$template);

    require 
MYBB_ROOT."/inc/adminfunctions_templates.php";
    
find_replace_templatesets('index_boardstats''#{&#092;$whosonline}#'"{&#092;$whosonline}&#092;n{&#092;$online_today}");
}

function 
onlinetoday_deactivate()
{
    global 
$db;
    
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='online_today_index'");

    require 
MYBB_ROOT."/inc/adminfunctions_templates.php";

    
find_replace_templatesets('index_boardstats''#(&#092;n?){&#092;$online_today}#'''0);
}

function 
add_onlinetoday()
{
    global 
$db$mybb$templates$online_today$lang$theme;
    
$online_today '';

    if(
$mybb->settings['showwol'] != && $mybb->usergroup['canviewonline'] != 0)
    {
        
$lang->load("onlinetoday");
        
$lang->load("index");
        
$timesearch time() - 24*60*60;
        
$queries = array();
        
$queries[] = $db->simple_select(
            
"users u LEFT JOIN ".TABLE_PREFIX."sessions s ON (u.uid=s.uid)"
            
"s.sid, s.ip, s.time, s.location, u.uid, u.username, u.invisible, u.usergroup, u.displaygroup",
            
"u.lastactive > $timesearch ORDER BY u.username ASC, s.time DESC"
        
);
        
$queries[] = $db->simple_select(
            
"sessions s LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid)",
            
"s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup",
            
"s.time>'$timesearch' ORDER BY u.username ASC, s.time DESC"
        
);
        
$comma $onlinemembers '';
        
$membercount $guestcount $anoncount 0;
        
$doneusers $ips = array();
        foreach(
$queries as $query)
        {
            while(
$user $db->fetch_array($query))
            {
                if(isset(
$user['sid']))
                {
                    
$botkey strtolower(str_replace("bot="''$user['sid']));
                }

                if(
$user['uid'] > 0)
                {
                    if(
$doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']])
                    {
                        if(
$user['invisible'] == 1)
                        {
                            ++
$anoncount;
                        }
                        ++
$membercount;
                        if(
$user['invisible'] != || $mybb->usergroup['canviewwolinvis'] == || $user['uid'] == $mybb->user['uid'])
                        {
                            
$invisiblemark = ($user['invisible'] == 1) ? "*" "";
                            
$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
                            
$user['profilelink'] = build_profile_link($user['username'], $user['uid']);
                            eval(
"&#092;$onlinemembers .= &#092;"".$templates->get("index_whosonline_memberbit"10)."&#092;";");
                            
$comma ", ";
                        }

                        if(isset(
$user['time']))
                        {
                            
$doneusers[$user['uid']] = $user['time'];
                        }
                        else
                        {
                            
$doneusers[$user['uid']] = $user['lastactive'];
                        }
                    }
                }
                else if(
strstr($user['sid'], "bot=") !== false && $session->bots[$botkey] && !in_array($user['ip'], $ips))
                {
                    
$onlinemembers .= $comma.format_name($session->bots[$botkey], $session->botgroup);
                    
$comma ", ";
                    ++
$botcount;
                }
                else
                {
                    ++
$guestcount;
                    
$guests[] = $user['ip'];
                }
            }
        }

        
$onlinecount $membercount $guestcount;
        
$onlinebit = ($onlinecount != 1) ? $lang->online_online_plural $lang->online_online_singular;
        
$memberbit = ($membercount != 1) ? $lang->online_member_plural $lang->online_member_singular;
        
$anonbit = ($anoncount != 1) ? $lang->online_anon_plural $lang->online_anon_singular;
        
$guestbit = ($guestcount != 1) ? $lang->online_guest_plural $lang->online_guest_singular;
        
$lang->online_note_today $lang->sprintf($lang->online_note_todaymy_number_format($onlinecount), $onlinebit24my_number_format($membercount), $memberbitmy_number_format($anoncount), $anonbitmy_number_format($guestcount), $guestbit);
        eval(
"&#092;$online_today = &#092;"".$templates->get("online_today_index")."&#092;";");
    }
}
?>
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#2
Support Team
Hi please replace:

PHP Code:
$user['profilelink'] = build_profile_link($user['username'], $user['uid']); 

With:

PHP Code:
$onlinetime my_date($mybb->settings['timeformat'], $user['lastactive']);
$user['profilelink'] = "<a href=&#092;"{$mybb->settings['bburl']}/".get_profile_link($user['uid'])."&#092;" title=&#092;"Last Visit: $onlinetime&#092;">{$user['username']}</a>"
Midori Offline referral

Posts: 41
Joined: Apr 2014
Reputation: 1

#3
Junior Member
(06-07-2014 07:36 PM)marcus_avrelius Wrote:  Hi please replace:

PHP Code:
$user['profilelink'] = build_profile_link($user['username'], $user['uid']); 

With:

PHP Code:
$onlinetime my_date($mybb->settings['timeformat'], $user['lastactive']);
$user['profilelink'] = "<a href=&#092;"{$mybb->settings['bburl']}/".get_profile_link($user['uid'])."&#092;" title=&#092;"Last Visit: $onlinetime&#092;">{$user['username']}</a>"

Wow 001_tt1, Perfect and clean ,Thank you Markus good job ,I love your worksHeart
Midori Offline referral

Posts: 41
Joined: Apr 2014
Reputation: 1

#4
Junior Member
A bug
It`s show current time for all members , visitors with same time . 001_scared001_crying
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#5
Support Team
it's 22:30 over here in Spain I will check it tomorrow Smile
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#6
Support Team
Backup your plugin file!

Replace the code with this one:
PHP Code:
<?php
/**
 *    Copyright © 2006-2008 CraKteR, crakter [at] gmail [dot] com
 *
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *    @version $Id: onlinetoday.php 29 2008-08-14 19:00:36Z CraKteR $
 *    @copyright $LastChangedDate: 2008-08-14 21:00:36 +0200 (to, 14 aug 2008) $
 *    @author CraKteR <crakter@gmail.com>
 */

if(!defined("IN_MYBB"))
{
    die(
"This file cannot be accessed directly.");
}

$plugins->add_hook('index_start''add_onlinetoday'1000000);

function 
onlinetoday_info()
{
    return array(
        
"name"            =>    "Show the users that has been online today",
        
"description"    =>    "Shows the users that has been online within 24 hours.",
        
"website"        =>    "",
        
"author"        =>    "CraKteR",
        
"authorsite"    =>    "mailto:crakter@gmail.com",
        
"version"        =>    "2.0",
        
"guid"            =>    "c2f1dd8db9b4f3898cb58f5ed02f9b53",
        
"compatibility" =>    "16*",
    );
}

function 
onlinetoday_activate()
{
    global 
$db;
    
$template = array(
        
"tid"        => NULL,
        
"title"        => "online_today_index",
        
"template"    => "<tr>
    <td class=&#092;"tcat&#092;"><strong>{&#092;$lang->whos_online_today}</strong> [<a href=&#092;"online.php?action=today&#092;">{&#092;$lang->complete_list}</a>]</td>
</tr>
<tr>
    <td class=&#092;"trow1&#092;"><span class=&#092;"smalltext&#092;">{&#092;$lang->online_note_today}<br />{&#092;$onlinemembers}</span></td>
</tr>"
,
        
"sid"        => "-1"
    
);
    
$db->insert_query("templates"$template);

    require 
MYBB_ROOT."/inc/adminfunctions_templates.php";
    
find_replace_templatesets('index_boardstats''#{&#092;$whosonline}#'"{&#092;$whosonline}&#092;n{&#092;$online_today}");
}

function 
onlinetoday_deactivate()
{
    global 
$db;
    
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='online_today_index'");

    require 
MYBB_ROOT."/inc/adminfunctions_templates.php";

    
find_replace_templatesets('index_boardstats''#(&#092;n?){&#092;$online_today}#'''0);
}

function 
add_onlinetoday()
{
    global 
$db$mybb$templates$online_today$lang$theme;
    
$online_today '';

    if(
$mybb->settings['showwol'] != && $mybb->usergroup['canviewonline'] != 0)
    {
        
$threshold TIME_NOW-(60*60*24);
        
$queries = array();
        
$queries[] = $db->simple_select(
            
"users u LEFT JOIN ".TABLE_PREFIX."sessions s ON (u.uid=s.uid)"
            
"s.sid, s.ip, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup",
            
"u.lastactive > $threshold ORDER BY u.username ASC, s.time DESC"
        
);
        
        
$queries[] =$db->simple_select("users""*""lastactive > '{$threshold}'", array("order_by" => "lastactive""order_dir" => "desc"));
        
$comma $onlinemembers '';
        
$membercount $guestcount $anoncount 0;
        
$doneusers $ips = array();
        foreach(
$queries as $query)
        {
            while(
$user $db->fetch_array($query))
            {
                
                if(isset(
$user['sid']))
                {
                    
$botkey strtolower(str_replace("bot="''$user['sid']));
                }

                if(
$user['uid'] > 0)
                {
                    if(
$doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']])
                    {
                        if(
$user['invisible'] == 1)
                        {
                            ++
$anoncount;
                        }
                        ++
$membercount;
                        if(
$user['invisible'] != || $mybb->usergroup['canviewwolinvis'] == || $user['uid'] == $mybb->user['uid'])
                        {
                            
$invisiblemark = ($user['invisible'] == 1) ? "*" "";
                            
$user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
                            
                            
$onlinetime my_date($mybb->settings['timeformat'], $user['lastactive']);
                            
$user['profilelink'] = "<a href=&#092;"{$mybb->settings['bburl']}/".get_profile_link($user['uid'])."&#092;" title=&#092;"Last Visit: {$onlinetime}&#092;">{$user['username']}</a>";
                            
                            eval(
"&#092;$onlinemembers .= &#092;"".$templates->get("index_whosonline_memberbit"10)."&#092;";");
                            
$comma ", ";
                        }
    
                        if(isset(
$user['time']))
                        {
                            
$doneusers[$user['uid']] = $user['time'];
                        }
                        else
                        {
                            
$doneusers[$user['uid']] = $user['lastactive'];
                        }
                    }
                }
                else if(
strstr($user['sid'], "bot=") !== false && $session->bots[$botkey] && !in_array($user['ip'], $ips))
                {
                    
$onlinemembers .= $comma.format_name($session->bots[$botkey], $session->botgroup);
                    
$comma ", ";
                    ++
$botcount;
                }
                else
                {
                    ++
$guestcount;
                    
$guests[] = $user['ip'];
                }
            }
        }

        
$onlinecount $membercount $guestcount;
        
$onlinebit = ($onlinecount != 1) ? $lang->online_online_plural $lang->online_online_singular;
        
$memberbit = ($membercount != 1) ? $lang->online_member_plural $lang->online_member_singular;
        
$anonbit = ($anoncount != 1) ? $lang->online_anon_plural $lang->online_anon_singular;
        
$guestbit = ($guestcount != 1) ? $lang->online_guest_plural $lang->online_guest_singular;
        
$lang->online_note_today $lang->sprintf($lang->online_note_todaymy_number_format($onlinecount), $onlinebit24my_number_format($membercount), $memberbitmy_number_format($anoncount), $anonbitmy_number_format($guestcount), $guestbit);
        eval(
"&#092;$online_today = &#092;"".$templates->get("online_today_index")."&#092;";");
    }
}
?>
Midori Offline referral

Posts: 41
Joined: Apr 2014
Reputation: 1

#7
Junior Member
Thank you Dear Markus . This work like a charm now. 001_tt1
Only two lines disappeared 81,82
PHP Code:
$lang->load("onlinetoday");
$lang->load("index"); 
I added those. Thanks again .HeartHeartHeart
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#8
Support Team
Forgot to put it back. I had to remove them cause this plugin needs a language file which I didn't have so I remove them to install the plugin. Bye.





User(s) browsing this thread: 1 Guest(s)