Example #1
0
<?php

header("Content-Type: application/json");
if (!class_exists("EnhancedMySQLi")) {
    require_once "./../../EnhancedMySQLi/EnhancedMySQLi.php";
}
$CONFIG_LOCATION = __DIR__ . "/../../../../Config.json";
$config = json_decode(file_get_contents($CONFIG_LOCATION), true);
$MySQLiSettings = $config["MySQLi"];
$sql = new EnhancedMySQLi($MySQLiSettings["Host"], $MySQLiSettings["User"], $MySQLiSettings["Password"], $MySQLiSettings["Database"]);
$temp = $sql->query("SELECT * FROM PlaylistList WHERE room = \"" . $_GET["room"] . "\";")["rows"];
$data = array();
foreach ($temp as $playlist) {
    $songList = array();
    $list = $sql->query("SELECT song FROM Playlists_Songs WHERE playlist = " . $playlist["id"] . " ORDER BY position")["rows"];
    foreach ($list as $song) {
        array_push($songList, $song["song"]);
    }
    array_push($data, array("id" => $playlist["id"], "name" => $playlist["name"], "list" => $songList));
}
echo json_encode($data);
Example #2
0
<?php

header("Content-Type: application/json");
if (!class_exists("EnhancedMySQLi")) {
    require_once "./../EnhancedMySQLi/EnhancedMySQLi.php";
}
$CONFIG_LOCATION = __DIR__ . "/../../../Config.json";
$config = json_decode(file_get_contents($CONFIG_LOCATION), true);
$MySQLiSettings = $config["MySQLi"];
$sql = new EnhancedMySQLi($MySQLiSettings["Host"], $MySQLiSettings["User"], $MySQLiSettings["Password"], $MySQLiSettings["Database"]);
$temp = $sql->query("SELECT * FROM DefaultRoom")["rows"];
$data = array();
foreach ($temp as $value) {
    $data[$value["key"]] = $value["value"];
}
echo json_encode($data);
Example #3
0
<?php

header("Content-Type: application/json");
if (!class_exists("EnhancedMySQLi")) {
    require_once "./../../EnhancedMySQLi/EnhancedMySQLi.php";
}
$CONFIG_LOCATION = __DIR__ . "/../../../../Config.json";
$config = json_decode(file_get_contents($CONFIG_LOCATION), true);
$MySQLiSettings = $config["MySQLi"];
$sql = new EnhancedMySQLi($MySQLiSettings["Host"], $MySQLiSettings["User"], $MySQLiSettings["Password"], $MySQLiSettings["Database"]);
$position = $_GET["position"] + 1;
$playlist = $_GET["playlist"];
$sql->query("DELETE FROM Playlists_Songs WHERE playlist={$playlist} AND position={$position}");
$sql->query("UPDATE Playlists_Songs SET position = position - 1 WHERE playlist = {$playlist} AND position >= {$position};");
Example #4
0
<?php

/*
 * Re order a songs position in the playlist
 */
header("Content-Type: application/json");
if (!class_exists("EnhancedMySQLi")) {
    require_once "./../../EnhancedMySQLi/EnhancedMySQLi.php";
}
$CONFIG_LOCATION = __DIR__ . "/../../../../Config.json";
$config = json_decode(file_get_contents($CONFIG_LOCATION), true);
$MySQLiSettings = $config["MySQLi"];
$sql = new EnhancedMySQLi($MySQLiSettings["Host"], $MySQLiSettings["User"], $MySQLiSettings["Password"], $MySQLiSettings["Database"]);
$playlist = $_GET["playlist"];
//the database is not on a zero based index, so we must add one to the index
$new = intval($_GET["new"]) + 1;
$old = intval($_GET["old"]) + 1;
$id = $sql->query("SELECT id FROM Playlists_Songs WHERE playlist = {$playlist} AND position = {$old};")["rows"][0]["id"];
if ($new < $old) {
    $sql->query("UPDATE Playlists_Songs SET position = position + 1 WHERE playlist = {$playlist} AND position >= {$new} AND position <= {$old};");
} else {
    if ($old < $new) {
        $sql->query("UPDATE Playlists_Songs SET position = position - 1 WHERE playlist = {$playlist} AND position <= {$new} AND position >= {$old};");
    }
}
$sql->query("UPDATE Playlists_Songs SET position = {$new} WHERE id = {$id}");
echo json_encode($sql->query("SELECT * FROM Playlists_Songs WHERE playlist = {$playlist} ORDER BY position;")["rows"]);
Example #5
0
<?php

header("Content-Type: application/json");
if (!class_exists("EnhancedMySQLi")) {
    require_once "./../../EnhancedMySQLi/EnhancedMySQLi.php";
}
$CONFIG_LOCATION = __DIR__ . "/../../../../Config.json";
$config = json_decode(file_get_contents($CONFIG_LOCATION), true);
$MySQLiSettings = $config["MySQLi"];
$sql = new EnhancedMySQLi($MySQLiSettings["Host"], $MySQLiSettings["User"], $MySQLiSettings["Password"], $MySQLiSettings["Database"]);
$sql->query("INSERT INTO Playlists_Songs (playlist, song, position) VALUES (" . $_GET["playlist"] . ", \"" . $_GET["song"] . "\", " . $_GET["position"] . ")");
Example #6
0
<?php

header("Content-Type: application/json");
if (!class_exists("EnhancedMySQLi")) {
    require_once "./../../EnhancedMySQLi/EnhancedMySQLi.php";
}
$CONFIG_LOCATION = __DIR__ . "/../../../../Config.json";
$config = json_decode(file_get_contents($CONFIG_LOCATION), true);
$MySQLiSettings = $config["MySQLi"];
$sql = new EnhancedMySQLi($MySQLiSettings["Host"], $MySQLiSettings["User"], $MySQLiSettings["Password"], $MySQLiSettings["Database"]);
$sql->query("INSERT INTO PlaylistList (room, name) VALUES (\"" . $_GET["room"] . "\", \"" . $_GET["name"] . "\")");
echo json_encode($sql->query("SELECT * FROM PlaylistList WHERE room=\"" . $_GET["room"] . "\" AND name=\"" . $_GET["name"] . "\";")["rows"][0]);