TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,229
  • Total Topics: 21,353
  • Online today: 976
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 334
  • Total: 334

Google bot and Spiders mod for SMF1.1rc3 - default theme

Started by dozzer, December 07, 2006, 10:11:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


siath

Ok sorry it took so long got a bit busy, here it is. But, let me warn you I have additions to the block that you might not have. I would suggest you just take the parts you need and dump the rest, unless you don't care if you have the additions. This snip of code take nothing else to run it it is self contained, as long as you have the google bots and spiders for SMF.

REMEMBER BACK UP THIS FILE BEFORE YOU MODIFY IT!!!!

In TPortalBlocks.template.php replace this function:

// Modified By OnTap©, Spider additions by Siath
function TPortal_statsbox()
{
       global $context, $settings, $options, $scripturl, $txt, $db_prefix, $modSettings;

        echo '<div style="padding: 5px;" class="smalltext">';

      $bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
      $bullet2 = '<img src="'.$settings['images_url'].'/TPdivider2.gif" alt="" border="0" style="margin:0 2px 0 0;" />';


   $result = db_query("
      SELECT COUNT(ID_BOARD)
      FROM {$db_prefix}boards", __FILE__, __LINE__);
   list ($modSettings['boards']) = mysql_fetch_row($result);
   mysql_free_result($result);

   $result = db_query("
      SELECT COUNT(ID_CAT)
      FROM {$db_prefix}categories", __FILE__, __LINE__);
   list ($modSettings['categories']) = mysql_fetch_row($result);
   mysql_free_result($result);

       if(isset($context['TPortal']['userbox']['stats']))
      // members stats
            echo '
                 <img src="'.$settings['images_url'].'/icons/members.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=mlist"><b>'.$txt[19].'</b></a>
                 <br />'.$bullet.$txt[488].': ' , isset($modSettings['memberCount']) ? $modSettings['memberCount'] : $modSettings['totalMembers'] , '
                 <br />'.$bullet.$txt['tp-latest']. ': <a href="', $scripturl, '?action=profile;u=', $modSettings['latestMember'], '"><b>', $modSettings['latestRealName'], '</b></a>';


$today = strtotime("24 hours ago");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');

$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);

settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");

echo '<br /><img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />', 'New This Year: ', $modSettings['totalMembers'],'<br />';

echo '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />', 'New This Month: ', $row['month'],'<br />';

echo '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />', 'New This Week: ', $row['week'],'<br />';

echo '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />', 'New Today: ', $row['today'];

       if(isset($context['TPortal']['userbox']['stats_all']))
      // more stats
            echo '
                  <hr /><img src="'.$settings['images_url'].'/icons/info.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=stats"><b>'.$txt['tp-stats'].'</b></a>
                 <br />'.$bullet.$txt[489].': '.$modSettings['totalMessages']. '
                 <br />'.$bullet. $txt[490].': '.$modSettings['totalTopics']. '
                 <br />'.$bullet. $txt[658].': '.$modSettings['categories']. '
                 <br />'.$bullet. $txt[665].': '.$modSettings['boards']. '
                 <br />'.$bullet.$txt['tp-mostonline-today'].': '.$modSettings['mostOnlineToday'].'
                 <br />'.$bullet.$txt['tp-mostonline'].': '.$modSettings['mostOnline'].'<br />
                 ('.timeformat($modSettings['mostDate']).')
              ';


       if(isset($context['TPortal']['userbox']['online'])){
      // add online users
            echo '<hr /><img src="'.$settings['images_url'].'/icons/online.gif" style="margin: 0;" align="bottom" alt="" />
                 <a href="'.$scripturl.'?action=who"><b>'.$txt[158].'</b></a><br />';

            $online = ssi_whosOnline('array');
            echo $bullet.$txt['tp-users'].': '.$online['num_users'];
            echo '<br />'.$bullet.$txt['tp-hidden'].': '.$online['hidden'];
            echo '<br />'.$bullet.$txt['tp-buddies'].': '.$online['buddies'];

           // Allowed user to see spiders online?
              if (!allowedTo('googlebot_view'))
                  {
            echo '<br />'.$bullet.$txt['tp-guests'].': '.($online['guests'] + $online['num_spiders']);
                   } else {
            echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
            echo '<br />'.$bullet.$txt['tp-spiders'].': '.$online['num_spiders'];
                        }
            echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />

         <div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">';

      foreach($online['users'] as $user){
      echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
      echo '<br />';
      }
   if (!empty($context['spiders']) && (!$modSettings['ob_googlebot_display_own_list']))
   {
     foreach($context['spiders'] as $spider) {
      echo $bullet2 , $spider;
      echo '<br />';
      }
   }
      echo '</div>';
     }
   if (!empty($context['spiders']) && ($modSettings['ob_googlebot_display_own_list']))
   {
         echo '<br /><b>'.'Bots Online'.'</b><br /><hr />';
         echo '<div style="width: 100%; ' , $online['num_spiders']>10 ? 'height: 10ex;overflow: auto;' : '' ,'">';
     foreach($context['spiders'] as $spider) {
      echo $bullet2 , $spider;
      echo '<br />';
      }
         echo '</div>';
   }
  echo '</div>';
}


**Oops forgot to remove my users in chat addition, not everyone will have that. If you already got this code just search for chat and remove that one line and that should be it. I have already fixed the code here so copy paste if you want it. Sorry about that.

Hairy

I got an error using that code but I worked out what was causing it:

**********EDIT*********
*********code removed by Hairy*********
********EDIT***********

Also the following needs to be added to the TPortal.English.php file:

$txt['tp-hidden'] = 'Hidden';
$txt['tp-buddies'] = 'Buddies';
$txt['tp-spiders'] = 'Spiders';




But for some reason I am still not getting the names of the spiders in the list  :-\

G6Cad

Edit, sorry, shoud be as the code say...

siath

The reason you don't see spider is because the code you put up is wrong.

          echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />

If you can't look at that and tell it's wrong...

First thing is you didn't finish it

          echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />';

But even that is wrong, you're placing a horizonal rule at the end of a box for no reason.

There is something else throwing errors for you.
Change that line back to the default and post the error please.
This code works on my board and at least 2 others not to mention the people here who I have helped install it in theirs.

I'm not trying to be mean and sorry if I'm coming off that way. But, just changing code and posting as this was wrong, doesn't mean it is and can create a bunch of problems, Posting an error and asking for help let me go back and look or come help you on your forum. Or even G6 or one of the other people smarter than I to help and correct something flawed.

Please, remove your code and post the error, as your code is wrong.

Something didn't install right or got broke when you copied pasted or something.

I prolly need to do a completely new post about this and let this one get locked. That way all the information is in one area.

Thanks,
Siath

Hairy

That code is from the original TP code so if it's wrong and Bloc shouldn't have that there he might want to know, here is the error it gives:

Template Parse Error!
There was a problem loading the /Themes/default/TPortalBlocks.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.

Parse error: syntax error, unexpected '<' in .../Themes/default/TPortalBlocks.template.php on line 686

677:               if (!allowedTo('googlebot_view'))
678:                   {
679:             echo '<br />'.$bullet.$txt['tp-guests'].': '.($online['guests'] + $online['num_spiders']);
680:                    } else {
681:             echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
682:             echo '<br />'.$bullet.$txt['tp-spiders'].': '.$online['num_spiders'];
683:                         }
684:             echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'];
685:

686:          <div style="width: 100%; ' , $online['num_users']>14 ? 'height: 23ex;overflow: auto;' : '' ,'">;

687:
688:       foreach($online['users'] as $user){
689:       echo $bullet2 , $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'];
690:       echo '<br />';


Cheers

siath

Ok first off you're right I'm wrong, I forgot I removed my chats stat.

My bad sorry, early morning and all. So yes

          echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'].'<hr />

is correct :P

Mine was like this

            echo '<br />'.$bullet.$txt['tp-guests'].': '.$online['guests'];
            echo '<br />'.$bullet.$txt['tp-spiders'].': '.$online['num_spiders'];
                        }
            echo '<br />'.$bullet.$txt['tp-total'].': '.$online['total_users'];
            echo '<hr />'.$bullet.'Users in Chat'.': '.$modSettings['chatNumUsers'].'<hr />

I removed the chat line forgot to fix the total line.

I feel like an idiot now.

Ok, but let me understand you're not seeing spiders (names) below the users logged in?

Updated my code to reflect the error pointed out by Hairy, thanks!

Sorry for being an idiot,
Siath

Hairy

 :2funny: No problem mate, I appreciate the help   :D

I'll attach a pic of what I see, theres no spiders on my forum at the moment but when there is it says there are X amount of spiders but nothing else changes...

Also It's 12:52 AM here so I really got to go to bed right now but will check it tomorrow.

Cheers

siath

Make sure you have google bot and spiders set to display own list :) If you don't have that option enabled they will not show up in a list it will just count them. I did this so if people just wanted them to be counted and not shown ect ect.

Hairy

That's already chosen but I just ticked "Display agent instead of name" maybe that will do something for me. (lend me some spiders please  :D)

I'll post back when I find out.

PS. I notice the info centre in the forum doesn't list them either but it shows when in "Who's online"

This website is proudly hosted on Crocweb Cloud Website Hosting.