3

isagent

is_agent
SYNOPSIS

is_agent($s, $agent=false)

CODE
  1. function is_agent($s, $agent=false) {
  2.     if (!$agent) {
  3.         require_once 'useragent.php';
  4.  
  5.         $agent=user_agent();
  6.     }
  7.  
  8.     return $agent and preg_match('/'. $s . '/i', $agent);
  9. }
is_opengraph
SYNOPSIS

is_opengraph($agent=false)

DESCRIPTION

is_opengraph returns true if $agent is the name of an agent capable of reading Open Graph tags. By default, if $agent is false, is_opengraph tests the value returned by user_agent.

CODE
  1. function is_opengraph($agent=false) {
  2.     $bots = array(
  3.         'facebookexternalhit',
  4.         'facebot',
  5.         'google',
  6.         'twitterbot',
  7.         'linkedinbot',
  8.         'pinterest',
  9.     );
  10.  
  11.     return is_agent(implode('|', $bots), $agent);
  12. }
is_bot
SYNOPSIS

is_bot($agent=false)

DESCRIPTION

is_bot returns true if $agent is the name of a search engine agent. By default, if $agent is false, is_bot tests the value returned by user_agent.

CODE
  1. function is_bot($agent=false){
  2.     $bots = array(
  3.         'googlebot',
  4.         'bingbot',
  5.         'yahoo! slurp',
  6.         'baiduspider',
  7.         'yandexbot',
  8.     );
  9.  
  10.     return is_agent(implode('|', $bots), $agent);
  11. }
SEE ALSO

useragent

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

===

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].