= 200 and $status < 400) {
$value = substr($value, $header_length);
// echo '
-ch- ('. $value . ')
';
return $value;
}
else $pwg_mode = 'failed'; // Sorry but remind it as well
}
// No other solutions
return false;
}
}
// Select the correct menu on loc_end_admin
function whois_select_menu($menu) {
global $conf_whois, $template;
if ($conf_whois['Add icon to History'] or !$conf_whois['Add to Plugins menu'])
$template->assign('ACTIVE_MENU', 4);
else $template->assign('ACTIVE_MENU', 3);
}
// Template function
function Whois_most($text, $count, $when, $format) {
return sprintf(l10n($text),$count,date(l10n($format),$when));
}
function whois_country($trace, $bypass = false) {
if (!isset($trace['country'])) {
pwg_query('ALTER TABLE ' . WHOIS_ONLINE_TABLE . ' ADD `country` VARCHAR( 254 ) NOT NULL AFTER `lang` ;');
$trace['country']='';
}
$c = array();
if ($trace['country']!='') $c = @unserialize(htmlspecialchars_decode($trace['country']));
if (isset($c['Code']) and $c['Code']!='' and $c['Code']!='__') return $c;
if ($bypass and isset($c['Code'])) return $c;
$result = pwg_get_contents ('http://api.hostip.info/get_html.php?ip=' . $trace['IP'], 'r');
if ( $result !== false ) {
$tokens = preg_split("/[:]+/", $result);
$c = array ('Name' => $tokens[1], 'City' => substr($tokens[3],0,-3));
if (strpos ($c['Name'], '?') === FALSE) {
$c['Code'] = substr($c['Name'],-8,2); # " (Private Address) (XX) City"
$c['Name'] = ucwords ( strtolower( substr($c['Name'],0,-5)));
}
else $c = Array('Code' => '__', 'Name' => l10n('Unknown country'), 'City' => 'N/A',);
}
if (stripos($c['Name'], 'Squid')!==false or $c['Code'] =='XX')
$c = Array('Code' => '__', 'Name' => l10n('Unknown country'), 'City' => 'N/A',);
$new = htmlspecialchars(serialize($c),ENT_QUOTES,'UTF-8');
if ($new == $trace['country']) return $c;
pwg_query('UPDATE ' . WHOIS_ONLINE_TABLE . '
SET `country` = \'' . $new . '\'
WHERE `session_id` = \'' . $trace['session_id'] . '\';');
return $c;
}
function whois_flag($trace, &$step, $limit = 10) {
$flag = WHOIS_ONLINE_PATH . 'flags/' . $trace['Country']['Code'] . '.jpg';
if (file_exists($flag) and $trace['Country']['Code'] != '__' ) return $flag;
if ($trace['Country']['Code'] == '__' ) {
$flag = WHOIS_ONLINE_PATH . 'flags/' . substr($trace['lang'],-2, 2) . '.jpg';
if (file_exists($flag)) return $flag;
return WHOIS_ONLINE_PATH . 'flags/__.jpg';
}
if ( $step > $limit ) return WHOIS_ONLINE_PATH . 'flags/.jpg';
$f = fopen ('http://api.hostip.info/flag.php?ip=' . $trace['IP'], 'r');
$result='';
while ($l = fgets ($f, 1024)) $result .= $l;
fclose ($f);
$f = fopen($flag,"w+");
fputs($f,$result);
fclose($f);
return $flag;
}
/*
returns (mixed): (string) 'bot agent name' || (bool) false
@param (string) HTTP_USER_AGENT
*/
function is_a_bot($agent = '')
{
global $conf;
if ($agent == '') $agent = $_SERVER['HTTP_USER_AGENT'];
$botlist = array('Teoma', 'alexa', 'froogle', 'Gigabot', 'inktomi',
'looksmart', 'URL_Spider_SQL', 'Firefly', 'NationalDirectory',
'Ask Jeeves', 'TECNOSEEK', 'InfoSeek', 'WebFindBot', 'girafabot',
'crawler', 'www.galaxy.com', 'Googlebot', 'Scooter', 'Slurp',
'msnbot', 'appie', 'FAST', 'WebBug', 'Spade', 'ZyBorg', 'rabaz',
'Baiduspider', 'Feedfetcher-Google', 'TechnoratiSnoop', 'Rankivabot',
'Mediapartners-Google', 'Sogou web spider', 'WebAlta Crawler');
if (isset($conf['search_agents']))
$botlist = array_merge( $botlist, array_diff( $conf['search_agents'], $botlist ) );
foreach($botlist as $bot) {
if (stripos($agent, $bot)!==false) return $bot;
}
return false;
}
?>