コード例 #1
0
ファイル: sync.php プロジェクト: benbruscella/Gramophone
function processFileUpload()
{
    $target_path = $GLOBALS['upload_path'];
    $target_path = $target_path . basename($_FILES['audioFile']['name']);
    if (move_uploaded_file($_FILES['audioFile']['tmp_name'], $target_path)) {
        $addMusic = new addMusic();
        if ($_POST['upload_structured'] == "true") {
            $addMusic->getID3Data($target_path, $goodData);
            $final_path = $GLOBALS['upload_path'] . $goodData['artist'] . "/" . $goodData['album'];
            // need some logic to handle illegal filesystem characters before you do this.
            //$final_file_name = $goodData['artist'] . "-" . $goodData['album'] . "-" . $goodData['track'] . "-" . $goodData['name'];
            // for now just keep the filename the same
            $final_file_name = basename($_FILES['audioFile']['name']);
            $final_path_file_name = $final_path . "/" . $final_file_name;
            mkdir($final_path, 0777, true);
            rename($target_path, $final_path_file_name);
            $addMusic->setPath($final_path);
            $addMusic->setFileList($final_path, "/" . $final_file_name, $songs);
        } else {
            $addMusic->setPath($GLOBALS['upload_path']);
            $addMusic->setFileList($GLOBALS['upload_path'], basename($_FILES['audioFile']['name']), $songs);
            // removed as this tries to update every thing in the directory.
            //$addMusic->getSongs($GLOBALS['upload_path'],$songs);
        }
        $songsAdded = $addMusic->insertSongs();
        if ($songsAdded > 0) {
            return true;
        }
    }
    return false;
}
コード例 #2
0
ファイル: add.php プロジェクト: benbruscella/Grammafone
<div id="wrap">
	<div id="header">
		<h1>mp3act Add Music</h1>
		Enter a music directory on the server or upload a file.
	</div>
	<p id="error" class='pad'></p>
 <?php 
if (isset($_GET['add']) && $_GET['add'] == 1 && isset($_GET['musicpath'])) {
    $path = $_GET['musicpath'];
    if ($path[strlen($path) - 1] != '/') {
        $path .= "/";
    }
    session_write_close();
    // otherwise progress isn't shown!
    echo "<div class='box'><div class=\"head\"><h2>Import results</h2></div><ul>";
    $addMusic = new addMusic();
    $addMusic->setPath($path);
    $addMusic->getSongs($path, $songs, $errors);
    $songsAdded = $addMusic->insertSongs();
    echo "<li>Added <strong>{$songsAdded} Songs</strong> To The Database</li>";
    echo "</ul></div>";
} elseif (isset($_FILES['musicfile']['name'])) {
    echo "<pre>";
    print_r($_FILES);
    echo "</pre>";
    echo $_FILES['musicfile']['tmp_name'];
    echo "<br/>" . $_FILES['musicfile']['name'];
    move_uploaded_file($_FILES['musicfile']['tmp_name'], $GLOBALS[upload_path] . "/" . $_FILES['musicfile']['name']);
} else {
    echo "<form action='add.php' method='get' onsubmit='return validator()'>\n";
    echo "<p class='pad'><input type='hidden' value=1 name='add' /><input type='text' onfocus='this.select()' name='musicpath' id='musicpath' size='45' id='musicpath' value='/path/to/music' /><br/><br/>";
コード例 #3
0
ファイル: browse.php プロジェクト: benbruscella/Grammafone
		<form name="importForm" method="get" action="browse.php">
			<input type='hidden' value=1 name='import' />
			<div id="imptable">
			</div>
		</form>
	</div>

<?php 
    } else {
        // do the import..
        set_time_limit(0);
        // no time limit, this can take a while eh!
        session_write_close();
        // otherwise progress isn't shown!
        echo "<div class='box'><div class=\"head\"><h2>Import results</h2></div><ul>";
        $addMusic = new addMusic();
        /* start by doing directories. progress per directory. */
        if (count($queuedirs) > 0) {
            foreach ($queuedirs as $importdir) {
                echo "<li>Importing directory {$importdir}</li>";
                if ($path[strlen($importdir) - 1] != '/') {
                    $importdir .= "/";
                }
                $addMusic->setPath($importdir);
                unset($songs);
                $addMusic->getSongs($importdir, $songs);
                $songsAdded = $addMusic->insertSongs();
                echo "<li>Added <strong>{$songsAdded} Songs</strong> To The Database</li>";
            }
        }
        /* then do files. here we can have one progress bar for all! */