Beispiel #1
0
if ($dirhelper->checkExists($fstat_data_dir) == false || $dirhelper->checkExists($fstat_cache_dir) == false || $dirhelper->checkExists($fstat_cache_dir . "ip/") == false) {
    return 0;
}
//Delete old entrys in the Ip directory
$dirhelper->deleteOldIPs($fstat_cache_dir . "ip", $fstat_new_user);
//get the user from cache, on success it is a old user is_new is false then
$user->getFromCache(__DIR__ . "/" . $fstat_cache_dir . "ip");
if ($user->is_new) {
    //Daten auswerten
    $current_folder = __DIR__ . "/" . $fstat_data_dir . "stat/" . gmdate("Y", $user->time) . "/" . gmdate("m", $user->time);
    if ($dirhelper->checkExists($fstat_data_dir . "stat") == false || $dirhelper->checkExists($fstat_data_dir . "stat/" . gmdate("Y", $user->time)) == false || $dirhelper->checkExists($current_folder, true) == false) {
        //quit the execution here
        return 0;
    }
    //User Agent Parser
    $parser = new UAS\Parser(__DIR__ . "/" . $fstat_cache_dir, $fstat_update_interval, false, $fstat_update_auto);
    $uaa = $parser->Parse($user->agent);
    //ReferParser
    $ref = new Reference(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "");
    $ref->parse();
    //Country Parser
    $country = new Country(__DIR__ . "/dbip-country-1.csv", __DIR__ . "/dbip-country-2.csv", __DIR__ . "/dbip-country-3.csv", __DIR__ . "/dbip-country-4.csv", __DIR__ . "/dbip-country-5.csv");
    $country->parse($user->ip);
    //Browser Typ ist bis jetzt nicht deklariert
    $user->type = $uaa['typ'];
    //Daten in XML schreiben:
    $tmp_filename = $current_folder . "/" . gmdate("d", $user->time) . ".xml";
    if (file_exists($tmp_filename)) {
        $xmldoc = new DOMDocument();
        $xmldoc->preserveWhiteSpace = false;
        $xmldoc->formatOutput = true;
Beispiel #2
0
if ($argc < 2 || $argc > 3) {
    echo "Usage: {$argv[0]} <partner_id> [date]\n";
    die;
}
$partnerId = (int) $argv[1];
$date = strftime('%Y-%m-%d', strtotime($argv[2] ?: 'now'));
echo "User agents for {$partnerId} on {$date}\n";
mysqlConnect(MYSQL_SLAVE);
$sql = "SELECT lsm.user_agent AS user_agent FROM log_sessions ls LEFT JOIN log_session_meta lsm ON (lsm.log_session_id=ls.id) WHERE ls.time_firstaction >= '{$date}' AND ls.time_firstaction < TIMESTAMPADD(DAY, 1, '{$date}') AND ls.partner_id={$partnerId};";
$select = mysql_query($sql);
$uas = array();
while ($row = mysql_fetch_assoc($select)) {
    $uas[$row['user_agent']]++;
}
$browsers = array();
$parser = new \UAS\Parser();
$parser->SetCacheDir(sys_get_temp_dir() . "/uascache/");
foreach ($uas as $ua => $count) {
    $browser = 'unknown';
    if ($ret = $parser->parse($ua)) {
        $browser = "{$ret['typ']} - {$ret['ua_family']}";
    }
    $browsers[$browser] += $count;
}
ksort($browsers);
$total = $max1 = $max2 = 0;
foreach ($browsers as $browser => $count) {
    $max1 = max($max1, strlen($browser));
    $max2 = max($max2, strlen($count));
    $total += $count;
}