TODO:

General:
- add columns to trip (& location?) tables to store remote IP
- logging requests to MySQL
- redo geoJSON support for more track features in the backend
- Track statistics, like distance, average speed, etc.
- implement shortcode to display TrackMe/OsmAnd password (feature request through WP forum)
- implement generic HTTP GET interface and/or CelltracGTS/Free support
- uLogger support
- implement one universal URL endpoint for Trackserver, that handles all the protocols
- implement 'access keys' to replace individual app passwords. They should also work for Basic auth, in addition to WP password.
- support GET/POST parameters for source, comment, track name prefix
- comment field for location entries, to be used for extra data that's available in some apps, like battery level, etc.

Frontend:
- query tracks by string match with wildcards, instead of just by id
- query tracks by collection, when admin backend is implemented
- avatar support for live tracks (like in OwnTracks)
- live tracking tooltip format template
- track decorations, for example with the [PolylineDecorator](https://github.com/bbecquet/Leaflet.PolylineDecorator) plugin
- infobar tags for total elapsed time, average speed, number of points

Admin backend:
- add user profile setting for default map center (replace hardcoded coordinates)
- file tracks in folders/collections
- add waypoints
- add HOWTO screens for OwnTracks, LocusMaps and other supported apps
- add a Users page for Trackserver user profile management by WP admins
- add a button to create a 'Trackserver_Subscriber' role, which is Subscriber + 'use_trackserver'
- bulk action to remove / reapply geofences
- reverse geofence support
- map profiles, [leaflet-providers](https://github.com/leaflet-extras/leaflet-providers) plugin ?
- Move OsmAnd / SendLocation / OwnTracks trackname format from Options to Profile
- For OwnTracks / TrackMe cloud sharing, add a profile settings for share last location duration (TrackMe limit is 1h)
- delete or chown location data when removing users from WordPress

Javascript:
- better live tracking tooltip handling


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);


PASS AUTHORIZATION HEADER IN ENVIRONMENT

RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
