15

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.         'whatsapp',
  10.     );
  11.  
  12.     return is_agent(implode('|', $bots), $agent);
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.  
  2. function is_bot($agent=false){
  3.     $bots = array(
  4.         'googlebot',
  5.         'bingbot',
  6.         'yahoo! slurp',
  7.         'baiduspider',
  8.         'yandexbot',
  9.     );
  10.  
  11.     return is_agent(implode('|', $bots), $agent);
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].