Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Show related results

  • Loading branch information...
commit d1053a1894477cef75f3a3b50c2f5446d584ef76 1 parent 9f47a9d
@NielsLeenheer authored
View
1  .htaccess
@@ -30,6 +30,7 @@ RewriteRule ^results/television.html$ /backend/controllers/results.php?type=tel
RewriteRule ^results/other.html$ /backend/controllers/results.php?type=other
RewriteRule ^results/latest.html$ /backend/controllers/latest.php
RewriteRule ^results/search.html$ /backend/controllers/search.php
+RewriteRule ^results/related/(.+).html$ /backend/controllers/fingerprint.php?id=$1
RewriteRule ^devicelab/?$ /backend/controllers/lab.php
View
23 backend/controllers/fingerprint.php
@@ -0,0 +1,23 @@
+<?php
+
+ include('../config.php');
+ include('../libraries/database.php');
+ include('../libraries/template.php');
+ include('../libraries/tools.php');
+ include('../models/fingerprint.php');
+ include('../models/results.php');
+
+
+ $tpl = new Template('../templates/fingerprint.html');
+
+ if (isset($_REQUEST['id'])) {
+ if ($row = Fingerprint::getById($_REQUEST['id'])) {
+ $tpl->set('fingerprint', $row);
+ }
+
+ if ($row = Results::getByFingerprint($_REQUEST['id'])) {
+ $tpl->set('results', $row);
+ }
+ }
+
+ echo $tpl->fetch();
View
157 backend/models/fingerprint.php
@@ -0,0 +1,157 @@
+<?php
+
+ class Fingerprint {
+
+ function calculatePercentages($items) {
+ $total = 0;
+
+ while (list($k,$v) = each($items)) {
+ $total += $v['value'];
+ }
+
+ reset ($items);
+
+ while (list($k,$v) = each($items)) {
+ $items[$k]['percentage'] = round(($v['value'] / $total) * 100);
+
+ if ($items[$k]['percentage'] == 0) {
+ unset($items[$k]);
+ }
+
+ //unset($items[$k]['value']);
+ }
+
+ return $items;
+ }
+
+ function process($data) {
+ $data['items'] = Fingerprint::calculatePercentages($data['items']);
+
+ if (count($data['items']) == 1) {
+ $data['status'] = 'fixed';
+
+ reset ($data['items']);
+ list($data['value'],) = each($data['items']);
+
+ //unset($data['items']);
+ }
+
+ if (count($data['items']) > 20) {
+ $data['status'] = 'none';
+ unset($data['items']);
+ }
+
+ if ($data['status'] == 'fixed' || $data['status'] == 'list') {
+ $items = array();
+
+ reset ($data['items']);
+ while (list($k,$v) = each($data['items'])) {
+ $items[] = array('name' => $k, 'value' => $v['value'], 'percentage' => $v['percentage']);
+ }
+
+ $data['items'] = $items;
+
+ usort($data['items'], function ($a, $b) {
+ if ($a['value'] == $b['value']) {
+ return 0;
+ }
+ return ($a['value'] > $b['value']) ? -1 : 1;
+ });
+ }
+
+ return $data;
+ }
+
+
+ function getById($id) {
+ $results = array(
+ 'results' => array(),
+ 'browserName' => array('items' => array(), 'status' => 'list'),
+ 'browserVersion' => array('items' => array(), 'status' => 'list'),
+ 'osName' => array('items' => array(), 'status' => 'list'),
+ 'osVersion' => array('items' => array(), 'status' => 'list'),
+ 'deviceManufacturer' => array('items' => array(), 'status' => 'list'),
+ 'deviceModel' => array('items' => array(), 'status' => 'list')
+ );
+
+ $res = mysql_query("
+ SELECT
+ *
+ FROM
+ results
+ WHERE
+ fingerprint = '" . mysql_real_escape_string($id) . "'
+ ORDER BY
+ humanReadable
+ ");
+
+ while ($row = mysql_fetch_object($res)) {
+ $results['results'][] = (object) array(
+ 'id' => $row->uniqueid,
+ 'name' => $row->humanReadable,
+ 'ago' => time_ago(strtotime($row->timestamp))
+ );
+
+ if (!isset($results['browserName']['items'][trim($row->browserName)])) {
+ $results['browserName']['items'][trim($row->browserName)] = array('value' => 0);
+ }
+
+ $results['browserName']['items'][trim($row->browserName)]['value']++;
+
+
+ if (!isset($results['browserVersion']['items'][trim($row->browserName . ' ' . $row->browserVersion)])) {
+ $results['browserVersion']['items'][trim($row->browserName . ' ' . $row->browserVersion)] = array('value' => 0);
+ }
+
+ $results['browserVersion']['items'][trim($row->browserName . ' ' . $row->browserVersion)]['value']++;
+
+
+ if (!isset($results['osName']['items'][trim($row->osName)])) {
+ $results['osName']['items'][trim($row->osName)] = array('value' => 0);
+ }
+
+ $results['osName']['items'][trim($row->osName)]['value']++;
+
+
+ if (!isset($results['osVersion']['items'][trim($row->osName . ' ' . $row->osVersion)])) {
+ $results['osVersion']['items'][trim($row->osName . ' ' . $row->osVersion)] = array('value' => 0);
+ }
+
+ $results['osVersion']['items'][trim($row->osName . ' ' . $row->osVersion)]['value']++;
+
+
+ if (!isset($results['deviceManufacturer']['items'][trim($row->deviceManufacturer)])) {
+ $results['deviceManufacturer']['items'][trim($row->deviceManufacturer)] = array('value' => 0);
+ }
+
+ $results['deviceManufacturer']['items'][trim($row->deviceManufacturer)]['value']++;
+
+
+ if (!isset($results['deviceModel']['items'][trim($row->deviceManufacturer . ' ' . $row->deviceModel)])) {
+ $results['deviceModel']['items'][trim($row->deviceManufacturer . ' ' . $row->deviceModel)] = array('value' => 0);
+ }
+
+ $results['deviceModel']['items'][trim($row->deviceManufacturer . ' ' . $row->deviceModel)]['value']++;
+ }
+
+
+ $results['browserName'] = Fingerprint::process($results['browserName']);
+ $results['browserVersion'] = Fingerprint::process($results['browserVersion']);
+ $results['osName'] = Fingerprint::process($results['osName']);
+ $results['osVersion'] = Fingerprint::process($results['osVersion']);
+ $results['deviceManufacturer'] = Fingerprint::process($results['deviceManufacturer']);
+ $results['deviceModel'] = Fingerprint::process($results['deviceModel']);
+
+ if ($results['deviceManufacturer']['status'] == 'fixed' && $results['deviceManufacturer']['value'] == '') {
+ $results['deviceManufacturer']['status'] = 'none';
+ unset($results['deviceManufacturer']['value']);
+ }
+
+ if ($results['deviceModel']['status'] == 'fixed' && $results['deviceModel']['value'] == '') {
+ $results['deviceModel']['status'] = 'none';
+ unset($results['deviceModel']['value']);
+ }
+
+ return $results;
+ }
+ }
View
4 backend/models/results.php
@@ -98,7 +98,7 @@ function getByBrowser($browser, $version) {
function getByUniqueId($id) {
$res = mysql_query("
SELECT
- r.uniqueid AS id, 'Unique id' AS nickname, f.score, f.maximum, f.points, f.results, humanReadable, useragentHeader AS useragent, deviceWidth, deviceHeight
+ r.uniqueid AS id, 'Unique id' AS nickname, f.score, f.maximum, f.points, f.results, humanReadable, useragentHeader AS useragent, deviceWidth, deviceHeight, f.fingerprint
FROM
results AS r
LEFT JOIN fingerprints AS f ON (r.fingerprint = f.fingerprint)
@@ -115,7 +115,7 @@ function getByUniqueId($id) {
function getByFingerprint($id) {
$res = mysql_query("
SELECT
- score, points, results
+ score, maximum, points, results
FROM
fingerprints
WHERE
View
198 backend/templates/fingerprint.html
@@ -0,0 +1,198 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title data-i18n>HTML5test - How well does your browser support HTML5?</title>
+
+ <meta charset="UTF-8">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-status-bar-style" content="black">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+ <link rel="stylesheet" href="/css/main.css" type="text/css">
+ <link rel="stylesheet" href="/css/reporting.css" type="text/css">
+
+ <script src='/translation.js' type='text/javascript'></script>
+
+ <script src='/scripts/base.js' type='text/javascript'></script>
+ <script src='/scripts/reporting.js' type='text/javascript'></script>
+
+ <link rel="icon" href="/images/icon.png">
+ <link rel="apple-touch-icon" href="/images/button.png">
+ </head>
+
+ <body>
+ <div class='header'>
+ <h1 data-i18n><span>HTML<strong>5</strong>test</span> <em>how well does your browser support HTML5?</em></h1>
+ <div class='navigation'>
+ <ul class='left'>
+ <li><a href='/index.html' data-i18n>Your browser</a></li>
+ <li class='selected'><a href='/results/desktop.html' data-i18n>Other browsers</a></li>
+ <li><a href='/compare/browser/index.html' data-i18n>Compare</a></li>
+ </ul>
+ <ul class='right'>
+ <li><a href='http://blog.html5test.com/' data-i18n>News</a></li>
+ <li><a href='/devicelab'>Device Lab</a></li>
+ <li><a href='/about.html' data-i18n>About<span> the test</span></a></li>
+ </ul>
+ </div>
+ </div>
+
+ <div class='page saved'>
+ <div id='contents' class='column'>
+ <div id='score'>
+ <div class='pointsPanel'>
+ <h2><span>This browser scored</span> <strong><?php echo $results->score; ?></strong> <span>out of <?php echo $results->maximum; ?> points</span></h2>
+ <hr>
+ </div>
+ </div>
+
+ <div class='paper'>
+ <div>
+ <div class='scorePanel'>
+
+ <h2 data-i18n>Related</h2>
+
+ <div class='left'>
+ <div>
+ <h3 data-i18n>Test results</h3>
+ <table class='scoreTable latestTable'>
+ <thead>
+ <tr>
+ <th class='nickname' data-i18n>Browser</th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach($fingerprint['results'] as $item): ?>
+ <tr>
+ <th class='nickname'><a href='//html5te.st/<?php echo $item->id; ?>'><?php echo $item->name; ?></a></th>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+ <div class='right'>
+ <div>
+
+ <?php if ($fingerprint['browserVersion']['status'] != 'none'): ?>
+ <h3 data-i18n>Browsers</h3>
+
+ <div class='column'>
+ <table class='scoreTable'>
+ <thead>
+ <tr>
+ <th class='' data-i18n>Version</th>
+ <th class='count' data-i18n>Count</th>
+ <th class='percentage' data-i18n>Percentage</th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach($fingerprint['browserVersion']['items'] as $item): ?>
+
+ <tr>
+ <td class=''><?php echo $item['name'] == '' ? 'Default' : $item['name']; ?></td>
+ <th class='count'><?php echo $item['value']; ?></th>
+ <th class='percentage'><?php echo $item['percentage']; ?>%</th>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ </div>
+ <?php endif; ?>
+
+
+ <?php if ($fingerprint['osVersion']['status'] != 'none'): ?>
+ <h3 data-i18n>Operating Systems</h3>
+
+ <div class='column'>
+ <table class='scoreTable'>
+ <thead>
+ <tr>
+ <th class='' data-i18n>Version</th>
+ <th class='count' data-i18n>Count</th>
+ <th class='percentage' data-i18n>Percentage</th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach($fingerprint['osVersion']['items'] as $item): ?>
+
+ <tr>
+ <td class=''><?php echo $item['name']; ?></td>
+ <th class='count'><?php echo $item['value']; ?></th>
+ <th class='percentage'><?php echo $item['percentage']; ?>%</th>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ </div>
+ <?php endif; ?>
+
+
+ <?php if ($fingerprint['deviceModel']['status'] != 'none'): ?>
+ <h3 data-i18n>Devices</h3>
+
+ <div class='column'>
+ <table class='scoreTable'>
+ <thead>
+ <tr>
+ <th class='' data-i18n>Model</th>
+ <th class='count' data-i18n>Count</th>
+ <th class='percentage' data-i18n>Percentage</th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php foreach($fingerprint['deviceModel']['items'] as $item): ?>
+
+ <tr>
+ <td class=''><?php echo $item['name']; ?></td>
+ <th class='count'><?php echo $item['value']; ?></th>
+ <th class='percentage'><?php echo $item['percentage']; ?>%</th>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+ </div>
+ <?php endif; ?>
+ </div>
+ </div>
+
+ <hr>
+
+ <p>
+ Please note that all data shown above are unconfirmed test results. They could be fake or
+ belong to a different browser than the one listed.
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div class='footer'>
+ <div>
+ <div class='copyright'>
+ <p>
+ Created by Niels Leenheer.
+ Please note that the HTML5 test is not affiliated with the W3C or the HTML5 working group.
+ HTML5 Logo by <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a>
+ </p>
+
+ <div id='cloudvps'>
+ <a href="http://www.cloudvps.nl" target="_blank" ><b>CloudVPS</b><br> High Availability<br> Cloud Servers</a>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <script src='//www.google-analytics.com/ga.js'></script>
+ <script>
+ <!--
+ try {
+ var pageTracker = _gat._getTracker("UA-68192-4");
+ pageTracker._trackPageview();
+ } catch(err) {}
+ //-->
+ </script>
+ </body>
+</html>
View
3  backend/templates/latest.html
@@ -44,8 +44,7 @@ <h1 data-i18n><span>HTML<strong>5</strong>test</span> <em>how well does your bro
<li><a data-i18n href='/results/desktop.html'>Desktop<span> browsers</span></a></li>
<li><a data-i18n href='/results/tablet.html'>Tablets</a></li>
<li><a data-i18n href='/results/mobile.html'>Mobiles</a></li>
- <li><a data-i18n href='/results/gaming.html'>Gaming</a></li>
- <li><a data-i18n href='/results/television.html'>Television</a></li>
+ <li><a data-i18n href='/results/other.html'>Other</a></li>
<li class='more'><a data-i18n href='/results/search.html'>Search</a></li>
<li class='more selected'><a data-i18n href='/results/latest.html'>Latest</a></li>
</ul>
View
4 backend/templates/saved.html
@@ -108,8 +108,8 @@ <h1 data-i18n><span>HTML<strong>5</strong>test</span> <em>how well does your bro
var button = document.createElement('a');
button.className = 'button latest';
- button.href = '/results/latest.html';
- button.innerHTML = '<span>Latest results...</span>';
+ button.href = '/results/related/' + r.fingerprint + '.html';
+ button.innerHTML = '<span>Related results...</span>';
buttons.appendChild(button);
var button = document.createElement('a');
View
3  backend/templates/search.html
@@ -44,8 +44,7 @@ <h1 data-i18n><span>HTML<strong>5</strong>test</span> <em>how well does your bro
<li><a data-i18n href='/results/desktop.html'>Desktop<span> browsers</span></a></li>
<li><a data-i18n href='/results/tablet.html'>Tablets</a></li>
<li><a data-i18n href='/results/mobile.html'>Mobiles</a></li>
- <li><a data-i18n href='/results/gaming.html'>Gaming</a></li>
- <li><a data-i18n href='/results/television.html'>Television</a></li>
+ <li><a data-i18n href='/results/other.html'>Other</a></li>
<li class='more selected'><a data-i18n href='/results/search.html'>Search</a></li>
<li class='more'><a data-i18n href='/results/latest.html'>Latest</a></li>
</ul>
View
5 css/main.css
@@ -1159,7 +1159,10 @@ body.indexVisible > div#index button#indexbutton {
line-height: 145px;
margin: 0 10px;
}
-
+.pointsPanel hr {
+ border: none;
+ border-top: 8px solid #d9d9d9;
+}
.blocked {
background: #ec6534;
padding: 20px;
View
17 css/reporting.css
@@ -13,8 +13,7 @@
float: left;
}
-.scorePanel .left h3,
-.scorePanel .right h3 {
+.scorePanel h3 {
font-size: 1.6em;
text-transform: lowercase;
color: #888;
@@ -120,6 +119,11 @@
font-family: "Helvetica Neue", "Helvetica", "Arial", "Lucida Grande", sans-serif;
font-weight: bold;
}
+.scoreTable .count,
+.scoreTable .percentage {
+ width: 20%;
+ text-align: right;
+}
@media (max-width: 680px) {
.scoreTable .description {
@@ -127,6 +131,15 @@
}
}
+.latestTable {
+ table-layout: fixed;
+}
+.latestTable th {
+}
+.latestTable a {
+ overflow-x: hidden;
+ text-overflow: ellipsis;
+}
.latestTable .nickname {
width: 60%;
}
Please sign in to comment.
Something went wrong with that request. Please try again.