Author Topic: I have a few questions about some PHP Scripts.  (Read 187 times)

0 Members and 1 Guest are viewing this topic.

Offline 3one5Topic starter

  • Irregular
  • Posts: 1
    • View Profile
I have a few questions about some PHP Scripts.
« on: March 14, 2010, 08:55:25 PM »
I have a PHP book on the way so please understand that I am a bit of a newb but willing to set out on my own and learn.

I am running Big Brother GPS on my Motorola Droid.  The application came with a couple sample scipts to get you going.

http://bk.gnarf.org/creativity/bigbrothergps/bbg-website.tar.gz

The application on the phone is pointed at bbg_recv.php and then you use a web browser to view bbg_map.php to see the location on a google map.  I've done some playing around with the scripts and added a battery life indicator but was not successful getting the charge state.  Here are the scripts as they sit now.

bbg_recv.php
?php

/* Get the position data from the POST parameters */
$lat $_POST["latitude"];
$lon $_POST["longitude"];
$acc $_POST["accuracy"];
$bat $_POST["battlevel"];
$crg $_POST["charging"];

/* Write the position data to a file for the map script */
if ($lat && $lon && $acc && $bat) {
    
$fcur fopen("/tmp/position.cur""w");

    
$time time();
    
$out "$time:$lat:$lon:$acc:$bat\n";

    
fputs($fcur$out);

    
fclose($fcur);

}

?>




bbg_map.php

?php

/* Get the position data from the POST parameters */
$lat $_POST["latitude"];
$lon $_POST["longitude"];
$acc $_POST["accuracy"];
$bat $_POST["battlevel"];
$crg $_POST["charging"];

/* Write the position data to a file for the map script */
if ($lat && $lon && $acc && $bat) {
    
$fcur fopen("/tmp/position.cur""w");

    
$time time();
    
$out "$time:$lat:$lon:$acc:$bat\n";

    
fputs($fcur$out);

    
fclose($fcur);

}

?>




Here is what I need some help with.  First I would like the position.cur file to be copied to another location and be renamed with date and time so I have a position log.  I'm currently using a shell script scheduled through crontab to accomplish this.  However I know it can be done with PHP and be cleaner.  Second, the map the is presented with bbg_map.php does not show a marker on the location.  If you zoom the map in it takes you to where the phone is so I know that is correct.  I just don't know how to get the marker to show up.  After playing with this for a while I'm thinking this has nothing to do with PHP what so ever, but any help is appreciated.  Anyone want to give this newb a little help?

Also, if it helps at all, here is the contents of the position.cur file.  It is formatted in Time:Latitude:Longitude:Acccuracy:Battery Life

Code: [Select]
1268608548:49.17820328333333:-101.84451646666666:16.0:30