checkUrlVariables(); if ( $this->checkConfig() == 0 ){ $this->showConfig(); return; } if ( $this->checkMpd() == 0 ){ $this->showConfig(); return; } $this->showAvailableClients(); } function checkConfig(){ global $mpd_host, $mpd_port; $has_error = 0; if (!isset($mpd_host)){ $mpd_host = 'localhost'; echo 'mpd host is not set
'; $has_error = 1; } if (!isset($mpd_port)){ $mpd_port= 6600; echo 'mpd port is not set
'; $has_error = 1; } if ($has_error){ return 0; } return 1; } function checkMpd(){ global $mpd_host, $mpd_port; $has_error=0; $fp = @fsockopen($mpd_host,$mpd_port,$errno,$errstr,10); if(!$fp) { echo 'Cannot connect to mpd: '.$errstr.'('.$errno.')

'; return 0; } fclose( $fp ); return 1; } function addClient( $client, $link, $desc ){ echo ''.$client.''; echo '

'; echo $desc; echo '
'; echo '
'; } function showAvailableClients(){ $this->addClient( 'phpMp', 'phpmp', 'v0.11.0 - the original client'); $this->addClient( 'phpMp+', 'phpmp+', 'v0.2.3 - client by BohwaZ'); $this->addClient( 'phpMp2', 'phpmp2', 'v0.11.0 - client by mpd team'); $this->addClient( 'phpMp3', 'phpmp3', 'v0.2 - client by angry_elf'); $this->addClient( 'IPodMp', 'ipodmp', 'client by Hendrik Stoetter 03/2008 link'); $this->addClient( 'MPD-Web-Remote', 'mobile.clients/MPD-Web-Remote', 'client by Thomas Preston link'); //only for testing //$this->addClient( 'mpd.class.test', 'phpMpClassTest', 'test client by tswaehn'); } function checkUrlVariables(){ global $url_mpd_host, $url_mpd_port, $url_action; global $mpd_host, $mpd_port; $host = 'localhost'; $port = 6600; if (isset($url_mpd_host)){ $mpd_host = $url_mpd_host; } if (isset($url_mpd_port)){ $mpd_port = $url_mpd_port; } if (isset($url_action)){ switch ($url_action){ case 'save_mpd_settings' : $this->saveSettings( $mpd_host, $mpd_port ); break; } } } function saveSettings( $host, $port ){ $text = ''; $filename = './config/mpd_config.php'; $fh = @fopen( $filename , 'w'); if ($fh){ fwrite( $fh, $text ); fclose($fh); } else { echo 'Failed to write settings to '.$filename.'
'; echo 'Please check your file permissions.

'; } } function showConfig(){ global $mpd_host, $mpd_port; echo '

'; echo 'Please configure mpd and enter your mpd settings'; echo '

'; echo '

'; echo 'mpd host '; echo ''; echo '

'; echo 'mpd port '; echo ''; echo '

'; echo ''; echo ''; echo '

'; } } ?>