./index.php
Encontre:
// Load the settings from the settings table, and perform operations like optimizing.
reloadSettings();
Adcione Após:
//Get rid of ?PHPSESSID in the case is a Googlebot any other Spider. Even if is a user (maybe User-Agent extension), will be redirected. Easier this way.
if ($modSettings['ob_googlebot_redirect_phpsessid'] && ob_googlebot_getAgent($_SERVER['HTTP_USER_AGENT'], $spider_name, $agent))
{
$actualurl = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$correcturl = preg_replace('/([?&]PHPSESSID=[^&]*)/', '', $actualurl);
$correcturl = str_replace('index.php&', 'index.php?', $correcturl);
if ($correcturl != $actualurl) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . $correcturl);
exit();
}
}
./SSI.php
Encontre:
// Load the users online right now.
$result = db_query("
Adcione Antes:
global $modSettings;
Encontre:
lo.ID_MEMBER, lo.logTime,
Adcione Após:
lo.url,
Encontre:
while ($row = mysql_fetch_assoc($result))
{
if (!isset($row['realName']))
Adcione Antes:
$return['spiders'] = array();
$return['num_spiders'] = 0;
Encontre:
$return['guests']++;
Substitua Por:
{
// Get the request parameters..
$actions = @unserialize($row['url']);
// Is a spider?
$is_spider = ob_googlebot_getAgent($actions['USER_AGENT'], $spider_name, $agent, $row['ID_MEMBER'] == 0);
if (!$is_spider)
$return['guests']++;
else
{
$return['num_spiders']++;
if ($modSettings['ob_googlebot_display_agent'])
$spider_name = $agent;
if ($modSettings['ob_googlebot_count_all_instances'] && $modSettings['ob_googlebot_display_all_instances'])
$return['spiders'][] = $spider_name;
else
$return['spiders'][$agent] = $spider_name;
}
}
Encontre:
if (!empty($return['users']))
{
krsort($return['users']);
$userlist = array_keys($return['users']);
$return['users'][$userlist[count($userlist) - 1]]['is_last'] = true;
}
Adcione Após:
// Sort spiders list
ksort($return['spiders']);
// Allowed user to see spiders online?
if (!allowedTo('googlebot_view'))
{
$return['spiders'] = array();
$return['guests'] += $return['num_spiders'];
}
// Don't count all instances of a spider, only 1 for each different spider
if (!empty($return['spiders']) && !$modSettings['ob_googlebot_count_all_instances'])
$return['num_spiders'] = count($return['spiders']);
// Diplay how many instances of each spider
if (!empty($return['spiders']) && $modSettings['ob_googlebot_count_all_instances'] && $modSettings['ob_googlebot_display_all_instances'])
{
$spider_grouped = array_count_values($return['spiders']);
$return['spiders'] = array();
foreach ($spider_grouped as $k => $v)
$return['spiders'][$k] = $k . ($v == 1 ? '' : ' (' . $v . ')');
}
Encontre:
$return['total_users'] = $return['num_users'] + $return['guests']
Adcione Após:
+ ($modSettings['ob_googlebot_count_most_online'] ? $return['num_spiders'] : 0)
Encontre:
$return['guests'], ' ', $return['guests'] == 1
Adcione Antes:
(empty($return['spiders']) ? '' : $return['num_spiders'] . ' ' . ($return['num_spiders'] == 1 ? $txt['ob_googlebot_spider'] : $txt['ob_googlebot_spiders']) . ', '),
Encontre:
foreach ($return['users'] as $user)
echo $user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link'], $user['is_last'] ? '' : ', ';
Adcione Após:
if (!empty($return['spiders']))
{
if ($modSettings['ob_googlebot_display_own_list'])
echo '
<br />';
else
{
if (!empty($return['users']))
echo ', ';
}
echo implode(', ', $return['spiders']);
}
./Sources/BoardIndex.php
Encontre:
// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
Substitua Por:
// Load the users online right now.
$result = db_query("
SELECT
lo.ID_MEMBER, lo.logTime, lo.url, mem.realName, mem.memberName, mem.showOnline,
Encontre:
$context['num_users_hidden'] = 0;
Adcione Após:
$context['spiders'] = array();
$context['num_spiders'] = 0;
Encontre:
$context['num_guests']++;
continue;
Substitua Por:
// Get the request parameters..
$actions = @unserialize($row['url']);
// Is a spider?
$is_spider = ob_googlebot_getAgent($actions['USER_AGENT'], $spider_name, $agent);
if (!$is_spider)
$context['num_guests']++;
else
{
$context['num_spiders']++;
if ($modSettings['ob_googlebot_display_agent'])
$spider_name = $agent;
if ($modSettings['ob_googlebot_count_all_instances'] && $modSettings['ob_googlebot_display_all_instances'])
$context['spiders'][] = $spider_name;
else
$context['spiders'][$agent] = $spider_name;
}
continue;
Encontre:
$context['num_users_online'] = count($context['users_online']) + $context['num_users_hidden'];
Substitua Por:
ksort($context['spiders']);
$context['num_users_online'] = count($context['users_online']) + $context['num_users_hidden'];
// Allowed user to see spiders online?
if (!allowedTo('googlebot_view'))
$context['spiders'] = array();
// Don't count all instances of a spider, only 1 for each different spider
if (!empty($context['spiders']) && !$modSettings['ob_googlebot_count_all_instances'])
$context['num_spiders'] = count($context['spiders']);
// Diplay how many instances of each spider
if (!empty($context['spiders']) && $modSettings['ob_googlebot_count_all_instances'] && $modSettings['ob_googlebot_display_all_instances'])
{
$spider_grouped = array_count_values($context['spiders']);
$context['spiders'] = array();
foreach ($spider_grouped as $k => $v)
$context['spiders'][$k] = $k . ($v == 1 ? '' : ' (' . $v . ')');
}
Encontre:
$total_users = $context['num_guests'] +
Adcione Após:
($modSettings['ob_googlebot_count_most_online'] ? $context['num_spiders'] : 0) +
Encontre:
// Set the latest member.
Adcione Antes:
// Allowed user to see spiders online (We change stuff here AFTER stats update). Spiders are displayed as guests again.
if (!allowedTo('googlebot_view'))
$context['num_guests'] += $context['num_spiders'];
./Sources/ManagePermissions.php
Encontre:
'profile_remote_avatar' => false,
)
Adcione Após:
,
'googlebot' => array(
'googlebot_view' => false,
)
./Sources/ModSettings.php
Encontre:
$context['sub_template'] = 'show_settings';
$subActions = array(
Adcione Após:
'googlebot' => 'ModifyGooglebotSettings',
Encontre:
require_once($sourcedir . '/ManageServer.php');
$subActions = array(
Adcione Após:
'googlebot' => 'ModifyGooglebotSettings',
Encontre:
'karma' => array(
'title' => $txt['smf293'],
'href' => $scripturl . '?action=featuresettings;sa=karma;sesc=' . $context['session_id'],
Adcione Após:
),
'googlebot' => array(
'title' => $txt['ob_googlebot_modname'],
'href' => $scripturl . '?action=featuresettings;sa=googlebot;sesc=' . $context['session_id'],
Encontre:
$context['post_url'] = $scripturl . '?action=featuresettings2;save;sa=karma';
$context['settings_title'] = $txt['smf293'];
prepareDBSettingContext($config_vars);
}
Adcione Após:
function ModifyGooglebotSettings()
{
global $txt, $scripturl, $context, $settings, $sc;
$config_vars = array(
// Count all instances of spiders?
array('check', 'ob_googlebot_count_all_instances'),
array('check', 'ob_googlebot_display_all_instances'),
array('check', 'ob_googlebot_display_agent'),
array('check', 'ob_googlebot_display_own_list'),
'',
// Count spiders on most online?
array('check', 'ob_googlebot_count_most_online'),
'',
// Redirect PHPSESSID URLs?
array('check', 'ob_googlebot_redirect_phpsessid'),
);
// Saving?
if (isset($_GET['save']))
{
saveDBSettings($config_vars);
redirectexit('action=featuresettings;sa=googlebot');
}
$context['post_url'] = $scripturl . '?action=featuresettings2;save;sa=googlebot';
$context['settings_title'] = $txt['ob_googlebot_modname'];
prepareDBSettingContext($config_vars);
}
./Sources/Subs.php
Encontre:
function template_footer()
{
global $context, $settings, $modSettings, $time_start, $db_count;
Adcione Após:
global $user_info, $db_prefix;
//Googlebot stats - Get info for this page
if ($modSettings['ob_googlebot_stats'])
{
$ob_googlebot_start = isset($context['start'])?$context['start']:'0';
if (isset($context['current_topic'])) // We are on a topic
{
$key = 'topic';
$value = "$context[current_topic].$ob_googlebot_start";
}
elseif (isset($context['current_board'])) // We are on a board
{
$key = 'board';
$value = "$context[current_board].$ob_googlebot_start";
}
else // We are somewhere else
{
$key = 'url';
// Remove PHPSESSID, just in case that the user has it in his URL, to avoid duplicates
$value = "$_SERVER[REQUEST_URI]";
$value = preg_replace('/([?&]PHPSESSID=[^&]*)/', '', $value);
$value = str_replace('index.php&', 'index.php?', $value);
}
$result = db_query("
SELECT lastvisit, frequency, visits
FROM {$db_prefix}ob_googlebot_stats
WHERE $key = '$value'
AND agent = 'Googlebot'
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($result) == 0) //No stats yet.
$lastvisit = $frequency = $visits = 0;
else
list ($lastvisit, $frequency, $visits) = mysql_fetch_row($result);
mysql_free_result($result);
// Is Googlebot? if so, we will update the stats BEFORE displaying it.
if (ob_googlebot_getAgent($_SERVER['HTTP_USER_AGENT'], $spider_name, $agent))
if ($agent == 'Googlebot')
{
$now = time();
$visits++;
if ($visits == 1) // First time, insert new record
db_query("
INSERT INTO {$db_prefix}ob_googlebot_stats
($key, visits, lastvisit, agent)
VALUES
('$value', $visits, $now, '$agent')
", __FILE__, __LINE__);
else
{
if ($visits == 2)
$frequency = $now - $lastvisit; /* This is the SECOND time Google visits this page */
else
$frequency = (($frequency * ($visits - 1)) + ($now - $lastvisit)) / $visits;
db_query("
UPDATE {$db_prefix}ob_googlebot_stats
SET frequency = $frequency, visits = $visits, lastvisit = $now
WHERE $key = '$value'
AND agent = 'Googlebot'
LIMIT 1", __FILE__, __LINE__);
}
$lastvisit = $now;
}
if ($visits > 0)
$context['ob_googlebot_stats'] = array(
'Googlebot' => array('frequency' => $frequency, 'visits' => $visits, 'lastvisit' => $lastvisit)
);
}
Encontre (No fim do Arquivo):
?>
Adcione Antes:
//Function to check if the user-agent provided belongs to a spider. Based on getAgent function made by Owdy.
function ob_googlebot_getAgent(&$user_agent, &$spider_name, &$result)
{
$known_spiders = array (
//Search Spiders
array (
'agent' => 'WISENutbot',
'spidername' => 'Looksmart spider',
),
array (
'agent' => 'MSNBot',
'spidername' => 'MSN spider',
),
array (
'agent' => 'W3C_Validator',
'spidername' => 'W3C Validator',
),
array (
'agent' => 'Googlebot-Image',
'spidername' => 'Google-Image Spider',
),
array (
'agent' => 'Googlebot',
'spidername' => 'Google spider',
),
array (
'agent' => 'Mediapartners-Google',
'spidername' => 'Google AdSense spider',
),
array (
'agent' => 'Openbot',
'spidername' => 'Openfind spider',
),
array (
'agent' => 'Yahoo! Slurp',
'spidername' => 'Yahoo spider',
),
array (
'agent' => 'FAST-WebCrawler',
),
array (
'agent' => 'Wget',
),
array (
'agent' => 'Ask Jeeves',
),
array (
'agent' => 'Speedy Spider',
),
array (
'agent' => 'SurveyBot',
),
array (
'agent' => 'IBM_Planetwide',
),
array (
'agent' => 'GigaBot',
),
array (
'agent' => 'ia_archiver',
),
array (
'agent' => 'FAST-WebCrawler',
),
array (
'agent' => 'Inktomi Slurp',
),
array (
'agent' => 'appie',
'spidername' => 'Walhello spider',
),
array (
'agent' => 'FeedBurner/1.0',
'spidername' => 'Feedburner',
),
array (
'agent' => 'Feedfetcher-Google',
),
array (
'agent' => 'OmniExplorer_Bot/6.68',
'spidername' => 'OmniExplorer Bot',
),
array (
'agent' => 'http://www.relevantnoise.com',
'spidername' => 'relevantNOISE',
),
array (
'agent' => 'NewsGatorOnline/2.0',
'spidername' => 'NewsGatorOnline',
),
array (
'agent' => 'ping.blo.gs/2.0',
),
array (
'agent' => 'Jakarta Commons-HttpClient/3.0.1',
'spidername' => 'Amazon',
),
array (
'agent' => 'Jakarta Commons-HttpClient/3.0-rc2',
'spidername' => 'Amazon',
),
);
foreach($known_spiders AS $poss)
if (strpos(strtolower($user_agent), strtolower($poss['agent'])) !== false)
{
$spider_name = isset($poss['spidername']) ? $poss['spidername'] : $poss['agent'];
$result = $poss['agent'];
return true;
}
return false;
}
./Themes/default/languages/Modifications.english.php
Encontre: (no fim do arquivo):
?>
Adcione Antes:
// OB - Googlebot - Begin
// Boardindex Strings
$txt['ob_googlebot_modname'] = 'Googlebot & Spiders';
$txt['ob_googlebot_spider'] = 'Spider';
$txt['ob_googlebot_spiders'] = 'Spiders';
$txt['ob_googlebot_spiders_last_active'] = 'Spiders active in past ' . $modSettings['lastActive'] . ' minutes';
// ModSettings
$txt['ob_googlebot_count_all_instances'] = 'Count all instances of same spider';
$txt['ob_googlebot_display_all_instances'] = 'Display all instances of same spider <div class="smalltext">("' . $txt['ob_googlebot_count_all_instances'] . '" must be selected)</div>';
$txt['ob_googlebot_display_agent'] = 'Display agent instead of name';
$txt['ob_googlebot_display_own_list'] = 'Display spiders in its own list';
$txt['ob_googlebot_count_most_online'] = 'Count in "Most Online"';
$txt['ob_googlebot_redirect_phpsessid'] = 'Redirect PHPSESSID URLs';
// Stats
$txt['ob_googlebot_stats_lastvisit'] = 'Google visited last this page ';
// Permissions
$txt['permissiongroup_googlebot'] = $txt['ob_googlebot_modname'];
$txt['permissionname_googlebot_view'] = 'View Googlebot & Spiders';
// OB - Googlebot - End
./Themes/default/languages/Modifications.portuguese_pt.php (Ou a versão que usa)
Encontre (no fim do arquivo):
?>
Adcione Antes:
// OB - Googlebot - Begin translated By Darkness
// Boardindex Strings
$txt['ob_googlebot_modname'] = 'Googlebot & Spiders';
$txt['ob_googlebot_spider'] = 'Spider';
$txt['ob_googlebot_spiders'] = 'Spiders';
$txt['ob_googlebot_spiders_last_active'] = 'Spiders ativos nos últimos ' . $modSettings['lastActive'] . ' minutos';
// ModSettings
$txt['ob_googlebot_count_all_instances'] = 'Contar todas as instâncias do mesmo Spider';
$txt['ob_googlebot_display_all_instances'] = 'Exibir todas as instâncias do mesmo Spider <div class="smalltext">("' . $txt['ob_googlebot_count_all_instances'] . '" deve ser selecionado)</div>';
$txt['ob_googlebot_display_agent'] = 'Nome de exibição e o uso do agente';
$txt['ob_googlebot_display_own_list'] = 'Exibir os Spiders na sua própria lista';
$txt['ob_googlebot_count_most_online'] = 'Contagem no "Mais onlines"';
$txt['ob_googlebot_redirect_phpsessid'] = 'Redirecionar PHPSESSID URLs';
// Stats
$txt['ob_googlebot_stats_lastvisit'] = 'Google finalmente visitou esta página ';
// Permissions
$txt['permissiongroup_googlebot'] = $txt['ob_googlebot_modname'];
$txt['permissionname_googlebot_view'] = 'Visualizar Googlebot & Spiders';
// OB - Googlebot - End Translated By Darkness
./Themes/default/index.template.php (Se necessário também no Thema que usas)
Encontre:
if ($context['show_load_time'])
echo '
<span class="smalltext">', $txt['smf301'], $context['load_time'], $txt['smf302'], $context['load_queries'], $txt['smf302b'], '</span>';
Adcione Após:
if (isset($context['ob_googlebot_stats']))
echo '
<br /><br /><span class="smalltext">', $txt['ob_googlebot_stats_lastvisit'], timeformat($context['ob_googlebot_stats']['Googlebot']['lastvisit']), '</span>';
./Themes/default/BoardIndex.template.php (Se Necessário também no thema que usas)
Encontre:
$context['num_guests'], ' ', $context['num_guests'] == 1
Adcione Antes:
(empty($context['spiders']) ? '' : $context['num_spiders'] . ' ' . ($context['num_spiders'] == 1 ? $txt['ob_googlebot_spider'] : $txt['ob_googlebot_spiders']) . ', '),
Encontre:
', $txt[140], ':<br />', implode(', ', $context['list_users_online']);
Adcione Após:
if (!empty($context['spiders']))
{
if ($modSettings['ob_googlebot_display_own_list'])
echo '
<br />
', $txt['ob_googlebot_spiders_last_active'], ':<br />';
else
{
if (empty($context['users_online']))
echo '
', $txt[140], ':<br />';
else
echo ', ';
}
echo implode(', ', $context['spiders']);
}