示例#1
0
 /**
  * Connects to the player and returns true or false based on what happens
  * 
  * @author Ross Carlson
  * @version 2/9/05
  * @since 2/9/05
  * @param return Returns true or false
  */
 function connect()
 {
     return playerConnect();
 }
示例#2
0
/**
 * The installer function for this jukebox
 * 
 * @author Ross Carlson
 * @version 11/20/05
 * @since 11/20/05
 * @param $step int The step of the install process we are on
 */
function jbInstall($step)
{
    global $jbArr;
    echo "<strong>MPD Jukebox Installer</strong><br><br>";
    // Now which step are we on?
    switch ($step) {
        case "2":
            // Now let's create the step 2 page
            ?>
				Please complete the following to setup MPD with Jinzora.<br><br>
				<strong>NOTE:</strong> MPD must already be running and have imported the same media folder(s)<br>that Jinzora has in order for MPD to function properly with Jinzora.<br><br>
				<form method="post">
					<table>
						<tr>
							<td>
								Server:
							</td>
							<td>
								<input type="text" value="localhost" name="edit_server" class="jz_input">
							</td>
						</tr>
						<tr>
							<td>
								Port:
							</td>
							<td>
								<input type="text" value="6600" name="edit_port" class="jz_input">
							</td>
						</tr>
						<tr>
							<td>
								Password:
							</td>
							<td>
								<input type="password" value="" name="edit_password" class="jz_input"> (optional)
							</td>
						</tr>
						<tr>
							<td>
								Name:
							</td>
							<td>
								<input type="text" value="MPD Player" name="edit_description" class="jz_input">
							</td>
						</tr>
						<tr>
							<td></td>
							<td>
								<br>
								<input type="submit" value="Test Connection and Write Settings" name="edit_finish" class="jz_submit">
								<br><br>
							</td>
						</tr>
					</table>
					<input type="hidden" name="edit_step" value="3">
					<input type="hidden" name="edit_jukebox_type" value="mpd">					
				</form>
				<?php 
            exit;
            break;
        case "3":
            // Let's test the connection to the player
            // First let's set all the variables for it
            $jbArr[0]['server'] = $_POST['edit_server'];
            $jbArr[0]['port'] = $_POST['edit_port'];
            $jbArr[0]['description'] = $_POST['edit_description'];
            $jbArr[0]['password'] = $_POST['edit_password'];
            $jbArr[0]['type'] = "mpd";
            $_SESSION['jb_id'] = 0;
            echo "Testing connection to MPD...<br>";
            if (playerConnect()) {
                echo word("Success! Please wait while we write the settings...") . "<br><br>";
                flushdisplay();
                sleep(1);
            } else {
                echo word("Failed!  Jinzora had an issue communicating with MPD, ensure that it's running and that you've specified the proper settings");
                exit;
            }
            // Ok, let's create the settings file
            $content = "<?" . "php\n";
            $content .= "\$" . "jbArr[0]['server'] = '" . $_POST['edit_server'] . "';\n";
            $content .= "\$" . "jbArr[0]['port'] = '" . $_POST['edit_port'] . "';\n";
            $content .= "\$" . "jbArr[0]['description'] = '" . $_POST['edit_description'] . "';\n";
            $content .= "\$" . "jbArr[0]['password'] = '******'edit_password'] . "';\n";
            $content .= "\$" . "jbArr[0]['type'] = 'mpd';\n";
            $content .= "?>";
            // Now let's write it out IF we can
            $filename = getcwd() . "/jukebox/settings.php";
            if (is_writable($filename)) {
                $handle = fopen($filename, "w");
                fwrite($handle, $content);
                fclose($handle);
                ?>
					<form method="post">
						<input type="submit" name="continue" value="Continue to the Jukebox interface" class="jz_submit"><br><br>
					</form>
					<?php 
                exit;
            } else {
                echo 'It looks like your jukebox settings file at "' . $filename . '" is not writeable.<br>You must make it writeable to proceed!';
                echo '<br><br>If you are on Linux you can execute "chmod 666 ' . $filename . '" at a shell to make it writeable.<br><br>';
                echo "Or copy and paste the below information into the file at: " . getcwd() . "/jukebox/settings.php<br><br>";
                echo str_replace("    ", "&nbsp;&nbsp;&nbsp;&nbsp;", nl2br(str_replace("<?php", "&lt;php", $content)));
                echo "<br><br>";
                exit;
            }
            break;
    }
}