SET
SQL_MODE =
"NO_AUTO_VALUE_ON_ZERO"
;
time_zone =
"+00:00"
CREATE
TABLE
entries (
IdEntry
int
(9)
NOT
NULL
AUTO_INCREMENT,
`
TimeStamp
timestamp
DEFAULT
CURRENT_TIMESTAMP
,
Latitude
decimal
(12,8)
'0.00000000'
Longitude
Device
varchar
(50)
''
Annotation text
PRIMARY
KEY
(IdEntry),
Idx_Device (Device),
Idx_Entry (IdEntry,`
`)
) ENGINE=InnoDB
CHARSET=utf8 AUTO_INCREMENT=1;
01.
<?php
02.
//-- Connecting to "geolog" database, on "localhost" server: replace <USER> and <PASSWORD> variables with the ones which corresponds to your MySQL installation
03.
$mysqli
=
new
mysqli(
'localhost'
'<USER>'
'<PASSWORD>'
'geolog'
);
04.
if
(
->connect_errno) {
05.
echo
"Failed to connect to MySQL: ("
.
->connect_errno .
") "
->connect_error;
06.
exit
();
07.
}
08.
09.
//-- Preparing parametrized INSERT
10.
(!(
$stmt
->prepare(
"INSERT INTO entries(Latitude, Longitude, Device, Annotation) VALUES (?, ?, ?, ?)"
))) {
11.
"Prepare failed: ("
->errno .
->error;
12.
13.
14.
//-- Acquire GET parameters
15.
$latitude
$_GET
[
'lt'
];
16.
$longitude
'ln'
17.
$device
'd'
18.
$annotation
'n'
19.
20.
//-- Bind GET parameters to prepared statement's variables
21.
(!
->bind_param(
"ddss"
)) {
22.
"Binding parameters failed: ("
23.
24.
25.
//-- Execute INSERT query
26.
->execute()) {
27.
"Execute failed: ("
28.
29.
30.
//-- Closing connection / cleanup
31.
->close();
32.
mysqli_close(
33.
?>
<
Page
x:Class
"FollowMe.Settings"
xmlns
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
"http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local
"using:FollowMe"
xmlns:d
"http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc
"http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable
"d"
Background
"{ThemeResource ApplicationPageBackgroundThemeBrush}"
Loaded
"Page_Loaded"
>
Page.BottomAppBar
CommandBar
AppBarButton
Icon
"Accept"
Label
"Save"
Click
"AppBarButton_Click"
/>
"Cancel"
"CancelButton_Click"
</
Grid
x:Name
"LayoutRoot"
Grid.ChildrenTransitions
TransitionCollection
EntranceThemeTransition
Grid.RowDefinitions
RowDefinition
Height
"Auto"
"*"
<!-- Title Panel -->
StackPanel
Grid.Row
"0"
Margin
"19,0,0,0"
TextBlock
Text
"FollowMe"
Style
"{ThemeResource TitleTextBlockStyle}"
"0,12,0,0"
34.
"Settings"
"0,-6.5,0,26.5"
"{ThemeResource HeaderTextBlockStyle}"
CharacterSpacing
"{ThemeResource PivotHeaderItemCharacterSpacing}"
35.
36.
37.
HorizontalAlignment
"Left"
"19,9.833,0,0"
"1"
TextWrapping
"Wrap"
"Web service URI"
VerticalAlignment
"Top"
FontFamily
"Segoe WP"
FontSize
"18"
38.
TextBox
"txtWebUri"
"19,38.833,0,0"
Width
"362"
PlaceholderText
"http://localhost/"
39.
"19,103.833,0,0"
"Culture for coordinates"
40.
ComboBox
"cmbLang"
"19,122.833,0,0"
"182"
41.
x:String
>it-IT</
42.
>en-US</
43.
44.
45.
using
FollowMe.Common;
System;
Windows.Storage;
Windows.UI.Xaml;
Windows.UI.Xaml.Controls;
Windows.UI.Xaml.Navigation;
namespace
FollowMe
{
public
sealed
partial
class
Settings : Page
private
NavigationHelper navigationHelper;
ObservableDictionary defaultViewModel =
ObservableDictionary();
Settings()
this
.InitializeComponent();
.navigationHelper =
NavigationHelper(
.navigationHelper.LoadState +=
.NavigationHelper_LoadState;
.navigationHelper.SaveState +=
.NavigationHelper_SaveState;
void
NavigationHelper_SaveState(
object
sender, SaveStateEventArgs e)
NavigationHelper_LoadState(
sender, LoadStateEventArgs e)
NavigationHelper NavigationHelper
get
return
.navigationHelper; }
ObservableDictionary DefaultViewModel
.defaultViewModel; }
#region NavigationHelper registration
46.
protected
override
OnNavigatedTo(NavigationEventArgs e)
47.
48.
.navigationHelper.OnNavigatedTo(e);
49.
50.
51.
OnNavigatedFrom(NavigationEventArgs e)
52.
53.
.navigationHelper.OnNavigatedFrom(e);
54.
55.
56.
#endregion
57.
58.
AppBarButton_Click(
sender, RoutedEventArgs e)
59.
60.
var ap = ApplicationData.Current.LocalSettings;
61.
ap.Values[
"WebURI"
] = txtWebUri.Text;
62.
"Language"
] = cmbLang.SelectedValue.ToString();
63.
64.
Frame.Navigate(
typeof
(MainPage));
65.
66.
67.
Page_Loaded(
68.
69.
70.
try
71.
72.
txtWebUri.Text = ap.Values[
].ToString();
73.
cmbLang.SelectedValue = ap.Values[
74.
75.
catch
76.
77.
78.
79.
CancelButton_Click(
80.
81.
82.
83.
84.
"FollowMe.MainPage"
"Manage"
Button
Content
"Check in"
"button1_Click"
"10,381,0,0"
Name
"button1"
"117"
"380"
"10,10,0,0"
"28"
FontWeight
"Bold"
"txtNotes"
"10,69,0,0"
"Type any notes here"
"10,130,0,0"
"Latitude"
"10,152,0,0"
"Longitude"
"lblLatitude"
"104,130,0,0"
"0.00000000"
"lblLongitude"
"104,152,0,0"
Windows.Devices.Geolocation;
Windows.Web.Http;
Windows.UI.Popups;
System.Globalization;
Windows.Security.ExchangeActiveSyncProvisioning;
MainPage : Page
Geolocator geo =
null
MainPage()
async
button1_Click(
geo =
Geolocator();
bool
isErr =
false
string
errMsg =
""
button1.IsEnabled =
Geoposition pos = await geo.GetGeopositionAsync();
double
lat = pos.Coordinate.Point.Position.Latitude;
lon = pos.Coordinate.Point.Position.Longitude;
lblLatitude.Text = lat.ToString();
lblLongitude.Text = lon.ToString();
CultureInfo cI =
CultureInfo(ap.Values[
].ToString());
String devName =
EasClientDeviceInformation().FriendlyName;
HttpClient hwc =
HttpClient();
Uri myAddress =
Uri(ap.Values[
].ToString() +
"?lt="
+
lat.ToString(cI.NumberFormat) +
"&ln="
+ lon.ToString(cI.NumberFormat) +
"&d="
+ devName +
"&n="
+ txtNotes.Text);
HttpResponseMessage x = await hwc.GetAsync(myAddress);
(Exception ex)
true
errMsg = ex.Message;
(isErr)
var dialog =
MessageDialog(errMsg);
await dialog.ShowAsync();
(Settings));
<html>
<head>
<title>GeoLog</title>
<!-- OMITTED: CSS part, you'll find it in the complete source code -->
</head>
<body>
<table>
<tr>
<th>Id</th>
<th>
Date
</th>
<th>Lat.</th>
<th>Long.</th>
<th>Device</th>
<th>Annotations</th>
<th>Map</th>
</tr>
//-- Connecting to "geolog" database, on "localhost" server
//-- Declaring and executing a SELECT on "entries" table, to retrieve all the records in it
$query
"SELECT * FROM entries ORDER BY IdEntry"
$result
->query(
//-- For each retrieved record, we'll add to the DOM a table row, containing the read values
while
$row
->fetch_array()){ ?>
<td><?php
'IdEntry'
];?></td>
'TimeStamp'
'Latitude'
'Longitude'
'Device'
'Annotation'
<td>[<a href=
"map.php?lt=<?php echo $row['Latitude'];?>&ln=<?php echo $row['Longitude'];?>&d=<?php echo $row['Device'];?>&n=<?php echo $row['Annotation'];?>"
>Link</a>]</td>
<?php }
//-- Close connection / cleanup
</body>
<meta name=
"viewport"
content=
"initial-scale=1.0, user-scalable=no"
<meta charset=
"utf-8"
<style>
html, body, #map {
height: 100%;
margin: 0px;
padding: 0px;
width:100%;
</style>
<script src=
"https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&language=it"
></script>
<script>
var
initialize =
function
(){
latlng =
google.maps.LatLng(<?php
","
;?>);
options = { zoom: 18,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map =
google.maps.Map(document.getElementById(
'map'
), options);
marker =
google.maps.Marker({ position: latlng,
map: map,
title:
'<?php echo $device;?>'
});
window.onload = initialize;
</script>
<div id=
"map"
></div>
</html>