TODO:

Server:
- Fix default map center for live map
- implement TrackMe export to KML/GPX. How? Create blog post?
- implement tripname normalization; find a way around Trackme using the name as the PK
- reverse geocoding for trip names
- maybe use export button to trigger tripame normalization
- add columns to trip (& location?) tables to store remote IP
- logging requests to MySQL
- DONE: use geoJSON instead of Polyline, if callbacks are feasable for extracting metadata
  or use a second HTTP request for the metadata
- implement GPSgate protocol
- DONE: implement OSMand protocol
- DONE: don't use the WP password for TrackMe tracking, it is insecure. Use a secret like with OsmAnd.
- implement shortcode to display TrackMe/OsmAnd password (feature request through WP forum)
- implement live tracking multiple users (feature request)
- multi-site support - http://rabinshrestha.com/make-wordpress-plugin-compatible-with-multisite/
- implement generic HTTP GET interface and/or CelltracGTS/Free support

Frontend:
- DONE: Leaflet shortcode / map view.
- DONE: Icons for start/finish
- DONE: Media manager integration
- DONE: autoupdate (live tracking) toggle button
- DONE: ability to show multiple tracks per map

Admin backend:
- DONE: Manage trips (name, comment, delete)
- DONE: Internationalization
- DONE: Add HOWTO screens for all clients
- DONE: Add columns for nr. of points and distance to table with tracks
- file tracks in folders/collections
- DONE: make secrets for TrackMe / OsmAnd a per-user setting

Javascript:
- DONE: move the thickbox manipulation to its own file
- DONE: properly destroy map objects in the admin viewer when closing the thickbox



REWRITE RULES

$url = site_url(null, 'http');
$base_uri = preg_replace('/^http:\/\/[^\/]+/', '', $url);
$tag = $this -> options ['trackme_slug'];
$extension = $this -> options ['trackme_extension'];
$ajax_uri = admin_url('admin-ajax.php?action=trackserver_trackme');
$ajax_uri = preg_replace('/^https?:\/\/[^\/]+/', '', $ajax_uri);

$apache = <<<EOF
# BEGIN Trackserver
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase $base_uri/
RewriteRule ^$tag/requests\.$extension /wp/wp-admin/admin-ajax.php?action=trackserver_trackme [L]
</IfModule>
# END Trackserver
EOF;

$nginx = <<<EOF
location = $base_uri/$tag/requests.$extension {
        try_files \$uri \$uri/ $ajax_uri;
}
EOF;

$apache = htmlspecialchars($apache);
$nginx  = htmlspecialchars($nginx);

