7 <title
>Adorno
- Directory of
<?php
echo str_replace(" ","",nice_track_name("$d")); ?
></title
>
10 <table width
=100%
><tr
>
11 <td
><h2
>Directory of
<?php
echo nice_track_name("$d"); ?
></h2
></td
>
12 <td align
=right
><a href
="/?submit=a&action=next">NEXT
</a
>  
; |
 
;
13 <a href
="/dir.php?d=$dd&submit=a&action=clear">CLEAR
</a
>  
; |
 
;
14 <a href
="/dir.php?d=$dd&submit=a&action=quit">QUIT
</a
>  
; |
 
;
15 <a href
="/dir.php?d=$dd&submit=a&action=off">OFF
</a
>  
; |
 
;
23 $dirname = eregi_replace( "\/*$", "", "/music" . "$d" );
24 $dirname = "/music" . "$d";
29 if ( $dir = opendir( "$dirname" ) ) {
30 while (($file = readdir($dir)) !== false) {
31 if ( is_dir( "$dirname/$file" ) ) {
32 if ( ereg( "^\.", $file ) ) continue;
33 array_push( $dirlist, $file );
36 if ( !ereg( "\.(mp3)|(ogg)$", $file ) ) continue;
37 array_push( $tracklist, $file );
38 if ( ! $in_database ) {
39 $md5 = `
/usr
/bin
/md5sum
"$dirname$file"`
;
40 list( $hashkey, $track) = explode( " ", trim($md5), 2);
41 $query = "SELECT * FROM tracks WHERE hash_key = '$hashkey';";
42 $result = pg_Exec( $dbconn, $query);
43 if ( $result && pg_NumRows($result) > 0 ) {
44 echo "$track was found in database<br>\n";
48 $md5 = `
/usr
/bin
/md5sum
"$dirname$file"`
;
49 array_push( $md5list, $md5 );
57 $file = ereg_replace( "/[^/]+/$", "/", $d);
58 echo "<p><a href=\"/dir.php?d=$file\">Up one level</a><br>\n";
62 while (list ($key, $val) = each ($dirlist)) {
63 // echo " <a href=\"/dir.php?d=$d&submit=a&action=queue&track=$d$val\">$val</a><br>\n";
64 echo "<a href=\"/dir.php?d=$d" . urlencode($val) . "/\">" . str_replace(" ", " ", $val) . "</a> \n";
70 if ( count($tracklist) > 0 ) {
71 echo "<p><b>Select tracks to Play</b><br>\n";
74 while (list ($key, $val) = each ($tracklist)) {
75 echo " <a href=\"/dir.php?d=$dd&submit=a&action=queue&track=$dd" . urlencode($val) . "\">$val</a><br>\n";
80 if ( count($md5list) > 0 ) {
81 echo "<p><b>Database List</b><br>\n";
83 while (list ($key, $val) = each ($md5list)) {
84 list( $hashkey, $track) = explode( " ", trim($val), 2);
85 $query = "SELECT * FROM tracks WHERE hash_key = '$hashkey';";
86 $result = pg_Exec( $dbconn, $query);
87 if ( $result && pg_NumRows($result) > 0 ) {
88 echo "$track was found in database<br>\n";
91 $track = trim($track);
92 echo "$track added into database<br>\n";
93 $safe_track = eregi_replace( '^.*/([^/]+)$', "\\1", str_replace( "'", "''", $track ));
94 $safe_path = str_replace( "'", "''", $track );
95 if ( eregi( '\.mp3$', $track ) ) {
96 $command = "mp3info -p '%n\t%t\t%l\t%a' '$track'"; // track number >> track title >> album name >> artist name
97 // error_log( "mdaemon: $command", 0);
98 $mp3info = `
$command`
; // track number >> track title >> album name >> artist name
99 // error_log( "mdaemon: $mp3info", 0);
100 list( $tnum, $ttitle, $talbum, $tartist ) = split( "\t", $mp3info, 4);
101 $tnum = intval($tnum);
102 $ttitle = str_replace( "'", "''", $ttitle );
103 $talbum = str_replace( "'", "''", $talbum );
104 $tartist = str_replace( "'", "''", $tartist );
105 $query = "INSERT INTO tracks ( hash_key, path_name, title, artist, album, tracknum ) ";
106 $query .= "VALUES( '$hashkey', '$safe_path', '$ttitle', '$tartist', '$talbum', '$tnum') ;";
108 else if ( eregi( '\.ogg$', $track ) ) {
109 $ogginfo = `ogginfo
$track`
;
112 // header_integrity=pass
113 // ARTIST=Cranberries
114 // ALBUM=Bury the Hatchett
117 // vendor=Xiphophorus libVorbis I 20011231
121 // bitrate_upper=none
122 // bitrate_nominal=112015
123 // bitrate_lower=none
124 // stream_integrity=pass
125 // bitrate_average=114037
128 // stream_truncated=false
130 $trackinfo = split( "\n", $ogginfo);
131 while( list( $k , $v ) = each( $trackinfo ) ) {
132 list( $type, $value ) = split( "=", $v, 2);
133 switch ( strtoupper($type) ) {
134 case 'ARTIST': $tartist = $value; break;
135 case 'ALBUM': $talbum = $value; break;
136 case 'TITLE': $ttitle = $value; break;
137 case 'TRACKNUMBER': $tnum = $value; break;
140 $tnum = intval($tnum);
141 $ttitle = str_replace( "'", "''", $ttitle );
142 $talbum = str_replace( "'", "''", $talbum );
143 $tartist = str_replace( "'", "''", $tartist );
145 $query = "INSERT INTO tracks ( hash_key, path_name, title, artist, album, tracknum ) ";
146 $query .= "VALUES( '$hashkey', '$safe_path', '$ttitle', '$tartist', '$talbum', '$tnum') ;";
147 // $query = "INSERT INTO tracks ( hash_key, path_name, title ) VALUES( '$hashkey', '$safe_path', '$safe_track') ;";
150 $query = "INSERT INTO tracks ( hash_key, path_name, title ) VALUES( '$hashkey', '$safe_path', '$safe_track') ;";
152 $result = pg_Exec( $dbconn, $query);
154 // echo " <a href=\"/dir.php?d=$d&submit=a&action=queue&track=$d$val\">$val</a><br>\n";