1<?php
2if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__) .'/../../../../') . '/');
3if(!defined('QS_META')) define ('QS_META', DOKU_INC . 'data/meta/quickstats/');
4
5 function qs_useragent_search_ci ($needle = null, $month)
6 {
7   $found = array();
8   $misc_data_file = QS_META . $month . '/misc_data.ser';
9   $data = unserialize(file_get_contents($misc_data_file));
10
11    foreach($data['version'] as $key =>$val)
12    {
13
14        if(stristr($key, $needle) !== false) {
15          $found[] = $key;
16         }
17
18    }
19     return $found;
20 }
21
22  $page_totals_file = QS_META . 'page_totals.ser';
23  $page_totals = unserialize(file_get_contents($page_totals_file));
24  $months = array_keys($page_totals);
25  $qs_agents = array();
26
27  $search_term = rawurldecode(trim($_POST['other_agent']));
28  if(!$search_term) {
29     echo "";
30     exit;
31  }
32  foreach($months as $month) {
33     $qs_agents = array_merge($qs_agents,qs_useragent_search_ci ($search_term,$month));
34  }
35  $qs_agents = array_unique($qs_agents);
36  if(!count($qs_agents))  {
37     echo "";
38     exit;
39   }
40  $ret_str = implode('::',$qs_agents);
41  echo rawurlencode(rtrim($ret_str,':'));
42  exit;
43
44?>
45