Exemplo n.º 1
0
Arquivo: ajax.php Projeto: k3x/VoteMPD
<?php

require "includes/settings.php";
require "includes/functions.php";
// error on no action
if (!isset($_GET["action"])) {
    doError("No action specified");
}
//specify what to do on which action
switch ($_GET["action"]) {
    case "showhighscore":
        $r = doShowhighscore();
        if ($r === false) {
            doError("Error while getting highscore");
        } else {
            doOutput($r, "showhighscore");
        }
        break;
    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"])) {
Exemplo n.º 2
0
function doDownloadFilelist()
{
    $z = getMpdCurrentSong();
    if ($z["state"] != "play" || !isset($z["fileinfos"])) {
        $z = array();
    } else {
        $z = array($z["fileinfos"]);
    }
    $a = array();
    $b = array();
    $c = array();
    $d = array();
    $already = array();
    foreach ($z as $item) {
        if (!in_array($item->id, $already)) {
            $a[] = $item;
            $already[] = $item->id;
        }
    }
    foreach (doGetmyvotes() as $item) {
        if (!in_array($item->id, $already)) {
            $b[] = $item;
            $already[] = $item->id;
        }
    }
    foreach (doShowhighscore() as $item) {
        if (!in_array($item->id, $already)) {
            $c[] = $item;
            $already[] = $item->id;
        }
    }
    foreach (getBrowsePlaylog(10)["files"] as $item) {
        if (!in_array($item->id, $already)) {
            $d[] = $item;
            $already[] = $item->id;
        }
    }
    return array("a" => $a, "b" => $b, "c" => $c, "d" => $d);
}