PHP Code:
<?
include('db.php');
function scanID3($file)
{
require_once 'system/getid3/getid3.php'; //change to getid3 location
$res = false;
$getID3 = new getID3();
$id3 = $getID3->analyze($file);
if (isset($id3["fileformat"]) && $id3["fileformat"] == "mp3") {
$res = array();
$res["file"] = $file;
$res["album"] = $id3["tags"]["id3v2"]["album"][0];
$res["title"] = $id3["tags"]["id3v2"]["title"][0];
if (isset($id3["tags"]["id3v2"]["artist"][0])) {
$res["artist"] = $id3["tags"]["id3v2"]["artist"][0];
} else {
$res["artist"] = "Unknown";
}
$res["trackNumber"] = $id3["tags"]["id3v2"]["track_number"][0];
$res["link"] = str_replace(["_aaID_", "_trackID_"], [md5($res["artist"] . "_" . $res["album"]), $res["trackNumber"]], $this->config["link"]);
if (strpos($res["trackNumber"], "/")) {
$res["trackNumber"] = substr($res["trackNumber"], 0, strpos($res["trackNumber"], "/"));
}
$res["trackNumber"] = sprintf("d", $res["trackNumber"]);
if(isset($id3['comments']['picture'][0])){
$res['image'] = 'data:'.$id3['comments']['picture'][0]['image_mime'].';charset=utf-8;base64,'.base64_encode($id3['comments']['picture'][0]['data']);
}
else
{
$res['image'] = 'unknown';
}
} else {
//var_dump($file);
}
return $res;
}
$id=$_REQUEST['id'];
$query = "update files SET views = views+1 where id ='".$id."'";
$update = mysqli_query($con,$query) or die(mysql_error());
$query = "SELECT * from files where id='".$id."'";
$result = mysqli_query($con,$query) or die(mysql_error());
$row = mysqli_fetch_assoc($result);
$url = $row['mp3path'];
$mp3data = scanID3($url);
echo 'Album: '.$mp3data['album'].'<br/>';
echo 'Title: '.$mp3data['title'].'<br/>';
echo 'Artist: '.$mp3data['artist'].'<br/>';
echo 'Track number: '.$mp3data['trackNumber'].'<br/>';
if($mp3data['image']!='unknown')
{
echo '<img src="'.$mp3data['image'].'" alt=""/><br/>';
}
?>
Notice: Undefined index: title in /home/mysong/public_html/file2.php on line 14
Notice: Trying to access array offset on value of type null in /home/sample/public_html/file2.php on line 14
Notice: Undefined index: track_number in /home/sample/public_html/file2.php on line 20
Notice: Trying to access array offset on value of type null in /home/sample/public_html/file2.php on line 20
Fatal error: Uncaught Error: Using $this when not in object context in /home/mysong/public_html/file2.php:21 Stack trace: #0 /home/sample/public_html/file2.php(4: scanID3('system/files/Wa...') #1 {main} thrown in /home/sample/public_html/file2.php on line 21
Comment