| 1 |
<?php |
| 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 |
if(is_array($_POST)){ |
| 34 |
|
| 35 |
$username = ''; |
| 36 |
$password = ''; |
| 37 |
$dataBase = ''; |
| 38 |
$table = ''; |
| 39 |
|
| 40 |
mysql_connect("localhost",$username,$password); |
| 41 |
mysql_select_db($dataBase); |
| 42 |
|
| 43 |
require("../../dojo/tests/resources/JSON.php"); |
| 44 |
$json = new Services_JSON(); |
| 45 |
|
| 46 |
|
| 47 |
$string = $json->decode(urldecode($_POST['key'])); |
| 48 |
|
| 49 |
|
| 50 |
print "<h1>Thank YOU!</h1>"; |
| 51 |
print " |
| 52 |
<p>Your results have been added to our database. No |
| 53 |
personal information outside of what you see here |
| 54 |
has been stored. |
| 55 |
</p> |
| 56 |
|
| 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! |
| 60 |
</p> |
| 61 |
|
| 62 |
<p>again ... thanks for your time.</p> |
| 63 |
|
| 64 |
"; |
| 65 |
|
| 66 |
print "<h3>Results Submitted:</h3>"; |
| 67 |
print "<pre style=\"font:6pt Terminal,sans-serif; border:1px solid #cecece; background-color:#ededed; padding:20px; \">"; |
| 68 |
|
| 69 |
$ua = $string->clientNavigator; |
| 70 |
$dojov = $string->dojoVersion; |
| 71 |
|
| 72 |
print "Client: ".$ua."\n"; |
| 73 |
print "Dojo v".$dojov."\n"; |
| 74 |
|
| 75 |
if(is_array($string->dataSet)){ |
| 76 |
print "\nTest Results:"; |
| 77 |
|
| 78 |
$dataSet = md5(serialize($string)); |
| 79 |
foreach ($string->dataSet as $test){ |
| 80 |
$data = array( |
| 81 |
'dataSet' => $dataSet, |
| 82 |
'useragent' => $ua, |
| 83 |
'dojover' => $dojov, |
| 84 |
'testNum' => $test->testNum, |
| 85 |
'testMethod' => $test->testMethod, |
| 86 |
'testTime' => $test->testTime, |
| 87 |
'testAverage' => $test->testAverage, |
| 88 |
'testCount' => $test->testCount, |
| 89 |
'dijit' => $test->dijit |
| 90 |
); |
| 91 |
print_r($data); |
| 92 |
add_rec($table,$data); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
if(is_array($string->errors)){ |
| 97 |
|
| 98 |
print "\nErrors:"; |
| 99 |
foreach ($string->errors as $error){ |
| 100 |
print_r($error); |
| 101 |
} |
| 102 |
} |
| 103 |
print "</pre>"; |
| 104 |
} |
| 105 |
|
| 106 |
function add_rec($table, $data){ |
| 107 |
|
| 108 |
if(!is_array($data)){ return FALSE; } |
| 109 |
|
| 110 |
$keys = array_keys($data); |
| 111 |
$values = array_values($data); |
| 112 |
$field=0; |
| 113 |
|
| 114 |
for($field;$field<sizeof($data);$field++){ |
| 115 |
if(!ereg("^[0-9].*$",$keys[$field])){ |
| 116 |
$sqlfields = $sqlfields.$keys[$field]."=\"".$values[$field]."\", "; |
| 117 |
} |
| 118 |
} |
| 119 |
$sqlfields = (substr($sqlfields,0,(strlen($sqlfields)-2))); |
| 120 |
|
| 121 |
if($query = mysql_query("insert into $table set $sqlfields")){ |
| 122 |
$id = mysql_insert_id(); |
| 123 |
return ($id); |
| 124 |
}else{ |
| 125 |
return FALSE; |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
?> |