Skip to content

Commit

Permalink
better insights of each vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaDafinser committed Nov 20, 2015
1 parent 1684210 commit ed97414
Show file tree
Hide file tree
Showing 126 changed files with 4,643 additions and 1,787 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ And put it to `data/full_php_browscap.ini`

#### Wurfl
Download the `wurfl.xml` from [here (need register)](http://www.scientiamobile.com/downloads) or [here (not allowed)](https://github.com/fauvel/wurfl-dbapi/blob/master/data/wurfl.xml)

You need to put the wurfl file to `data/wurfl.xml`

### Step 4) init caches
Expand Down Expand Up @@ -57,4 +58,4 @@ php bin/generateList.php

After executing Step 5) you have all data inside a `sqlite` database!

Just open it in `data/results.sqlite3`
Just open `data/results.sqlite3` with a viewer and query it...have fun :-)
238 changes: 203 additions & 35 deletions bin/generateList.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
use UserAgentParserComparison\GenerateHtmlList;
use UserAgentParserComparison\GenerateHtmlListV2;
use UserAgentParserComparison\UserAgentParserComparison;
use UserAgentParserComparison\GenerateHtmlListSimple;
include_once 'bootstrap.php';

$pdo = new PDO('sqlite:data/results.sqlite3');
Expand Down Expand Up @@ -41,71 +42,189 @@
$providers = array_column($result, 'providerName');

foreach ($providers as $providerName) {
$path = 'results/' . $providerName;
/**
* *****************************
* Grouped detection results
* *******************************
*/
$path = 'results/' . $providerName . '/grouped';

if (! file_exists($path)) {
mkdir($path, null, true);
}

/*
* No result found
* detected browsers
*/
$sql = "
SELECT
userAgent,
browserName as name
FROM vendorResult
JOIN userAgent ON uaId = userAgent_uaId
WHERE
providerName = '" . $providerName . "'
AND browserName IS NOT NULL
GROUP BY browserName
ORDER BY browserName
";
$stmt = $pdo->prepare($sql);
$stmt->execute();

$generate = new GenerateHtmlListSimple();
$generate->setResult($stmt->fetchAll(PDO::FETCH_ASSOC));
$generate->setTitle($providerName . ' - browsers detected');

file_put_contents($path . '/browser.html', $generate->getHtml());

/*
* detected engines
*/
$sql = "
SELECT
userAgent_uaId
userAgent,
engineName as name
FROM vendorResult
WHERE
JOIN userAgent ON uaId = userAgent_uaId
WHERE
providerName = '" . $providerName . "'
AND resultFound = 0
AND engineName IS NOT NULL
GROUP BY engineName
ORDER BY engineName
";
$stmt = $pdo->prepare($sql);
$stmt->execute();

$generate = new GenerateHtmlListV2();
$generate->setSubquery($sql);
$generate->setTitle($providerName . ' - no result found');
$generate = new GenerateHtmlListSimple();
$generate->setResult($stmt->fetchAll(PDO::FETCH_ASSOC));
$generate->setTitle($providerName . ' - rendering engines detected');

file_put_contents($path . '/noResultFound.html', $generate->getHtml());
file_put_contents($path . '/engine.html', $generate->getHtml());

/*
* Not detected as bot
* detected OS
*/
$sql = "
SELECT
userAgent_uaId
FROM userAgent
JOIN vendorResult
ON userAgent_uaId = uaId
userAgent,
osName as name
FROM vendorResult
JOIN userAgent ON uaId = userAgent_uaId
WHERE
providerName = '" . $providerName . "'
AND `group` = 'bot'
AND botIsBot = 0
AND osName IS NOT NULL
GROUP BY osName
ORDER BY osName
";
$generate = new GenerateHtmlListV2();
$generate->setSubquery($sql);
$generate->setTitle($providerName . ' - not detected as bot');
$stmt = $pdo->prepare($sql);
$stmt->execute();

file_put_contents($path . '/notDetectedAsBot.html', $generate->getHtml());
$generate = new GenerateHtmlListSimple();
$generate->setResult($stmt->fetchAll(PDO::FETCH_ASSOC));
$generate->setTitle($providerName . ' - operating systems detected');

file_put_contents($path . '/os.html', $generate->getHtml());

/*
* Is probably no bot
* detected model
*/
$sql = "
SELECT
userAgent_uaId
FROM userAgent
JOIN vendorResult
ON userAgent_uaId = uaId
userAgent,
deviceModel as name
FROM vendorResult
JOIN userAgent ON uaId = userAgent_uaId
WHERE
providerName = '" . $providerName . "'
AND `group` != 'bot'
AND botIsBot = 1
AND deviceModel IS NOT NULL
GROUP BY deviceModel
ORDER BY deviceModel
";
$stmt = $pdo->prepare($sql);
$stmt->execute();

$generate = new GenerateHtmlListSimple();
$generate->setResult($stmt->fetchAll(PDO::FETCH_ASSOC));
$generate->setTitle($providerName . ' - device models detected');

file_put_contents($path . '/deviceModel.html', $generate->getHtml());

/*
* detected brand
*/
$sql = "
SELECT
userAgent,
deviceBrand as name
FROM vendorResult
JOIN userAgent ON uaId = userAgent_uaId
WHERE
providerName = '" . $providerName . "'
AND deviceBrand IS NOT NULL
GROUP BY deviceBrand
ORDER BY deviceBrand
";
$stmt = $pdo->prepare($sql);
$stmt->execute();

$generate = new GenerateHtmlListSimple();
$generate->setResult($stmt->fetchAll(PDO::FETCH_ASSOC));
$generate->setTitle($providerName . ' - device brands detected');

file_put_contents($path . '/deviceBrand.html', $generate->getHtml());

/*
* detected type
*/
$sql = "
SELECT
userAgent,
deviceType as name
FROM vendorResult
JOIN userAgent ON uaId = userAgent_uaId
WHERE
providerName = '" . $providerName . "'
AND deviceType IS NOT NULL
GROUP BY deviceType
ORDER BY deviceType
";
$stmt = $pdo->prepare($sql);
$stmt->execute();

$generate = new GenerateHtmlListSimple();
$generate->setResult($stmt->fetchAll(PDO::FETCH_ASSOC));
$generate->setTitle($providerName . ' - device types detected');

file_put_contents($path . '/deviceType.html', $generate->getHtml());

/**
* *****************
* No result found
* **********************
*/
$path = 'results/' . $providerName . '/noResult';

if (! file_exists($path)) {
mkdir($path, null, true);
}

/*
* No result found
*/
$sql = "
SELECT
userAgent_uaId
FROM vendorResult
WHERE
providerName = '" . $providerName . "'
AND resultFound = 0
";

$generate = new GenerateHtmlListV2();
$generate->setSubquery($sql);
$generate->setTitle($providerName . ' - is probably no bot?');
$generate->setTitle($providerName . ' - no result found at all');

$path = 'results/' . $providerName;

file_put_contents($path . '/isProbablyNoBot.html', $generate->getHtml());
file_put_contents($path . '/atAll.html', $generate->getHtml());

/*
* No browser result found
Expand All @@ -124,7 +243,7 @@
$generate->setSubquery($sql);
$generate->setTitle($providerName . ' - no browser result found');

file_put_contents($path . '/noBrowserResultFound.html', $generate->getHtml());
file_put_contents($path . '/browser.html', $generate->getHtml());

/*
* No renderingEngine result found
Expand All @@ -143,7 +262,7 @@
$generate->setSubquery($sql);
$generate->setTitle($providerName . ' - no rendering engine result found');

file_put_contents($path . '/noRenderingEngineResultFound.html', $generate->getHtml());
file_put_contents($path . '/engine.html', $generate->getHtml());

/*
* No OS result found
Expand All @@ -162,6 +281,55 @@
$generate->setSubquery($sql);
$generate->setTitle($providerName . ' - no operating system result found');

file_put_contents($path . '/os.html', $generate->getHtml());

/**
* *****************
* bot things
* ***************
*/
$path = 'results/' . $providerName . '/bot';

if (! file_exists($path)) {
mkdir($path, null, true);
}
/*
* Should be detected as bot
*/
$sql = "
SELECT
userAgent_uaId
FROM userAgent
JOIN vendorResult
ON userAgent_uaId = uaId
WHERE
providerName = '" . $providerName . "'
AND `group` = 'bot'
AND botIsBot = 0
";
$generate = new GenerateHtmlListV2();
$generate->setSubquery($sql);
$generate->setTitle($providerName . ' - not detected as bot');

file_put_contents($path . '/shouldBeABot.html', $generate->getHtml());

/*
* Should NOT be detected as bot
*/
$sql = "
SELECT
userAgent_uaId
FROM userAgent
JOIN vendorResult
ON userAgent_uaId = uaId
WHERE
providerName = '" . $providerName . "'
AND `group` != 'bot'
AND botIsBot = 1
";
$generate = new GenerateHtmlListV2();
$generate->setSubquery($sql);
$generate->setTitle($providerName . ' - is probably no bot?');

file_put_contents($path . '/noOperatingSystemResultFound.html', $generate->getHtml());
file_put_contents($path . '/shouldNotBeABot.html', $generate->getHtml());
}
Loading

0 comments on commit ed97414

Please sign in to comment.