case "search": if (!isset($_POST["keyword"])) { doError("No keyword specified"); } $r = doSearch($_POST["keyword"]); if ($r === false) { doError("Error while searching"); } else { doOutput($r, "search"); } break; case "vote": if (!isset($_GET["id"])) { doError("No id specified"); } $r = doVote($_SERVER['REMOTE_ADDR'], $_GET["id"]); doOutput($r, "vote"); break; case "voteFolder": if (!isset($_GET["id"])) { doError("No id specified"); } if (!isset($_GET["vote"])) { doError("No vote specified"); } $vote = $_GET["vote"] == "true"; $r = doVoteFolder($_SERVER['REMOTE_ADDR'], $_GET["id"], $vote); doOutput(null, "voteFolder"); break; case "voteArtist": if (!isset($_GET["name"])) {
function doVotePlaylist($ip, $name, $vote) { $files = getBrowsePlaylist($name)["files"]; foreach ($files as $file) { $fid = $file->id; if ($vote) { doVote($ip, $fid, false); } else { doRemoveMyVote($ip, $fid, false); } } }