/**
 * Generates javascript for client functionality from 51Degrees data.
 */
function fiftyone_degrees_get_script()
{
    global $_fiftyone_degrees_needed_properties;
    $headers = fiftyone_degrees_get_headers();
    $_fiftyone_degrees_needed_properties = array();
    $profile_scripts = array();
    $other_scripts = array();
    $output = "\n";
    for ($i = 0; $i < $headers['property_count']; $i++) {
        $property = fiftyone_degrees_read_property($i, $headers);
        if ($property['value_type_id'] == 4) {
            $_fiftyone_degrees_needed_properties[] = $property['name'];
            if (strpos($property['name'], 'Profile') !== FALSE) {
                $profile_scripts[] = $property['name'];
            } else {
                $other_scripts[] = $property['name'];
            }
        }
    }
    $_51d = fiftyone_degrees_get_device_data($_SERVER['HTTP_USER_AGENT']);
    foreach ($other_scripts as $property) {
        if (isset($_51d[$property])) {
            $output .= $_51d[$property];
            $output .= "\n";
        }
    }
    $output .= "function FODPO() { var profileIds = new Array();\n";
    $c = count($profile_scripts);
    if ($c > 0 && (isset($_SESSION['51D_ProfileIds']) === FALSE || strlen($_SESSION['51D_ProfileIds']) == 0)) {
        foreach ($profile_scripts as $property) {
            if (isset($_51d[$property])) {
                $props = $_51d[$property];
                foreach ($props as $prop) {
                    $output .= $prop;
                    $output .= "\n";
                }
            }
        }
        $output .= "document.cookie = \"51D_ProfileIds=\" + profileIds.join(\"|\");";
    }
    $output .= "}\n";
    return str_replace('document.addEventListener("load", this.loadComplete.bind(this), true);', 'window.addEventListener("load", this.loadComplete.bind(this), true);', $output);
}
 public function getDeviceData($userAgent)
 {
     require_once __DIR__ . '/../Library/51Degrees_data_reader.php';
     return fiftyone_degrees_get_device_data($userAgent);
 }
<html>
<head>
<title>51Degrees Image Optimser Gallery</title>
<?php 
fiftyone_degrees_echo_header();
?>
</head>
<body>
<?php 
fiftyone_degrees_echo_menu();
if (array_key_exists('ua', $_GET)) {
    $ua = $_GET['ua'];
} else {
    $ua = $_SERVER['HTTP_USER_AGENT'];
}
?>
<div id="Content">
<form action="Tester.php" method="get">
  Useragent: <input type="text" name="ua" value="<?php 
echo $ua;
?>
" />
  <input type="submit" value="Submit">
</form>
<?php 
$properties = fiftyone_degrees_get_device_data($ua);
fiftyone_degrees_echo_properties($properties);
?>
</div>
</body>
</html>
 * Specifies what the width parameter should be for an optimised image url.
 * Defaults to 'w'.
 */
global $_fiftyone_degrees_image_width_parameter;
$_fiftyone_degrees_image_width_parameter = 'w';
/**
 * Specifies what the height parameter should be for an optimised image url.
 * Defaults to 'h'.
 */
global $_fiftyone_degrees_image_height_parameter;
$_fiftyone_degrees_image_height_parameter = 'h';
/**
 * If an image is requested with a width or height set to 'auto', the
 * parameter will be changed to the value set in 'defaultAuto'. This is most
 * useful for clients without javascript that should still be served images,
 * Defaults to 50.
 */
global $_fiftyone_degrees_default_auto;
$_fiftyone_degrees_default_auto = 50;
/**
 * Sets a factor images dimensions must have. Image sizes are rounded down to
 * nearest multiple. This can be used to control server load if many images are
 * being processed.
 */
global $_fiftyone_degrees_image_factor;
$_fiftyone_degrees_image_factor = 1;
require_once '51Degrees_data_reader.php';
if ((isset($_fiftyone_degrees_defer_execution) && $_fiftyone_degrees_defer_execution === TRUE) === FALSE) {
    global $_51d;
    $_51d = fiftyone_degrees_get_device_data($_SERVER['HTTP_USER_AGENT']);
}