$token))->fetch(); database_exec("INSERT INTO status (`status`, `user`, `longitude`, ". "`latitude`, `media`) VALUES(:status, :user, :long, :lat, :media)", array(":status" => $status, ":user" => $u["id"], ":long" => $long, ":lat" => $lat, ":media" => $media)); $s = database_exec("SELECT * FROM status WHERE id = :id", array(":id" => database_get()->lastInsertId()))->fetch(); $date = new DateTime($s["date"]); echo json_encode(array("status" => $s["status"], "creation_date" => $date->format(DateTime::ISO8601), "latitude" => $s["latitude"] === null ? null : floatval($s["latitude"]), "longitude" => $s["longitude"] === null ? null : floatval($s["longitude"]), "id" => intval($s["id"]), "user_id" => intval($u["id"]) )); } function status_feed() { check_token(); $limit = check_int(get_get("limit", false), 15); if ($limit < 1) $limit = 15; $page = max((check_int(get_get("page", false), 1) - 1), 0) * $limit; $s = database_query("SELECT * FROM status ORDER BY `id` DESC ". "LIMIT $page, $limit"); $data = array(); global $media_url; while (($u = $s->fetch()) !== false) { $date = new DateTime($u['date']); $data[] = array("id" => intval($u["id"]), "status" => $u["status"], "creation_date" => $date->format(DateTime::ISO8601), "latitude" => $u["latitude"] === null ? null : floatval($u["latitude"]), "longitude" => $u["longitude"] === null ? null : floatval($u["longitude"]), "author_username" => "42", "nb_confirm_up" => intval($u["up"]), "nb_confirm_down" => intval($u["down"]), "media_url" => ($u["media"] !== null ) ? $media_url . $u["media"] : null); } echo json_encode($data); } ?>