Skip to content

Instantly share code, notes, and snippets.

@mheadd
Created December 5, 2009 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mheadd/249884 to your computer and use it in GitHub Desktop.
Save mheadd/249884 to your computer and use it in GitHub Desktop.
<?php
/*
* Class to compare user agent string with Voxeo Prophcy versions.
*/
class sniffer {
private $smsUserAgentString = 'Voxeo-VXML/10';
private $phoneUserAgentString = 'Voxeo-VXML/8';
private $user_agent;
private $channelType;
public function __construct($user_agent) {
$this->user_agent = $user_agent;
}
public function getChannelType() {
if (strstr($this->user_agent, $this->phoneUserAgentString)) {
$this->channelType = 'phone';
}
else if (strstr($this->user_agent, $this->smsUserAgentString)) {
$this->channelType = 'sms';
}
else {
throw new badSnifferException("An invalid user agent type was detected.");
}
return $this->channelType;
}
}
/*
* Simple class definition to handle instances where the user agent is not known.
*/
class badSnifferException extends Exception { }
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment