Esempio n. 1
0
<?php

require_once "configuration/main.php";
echo "<div id='songsLoaded'>";
$mQuery = $mysql->query("SELECT `srecord` FROM `record` WHERE `unique_id` = '" . $_SESSION['unique_id'] . "'");
$mData = $mQuery->fetch_assoc();
$mQuery = $mysql->query("SELECT * FROM `albums` " . substr($mData['srecord'], 0, -5) . " ORDER BY RAND()");
while ($mData = $mQuery->fetch_assoc()) {
    $songQuery = $mysql->query("SELECT * FROM `songs` WHERE `album` = '" . $mData['album'] . "'");
    while ($songData = $songQuery->fetch_assoc()) {
        $songsLoaded++;
        if ($songData['album'] != $lastAlbum || !isset($lastAlbum)) {
            echo "</span> <span class='albumGroup'>";
            $lastAlbum = $songData['album'];
        }
        songContainer($songData['path'], $songData['title'], $songData['artist'], $songData['album'], $songData['length']);
    }
    $mysql->query("UPDATE `record` SET `srecord` = CONCAT(srecord, '`id` <> " . $mData['id'] . " AND ') WHERE `unique_id` = '" . $_SESSION['unique_id'] . "'");
    if ($songsLoaded >= SONGS_PER_LOAD) {
        break;
    }
}
echo "</div>";
Esempio n. 2
0
<?php

require_once "configuration/main.php";
echo "<div id='songsLoaded'>";
$nextColor = 0;
$mQuery = $mysql->query("SELECT `srecord` FROM `record` WHERE `unique_id` = '" . $_SESSION['unique_id'] . "'");
$mData = $mQuery->fetch_assoc();
$mQuery = $mysql->query("SELECT * FROM `albums` " . substr($mData['srecord'], 0, -5) . " ORDER BY RAND()");
while ($mData = $mQuery->fetch_assoc()) {
    $songQuery = $mysql->query("SELECT * FROM `songs` WHERE (`artist` = '" . $mData['album'] . "' AND `album` = '') OR `album` = '" . $mData['album'] . "'");
    while ($songData = $songQuery->fetch_assoc()) {
        $songsLoaded++;
        if (!$songColor[$songData['album'] ? $songData['album'] : $songData['artist']]) {
            $songColor[$songData['album'] ? $songData['album'] : $songData['artist']] = $tileColors[$nextColor];
            $nextColor++;
            if ($nextColor == count($tileColors)) {
                $nextColor = 0;
            }
        }
        if ($songData['album'] != $lastAlbum || !isset($lastAlbum)) {
            echo "</span> <span class='albumGroup'>";
            $lastAlbum = $songData['album'];
        }
        songContainer($songData['path'], $songData['title'], $songData['artist'], $songData['album'], $songData['length'], $songColor[$songData['album'] ? $songData['album'] : $songData['artist']], "songContainer", $songData['liked']);
    }
    $mysql->query("UPDATE `record` SET `srecord` = CONCAT(srecord, '`id` <> " . $mData['id'] . " AND ') WHERE `unique_id` = '" . $_SESSION['unique_id'] . "'");
    if ($songsLoaded >= SONGS_PER_LOAD) {
        break;
    }
}
echo "</div>";
Esempio n. 3
0
    $xmlHandle = simplexml_load_string(file_get_contents("http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist=" . urlencode($_POST['artist']) . "r&autocorrect=1&api_key=170ca8cf6781c668254a6524c3713d56"));
    if ($xmlHandle) {
        foreach ($xmlHandle->children() as $arrayValue) {
            foreach ($arrayValue->children() as $arrayValueEx) {
                foreach ($arrayValueEx->children() as $arrayValueExEx) {
                    if ($arrayValueExEx->getName() == "name") {
                        $mysql->query("INSERT INTO `similar` (`artist`, `similar`) VALUES ('" . escape($_POST['artist']) . "', '" . escape($arrayValueExEx) . "')");
                    }
                }
            }
        }
    } else {
        die("There was a problem while attempting to retrieve similar songs.");
    }
    $mQuery = $mysql->query("SELECT * FROM `similar` WHERE `artist` = '" . escape($_POST['artist']) . "' OR `similar` = '" . escape($_POST['artist']) . "'");
    if ($mQuery->num_rows) {
        while ($mData = $mQuery->fetch_assoc()) {
            $songQuery = $mysql->query("SELECT * FROM `songs` WHERE `artist` = '" . escape($mData['artist']) . "' OR `artist` = '" . escape($mData['similar']) . "'");
            while ($songData = $songQuery->fetch_assoc()) {
                $nextColor++;
                if ($nextColor == count($tileColors)) {
                    $nextColor = 0;
                }
                songContainer($songData['path'], $songData['title'], $songData['artist'], $songData['album'], $songData['length'], $tileColors[$nextColor], "songContainer", $songData['liked']);
            }
        }
    } else {
        die("No similar songs were found in your library.");
    }
}
echo "</div>";