<?php

require_once "includes.php";
/**
* Code to update ushahidi instance from crowdflower.
*
*/
SessionHandler::connect();
$date = date("Y-m-d H:i:s");
$short = "signal: " . $_POST['signal'] . " \npayload: " . $_POST['payload'];
if ($_POST['signal'] != "unit_complete") {
    $sql = "INSERT INTO debug (content, date) values ('(NON-COMPLETE): " . mysql_real_escape_string($short) . "', '{$date}');";
    mysql_query($sql);
    die;
    #We only want unit completion notifications
} else {
    $sql = "INSERT INTO debug (content, date) values ('" . mysql_real_escape_string($short) . "', '{$date}');";
    mysql_query($sql);
}
$requesta = json_decode(urldecode($_POST['payload']), true);
$id = $requesta['data']['ushahidi_id'];
$randIdent = $requesta['data']['randIdent'];
$message = $requesta['data']['sms_text'];
if ($id == '') {
    $sql = "INSERT INTO debug (content, date) values ('BAD ID: " . mysql_real_escape_string($short) . "', '{$date}');";
    mysql_query($sql);
    print "no id\n";
    die;
}
$sql = "SELECT location_name FROM location JOIN incident ON incident.location_id = location.id WHERE incident.id = {$id};";
$current_loc_name = DBQuery::return_value_from_sql($sql);
 public static function connect()
 {
     SessionHandler::connect();
 }