4 benchReceive.php - example way to handle incoming benchmark data,
5 or how to use JSON php class to mangle data. No benchmark data
9 -- Table structure for table `benchmarks`
12 CREATE TABLE `benchmarks` (
13 `id` int(11) NOT NULL auto_increment,
14 `useragent` varchar(242) NOT NULL default '',
15 `dojover` varchar(96) NOT NULL default '',
16 `testNum` int(11) NOT NULL default '0',
17 `dijit` varchar(64) NOT NULL default '',
18 `testCount` int(11) NOT NULL default '0',
19 `testAverage` float NOT NULL default '0',
20 `testMethod` varchar(10) NOT NULL default '',
21 `testTime` bigint(20) NOT NULL default '0',
22 `dataSet` varchar(64) NOT NULL default '',
24 KEY `dijit` (`dijit`,`testAverage`),
25 KEY `dataSet` (`dataSet`)
29 -- [end table struct] --
33 if (is_array($_POST)) {
40 mysql_connect("localhost",$username,$password);
41 mysql_select_db($dataBase);
43 require("../../dojo/tests/resources/JSON.php");
44 $json = new Services_JSON();
46 // see "escape()" call in benchTest.html
47 $string = $json->decode(urldecode($_POST['key']));
48 // $string = $json->decode($_POST['key']);
50 print "<h1>Thank YOU!</h1>";
52 <p>Your results have been added to our database. No
53 personal information outside of what you see here
57 <p>You can <a href= \"javascript:history.back()\">go back</a>
58 and run more tests, or even better, load up another browser
59 and the submit your tests again!
62 <p>again ... thanks for your time.</p>
66 print "<h3>Results Submitted:</h3>";
67 print "<pre style=\"font:6pt Terminal,sans-serif; border:1px solid #cecece; background-color:#ededed; padding:20px; \">";
69 $ua = $string->clientNavigator;
70 $dojov = $string->dojoVersion;
72 print "Client: ".$ua."\n";
73 print "Dojo v".$dojov."\n";
75 if (is_array($string->dataSet)) {
76 print "\nTest Results:";
77 // should client serialize a key, or is this safer?
78 $dataSet = md5(serialize($string));
79 foreach ($string->dataSet as $test) {
81 'dataSet' => $dataSet,
84 'testNum' => $test->testNum,
85 'testMethod' => $test->testMethod,
86 'testTime' => $test->testTime,
87 'testAverage' => $test->testAverage,
88 'testCount' => $test->testCount,
89 'dijit' => $test->dijit
92 add_rec($table,$data);
96 if (is_array($string->errors)) {
97 // not saving errors at this point
99 foreach ($string->errors as $error) {
106 function add_rec($table, $data) {
108 if (!is_array($data)) { return FALSE; }
110 $keys = array_keys($data);
111 $values = array_values($data);
114 for ($field;$field<sizeof($data);$field++) {
115 if (!ereg("^[0-9].*$",$keys[$field])) {
116 $sqlfields = $sqlfields.$keys[$field]."=\"".$values[$field]."\", ";
119 $sqlfields = (substr($sqlfields,0,(strlen($sqlfields)-2)));
121 if ($query = mysql_query("insert into $table set $sqlfields")) {
122 $id = mysql_insert_id();