";
break;
}
$el = strtok( $got, ":" );
$ret[$el] = strtok( "\0" );
$ret[$el] = ltrim( $ret[$el] );
}
if( ! isset( $ret ))
{
$ret = array();
}
return $ret;
}
function getCommandInfo( $conn, $MPDVersion )
{
fputs( $conn, "commands\n" );
while( ! feof( $conn ))
{
$got = fgets( $conn, "1024" );
$got = str_replace( "\n", "", $got );
if( strncmp( "OK", $got, strlen( "OK" )) == "0")
{
break;
}
if( strncmp( "ACK", $got, strlen( "ACK" )) == "0")
{
$ret = array();
if(strncmp($MPDVersion,"0.11.",strlen("0.11.") == 0 )) {
$ret = array(
// 0.11.x
"clearerror" => 1,
"deleteid" => 1,
"move" => 1,
"moveid" => 1,
"playid" => 1,
"playlistid" => 1,
"plchanges" => 1,
"seekid" => 1,
"swapid" => 1,
"update" => 1
);
};
// 0.10.x
$ret = $ret + array(
"add" => true,
"clear" => true,
"close" => true,
"crossfade" => true,
"close" => true,
"crossfade" => true,
"currentsong" => true,
"delete" => true,
"find" => true,
"list" => true,
"listall" => true,
"listallinfo" => true,
"load" => true,
"lsinfo" => true,
"next" => true,
"pause" => true,
"password" => true,
"ping" => true,
"play" => true,
"playlist" => true,
"playlistinfo" => true,
"previous" => true,
"random" => true,
"repeat" => true,
"rm" => true,
"save" => true,
"search" => true,
"seek" => true,
"setvol" => true,
"shuffle" => true,
"stats" => true,
"status" => true,
"stop" => true,
"swap" => true,
"volume" => true
);
return $ret;
}
$el = str_replace( "command: ", "", $got);
$ret[$el] = true;
}
fputs( $conn, "notcommands\n" );
while( ! feof( $conn ))
{
$got = fgets( $conn,1024 );
$got = str_replace( "\n", "", $got );
if( strncmp( "OK", $got, strlen( "OK" )) == "0" )
{
break;
}
if( strncmp( "ACK", $got, strlen( "ACK" )) == "0" )
{
echo "$got
";
break;
}
if( $el = str_replace( "command: ", "", $got ))
{
$ret["all"] = false;
$ret[$el] = false;
}
}
if( ! isset ( $ret["all"] ))
{
$ret["all"] = true;
}
return $ret;
}
function setNotSetSongFields( $song, $display_fields )
{
if( isset( $song["Title"] ))
{
for( $i = "0"; $i < count( $display_fields ); $i++ )
{
if( ! isset( $song[ $display_fields[$i] ] ))
{
$song[ $display_fields[$i] ] = "";
}
}
}
return $song;
}
function getPlaylistInfo( $conn, $song, $display_fields )
{
fputs( $conn, "playlistinfo $song\n" );
$count = -1;
while ( ! feof( $conn ))
{
$got = fgets( $conn, "1024" );
$got = str_replace( "\n", "", $got );
if( strncmp( "OK", $got, strlen( "OK" )) == "0")
{
break;
}
if( strncmp( "ACK" , $got, strlen( "ACK" )) == "0")
{
break;
}
$el = strtok( $got, ":");
if( strcmp( $el, "file" ) == "0" )
{
if( $count >= "0" )
{
$ret[$count] = setNotSetSongFields( $ret[$count], $display_fields );
}
$count++;
}
$ret[$count][$el] = strtok( "\0" );
$ret[$count][$el] = ltrim( $ret[$count][$el] );
}
if ( ! isset( $ret ))
{
$ret = array();
}
return $ret;
}
function printPlaylistInfo( $conn, $num, $hide, $show_options, $length, $commands, $arg, $color, $server, $config )
{
function local( $count, $start, $filenames_only, $ret, $num, $color, $server, $hide, $show_options, $commands, $config, $length )
{
$goto = $count > $start ? $count - 1 : $count;
$time = time();
if( $filenames_only !== true && isset($ret["Name"]) && $ret["Name"] > "0")
{
$display = $ret["Name"];
}
else
{
$display = songInfo2Display( $ret, $config["playlist_display_conf"], $config["playlist_display_conf_separator"], $config["filenames_only"], $config["regex"], $config["wordwrap"] );
}
$id = $ret["Id"];
if( isset( $num ) && ( $num == $count ))
{
echo "