Ejemplo n.º 1
0
<?php

/**
 * Sensor data push script
 * Handles all the incoming data from various sensors
 *
 * function examples
 * push.php?sid=0&auth=
 */
if (isset($_GET['sid']) && isset($_GET['auth']) && isset($_GET['val'])) {
    include_once 'config.php';
    include_once 'dbfunctions.php';
    $conn = OrclConnect();
    $sid = $_GET['sid'];
    $auth = $_GET['auth'];
    $val = $_GET['val'];
    $token = GetAuthToken($conn, $sid);
    if ($auth == $token) {
        echo "Auth Succeed: ";
        echo InsertData($conn, $sid, $val);
    } else {
        echo "Auth Failed";
    }
}
/* Do not show result page when the page is first loaded */
$show_result = FALSE;
$mytoken = '';
if ($_GET['token']) {
    $mytoken = $_GET['token'];
}
$mydomain = '';
if ($_GET['domain']) {
    $mydomain = $_GET['domain'];
}
$header = '';
$error = '';
/* Process Get Token request */
if (isset($_POST['GetToken'])) {
    $mydomain = $_POST['admin_domain'];
    $result = GetAuthToken($_POST['admin_email'], $_POST['admin_password'], "", "");
    $header = "Your token:";
    /* If an error is detected, show the error, not the result page */
    if (!stristr($result, "Error") && !stristr($result, "Authentication failed")) {
        $mytoken = $result;
        $show_result = TRUE;
    } else {
        $error = $result;
    }
}
/* Process Create Account Request */
if (isset($_POST['CreateAccount'])) {
    $result = CreateAccountWithEmail($mytoken, $mydomain, $_POST['firstname'], $_POST['lastname'], $_POST['username'], $_POST['password']);
    $show_result = TRUE;
}
/* Process Update Account Request */