Changeset 1795
- Timestamp:
- 09/06/10 20:33:09 (17 months ago)
- Location:
- trunk/site
- Files:
-
- 2 modified
-
gettrack.php (modified) (3 diffs)
-
ws/boatinfo/tracks.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/site/gettrack.php
r1660 r1795 4 4 header("content-type: text/plain; charset=UTF-8"); 5 5 6 $idu =htmlentities(quote_smart($_REQUEST['idu']));7 $idr =htmlentities(quote_smart($_REQUEST['idr']));8 $all =array_key_exists('all', $_REQUEST);6 $idu = get_cgi_var('idu', 0); 7 $idr = get_cgi_var('idr', 0); 8 $all = array_key_exists('all', $_REQUEST); 9 9 10 10 if ( round($idr) == 0 || round($idu) == 0 … … 31 31 */ 32 32 33 $query_race = "SELECT deptime FROM races WHERE idraces = ".round($idr); 34 $result = wrapper_mysql_db_query_reader($query_race) or die("Query [$query_race] failed \n"); 35 if ($row = mysql_fetch_assoc($result)) { 36 $deptime = $row['deptime']; 37 } else { 38 die("No such race : $idr\n"); 33 $now = time(); 34 35 $users = getUserObject($idu); 36 if (is_null($users)) die("No such user/boat : $idu"); 37 38 if (!raceExists($idr)) die("No such race : $idr\n"); //FIXME : select on races table made two times ! 39 $races = new races($idr); 40 41 $starttime = intval(get_cgi_var('starttime', 0)); //0 means now -1h 42 $endtime = intval(get_cgi_var('endtime', 0)); //0 means now 43 44 if ($users->hidden) die("User/Boat $idu is hidden"); 45 46 if ($races->bobegin < $now && $races->boend > $now) { 47 //BlackOut in place 48 $endtime = $races->bobegin; 39 49 } 40 50 41 $query = "SELECT histpos.time,histpos.lat,histpos.long FROM histpos" .42 " WHERE histpos.idusers=" . round($idu) .43 " AND histpos.race=" . round($idr) .44 " AND histpos.time >= ".$deptime.45 " ORDER BY time ASC";46 47 $result = wrapper_mysql_db_query_reader($query) or die("Query [$query] failed \n");48 $nbresults = mysql_num_rows($result);49 50 51 if ($all) { 51 $querynow = "SELECT positions.time,positions.lat,positions.long FROM positions" . 52 " WHERE positions.idusers=" . round($idu) . 53 " AND positions.race=" . round($idr) . 54 " AND positions.time >= $deptime". 55 " ORDER BY time ASC"; 56 $resultnow = wrapper_mysql_db_query_reader($querynow) or die("Query [$querynow] failed \n"); 57 $nbresults += mysql_num_rows($resultnow); 52 $pi = new positionsIterator($users->idusers, $races->idraces, $starttime, $endtime); 53 } else { 54 $pi = new fullPositionsIterator($users->idusers, $races->idraces, $starttime, $endtime); 58 55 } 59 56 … … 64 61 printf ("============================\n"); 65 62 66 while( $row = mysql_fetch_array($result, MYSQL_ASSOC)) {67 printf ("%d;%5.6f;%5.6f\n", $row[ 'time'],$row['lat']/1000,$row['long']/1000) ;63 foreach ($pi->records as $row) { 64 printf ("%d;%5.6f;%5.6f\n", $row[0],$row[1]/1000,$row[2]/1000) ; 68 65 } 69 66 70 if ($all) {71 while( $row = mysql_fetch_array($resultnow, MYSQL_ASSOC) ) {72 printf ("%d;%5.6f;%5.6f\n", $row['time'],$row['lat']/1000,$row['long']/1000) ;73 }74 }75 67 76 68 ?> -
trunk/site/ws/boatinfo/tracks.php
r1680 r1795 41 41 //BlackOut in place 42 42 $endtime = $races->bobegin; 43 } else {44 $endtime = intval(get_cgi_var('endtime', 0)); //0 means now45 43 } 46 47 $starttime = intval(get_cgi_var('starttime', 0)); //0 means now -1h48 44 49 45 $pi = new positionsIterator($users->idusers, $races->idraces, $starttime, $endtime);
