Example #1
0
function postDrawing()
{
    /* require the message the parameter */
    if (isset($_GET['image']) && isset($_GET['location_id'])) {
        $image = $_GET['image'];
        $location_id = isset($_GET['location_id']) ? $_GET['location_id'] : 1;
        //default is 1
        $dbc = connectToDB();
        /* insert the message into the message table query*/
        $query = "INSERT INTO drawing (image, location_id) VALUES (\"{$image}\", {$location_id})";
        $result = performQuery($dbc, $query);
        //inserted in the database
        echo "postMessage works yay";
        return header('status: 200');
    } else {
        echo "malfunction";
        errorJson('Upload malfunction');
    }
}
Example #2
0
function stream($IdPhoto = 0)
{
    if ($IdPhoto == 0) {
        // load the last 50 photos from the "photos" table, also join the "login" so that you can fetch the
        // usernames of the photos' authors
        $result = query("SELECT IdPhoto, title, l.IdUser, username FROM photos p JOIN login l ON (l.IdUser = p.IdUser) ORDER BY IdPhoto DESC LIMIT 50");
    } else {
        //do the same as above, but just for the photo with the given id
        $result = query("SELECT IdPhoto, title, l.IdUser, username FROM photos p JOIN login l ON (l.IdUser = p.IdUser) WHERE p.IdPhoto='%d' LIMIT 1", $IdPhoto);
    }
    if (!$result['error']) {
        // if no error occured, print out the JSON data of the
        // fetched photo data
        print json_encode($result);
    } else {
        //there was an error, print out to the iPhone app
        errorJson(-1, 'Photo stream is broken');
    }
}