News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

Custom Who.template.php - separated list for users, guests and spiders

Started by Owdy, November 03, 2004, 01:15:56 PM

Previous topic - Next topic

Bulakbol

The attached file in the first post is a replacement of default/who.template.php. It separates members' list from guests and spiders in the who's online link. If you are asking for a list of online members/guests/spiders in the board index, then you have to start a new topic in the support or coding discussion board.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Keeper

No I'm not asking for that.

The attached file in the first post separates lists but it does not order them. If you have ten pages worth of people and spiders online, the chances are that members are spread all over the ten pages as they would be without this replacement who.template.php.

In other words, if first page lists 4 members, 7 guests and 9 spiders, second page may again list another 6 members, 6 guests, 8 spiders, third page 3 members, 5 guests and 10 spiders and so on and on. Each page has separated lists of each, but surely the whole point of this replacement was to have ALL members first, then guests and finally spiders?

Bulakbol

I am not sure about that. Maybe you should request it as a mod here.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

kai920

Quote from: unrelenting on March 24, 2008, 09:07:18 PM
Here is a quick hack that will show only a Members section and a Guest section to regular members and guests. It won't show the Spiders as Spiders, instead it lumps them in with the guests.

It will display as usual to Admins and Mods. It's just a simple if/else addition with a couple lines removed from the 19-12-07 edit. If anyone notices something that needs changed then please let me know. I am not nearly as fluent at php as Owdy or some of the other prodigies here are.  :)

I too preferred to make my site look busier to guests and regular members.

http://www.datafilehost.com/download-aca6841d.html

Is it possible to edit who.template.php so that the custom guests/spiders separated list is shown *only* to admins? (and not moderators as well)

JimM

@Keeper - can you give us a screenshot of what you want changed.  I have this template running on my board and the members are all shown first, then the guest, then the spiders.  I don't have 10 pages of users online at a time though.  At most I have had 2 pages and they were still grouped as I described.
Jim "JimM" Moore
Former Support Specialist

Bulakbol

Quote from: kai920 on June 10, 2008, 03:07:26 AM

Is it possible to edit who.template.php so that the custom guests/spiders separated list is shown *only* to admins? (and not moderators as well)

Yes, you can do it my way though. :) Edit the default Who.template.php to display only logged-in members.
Move the bracket from line 38 and insert it in line 55. Just after "$alternate = !$alternate;"

Then rename this mod to Who_admin.template.php, and then in the Sources/Who.php, replace the
loadTemplate('Who');

with
if ($user_info['is_admin'])
loadTemplate('Who_admin');
else
loadTemplate('Who');
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Keeper

Quote from: JimM on June 10, 2008, 04:25:53 PM
@Keeper - can you give us a screenshot of what you want changed.  I have this template running on my board and the members are all shown first, then the guest, then the spiders.  I don't have 10 pages of users online at a time though.  At most I have had 2 pages and they were still grouped as I described.
I really don't know how to describe it any better than I already have. But I'll try.

Currently the online list goes like this:

PAGE 1

--Users--
User 1
User 2
User 2

--Guests--
Guest 1
Guest 2
Guest 3

-- Spiders--
Spider 1
Spider 2
Spider 3

PAGE 2

--Users---
User 4
User 5
User 6

--Guests--
Guest 4
Guest 5
Guest 6

--Spiders--
Spider 4
Spider 5
Spider 6

And so on and on.

It's supposed to go like this:

Page 1

--Users--
User 1
User 2
User 3
User 4
User 5
User 6
and keep listing until there are no more users to list or list continues from next page

-- Guests---
Guest 1
Guest 2
Guest 3
Guest 4
Guest 5
Guest 6
and keep listing until there are no more guests to list or list continues from next page

And finally list spiders last in one go.

Was this any better explanation?

JimM

@ Keeper - that's what I thought you were asking.  I don't have the problem so I don't think I can help.  I read back through the topic and Owdy addressed this.  I didn't see a solution though.  Sorry I can't help.
Jim "JimM" Moore
Former Support Specialist

Carlos Gandra

Keeper, this is not a solution, but works:

Go to admin - settings - layout settings and, in the number of members to show in the member list, put a huge number, like 200, 300, 500, depending on what you need. Save and go to the who's online list. Maybe they are all in the first page now. If not, increase the number. I'm using 500 and all members appear in first page, at the top.

Regards from Portugal
Carlos Gandra
Mundo dos Animais

Keeper

A good suggestion for a work-around (and it did work), but unfortunately it affects all member listings, not just who's online.

Carlos Gandra

That's true, so I said this is not a solution. Unfortunately I don't have the suf. knowledge to edit the code itself and solve this issue :(

Regards from Portugal
Carlos Gandra
Mundo dos Animais

chep

I had a bunch of requests from members who don't want to see the spider list. However I believe it is ok for admins. I am an old perl wanna be hacker and not familiar with php but here is the file I used. It seems to work. The idea is about as simple as this if statement inside the loop and deciding to continue if we are not admins.

  foreach($brokendown AS $group => $members)

{
if ( (! $context['user']['is_admin']) && ($group == "Spiders") )
{ // custom filtering - only admins see the spiders
  continue;
}



My updated template file
<?php
// If you wanna translate this file or ad more spiders, you can find instructions in this post
// http://www.simplemachines.org/community/index.php?topic=19243.msg156339#msg156339

// The only template in the file.
function template_main()

{

global
$context, $settings, $options, $scripturl, $txt;

// Display the table header and linktree.

echo '

<div style="padding: 3px;">'
, theme_linktree(), '</div>';

$brokendown = array (

 
'Members' => array(),

 
'Guests' => array(),

 
'Spiders' => array(),

);



foreach(
$context['members'] AS $key => $member)

{

 
$spider = getAgent($member['query']['USER_AGENT'], $context['members'][$key]['name'], $agent, $member['id'] == 0);

 
$context['members'][$key]['agent'] = $agent;

 
$member['query']['USER_AGENT'] = isset($member['query']['USER_AGENT']) ? $member['query']['USER_AGENT'] : '';

 if (
$member['id'] != 0 )

 
$brokendown['Members'][] = &$context['members'][$key];

 else if (
$spider )

 
$brokendown['Spiders'][] = &$context['members'][$key];

 else

 
$brokendown['Guests'][] = &$context['members'][$key];

}

// echo '<pre>'; print_r($brokendown['Spiders']); echo '</pre>'; return;

foreach($brokendown AS $group => $members)

{
if ( (!
$context['user']['is_admin']) && ($group == "Spiders") )
{
// custom filtering - only admins see the spiders
 
continue;
}
 echo
'

<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder">

 <tr>

  <td class="catbg">'
, $group, '</td>

 </tr>

</table>

<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder">

 <tr class="titlebg">

  <td width="30%"><a href="'
. $scripturl . '?action=who;sort=user', $context['sort_direction'] == 'down' && $context['sort_by'] == 'user' ? ';asc' : '', '">', $txt['who_user'], ' ', $context['sort_by'] == 'user' ? '<img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>

  <td style="width: 14ex;"><a href="'
. $scripturl . '?action=who;sort=time', $context['sort_direction'] == 'down' && $context['sort_by'] == 'time' ? ';asc' : '', '">', $txt['who_time'], ' ', $context['sort_by'] == 'time' ? '<img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>

  <td>'
, $txt['who_action'], '</td>

 </tr>'
;


 
// This is used to alternate the color of the background.

 
$alternate = true;


 
// For every member display their name, time and action (and more for admin).

 
foreach ($members as $member)

 {


 
// $alternate will either be true or false.  If it's true, use "windowbg2" and otherwise use "windowbg".

 
echo '

  <tr class="windowbg'
, $alternate ? '2' : '', '">

   <td>'
;


 
// Guests don't have information like icq, msn, y!, and aim... and they can't be messaged.

 
if (!$member['is_guest'])

  {

   echo
'

    <div style="float: right; width: 14ex;">

     '
, $context['can_send_pm'] ? '<a href="' . $member['online']['href'] . '" title="' . $member['online']['label'] . '">' : '', $settings['use_image_buttons'] ? '<img src="' . $member['online']['image_href'] . '" alt="' . $member['online']['text'] . '" border="0" align="middle" />' : $member['online']['text'], $context['can_send_pm'] ? '</a>' : '', '

     '
, $member['icq']['link'], ' ', $member['msn']['link'], ' ', $member['yim']['link'], ' ', $member['aim']['link'], '

    </div>'
;

 }

 if (!
$member['agent'])
 {
 
$member['agent'] = '?';
 }
 if (
$member['agent'] == '')
 {
 
$member['agent'] = '?';
 }

 echo
'

   <span'
, $member['is_hidden'] ? ' style="font-style: italic;"' : '', '>', $member['is_guest'] ? $member['name'] : '<a href="' . $member['href'] . '" title="' . $txt[92] . ' ' . $member['name'] . '"' . (empty($member['color']) ? '' : ' style="color: ' . $member['color'] . '"') . '>' . $member['name'] . '</a>', '</span>';


 if ( !empty(
$member['ip']) )

  echo
' <br /> <span class="smalltext">(<b><a href="' . $scripturl . '?action=trackip;searchip=' . $member['ip'] . '" target="_blank" title="' . $member['ip'] . '" class="smalltext2">' . $member['ip'] . '</a></b>, <acronym title="' . $member['query']['USER_AGENT'] . '">' . $member['agent'] . '</acronym>)</span>';


 echo
'

  </td>

  <td nowrap="nowrap">'
, $member['time'], '</td>

  <td>'
, $member['action'], '</td>

 </tr>

 

 '
;


 
// Switch alternate to whatever it wasn't this time. (true -> false -> true -> false, etc.)

 
$alternate = !$alternate;

 }

 echo
'</table><br/>';
}

echo
'

<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder"><tr><td class="titlebg">

 <b>'
, $txt[139], ':</b> ', $context['page_index'], '

</td></tr></table>'
;

 

}


function
getAgent( &$user_agent, &$user_name, &$result, $guest )

{
$known_agents = array (
//hakukoneet
 
array (
 
'agent' => 'sogou spider',
 
'spidername' => 'Sogou spider',
 
'spider' => true,
  ),
 array (
 
'agent' => 'Twiceler',
 
'spidername' => 'Twiceler spider',
 
'spider' => true,
  ),
                array (
 
'agent' => 'www.fi crawler',
 
'spidername' => 'www.fi spider',
 
'spider' => true,
  ),
 array (
                       
'agent' => 'WISENutbot',
                       
'spidername' => 'Looksmart spider',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'MSNBot',
                       
'spidername' => 'MSN spider',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'W3C_Validator',
                       
'spidername' => 'W3C Validator',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'Googlebot-Image',
                       
'spidername' => 'Google-Image spider',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'Googlebot',
                       
'spidername' => 'Google spider',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'appie',
                       
'spidername' => 'Walhello spider',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'Mediapartners-Google',
                       
'spidername' => 'Google AdSense spider',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'Scooter',
                       
'spidername' => 'Altavista spider',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'FAST-WebCrawler',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'Wget',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'Ask Jeeves',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'Speedy Spider',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'SurveyBot',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'IBM_Planetwide',
                     
'spider' => true,
               ),
               array (
                       
'agent' => 'GigaBot',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'ia_archiver',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'FAST-WebCrawler',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'Yahoo! Slurp',
                       
'spidername' => 'Yahoo spider',
                       
'spider' => true,
               ),
               array (
                       
'agent' => 'Inktomi Slurp',
                       
'spider' => true,
               ),
 array (
 
'agent' => 'appie',
 
'spidername' => 'Walhello spider',
 ),
 array (
             
'agent' => 'FeedBurner/1.0',
         
'spidername' => 'Feedburner',
 
'spider' => true,
        ),
         array (
             
'agent' => 'Feedfetcher-Google',
 
'spidername' => 'Googlen Feedfetcher',
 
'spider' => true,
        ),
        array (
             
'agent' => 'OmniExplorer_Bot/6.68',
             
'spidername' => 'OmniExplorer Bot',
 
'spider' => true,
        ),
        array (
             
'agent' => 'http://www.relevantnoise.com',
             
'spidername' => 'relevantNOISE',
 
'spider' => true,
        ),
        array (
         
'agent' => 'NewsGatorOnline/2.0',
             
'spidername' => 'NewsGatorOnline',
 
'spider' => true,
        ),
        array (
             
'agent' => 'ping.blo.gs/2.0',
 
'spider' => true,
        ),
        array (
             
'agent' => 'Jakarta Commons-HttpClient/3.0.1',
             
'spidername' => 'Amazon',
 
'spider' => true,
        ),
          array (
             
'agent' => 'Jakarta Commons-HttpClient/3.0-rc2',
             
'spidername' => 'Amazon',
 
'spider' => true,
        ),  
          array (
             
'agent' => 'accelobot',
             
'spidername' => 'Accelovation spider',
 
'spider' => true,
        ),  
          array (
             
'agent' => 'NetSeer',
             
'spidername' => 'NetSeer Crawler',
 
'spider' => true,
        ),  
          array (
             
'agent' => 'Ilial',
             
'spidername' => 'Ilial.com Bot',
 
'spider' => true,
        ),  
          array (
             
'agent' => 'LinksManager',
             
'spidername' => 'Linksmanager Bot',
 
'spider' => true,
        ),  
          array (
             
'agent' => 'page-store',
             
'spidername' => 'Page-Store.com Bot',
 
'spider' => true,
        ),  
          array (
             
'agent' => 'MSRBOT',
             
'spidername' => 'Microsoft Research Bot',
 
'spider' => true,
        ),  
          array (
             
'agent' => 'WebAlta',
             
'spidername' => 'WebAlta.net Bot',
 
'spider' => true,
        ),  
          array (
             
'agent' => 'imageshack.us',
             
'spidername' => 'ImageShack Bot',
 
'spider' => true,
        ),  
          array (
             
'agent' => 'PageFetcher-Google',
             
'spidername' => 'PageFetcher-Google Bot',
 
'spider' => true,
        ),
          array (
             
'agent' => 'majestic',
             
'spidername' => 'Majestic12 Bot',
 
'spider' => true,
        ),
   
//phones
               
array (
                       
'agent' => 'Nokia',
               ),
               array (
                       
'agent' => 'Samsung',
               ),
               array (
                       
'agent' => 'Ericsson',
               ),
                 array (
                       
'agent' => 'Siemens',
               ),
                array (
                       
'agent' => 'Motorola',
               ),
                array (
                       
'agent' => 'BlackBerry',
               ),
   
//browsers
               
array (
                       
'agent' => 'Opera',
                ),
               array (
                       
'agent' => 'Firefox',
               ),
               array (
                       
'agent' => 'Firebird',
               ),
               array (
                       
'agent' => 'Safari',
               ),
  array (
 
'agent' => 'Google Desktop',
  ),
               array (
                       
'agent' => 'Netscape',
               ),
               array (
                       
'agent' => 'MyIE2',
               ),
               
               array (
                       
'agent' => 'Konqueror',
               ),
               array (
                       
'agent' => 'Galeon',
               ),
               array (
                       
'agent' => 'KMeleon',
               ),
               array (
                       
'agent' => 'NG/2.0',
               ),
               array (
                       
'agent' => 'Gecko',
                       
'name' => 'Mozilla',
               ),
               array (
                       
'agent' => 'MSIE',
                         
'name' => 'IE',
               ),
               
       );
foreach(
$known_agents AS $poss )

 if (
strpos(strtolower($user_agent), strtolower($poss['agent'])) !== false)

 {

  if (
$guest && isset($poss['spider']) && $poss['spider'] )

   
$user_name = isset($poss['spidername']) ? $poss['spidername'] : (isset($poss['name']) ? $poss['name'] : $poss['agent']);

 
$result = isset($poss['name']) ? $poss['name'] : $poss['agent'];

  return isset(
$poss['spider']) && $poss['spider'];

 }

$result = $user_agent;

return
false;

}


?>





FragaCampos

chep, weren't you looking for this?

QuoteHere is a quick hack that will show only a Members section and a Guest section to regular members and guests. It won't show the Spiders as Spiders, instead it lumps them in with the guests.

It will display as usual to Admins and Mods. It's just a simple if/else addition with a couple lines removed from the 19-12-07 edit. If anyone notices something that needs changed then please let me know. I am not nearly as fluent at php as Owdy or some of the other prodigies here are.  :)

I too preferred to make my site look busier to guests and regular members.

http://www.datafilehost.com/download-aca6841d.html

It worked for me.

chep

Quote
chep, weren't you looking for this?
No. There is a distinct difference.

khamseen

Absolutely love this, it's fantastic and easy to install (upload), nice job mate.
"In hope we find despair and in despair we find truth." - Myself

ellion

just wondering what this mod does and why is it useful. i am about to install the spiders abots mod and was directed to lok over this mod. can anyone enlightn me?

Kindred

ummmmmm.....

Custom Who.template.php -
it creates a separated list for users, guests and spiders

(just like the thread title says. :) )
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

pinoypetfinder

aah! I finally found it! Thanks Owdy! Been trying to figure out how to put that who's online list back (after i upgrade our forum to 1.1.5, all my mods stopped working and had to reinstall them, then the i got stucked for about 20mins trying to figure out how to separate the bots/users and guests. so yeah, thanks!

and btw, the mod link you posted doesn't seem to be working, i downloaded it (before i found your thread) and tried to installed it but i get a who.template error so i didn't proceed.

assam_siddibapa

This mod is really cool..

I need to modify tis one


I need first users , guest , spiders .

I mean to saythat now all there are shown on all pages .... how can i make it in the above order.

Advertisement: