All pastes #130075 Raw Edit

Anonymous

public text v1 · immutable
#130075 ·published 2006-08-13 22:00 UTC
rendered paste body
<?php

class CMP3File
{ // CMP3File declaration
    
    //properties
    var $title;
    var $artist;
    var $album;
    var $year;
    var $comment;
    var $genre;
    
    
    function getid3 ($file)
    { // read the ID3 tag from an MP3 file
        if (file_exists($file))
        { //after verifying the file exists,
            $id_start = filesize($file) - 128;
            
            $fp = fopen($file, "r");
            fseek($fp, $id_start);
            $tag = fread($fp,3);
            if ($tag == "TAG")
            {
                $this->title    = fread($fp, 30);
                $this->artist    = fread($fp, 30);
                $this->album    = fread($fp, 30);
                $this->year        = fread($fp, 4);
                $this->comment    = fread($fp, 30);
                $this->genre    = fread($fp, 1);
                fclose($fp);
                return true;
            }
            else
            { //there is no ID3 tag in the file
                fclose($fp);
                return false;
            }
        } else //the file doesn't exist
            return false;
    }
}

?>