caniOn-Web-Server uses php- and mysql-server-extensions to process the http-requests from android app caniOn.
caniOn database schema:
There are two columns in caniOn database schema.
caniOn-Web-Server uses following php-scripts to push/pull carstate data provided from/to android app caniOn.
push.php
<?php $servername = "my.server.net"; $username = "my username"; $password = "my password"; $dbname = "canion"; mysql_connect($servername, $username, $password) or die ("no connection to " . $servername . " possible"); mysql_select_db($dbname) or die ("database " . $dbname . " does not exist."); $select = "SELECT IDENTITY,CARSTATE FROM carstate WHERE IDENTITY='" . $_POST["Identity"] . "';"; $result = mysql_query($select); $numrows = mysql_num_rows($result); if ($numrows == 0) { $insert = "INSERT INTO carstate () VALUES ('" . $_POST["Identity"] . "','" . $_POST["CarState"] . "');"; $push = mysql_query($insert); } else { $update = "UPDATE carstate SET CARSTATE='" . $_POST["CarState"] . "' WHERE IDENTITY='" . $_POST["Identity"] . "';"; $push = mysql_query($update); } $timestamp = date('H:i:s', time() - date('Z') + ($_POST["TimeZoneOffset"] * 3600)); echo "\r\n" . $timestamp . " - db push "; if($push == true) { echo "ok"; } else { echo "failed"; } ?>
pull.php
<?php $servername = "my.server.net"; $username = "my username"; $password = "my password"; $dbname = "canion"; mysql_connect($servername, $username, $password) or die ("no connection to " . $servername . " possible"); mysql_select_db($dbname) or die ("database " . $dbname . " does not exist."); $select = "SELECT IDENTITY,CARSTATE FROM carstate WHERE IDENTITY='" . $_POST["Identity"] . "';"; $result = mysql_query($select); $numrows = mysql_num_rows($result); $timestamp = date('H:i:s', time() - date('Z') + ($_POST["TimeZoneOffset"] * 3600)); if ($numrows == 0) { echo $timestamp . " - no data available\r\n"; } else { $row = mysql_fetch_assoc($result); echo $timestamp . " - db pull ok\r\n"; echo "\t\t\t\t\t\r\n"; echo "Identity=" . $row["IDENTITY"] . "\r\nCarState=" . $row["CARSTATE"] . "\r\n"; } ?>
You can use caniOn-Web-Server as shared service. Please activate encryption in android app caniOn therefore, so your carstate data are confidential to your eyes only.
You can use these scripts and build your own Web-Server with this features. So your data are always under your control. You can also use these scripts as idea and handle the carstate data in a different manner.
Martin & Xavier