TeraWurfl
[ class tree: TeraWurfl ] [ index: TeraWurfl ] [ all elements ]

Class: TeraWurflWebservice

Source Location: /TeraWurflWebservice.php

Class Overview


The server-side Tera-WURFL webservice provider. Normally used with webservice.php


Variables

Methods



Class Details

[line 23]
The server-side Tera-WURFL webservice provider. Normally used with webservice.php



[ Top ]


Class Variables

static $ALLOWED_CLIENT_IPS =  false

[line 44]

Allow clients to query the webservice only from the listed networks. Setting this variable to false disables the filter and allows connections from ANY client IP.

To allow only certain networks, put them in CIDR notation in an array. For example, to allow only the range 172.16.10.0/24 and the single IP 192.168.2.17 you would use this as the setting:

  1.  public static $ALLOWED_CLIENT_IPS array('172.16.10.0/24','192.168.2.17/32');

NOTE: 127.0.0.1/32 is automatically allowed, however, some clients may use a different loopback address like 127.1.1.1. In this case, add 127.0.0.0/8 to your list.

Unauthorized attempts to use this webservice are logged to the Tera-WURFL log file with a severity of LOG_WARNING.




Tags:

access:  public

Type:   array|bool


[ Top ]

static $FORMAT_JSON =  'json'

[line 50]



Tags:

var:  Data formats
access:  public

Type:   string


[ Top ]

static $FORMAT_XML =  'xml'

[line 49]



Tags:

var:  Data formats
access:  public

Type:   string


[ Top ]

$access_log_filename =  'webservice_access.log'

[line 77]

Filename of access log



Tags:

access:  public

Type:   string


[ Top ]

$access_log_path =  null

[line 82]

The directory where the access log is stored. Set to null to use the Tera-WURFL data/ directory



Tags:

access:  public

Type:   string


[ Top ]

$enable_access_log =  false

[line 72]

Log all access of the webservice



Tags:

var:  Enable
access:  public

Type:   bool


[ Top ]

$enable_error_log =  true

[line 57]

Log all errors from the webservice



Tags:

var:  Enable
access:  public

Type:   bool


[ Top ]

$errors =

[line 87]

Errors encountered during processing



Tags:

var:  errors
access:  public

Type:   array


[ Top ]

$error_log_filename =  'webservice_error.log'

[line 62]

Filename of error log



Tags:

access:  public

Type:   string


[ Top ]

$error_log_path =  null

[line 67]

The directory where the error log is stored. Set to null to use the Tera-WURFL data/ directory



Tags:

access:  public

Type:   string


[ Top ]

$flatCapabilities = array()

[line 124]



Tags:

var:  Capabilities array flattened into a Key=>Value pair array
access:  protected

Type:   array


[ Top ]

$format =

[line 92]



Tags:

var:  Format of request
access:  protected

Type:   string


[ Top ]

$json =

[line 100]



Tags:

var:  JSON Response
access:  protected

Type:   string


[ Top ]

$out_cap = array()

[line 104]



Tags:

var:  Capabilities to be included in output
access:  protected

Type:   array


[ Top ]

$out_errors = array()

[line 112]



Tags:

var:  Errors to be included in response
access:  protected

Type:   array


[ Top ]

$search_results = array()

[line 108]



Tags:

var:  Capabilities that were found in WURFL
access:  protected

Type:   array


[ Top ]

$userAgent =

[line 116]



Tags:

var:  Incoming user agent
access:  protected

Type:   string


[ Top ]

$wurflObj =

[line 120]



Tags:

var:  Instance of TeraWurfl
access:  protected

Type:   null|TeraWurfl


[ Top ]

$xml =

[line 96]



Tags:

var:  XML Response
access:  protected

Type:   string


[ Top ]



Class Methods


static method ipInCIDRNetwork [line 207]

static bool ipInCIDRNetwork( string $cidr_network, string $ip)

See if a given ip ($ip) is in a given CIDR network ($cidr_network)



Tags:

return:  IP Address is in CIDR Network
access:  public


Parameters:

string   $cidr_network   CIDR Network (e.g. "192.168.2.0/24")
string   $ip   IP Address

[ Top ]

constructor __construct [line 133]

TeraWurflWebservice __construct( string $userAgent, string $searchPhrase, [string $data_format = 'xml'], [null|TeraWurfl $teraWurflInstance = null])

Instantiates a new TeraWurflWebservice



Tags:

access:  public


Parameters:

string   $userAgent   User Agent
string   $searchPhrase   Search phrase
string   $data_format   String
null|TeraWurfl   $teraWurflInstance   Instance of TeraWurfl to use for detection

[ Top ]

method addError [line 261]

void addError( string $name, string $desc)

Add an error to the errors array that will be sent in the response



Tags:

access:  protected


Parameters:

string   $name   Capability name that is in error
string   $desc   Description of the error

[ Top ]

method exportValue [line 251]

string exportValue( null|int|bool|string|float $in)

Converts PHP variables to an XML friendly string



Tags:

return:  Value
access:  protected


Parameters:

null|int|bool|string|float   $in   Value

[ Top ]

method flattenCapabilities [line 298]

void flattenCapabilities( )

Flatten the multidimensional capabilities array into a list of capabilities.



Tags:

access:  protected


[ Top ]

method generateJSON [line 337]

void generateJSON( )

Generate JSON response



Tags:

access:  protected


[ Top ]

method generateXML [line 316]

void generateXML( )

Generate the XML response



Tags:

access:  protected


[ Top ]

method generateXMLErrors [line 353]

string generateXMLErrors( )

Generate the errors section of the XML response



Tags:

return:  XML errors section
access:  protected


[ Top ]

method getResponse [line 166]

string getResponse( )

Get the response that would normally be sent to the client.



Tags:

return:  Response
access:  public


[ Top ]

method isClientAllowed [line 237]

bool isClientAllowed( )

Is the connecting client allowed to use this webservice



Tags:

access:  protected


[ Top ]

method logAccess [line 369]

void logAccess( )

Log this access with the IP of the requester and the user agent



Tags:

access:  protected


[ Top ]

method logError [line 388]

void logError( string $text, [int $requestedLogLevel = LOG_NOTICE], [string $func = "TeraWurflWebservice"])

Log an error in the TeraWurflWebservice log file



Tags:

access:  protected


Parameters:

string   $text   The error message text
int   $requestedLogLevel   The log level / severity of the error
string   $func   The function or code that was being run when the error occurred

[ Top ]

method search [line 270]

void search( string $searchPhrase)

Search through all the capabilities and place the requested ones in search_results to be sent in the response.



Tags:

access:  protected


Parameters:

string   $searchPhrase   Search phrase (e.g. "is_wireless_device|streaming|tera_wurfl")

[ Top ]

method sendHTTPHeaders [line 181]

void sendHTTPHeaders( )

Send the HTTP Headers for the return data



Tags:

access:  public


[ Top ]

method sendResponse [line 197]

void sendResponse( )

Send the complete response to the client, including the HTTP Headers and the response.



Tags:

access:  public


[ Top ]

method __handleExceptions [line 409]

void __handleExceptions( Exception $exception)

Exception handler for webservice



Tags:

access:  public


Parameters:

Exception   $exception  

[ Top ]


Documentation generated on Thu, 03 Oct 2013 15:19:20 -0400 by phpDocumentor 1.4.4