/** * Reads the headers of the data file to be used throughout the detection. * * @return array * The headers of the data file. */ function fiftyone_degrees_get_headers() { global $_fiftyone_degrees_data_file_path; $headers['data_file_path'] = $_fiftyone_degrees_data_file_path; $_fiftyone_degrees_data_file = fiftyone_degrees_get_data_file(0); $headers['info'] = fiftyone_degrees_get_data_info($_fiftyone_degrees_data_file); $version = "{$headers['info']['major_version']}.{$headers['info']['minor_version']}"; $supported_version = fiftyone_degrees_get_supported_version(); if ($version !== $supported_version) { die('An incompatible data file has been supplied. Ensure the lastest 51Degrees data and api are being used.'); } $headers['ascii_strings_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['ascii_strings_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['ascii_strings_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['component_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['component_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['component_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['map_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['map_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['map_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['property_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['property_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['property_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['values_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['values_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['values_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['profile_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['profile_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['profile_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['signatures_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['signatures_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['signatures_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['ranked_signatures_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['ranked_signatures_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['ranked_signatures_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['node_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['node_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['node_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['root_node_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['root_node_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['root_node_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['profile_offsets_offset'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['profile_offsets_length'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $headers['profile_offsets_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); return $headers; }
function fiftyone_degrees_gallery_get_profiles(&$offset, $limit, $hardware_value_id, $headers) { $end_offset = $headers['profile_length']; $profiles = array(); while ($offset < $end_offset) { $_fiftyone_degrees_data_file = fiftyone_degrees_get_data_file($offset + $headers['profile_offset']); $profile = array(); $profile['component_id'] = fiftyone_degrees_read_byte($_fiftyone_degrees_data_file); $profile['unique_id'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $profile['profile_value_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); $profile['signature_count'] = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); if ($profile['component_id'] == 0) { $_fiftyone_degrees_data_file = fiftyone_degrees_get_data_file($offset + 1 + 4 + 4 + 4 + 4 * 6 + $headers['profile_offset']); $profile_hardware_value_id = fiftyone_degrees_read_int($_fiftyone_degrees_data_file); if ($profile_hardware_value_id == $hardware_value_id) { $profile = fiftyone_degrees_read_profile($offset, $headers); //if (in_array($hardware_value_id, $profile['profile_values'])) { $profiles[] = $profile; //var_dump($profile['profile_values']); if (count($profiles) >= $limit) { break; } //} } } $offset += 1 + 4 + 4 + 4 + $profile['profile_value_count'] * 4 + 4 * $profile['signature_count']; } return $profiles; }