-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathruncomplete.php
60 lines (49 loc) · 2.04 KB
/
runcomplete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
date_default_timezone_set('America/Chicago');
$wpt_host = 'http://localhost';
$db = mysql_connect('example.com:5029', 'user', 'password');
mysql_select_db("wpt", $db);
$test_id = $_GET['id'];
$wpt = new SimpleXMLElement(file_get_contents($wpt_host . "/xmlResult/" . $test_id . "/"));
list($name, $mode) = explode(' | ', $wpt->data->label);
function convertToDateTime($timestamp) {
$dt = new DateTime();
$dt->setTimestamp($timestamp);
return $dt->format('Y-m-d H:i:s');
}
function sqlStrWrap($val) {
return "'" . mysql_real_escape_string($val) . "'";
}
function sqlNumWrap($val) {
return ($val ? $val : 0);
}
$firstView = $wpt->data->median->firstView;
$repeatView = $wpt->data->median->repeatView;
$data = array(
sqlStrWrap($wpt->data->testId),
sqlStrWrap($wpt->data->location),
sqlStrWrap($name),
sqlStrWrap($mode),
sqlStrWrap($firstView->browser_name),
sqlStrWrap(convertToDateTime(intval($firstView->date))),
sqlStrWrap($wpt->data->testUrl),
sqlNumWrap($firstView->docTime),
sqlNumWrap($firstView->requestsDoc),
sqlNumWrap($firstView->bytesInDoc),
sqlNumWrap($firstView->fullyLoaded),
sqlNumWrap($firstView->requests),
sqlNumWrap($firstView->bytesIn),
sqlNumWrap($repeatView->docTime),
sqlNumWrap($repeatView->requestsDoc),
sqlNumWrap($repeatView->bytesInDoc),
sqlNumWrap($repeatView->fullyLoaded),
sqlNumWrap($repeatView->requests),
sqlNumWrap($repeatView->bytesIn)
);
$sql = 'insert into TestResults (TestID,Location,Label,Mode,Browser,Date,URL,DocTime,DocRequests,DocBytes,FullyLoaded,FullRequests,FullBytes,CachedDocTime,CachedDocRequests,CachedDocBytes,CachedFullyLoaded,CachedFullRequests,CachedFullBytes) values (' . implode(',', $data) . ');';
print $sql;
if (sqlNumWrap($firstView->fullyLoaded) > 0) {
mysql_query($sql);
}
mysql_close($db);
?>