1<?php
2/////////////////////////////////////////////////////////////////
3/// getID3() by James Heinrich <info@getid3.org>               //
4//  available at https://github.com/JamesHeinrich/getID3       //
5//            or https://www.getid3.org                        //
6//            or http://getid3.sourceforge.net                 //
7//                                                             //
8// /demo/demo.simple.php - part of getID3()                    //
9// Sample script for scanning a single directory and           //
10// displaying a few pieces of information for each file        //
11//  see readme.txt for more details                            //
12//                                                            ///
13/////////////////////////////////////////////////////////////////
14
15die('For security reasons, this demo has been disabled. It can be enabled by removing line '.__LINE__.' in demos/'.basename(__FILE__));
16
17
18echo '<html><head>';
19echo '<title>getID3() - /demo/demo.simple.php (sample script)</title>';
20echo '<style type="text/css">BODY,TD,TH { font-family: sans-serif; font-size: 9pt; }</style>';
21echo '</head><body>';
22
23// include getID3() library (can be in a different directory if full path is specified)
24require_once('../getid3/getid3.php');
25
26// Initialize getID3 engine
27$getID3 = new getID3;
28
29$DirectoryToScan = '/change/to/directory/you/want/to/scan'; // change to whatever directory you want to scan
30$dir = opendir($DirectoryToScan);
31echo '<table border="1" cellspacing="0" cellpadding="3">';
32echo '<tr><th>Filename</th><th>Artist</th><th>Title</th><th>Bitrate</th><th>Playtime</th></tr>';
33while (($file = readdir($dir)) !== false) {
34	$FullFileName = realpath($DirectoryToScan.'/'.$file);
35	if ((substr($file, 0, 1) != '.') && is_file($FullFileName)) {
36		set_time_limit(30);
37
38		$ThisFileInfo = $getID3->analyze($FullFileName);
39
40		$getID3->CopyTagsToComments($ThisFileInfo);
41
42		// output desired information in whatever format you want
43		echo '<tr>';
44		echo '<td>'.htmlentities($ThisFileInfo['filenamepath']).'</td>';
45		echo '<td>'              .htmlentities(!empty($ThisFileInfo['comments_html']['artist']) ? implode('<br>', $ThisFileInfo['comments_html']['artist'])         : chr(160)).'</td>';
46		echo '<td>'              .htmlentities(!empty($ThisFileInfo['comments_html']['title'])  ? implode('<br>', $ThisFileInfo['comments_html']['title'])          : chr(160)).'</td>';
47		echo '<td align="right">'.htmlentities(!empty($ThisFileInfo['audio']['bitrate'])        ?           round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : chr(160)).'</td>';
48		echo '<td align="right">'.htmlentities(!empty($ThisFileInfo['playtime_string'])         ?                 $ThisFileInfo['playtime_string']                  : chr(160)).'</td>';
49		echo '</tr>';
50	}
51}
52echo '</table>';
53
54echo '</body></html>';
55