diff options
author | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
---|---|---|
committer | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
commit | e44a7e37b6c7b5961adaffc62b9042b8d442938e (patch) | |
tree | 95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dijit/bench/benchReceive.php | |
parent | a62b9742ee5e28bcec6872d88f50f25b820914f6 (diff) | |
download | semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2 |
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dijit/bench/benchReceive.php')
-rw-r--r-- | includes/js/dijit/bench/benchReceive.php | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/includes/js/dijit/bench/benchReceive.php b/includes/js/dijit/bench/benchReceive.php new file mode 100644 index 0000000..6330077 --- /dev/null +++ b/includes/js/dijit/bench/benchReceive.php @@ -0,0 +1,129 @@ +<?php +/* + + benchReceive.php - example way to handle incoming benchmark data, + or how to use JSON php class to mangle data. No benchmark data + is stored currently. + +-- +-- Table structure for table `benchmarks` +-- + +CREATE TABLE `benchmarks` ( + `id` int(11) NOT NULL auto_increment, + `useragent` varchar(242) NOT NULL default '', + `dojover` varchar(96) NOT NULL default '', + `testNum` int(11) NOT NULL default '0', + `dijit` varchar(64) NOT NULL default '', + `testCount` int(11) NOT NULL default '0', + `testAverage` float NOT NULL default '0', + `testMethod` varchar(10) NOT NULL default '', + `testTime` bigint(20) NOT NULL default '0', + `dataSet` varchar(64) NOT NULL default '', + PRIMARY KEY (`id`), + KEY `dijit` (`dijit`,`testAverage`), + KEY `dataSet` (`dataSet`) +) TYPE=MyISAM; + +-- +-- [end table struct] -- + +*/ + +if (is_array($_POST)) { + + $username = ''; + $password = ''; + $dataBase = ''; + $table = ''; + + mysql_connect("localhost",$username,$password); + mysql_select_db($dataBase); + + require("../../dojo/tests/resources/JSON.php"); + $json = new Services_JSON(); + + // see "escape()" call in benchTest.html + $string = $json->decode(urldecode($_POST['key'])); + // $string = $json->decode($_POST['key']); + + print "<h1>Thank YOU!</h1>"; + print " + <p>Your results have been added to our database. No + personal information outside of what you see here + has been stored. + </p> + + <p>You can <a href= \"javascript:history.back()\">go back</a> + and run more tests, or even better, load up another browser + and the submit your tests again! + </p> + + <p>again ... thanks for your time.</p> + + "; + + print "<h3>Results Submitted:</h3>"; + print "<pre style=\"font:6pt Terminal,sans-serif; border:1px solid #cecece; background-color:#ededed; padding:20px; \">"; + + $ua = $string->clientNavigator; + $dojov = $string->dojoVersion; + + print "Client: ".$ua."\n"; + print "Dojo v".$dojov."\n"; + + if (is_array($string->dataSet)) { + print "\nTest Results:"; + // should client serialize a key, or is this safer? + $dataSet = md5(serialize($string)); + foreach ($string->dataSet as $test) { + $data = array( + 'dataSet' => $dataSet, + 'useragent' => $ua, + 'dojover' => $dojov, + 'testNum' => $test->testNum, + 'testMethod' => $test->testMethod, + 'testTime' => $test->testTime, + 'testAverage' => $test->testAverage, + 'testCount' => $test->testCount, + 'dijit' => $test->dijit + ); + print_r($data); + add_rec($table,$data); + } + } + + if (is_array($string->errors)) { + // not saving errors at this point + print "\nErrors:"; + foreach ($string->errors as $error) { + print_r($error); + } + } + print "</pre>"; +} + +function add_rec($table, $data) { + + if (!is_array($data)) { return FALSE; } + + $keys = array_keys($data); + $values = array_values($data); + $field=0; + + for ($field;$field<sizeof($data);$field++) { + if (!ereg("^[0-9].*$",$keys[$field])) { + $sqlfields = $sqlfields.$keys[$field]."=\"".$values[$field]."\", "; + } + } + $sqlfields = (substr($sqlfields,0,(strlen($sqlfields)-2))); + + if ($query = mysql_query("insert into $table set $sqlfields")) { + $id = mysql_insert_id(); + return ($id); + }else{ + return FALSE; + } +} + +?> |