require "class-config.php";
$config = new config("../config/config.php");
// include MPD-lib and connect
require_once 'lib-mpd.php';
$MPD = Net_MPD::factory('Playback', $config->host, intval($config->port), $config->pass);
if (!$MPD->connect()) {
    die(json_encode('error'));
}
$status = "success";
// switch ond action
switch ($_GET['action']) {
    case 'getCurrentSong':
        $status = $MPD->isCommand('currentsong') ? $MPD->getCurrentSong() : array('error');
        break;
    case 'play':
        $config->checkRights("controll_player") && $MPD->isCommand('playid') ? $MPD->playid($_GET['value']) : ($status = "error");
        break;
    case 'continue':
        $config->checkRights("start_playing") && $MPD->isCommand('playid') ? $MPD->playid($_GET['value']) : ($status = "error");
        break;
    case 'stop':
        $config->checkRights("controll_player") && $MPD->isCommand('stop') ? $MPD->stop() : array('error');
        break;
    case 'pause':
        $config->checkRights("pause_playing") && $MPD->isCommand('pause') ? $MPD->pause() : ($status = "error");
        break;
    case 'random':
        $config->checkRights("controll_player") && $MPD->isCommand('random') ? $MPD->random($_GET['value']) : ($status = "error");
        break;
    case 'repeat':
        $config->checkRights("controll_player") && $MPD->isCommand('repeat') ? $MPD->repeat($_GET['value']) : ($status = "error");
Ejemplo n.º 2
0
// read config
require "class-config.php";
$config = new config("../config/config.php");
if (isset($_SESSION['relaxx']) && $_SESSION['relaxx'] == $config->admin_name && $_SESSION['relaxx_pass'] == $config->admin_pass) {
    // include MPD-lib and connect
    require_once 'lib-mpd.php';
    $MPD = Net_MPD::factory('Admin', $config->host, intval($config->port), $config->pass);
    if (!$MPD->connect()) {
        echo json_encode('error');
        die;
    }
    // switch ond action
    switch ($_GET['action']) {
        case 'getOutputs':
            $status = $MPD->isCommand('outputs') ? $MPD->getOutputs() : 'error';
            break;
        case 'disableOutput':
            $config->checkRights("admin_mpd") && $MPD->isCommand('disableoutput') ? $MPD->disableOutput($_GET['value']) : ($status = "error");
            break;
        case 'enableOutput':
            $config->checkRights("admin_mpd") && $MPD->isCommand('enableoutput') ? $MPD->enableOutput($_GET['value']) : ($status = "error");
            break;
        case 'kill':
            $config->checkRights("admin_mpd") && $MPD->isCommand('kill') ? $MPD->kill() : ($status = "error");
            break;
        case 'updateDatabase':
            $config->checkRights("admin_mpd") && $MPD->isCommand('update') ? $MPD->updateDatabase($_GET['value']) : ($status = "error");
            break;
    }
    echo json_encode($status);
}
Ejemplo n.º 3
0
 // switch ond action
 switch ($_GET['action']) {
     case 'getPlaylistInfo':
         $status = $MPD->isCommand('playlistinfo') ? $MPD->getPlaylistInfo($_GET['value']) : 'error';
         break;
     case 'getPlaylists':
         $status = $MPD->isCommand('lsinfo') ? $MPD->getPlaylists() : 'error';
         break;
     case 'getCurrentSong':
         $status = $MPD->isCommand('currentsong') ? $MPD->getCurrentSong() : 'error';
         break;
     case 'listPlaylistInfo':
         $status = $MPD->isCommand('listplaylistinfo') ? $MPD->listPlaylistInfo($_GET['value']) : 'error';
         break;
     case 'savePlaylist':
         $config->checkRights("controll_playlist") && $MPD->isCommand('save') ? $MPD->savePlaylist(strip_tags($_GET['value'])) : ($status = "error");
         break;
     case 'loadPlaylist':
         $config->checkRights("controll_playlist") && $MPD->isCommand('load') ? $MPD->loadPlaylist($_GET['value']) : ($status = "error");
         break;
     case 'deletePlaylist':
         $config->checkRights("controll_playlist") && $MPD->isCommand('rm') ? $MPD->deletePlaylist($_GET['value']) : ($status = "error");
         break;
     case 'addSong':
         $config->checkRights("add_songs") && $MPD->isCommand('add') ? $MPD->addSong($_GET['value']) : ($status = "error");
         break;
     case 'swapSong':
         $pos = split(":", $_GET['value']);
         $config->checkRights("controll_playlist") && $MPD->isCommand('swap') ? $MPD->swapSong($pos[0], $pos[1]) : ($status = "error");
         break;
     case 'moveSong':