Ejemplo n.º 1
0
function art_insert($album_id, $artist, $album)
{
    mp3act_connect();
    $query = '';
    $image = art_query($artist, $album);
    if ($image != "") {
        $query = "UPDATE mp3act_albums SET album_art=\"{$album_id}.jpg\" WHERE album_id={$album_id}";
        mysql_query($query);
        $tmpimg = http_get($image);
        $path = $GLOBALS['abs_path'] . "/art/";
        $file = "{$album_id}.jpg";
        $filename = $path . $file;
        touch($filename);
        // Let's make sure the file exists and is writable first.
        if (is_writable($filename)) {
            // In our example we're opening $filename in append mode.
            // The file pointer is at the bottom of the file hence
            // that's where $somecontent will go when we fwrite() it.
            if (!($handle = fopen($filename, 'a'))) {
                echo "Cannot open file ({$filename})";
                exit;
            }
            // Write $somecontent to our opened file.
            if (fwrite($handle, $tmpimg) === FALSE) {
                echo "Cannot write to file ({$filename})";
                exit;
            }
            //echo "Success, wrote ($somecontent) to file ($filename)";
            fclose($handle);
        } else {
            echo "The file {$filename} is not writable";
        }
        return $file;
    } else {
        $query = "UPDATE mp3act_albums SET album_art=\"fail\" WHERE album_id={$album_id}";
        mysql_query($query);
    }
}
Ejemplo n.º 2
0
function art_insert($album_id, $artist, $album)
{
    mp3act_connect();
    // before looking at amazon, look in the album's directory
    // get album's directory
    $query = "SELECT filename FROM mp3act_songs WHERE album_id={$album_id}";
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    $albumcover = dirname($row[filename]) . "/folder.jpg";
    // if a folder.jpg exists in there, read it and write it's content in the art directory
    if (file_exists($albumcover)) {
        $fh = @fopen($albumcover, "rb");
        $tmpimg = @fread($fh, filesize($albumcover));
        fclose($fh);
        $filename = $GLOBALS['abs_path'] . "/art/" . $path . "{$album_id}.jpg";
        @touch($filename);
        // Let's make sure the art directory is writable first.
        if (is_writable($filename)) {
            if (!($handle = @fopen($filename, 'a'))) {
                //echo "Cannot open file ($filename)";
                return;
            }
            // Write $somecontent to our opened file.
            if (@fwrite($handle, $tmpimg) === FALSE) {
                //echo "Cannot write to file ($filename)";
                return;
            }
            @fclose($handle);
        } else {
            //echo "The file $filename is not writable";
        }
        return "{$album_id}.jpg";
    }
    // else look at amazon
    $image = art_query($artist, $album);
    if ($image != "") {
        $query = "UPDATE mp3act_albums SET album_art=\"{$album_id}.jpg\" WHERE album_id={$album_id}";
        mysql_query($query);
        $tmpimg = http_get($image);
        $path = $GLOBALS['abs_path'] . "/art/";
        $file = "{$album_id}.jpg";
        $filename = $path . $file;
        touch($filename);
        // Let's make sure the art directory is writable first.
        if (is_writable($filename)) {
            if (!($handle = @fopen($filename, 'a'))) {
                //echo "Cannot open file ($filename)";
                return;
            }
            // Write $somecontent to our opened file.
            if (@fwrite($handle, $tmpimg) === FALSE) {
                //echo "Cannot write to file ($filename)";
                return;
            }
            @fclose($handle);
        } else {
            //echo "The file $filename is not writable";
        }
        return $file;
    } else {
        // no cover found
        $query = "UPDATE mp3act_albums SET album_art=\"fail\" WHERE album_id={$album_id}";
        mysql_query($query);
    }
}
Ejemplo n.º 3
0
function art_insert($album_id, $artist, $album)
{
    mp3act_connect();
    $query = '';
    $image = art_query($artist, $album);
    if ($image != "") {
        $query = "UPDATE mp3act_albums SET album_art=\"{$album_id}.jpg\" WHERE album_id={$album_id}";
        mysql_query($query);
        $tmpimg = _http_get($image);
        $path = $GLOBALS['abs_path'] . "/art/";
        $file = "{$album_id}.jpg";
        $filename = $path . $file;
        touch($filename);
        // Let's make sure the art directory is writable first.
        if (is_writable($filename)) {
            if (!($handle = fopen($filename, 'a'))) {
                echo "Cannot open file ({$filename})";
                exit;
            }
            // Write $somecontent to our opened file.
            if (fwrite($handle, $tmpimg) === FALSE) {
                echo "Cannot write to file ({$filename})";
                exit;
            }
            fclose($handle);
        } else {
            echo "The file {$filename} is not writable";
        }
        return $file;
    } else {
        $query = "UPDATE mp3act_albums SET album_art=\"fail\" WHERE album_id={$album_id}";
        mysql_query($query);
    }
}