Ejemplo n.º 1
0
<?php

// Author: Jasper Davey
$status = 200;
$sql = sprintf("UPDATE Events SET name = '%s' WHERE id = '%s'", mysql_real_escape_string($result->name), mysql_real_escape_string($result->id));
if (!mysql_query($sql, $connection)) {
    $message = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $sql;
    print $message;
    $status = 404;
    reportBack($status);
}
reportBack($status);
function reportBack($status)
{
    // Return Results
    $status_array = array('status' => $status);
    $status_json = json_encode($status_array);
    die("{$status_json}");
}
    print $message;
    $status = 404;
    reportBack($status, $blank = "NULL", $blank = "NULL", $blank = "NULL", $blank = "NULL");
}
while ($row = mysql_fetch_assoc($userEvents)) {
    $events = explode(",", $row['events']);
}
// Query Events
foreach ($events as $singleEvent) {
    $sql = sprintf("SELECT Events.id, Events.owner, Events.name, Events.bio, Events.startDateTime, Events.endDateTime, Events.location\n                         FROM Events INNER JOIN Tags ON Events.id = Tags.owner\n                         WHERE Events.id = '%s' AND Tags.type = '%s'", mysql_real_escape_string($singleEvent), mysql_real_escape_string(1));
    $allEvents = mysql_query($sql, $connection);
    if (!$allEvents) {
        $message = 'Invalid query: ' . mysql_error() . "\n";
        $message .= 'Whole query: ' . $sql;
        print $message;
        $status = 404;
        reportBack($status, $blank = "NULL", $blank = "NULL", $blank = "NULL", $blank = "NULL");
    }
    while ($row = mysql_fetch_array($allEvents)) {
        array_push($eventsArray, $row['id']);
        break;
    }
}
reportBack($status, $result->id, $tagsArray, $events, $eventsArray);
function reportBack($status, $id, $tags, $events, $userEvents)
{
    // Return Results
    $status_array = array('status' => $status, 'id' => $id, 'tags' => $tags, 'events' => $events, 'userEvents' => $userEvents);
    $status_json = json_encode($status_array);
    die("{$status_json}");
}
Ejemplo n.º 3
0
<?php

// Author: Jasper Davey
// Input: none
$status = 200;
$userIDs = [];
$sql = sprintf("SELECT id FROM Users");
$allUsers = mysql_query($sql, $connection);
if (!$allUsers) {
    $message = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $sql;
    print $message;
    $status = 404;
    reportBack($status, $info = "NULL");
}
while ($row = mysql_fetch_assoc($allUsers)) {
    array_push($userIDs, explode(",", $row['id']));
}
reportBack($status, $userIDs);
function reportBack($status, $info)
{
    // Return Results
    $status_array = array('status' => $status, 'info' => $info);
    $status_json = json_encode($status_array);
    die("{$status_json}");
}
Ejemplo n.º 4
0
if (!$eventInfo) {
    $message = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $sql;
    print $message;
    $status = 404;
    reportBack($status, $info = "NULL");
}
// Query Tags
$sql = sprintf("SELECT * FROM Tags WHERE owner = '%s' AND type = '%s'", mysql_real_escape_string($result->id), mysql_real_escape_string(1));
$tags = mysql_query($sql, $connection);
if (!$tags) {
    $message = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $sql;
    print $message;
    $status = 404;
    reportBack($status, $info = "NULL");
}
while ($row = mysql_fetch_assoc($tags)) {
    array_push($eventTags, array('id' => $row['id'], 'owner' => $row['owner'], 'tag' => $row['tag'], 'nice' => $row['nice'], 'type' => $row['type']));
}
while ($row = mysql_fetch_assoc($eventInfo)) {
    $infoArray = array('id' => $row['id'], 'name' => $row['name'], 'owner' => $row['owner'], 'image' => $row['image'], 'bio' => $row['bio'], 'startDateTime' => $row['startDateTime'], 'endDateTime' => $row['endDateTime'], 'location' => $row['location'], 'attendees' => $row['attendees'], 'tags' => $eventTags);
}
reportBack($status, $infoArray);
function reportBack($status, $info)
{
    // Return Results
    $status_array = array('status' => $status, 'info' => $info);
    $status_json = json_encode($status_array);
    die("{$status_json}");
}
Ejemplo n.º 5
0
<?php

// Author: Jasper Davey
$status = 200;
$allComments = [];
$sql = sprintf("SELECT * FROM Comments WHERE event = '%s'", mysql_real_escape_string($result->event));
$comments = mysql_query($sql, $connection);
if (!$comments) {
    $message = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $sql;
    print $message;
    $status = 404;
    reportBack($status, $info = "NULL");
}
while ($row = mysql_fetch_assoc($comments)) {
    array_push($allComments, array('id' => $row['id'], 'owner' => $row['owner'], 'event' => $row['event'], 'datePosted' => $row['datePosted'], 'comment' => $row['comment']));
}
reportBack($status, $allComments);
function reportBack($status, $info)
{
    // Return Results
    $status_array = array('status' => $status, 'info' => $info);
    $status_json = json_encode($status_array);
    die("{$status_json}");
}
Ejemplo n.º 6
0
<?php

// Author: Jasper Davey
$status = 200;
$events = [];
$today = date("Y-m-d H:i:s");
$sql = sprintf("SELECT * FROM Events WHERE startDateTime < '%s'", mysql_real_escape_string($today));
$allEvents = mysql_query($sql, $connection);
if (!$allEvents) {
    $message = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $sql;
    print $message;
    $status = 404;
    reportBack($status, $info = "NULL");
}
while ($row = mysql_fetch_assoc($allEvents)) {
    array_push($events, explode(",", $row['id']));
}
reportBack($status, $events);
function reportBack($status, $info)
{
    // Return Results
    $status_array = array('status' => $status, 'info' => $info);
    $status_json = json_encode($status_array);
    die("{$status_json}");
}
Ejemplo n.º 7
0
// Debug query in case of error
if (!$query) {
    $message = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $sql;
    print $message;
    $status = 404;
    reportBack($status, $id = "NULL");
}
// Case if given wrong username
if (mysql_num_rows($query) == 0) {
    $status = 404;
    reportBack($status, $id = "NULL");
}
// If username found, check if password given is password on database
$id = 0;
while ($row = mysql_fetch_assoc($query)) {
    if ($row['password'] != $result->password) {
        $status = 304;
    } else {
        $status = 200;
    }
    $id = $row['id'];
}
reportBack($status, $id);
function reportBack($status, $id)
{
    // Return Results
    $status_array = array('status' => $status, 'id' => $id);
    $status_json = json_encode($status_array);
    die("{$status_json}");
}
    $message = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $sql;
    print $message;
    $status = 404;
    reportBack($status, $info = "NULL");
}
while ($row = mysql_fetch_assoc($user)) {
    $userFriends = explode(",", $row['friends']);
}
foreach ($userFriends as $singleFriend) {
    $sql = sprintf("SELECT * FROM Users WHERE id = '%s'", mysql_real_escape_string($singleFriend));
    $friend = mysql_query($sql, $connection);
    if (!$friend) {
        $message = 'Invalid query: ' . mysql_error() . "\n";
        $message .= 'Whole query: ' . $sql;
        print $message;
        $status = 404;
        reportBack($status, $info = "NULL");
    }
    while ($row = mysql_fetch_assoc($friend)) {
        array_push($userFriendsArray, explode(",", $row['events']));
    }
}
reportBack($status, $userFriendsArray);
function reportBack($status, $info)
{
    // Return Results
    $status_array = array('status' => $status, 'info' => $info);
    $status_json = json_encode($status_array);
    die("{$status_json}");
}