Exemplo n.º 1
0
/* add a browser item to holder */
static void
add_os_browser_node (GHolder * h, int hits, char *data, unsigned long long bw)
{
   GSubList *sub_list;
   char *type = NULL;
   int type_idx = -1;

   if (h->module == OS)
      type = verify_os (data, OPESYS_TYPE);
   else
      type = verify_browser (data, BROWSER_TYPE);

   type_idx = get_item_idx_in_holder (h, type);
   if (type_idx == -1) {
      h->items[h->idx].bw += bw;
      h->items[h->idx].hits += hits;
      h->items[h->idx].data = xstrdup (type);

      /* data (child) */
      sub_list = new_gsublist ();
      add_sub_item_back (sub_list, h->module, data, hits, bw);
      h->items[h->idx++].sub_list = sub_list;
      h->sub_items_size++;
   } else {
      sub_list = h->items[type_idx].sub_list;
      add_sub_item_back (sub_list, h->module, data, hits, bw);

      h->items[type_idx].sub_list = sub_list;
      h->items[type_idx].bw += bw;
      h->items[type_idx].hits += hits;
      h->sub_items_size++;
   }
   free (type);
}
Exemplo n.º 2
0
/* process data based on a unique key, this includes the following
 * modules, VISITORS, BROWSERS, OS */
static void
process_unique_data (char *host, char *date, char *agent)
{
#ifdef HAVE_LIBGEOIP
  char city[CITY_LEN] = "";
  char continent[CONTINENT_LEN] = "";
  char country[COUNTRY_LEN] = "";
#endif

  char *a = NULL, *browser_key = NULL, *browser = NULL;
  char *os_key = NULL, *opsys = NULL;

  char visitor_key[UKEY_BUFFER];
  char os_type[OPESYS_TYPE_LEN], browser_type[BROWSER_TYPE_LEN];

  a = deblank (xstrdup (agent));
  snprintf (visitor_key, sizeof (visitor_key), "%s|%s|%s", host, date, a);
  (visitor_key)[sizeof (visitor_key) - 1] = '\0';
  free (a);

  /* Check if the unique visitor key exists, if not,
   * process hit as unique visitor. Includes, BROWSERS, OSs, VISITORS. */
  if (process_generic_data (ht_unique_visitors, visitor_key) == -1) {
    process_generic_data (ht_unique_vis, date);
    browser_key = xstrdup (agent);
    os_key = xstrdup (agent);

    /* extract browser & OS from agent  */
    browser = verify_browser (browser_key, browser_type);
    if (browser != NULL)
      process_browser (ht_browsers, browser, browser_type);

    opsys = verify_os (os_key, os_type);
    if (opsys != NULL)
      process_opesys (ht_os, opsys, os_type);

#ifdef HAVE_LIBGEOIP
    if (geo_location_data != NULL) {
      if (conf.geoip_city_data)
        geoip_get_city (host, city);

      geoip_get_country (host, country);
      geoip_get_continent (host, continent);
      process_geolocation (ht_countries, country, continent, city);
    }
#endif
  }

  if (browser != NULL)
    free (browser);
  if (browser_key != NULL)
    free (browser_key);
  if (os_key != NULL)
    free (os_key);
  if (opsys != NULL)
    free (opsys);
}