diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-09-08 04:20:13 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-09-08 04:20:13 +0000 |
commit | e98446d5701b9467bc64003b0f08c7c915db1e61 (patch) | |
tree | f3816cf1f61672b18e27d131f7c656767421b9f3 | |
parent | 94991b185cc8e0048194e77749593c0388636444 (diff) | |
download | ampache-e98446d5701b9467bc64003b0f08c7c915db1e61.tar.gz ampache-e98446d5701b9467bc64003b0f08c7c915db1e61.tar.bz2 ampache-e98446d5701b9467bc64003b0f08c7c915db1e61.zip |
fixed missing password pass issue with the mpd controller
-rwxr-xr-x | docs/CHANGELOG | 3 | ||||
-rw-r--r-- | modules/localplay/mpd.controller.php | 2 | ||||
-rw-r--r-- | modules/mpd/mpd.class.php | 49 |
3 files changed, 30 insertions, 24 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 544c738f..496fd1ec 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,9 @@ -------------------------------------------------------------------------- v.3.3.2 + - Fixed an issue with the MPD Controller not passing the password + to the MPD class causing flames to shoot out if your MPD + had a password set - Fixed issue with transcoding not changing the mime type or the filename, currently hardcodes to mp3 and audio/mpeg - Updated Spanish Translation (Thx Bgordon) diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php index cd07e92e..3c99e63f 100644 --- a/modules/localplay/mpd.controller.php +++ b/modules/localplay/mpd.controller.php @@ -373,7 +373,7 @@ class AmpacheMpd { */ function connect() { - $this->_mpd = new mpd(conf('localplay_mpd_hostname'),conf('localplay_mpd_port')); + $this->_mpd = new mpd(conf('localplay_mpd_hostname'),conf('localplay_mpd_port'),conf('localplay_mpd_password')); if ($this->_mpd->connected) { return true; } diff --git a/modules/mpd/mpd.class.php b/modules/mpd/mpd.class.php index 2fe297f6..1191f39a 100644 --- a/modules/mpd/mpd.class.php +++ b/modules/mpd/mpd.class.php @@ -72,9 +72,9 @@ define("MPD_TBL_ALBUM","album"); class mpd {
// TCP/Connection variables
- var $host;
- var $port;
- var $password;
+ var $host; + var $port; + var $password; var $mpd_sock = NULL;
var $connected = FALSE;
@@ -119,20 +119,23 @@ class mpd { function mpd($srv,$port,$pwd = NULL) {
$this->host = $srv;
$this->port = $port;
- $this->password = $pwd;
+ $this->password = $pwd;
- $resp = $this->Connect();
- if ( is_null($resp) ) {
- $this->errStr = "Could not connect";
- return;
- } else {
- list ( $this->mpd_version ) = sscanf($resp, MPD_RESPONSE_OK . " MPD %s\n");
- if ( ! is_null($pwd) ) {
- if ( is_null($this->SendCommand(MPD_CMD_PASSWORD,$pwd)) ) {
- $this->connected = FALSE;
- return; // bad password or command
- }
- if ( is_null($this->RefreshInfo()) ) { // no read access -- might as well be disconnected!
+ $resp = $this->Connect(); + if ( is_null($resp) ) { + $this->errStr = "Could not connect"; + return; + } + else { list ( $this->mpd_version ) = sscanf($resp, MPD_RESPONSE_OK . " MPD %s\n"); + + if ( ! is_null($pwd) ) { + if ( is_null($this->SendCommand(MPD_CMD_PASSWORD,$pwd)) ) { + $this->connected = FALSE; + $this->errStr = "Password supplied is incorrect or Invalid Command"; + return; // bad password or command + } + + if ( is_null($this->RefreshInfo()) ) { // no read access -- might as well be disconnected!
$this->connected = FALSE;
$this->errStr = "Password supplied does not have read access";
return;
@@ -156,6 +159,7 @@ class mpd { function Connect() { if ( $this->debugging ) echo "mpd->Connect() / host: ".$this->host.", port: ".$this->port."\n"; $this->mpd_sock = fsockopen($this->host,$this->port,$errNo,$errStr,3); + /* Vollmerize this bizatch, if we've got php4.3+ we should * have these functions and we need them */ @@ -170,7 +174,6 @@ class mpd { stream_set_blocking($this->mpd_sock,TRUE); $status = socket_get_status($this->mpd_sock); } - if (!$this->mpd_sock) { $this->errStr = "Socket Error: $errStr ($errNo)"; return NULL; @@ -192,12 +195,12 @@ class mpd { } // end while - // Generic response
- $this->errStr = "Connection not available";
- return NULL;
- }
- }
-
+ // Generic response + $this->errStr = "Connection not available"; + return NULL; + } + } + /* SendCommand()
*
* Sends a generic command to the MPD server. Several command constants are pre-defined for
|