Commit ab69eef9 authored by S.Holzhauer's avatar S.Holzhauer

magic foodoo brocoli

parent 94f72899
......@@ -7,7 +7,13 @@
require_once 'dbconnection.php';
global $conn;
$ID = $_REQUEST['ID'];
if ($argc == 2) {
// Called from command line
$ID = $argv[1];
}
else {
$ID = isset($_REQUEST['ID']) ? $_REQUEST['ID'] : null;
}
date_default_timezone_set("Europe/Amsterdam");
$time = date("H:i:sa");
$date = date("Y-m-d");
......@@ -19,6 +25,7 @@ if ($ID != NULL && $ID != "IRPS001"){
FROM Camera
WHERE CameraID = '$ID';";
$result = $conn->query($sql);
//TO-DO if not found uitwerken
$row = $result->fetch_assoc();
$OuderId = $row['AlleenstaandeOuder_OuderID'];
......@@ -33,7 +40,7 @@ if ($ID != NULL && $ID != "IRPS001"){
}
//if the ID is from the server.
if ($ID == "IRPS001"){
else if ($ID == "IRPS001"){
// select all unhandled (handled = 0) entries in the `activiteiten` table which have passed (EndTime < current $time).
$sql = "SELECT *
FROM `Activiteiten`
......@@ -68,12 +75,12 @@ if ($ID == "IRPS001"){
//select the details from accounts connected to and details from the elder.
$sql = "SELECT A.Voorletters,A.Achternaam,A.Emailadres,C.Voorletters,C.Achternaam
FROM Account A
FROM AlleenstaandeOuder C
INNER JOIN Account_has_AlleenstaandeOuder B
ON B.Account_AccountID = A.AccountID
INNER JOIN AlleenstaandeOuder C
ON C.OuderID = B.AlleenstaandeOuder_OuderID
WHERE B.AlleenstaandeOuder_OuderID = '$OuderID';";
ON B.AlleenstaandeOuder_OuderID = C.OuderID
INNER JOIN Account A
ON A.AccountID = B.Account_AccountID
WHERE C.OuderID = '$OuderID';";
$result = $conn->query($sql);
//loop trough every account so they all get an email
while ($result && ($row = $result->fetch_assoc())){
......@@ -90,33 +97,35 @@ if ($ID == "IRPS001"){
mail($Email,"Camera Alert","Beste $AcName $Msg",$headers);
}
}
if (($Movement == 0) && ($Detected == 0)){
else if (($Movement == 0) && ($Detected == 0)){
$sql = "UPDATE `Activiteiten`
SET Status = 1,Handled = 1
SET Status = 1
, Handled = 1
WHERE ActivityID = '$ActivityID'";
$conn->query($sql);
}
if (($Movement == 1) && ($Detected == 1)){
else if (($Movement == 1) && ($Detected == 1)){
$sql = "UPDATE `Activiteiten`
SET Status = 1,Handled = 1
WHERE ActivityID = '$ActivityID'";
SET Status = 1
, Handled = 1
WHERE ActivityID = '$ActivityID'";
$conn->query($sql);
}
if (($Movement == 1) && ($Detected == 0)){
//set handled to 1
else if (($Movement == 1) && ($Detected == 0)){
//set handled to 1, status stays 0
$sql = "UPDATE `Activiteiten`
SET Handled = 1
WHERE ActivityID = '$ActivityID'";
SET Handled = 1
WHERE ActivityID = '$ActivityID'";
$conn->query($sql);
//select the details from accounts connected to and details from the elder.
$sql = "SELECT A.Voorletters,A.Achternaam,A.Emailadres,C.Voorletters,C.Achternaam
FROM Account A
INNER JOIN Account_has_AlleenstaandeOuder B
ON B.Account_AccountID = A.AccountID
INNER JOIN AlleenstaandeOuder C
ON C.OuderID = B.AlleenstaandeOuder_OuderID
WHERE B.AlleenstaandeOuder_OuderID = '$OuderID';";
FROM AlleenstaandeOuder C
INNER JOIN Account_has_AlleenstaandeOuder B
ON B.AlleenstaandeOuder_OuderID = C.OuderID
INNER JOIN Account A
ON A.AccountID = B.Account_AccountID
WHERE C.OuderID = '$OuderID';";
$result = $conn->query($sql);
//loop trough every account so they all get an email
while ($result && ($row = $result->fetch_assoc())){
......@@ -135,10 +144,9 @@ if ($ID == "IRPS001"){
}
}
//if id is empty
if ($ID == NULL){
else if ($ID == NULL){
//print to error log.
error_log("No ID was given.");
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment