Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / dromaeo / store.php
blob4ebb5c3f8a3a27ec083d9c9841e430d68f0f2f07
1 <?php
2 /*
3 Dromaeo Test Suite
4 Copyright (c) 2010 John Resig
6 Permission is hereby granted, free of charge, to any person
7 obtaining a copy of this software and associated documentation
8 files (the "Software"), to deal in the Software without
9 restriction, including without limitation the rights to use,
10 copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the
12 Software is furnished to do so, subject to the following
13 conditions:
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 OTHER DEALINGS IN THE SOFTWARE.
28 $server = 'mysql.dromaeo.com';
29 $user = 'dromaeo';
30 $pass = 'dromaeo';
32 require('JSON.php');
34 $json = new Services_JSON();
35 $sql = mysql_connect( $server, $user, $pass );
37 mysql_select_db( 'dromaeo' );
39 $id = str_replace(';', "", $_REQUEST['id']);
41 if ( $id ) {
42 $sets = array();
43 $ids = split(",", $id);
45 foreach ($ids as $i) {
46 $query = mysql_query( "SELECT * FROM runs WHERE id=$i;" );
47 $data = mysql_fetch_assoc($query);
49 $query = mysql_query( "SELECT * FROM results WHERE run_id=$i;" );
50 $results = array();
52 while ( $row = mysql_fetch_assoc($query) ) {
53 array_push($results, $row);
56 $data['results'] = $results;
57 $data['ip'] = '';
59 array_push($sets, $data);
62 echo $json->encode($sets);
63 } else {
64 $data = $json->decode(str_replace('\\"', '"', $_REQUEST['data']));
66 if ( $data ) {
67 mysql_query( sprintf("INSERT into runs VALUES(NULL,'%s','%s',NOW(),'%s');",
68 $_SERVER['HTTP_USER_AGENT'], $_SERVER['REMOTE_ADDR'], str_replace(';', "", $_REQUEST['style'])) );
70 $id = mysql_insert_id();
72 if ( $id ) {
74 foreach ($data as $row) {
75 mysql_query( sprintf("INSERT into results VALUES(NULL,'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s');",
76 $id, $row->collection, $row->version, $row->name, $row->scale, $row->median, $row->min, $row->max, $row->mean, $row->deviation, $row->runs) );
79 echo $id;