-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinfo2html.php
766 lines (697 loc) · 21.1 KB
/
info2html.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
<?php
include "sort.php";
/*******************************************************************************************************************************#
# #
# lsinfo2directoryTable: This takes the information from lsinfo readies the information for printDirectoryTable() #
# #
#*******************************************************************************************************************************#
# #
# $dcount => Directory Count #
# $dirstr => Directory Name #
# $dirindex => Directory Index #
# #
#*******************************************************************************************************************************/
function lsinfo2directoryTable( $lsinfo, $server, $sort, $addperm, $color )
{
$count = count( $lsinfo );
if( $count != "0" )
{
usort( $lsinfo, "dsort" );
}
$dic = 0;
$index=array();
for( $i = "0"; $i < $count; $i++ )
{
$dirstr = basename( $lsinfo[$i]["directory"] );
$full_dir = rawurlencode( $lsinfo[$i]["directory"] );
$print[$i] = "<tr bgcolor=\"{$color[ ($i%2) ]}\"><td>";
$fc = strtoupper( mbFirstChar( $dirstr ));
if ($dic == "0" || $index[ ($dic-1) ]!=$fc)
{
$index[ $dic ] = $fc;
$print[ $i ].= "<a name=d{$index[ $dic ]}></a>";
$dic++;
}
// If updating show the update links, otherwise show add links
if( $addperm === true )
{
$print[$i].= "[<a title=\"Add the $dirstr Directory\" href=\"index.php?body=playlist&server=$server&command=add&arg=$full_dir\" target=playlist>add</a>] ";
}
// This is a workaround to prevent letters that shouldn't be in the title from getting there.
$nice = str_replace(array("\"","\'"), '', $dirstr);
$print[$i].= "<a title=\"Browse the '".$nice."' Directory\" href=\"index.php?body=main&server=$server&sort=$sort&dir=$full_dir\">$dirstr</a></td></tr>";
}
if( ! isset( $index ))
{
$index = array();
}
if( ! isset( $print ))
{
$print = array();
}
$dir["count"] = $count;
$dir["index"] = $index;
$dir["print"] = $print;
return $dir;
}
function printSavePlaylistTable( $server, $color )
{
echo "<!-- Begin printSavePlaylistTable -->";
echo "<br>";
echo "<form action=index.php method=get>";
echo "<table summary=\"Save Playlist\" cellspacing=1 bgcolor=\"{$color["title"]}\">";
echo "<tr><td><b>Save Playlist</b></td></tr>";
echo "<tr bgcolor=\"{$color["body"][0]}\"><td>";
echo "<input name=arg size=40 autocomplete=on>";
echo "<input type=hidden name=body value=main>";
echo "<input type=hidden name=server value=\"$server\">";
echo "<input type=hidden value=save name=command>";
echo "<input type=submit value=save name=foo>";
echo "</td></tr></table></form>";
echo "<!-- End printSavePlaylistTable -->";
}
/*
begin printDirectoryTable
$dcount -> is the number of directories
$dprint -> array, has dcount elements, just do print $dprint[$i]
to print output for that directory, it was formatted
in lsinfo2directoryTable (this parses input from
lsinfo and make the $dprint's for output)
$dindex -> these are the links etc for the index elements point too
$printIndex -> function that takes $dinex and prints all the links
for the indexes
*/
function printDirectoryTable( $info, $dir, $sort, $server, $addperm, $color )
{
extract( $info );
if( $count != "0" )
{
echo "<!-- Begin printDirectoryTable -->";
echo "<br>";
echo "<table summary=\"Directory Border\" cellspacing=1 bgcolor=\"{$color["title"]}\">";
echo "<tr><td nowrap><b>Directories</b>";
printIndex($index,"","d");
$dir = rawurlencode($dir);
if( $addperm === true )
{
if(empty($dir)) {
$dir = '/';
}
echo " <small>(<a title=\"Add All Directories and Music\" target=playlist href=index.php?body=playlist&server=$server&command=add&arg=$dir>add all</a>)</small>";
}
echo "</td></tr>";
echo "<tr><td>";
echo "<table summary=\"Directory\" cellspacing=1 bgcolor=\"{$color["body"][1]}\">";
$directories = "";
for( $i=0; $i < $count; $i++)
{
$directories .= $print[ $i ];
}
echo $directories ."</table>";
echo "</td></tr></table>";
echo "<!-- End printDirectoryTable -->";
}
}
function lsinfo2playlistTable( $lsinfo, $sort, $delete, $server, $loadperm )
{
$pic = 0;
$count = count( $lsinfo );
if($count)
{
usort( $lsinfo, "strcasecmp" );
}
for( $i=0; $i < $count; $i++ )
{
$dirstr = basename( $lsinfo[$i] );
$dirurl = rawurlencode( $dirstr );
$dirurl = rawurlencode( $dirurl );
// Create the Playlist Index
$fc = strtoupper( mbFirstChar( $dirstr ));
if( $pic == "0" || ( $index[ $pic-1 ] != $fc ))
{
$index[ $pic ] = $fc;
$foo = $index[ $pic ];
$pic++;
$print[$i] = "<a name=p$foo></a>";
}
else
{
$print[$i] = "";
}
if( strcmp( $delete, "yes" ) == "0" )
{
$print[$i] .= "[<a title=\"Remove playlist $dirstr\" ";
$print[$i] .= "href=\"index.php?body=main&server=$server&sort=$sort&command=rm&arg=$dirurl\">del</a>] ";
}
if( $loadperm == true )
{
$print[$i] .= "<a title=\"Load the playlist $dirstr\" ";
$print[$i] .= "target=\"playlist\" href=\"index.php?body=playlist&server=$server&command=load&arg=$dirurl\">$dirstr</a> ";
}
else
{
$print[$i] .= "$dirstr ";
}
}
if( ! isset( $count ))
{
$count = "";
}
if( ! isset( $print ))
{
$print = array();
}
if( ! isset( $index ))
{
$index = array();
}
$pinfo["count"] = $count;
$pinfo["index"] = $index;
$pinfo["print"] = $print;
return $pinfo;
}
function display_time( $seconds )
{
if ($seconds > "60")
{
$min = floor( $seconds / 60 );
$sec = ( $seconds - ( $min * 60 ));
return sprintf( "%d:%02d", $min, $sec );
}
else
{
return sprintf( "0:%02d", $seconds );
}
}
function splitTagFile( $lsinfo, $display_fields, $filenames_only )
{
$stats = array();
$tagged = array();
$untagged = array();
for( $i="0"; $i < count( $lsinfo ); $i++ )
{
if( $filenames_only === true || empty( $lsinfo[$i]["Title"] ))
{
$untagged[] = $lsinfo[$i];
}
else
{
for( $j = "0"; $j < count( $display_fields ); $j++ )
{
if( ! empty( $lsinfo[$i][ $display_fields[$j] ] ) && ! in_array( $display_fields[$j], $stats ))
{
$stats[$j] = $display_fields[$j];
}
}
$tagged[] = $lsinfo[$i];
}
}
for( $i = "0"; $i < count( $display_fields ); $i++ )
{
if( isset( $stats[$i] ))
{
$ret[] = $stats[$i];
}
}
if( isset( $ret ))
{
$display_fields = $ret;
}
return( array( $tagged, $untagged, $display_fields ));
}
function fileinfo2musicTable( $info, $dir_url, $display_fields, $color, $server, $addperm )
{
$count = count( $info );
$dir_url = rawurlencode( $dir_url );
$index = array();
$index_key = "mf";
$mic = "0";
$mprint = array();
usort( $info, "fsort" );
for ( $i = "0"; $i < $count; $i++ )
{
$col = $color["file"]["body"][ ( $i%2 ) ];
$full_filename = rawurlencode( $info[$i]["file"] );
$split_filename = basename( $info[$i]["file"] );
$fc_filename = strtoupper( mbFirstChar( $split_filename ));
// Create the Filename Index
if ( $mic == "0" || $index[ ($mic-1) ] != $fc_filename )
{
$index[ $mic ] = $fc_filename;
$mprint[$i] = "<a name=\"$index_key{$index[ $mic ]}\"></a>";
$mic++;
}
else
{
$mprint[$i] = "";
}
if( $addperm === true )
{
$mprint[$i] = "<tr bgcolor=$col><td>$mprint[$i][<a title=\"Add this song to the active playlist\" ";
$mprint[$i] .= "target=\"playlist\" ";
$mprint[$i] .= "href=\"index.php?body=playlist&server=$server&command=add&arg=$full_filename\">add</a>]</td>";
$mprint[$i] .= "<td>$split_filename</td>";
}
else
{
$mprint[$i] = "<tr bgcolor=$col><td>$split_filename</td>";
}
// The <td>s here must be included inside the if() else() blocks in case the user doesn't want it displayed at all.
if( array_search( 'Time', $display_fields ))
{
$mprint[$i] .= "<td>" . display_time( $info[$i]['Time'] ) . "</td>";
}
$mprint[$i] .= "</tr>";
}
// The sort bar is created here.
$sort_bar = "<tr colspan=3 bgcolor=\"{$color["file"]["sort"]}\">";
// This creates the column for 'Add'
if( $addperm == true )
{
$sort_bar .= "<td width=\"1%\"></td>";
}
// In case 'Time' isn't part of the display fields at all
if( array_search( 'Time', $display_fields ))
{
$sort_bar .= "<td>Files</td><td width=\"1%\">Time</td></tr>";
}
else
{
$sort_bar .= "<td>File</td></tr>";
}
$ret["count"] = $count;
$ret["print"] = $mprint;
$ret["index"] = $index;
$ret["index_key"] = $index_key;
$ret["sortbar"] = $sort_bar;
$ret["title"] = "Untagged Music";
return( $ret );
}
/***************************************************************************************#
# #
# info2musicTable() - To ready the MPD information for printMusicTable() consumption #
# #
#***************************************************************************************#
# #
# $info => this is the lsinfo information put into an array #
# #
#***************************************************************************************/
function taginfo2musicTable( $info, $dir_url, $display_fields, $unknown, $color, $server, $addperm, $sort_array, $sort, $ordered, $url )
{
$count = count( $info );
$dir_url = rawurlencode( $dir_url );
$index = array();
$index_key = "mt";
$mic = "0";
$mprint = array();
usort( $info, "msort" );
for ( $i = "0"; $i < $count; $i++ )
{
$col = $color["meta"]["body"][ ( $i%2 ) ];
$full_filename = $info[$i]["file"];
$split_filename = basename( $full_filename );
if( isset( $info[$i][ $sort_array[0] ] ))
{
$fc_filename = strtoupper( mbFirstChar( $info[$i][ $sort_array[0] ] ));
}
$full_filename = rawurlencode( addslashes( $full_filename ));
// This is where the index for the particular table is made
// If the sort item exists in the music item, this is not the first letter that's going to be
// added to the index, and the index before hand is not the samee
if( strcmp( $sort_array[0], "Track" ))
{
if( isset( $info[$i][$sort_array[0]] ) && strlen( $info[$i][ $sort_array[0] ] ) &&
( $mic==0 || $index[ ( $mic - 1 ) ] != $fc_filename ))
{
$index[$mic] = $fc_filename;
$mprint[$i] = "<a name=\"$index_key$fc_filename\"></a>";
$mic++;
}
else
{
$mprint[$i] = "";
}
}
else
{
// If the desired sort item isset put it in
if( isset( $info[$i][ $sort_array[0] ] ))
{
$item = strtok( $info[$i][ $sort_array[0] ], "/" );
}
if( isset( $item ) && ( $mic == "0" || strcmp( $index[ ( $mic - 1 ) ], $item )))
{
$index[ $mic ] = $item;
$mic++;
$mprint[$i] = "<a name=\"$index_key$item\"></a>";
}
else
{
$mprint[$i] = "";
}
}
if( $addperm === true )
{
$mprint[$i] = "<tr bgcolor=$col><td width=\"1%\">$mprint[$i][";
$mprint[$i] .= "<a title=\"Add this song to the current playlist\" ";
$mprint[$i] .= "target=\"playlist\" ";
$mprint[$i] .= "href=\"index.php?body=playlist&server=$server&command=add&arg=";
$mprint[$i] .= rawurlencode($full_filename) . "\">add</a>]</td>";
}
else
{
$mprint[$i] = "<tr bgcolor=$col>";
}
for ( $x = 0; $x < sizeof($display_fields); $x++)
{
$mprint[$i] .= "<td>";
/*
* If $display_fields[$x] an Album, Artist, Date or Genre make the HTML anchored to a mpd 'find' command so the
* user can click anything in the Album Artist, Date or Genre fields and it will automatically search for them case sensitively
* Sort the known remaining tags by just echoing the sting, otherwise print config error.
*/
switch( $display_fields[$x] )
{
case 'Album':
case 'Artist':
case 'Composer':
case 'Performer':
case 'Date':
case 'Genre':
{
if( isset( $info[$i][ $display_fields[$x] ] ))
{
$local_url = rawurlencode( $info[$i][ $display_fields[$x] ] );
$mprint[$i] .= "<a title=\"Find by this keyword\" href=\"index.php?body=main&feature=search&server=$server&find=";
$mprint[$i] .= strtolower( $display_fields[$x] );
$mprint[$i] .= "&arg=$local_url&sort=$sort&dir=$dir_url\">";
$mprint[$i] .= "{$info[$i][ $display_fields[$x] ]}</a>";
}
else
{
$mprint[$i] .= $unknown;
}
break;
}
case 'Title':
{
$mprint[$i] .= $info[$i][ $display_fields[$x] ];
break;
}
case 'Time':
{
if ( isset( $info[$i][ $display_fields[$x] ] ))
{
$mprint[$i] .= display_time( $info[$i][ $display_fields[$x] ] );
}
else
{
$mprint[$i] .= $unknown;
}
break;
}
default:
{
if( isset( $info[$i][ $display_fields[$x] ]))
{
$mprint[$i] .= $info[$i][ $display_fields[$x] ];
}
else
{
$mprint[$i] .= "";
}
break;
}
}
$mprint[$i] .= "</td>";
}
}
// Sort bar is created here
$sort_bar = "<tr bgcolor=\"{$color["meta"]["sort"]}\">";
// This creates the column for 'Add'
if( $addperm === true )
{
$sort_bar .= "<td width=0></td>";
}
for( $j = 0; $j < count( $display_fields ); $j++ )
{
// Cut this in pieces so it wouldn't wrap
$sort_bar .= "<td>";
if( strcmp( $display_fields[$j], $sort_array[0] ) == "0" )
{
$sort_bar .= "<a title=\"Reverse this field\"";
if( strcmp( $ordered, "yes" ))
{
$sort_bar .= " href=\"$url&sort=" . pickSort($display_fields[$j]) . "&ordered=yes&server=$server\">";
}
else
{
$sort_bar .= "href=\"$url&sort=" . pickSort($display_fields[$j]) . "&ordered=no&server=$server\">";
}
$sort_bar .= "<b>{$display_fields[$j]}</b>";
}
else
{
$sort_bar .= "<a title=\"Sort by this field\" ";
$sort_bar .= "href=\"$url&sort=" . pickSort($display_fields[$j]) . "&ordered=no&server=$server\">";
$sort_bar .= $display_fields[$j];
}
$sort_bar .= "</a></td>";
}
$sort_bar .= "</tr>";
$ret["count"] = $count;
$ret["index"] = $index;
$ret["index_key"] = "mt";
$ret["print"] = $mprint;
$ret["sortbar"] = $sort_bar;
$ret["title"] = "Tagged Music";
return( $ret );
}
function createAddAll( $music, $song_separator )
{
$add_all = "";
for( $i="0"; $i < ( count( $music ) - "1" ); $i++ )
{
$add_all .= addslashes( $music[$i]["file"] ) . $song_separator;
}
// If this function gets called without any actual files this will save from getting notices
if( isset( $music[$i]["file"] ))
{
return $add_all . addslashes( $music[$i]["file"] );
}
}
/* This function is used to print the index for all tables that need an index */
function printIndex( $index, $title, $anc )
{
if( count( $index ))
{
$title = "<!-- Begin printIndex -->";
$title .= " [ ";
for ( $i = "0"; $i < count( $index ); $i++ )
{
$title .= "<a title=\"Goto the beginning of {$index[$i]}\" href=\"#$anc{$index[$i]}\">{$index[$i]}</a> ";
}
$title .= "]";
$title .="<!-- End printIndex -->";
echo $title;
}
}
/***************************************************************************************************************#
# #
# printMusicTable: A semi-generic function to print the musicTable in a uniform fashion #
# This function will probably be so generic that it will encompass all printTables #
# #
#***************************************************************************************************************#
# #
# (array) $info => This consists of all the specific information about the table, which consists of #
# REQUIRED: $print => This is an array of the music information, loop this in the body #
# #
# OPTIONAL: $add_all => This is a URL of all addall information for the current information #
# $index => This is an array of unique first characters from the music information #
# $sortbar => This is the sortbar, usually enables the sorting #
# $title => This is the title of the musicTable #
# #
#***************************************************************************************************************/
function printMusicTable( $add_all, $field_count, $use_javascript, $color, $info, $altcount, $sort_array, $server, $dir, $feature, $ordered )
{
if( is_array( $info ))
{
extract( $info );
}
else
{
return;
}
// This is the catchall, if there's any music print it.
if( $count > "0" )
{
echo "<br>";
echo "<!-- Begin printMusicTable -->";
$add_all = rawurlencode( $add_all );
echo '<form name="add_all" method="post" action="index.php" target="playlist">';
if( ! empty( $add_all ))
{
echo "<input type=hidden name=\"add_all\" value=\"$add_all\">";
}
echo "<input type=hidden name=\"body\" value=\"playlist\">";
echo "<input type=hidden name=\"server\" value=\"$server\">";
echo "</form>";
echo "<table summary=\"Music Separators\" cellspacing=1 bgcolor=\"{$color["title"]}\">";
echo "<tr><td>";
echo "<table summary=\"Music Separators\" cellspacing=1 bgcolor=\"{$color["title"]}\">";
echo "<a name=\"$title\"></a>";
if( $altcount > "0" )
{
echo "<tr><td colspan=". ( $field_count - 1 ) . "><b>$title</b>";
}
else
{
echo "<tr><td colspan=". ( $field_count - 1 ) . "><b>Music</b>";
}
// If not sorting by 'Time' display the index, due to bugs in 'Time'/index
if( strcmp( $sort_array[0], "Time" ) && isset( $index ))
{
echo printIndex( $index, "", $index_key );
}
if( ! empty( $add_all ))
{
if( $use_javascript === true )
{
if( $count > 0 && $altcount > 0 )
{
echo " <small>(<a title=\"Add all songs from this music table to the active playlist\" ";
echo "href=\"javascript:document.add_all.submit()\">add all tagged/untagged</a>)</small>";
}
else
{
echo " <small>(<a title=\"Add all songs from this music table to the active playlist\" ";
echo "href=\"javascript:document.add_all.submit()\">add all</a>)</small>";
}
}
}
echo "</td>";
if( strcmp( $feature, "search" ) == "0" || strcmp( $feature, "find" ) == "0" )
{
echo "<td align=right><b><small>Found $count results</small></b></td>";
}
echo "</tr></table>";
echo "<table summary=\"Music\" cellspacing=1 bgcolor=\"{$color["body"][1]}\">";
if( isset( $sortbar ))
{
echo $sortbar;
}
for( $i = "0"; $i < $count; $i++ )
{
echo $print[$i];
}
echo "</td></tr></table>";
echo "</td></tr></table>";
}
else
{
return;
}
}
function printPlaylistTable( $color, $server, $info, $delete, $rmperm )
{
extract( $info );
if ( $count > "0" )
{
// Begin table for Title & Index
echo "<!-- Begin printPlaylistTable -->";
echo "<br>";
echo "<table summary=\"Playlist Title & Index\" cellspacing=1 bgcolor=\"{$color["title"]}\">";
echo "<tr><a name=playlists></a>";
echo "<td nowrap>";
echo "<b>Saved Playlists</b>";
printIndex( $index, "", "p" );
if( strcmp( $delete, "yes" ) && $rmperm == true )
{
echo " <small>(<a title=\"Goto Delete Playlist Menu\" href=\"index.php?body=main&delete=yes&server=$server#playlists\">delete</a>)</small>";
}
echo "</td></tr>";
echo "<tr><td>";
echo "<table summary=\"Playlist\" cellspacing=1 bgcolor=\"{$color["body"][0]}\">";
// Begin for playlist
for ( $i=0; $i < $count; $i++ )
{
echo "<tr bgcolor=\"{$color["body"][$i%2]}\">";
echo "<td>{$print[$i]}</td>";
echo "</tr>";
}
echo "</table>";
echo "</td></tr></table>";
}
}
function songInfo2Display( $song_info, $display, $display_separator, $filenames_only, $regex, $wordwrap )
{
$song_display_conf = NULL;
$song_display = NULL;
// If it's a URL don't grab it's basename
if( preg_match( "/^[a-z]*:\/\//", $song_info["file"] ))
{
$song = $song_info["file"];
}
else
{
$song = basename( $song_info["file"] );
}
if( $filenames_only !== true && isset( $song_info["Title"] ) && strlen( $song_info["Title"] ) > "0" )
{
// This will replace all song_display_conf stuff with the actual value
foreach( $song_info as $key => $value )
{
#display is (Artist) $key is Artist, $value is Dave Matthews Band
for( $i = "0"; $i < count( $display ); $i++ )
{
if( ! isset( $song_display_conf[$i] )) {
$song_display_conf[$i] = '';
}
if( strstr( $display[$i], $key ) && $value != NULL )
{
// Don't put the separator before the display
if( $i != 0 )
{
$song_display_conf[$i] .= $display_separator;
}
$song_display_conf[$i] .= str_replace( $key, $value, $display[$i] );
}
}
}
for( $i = "0"; $i < count( $display) ; $i++) {
$song_display .= $song_display_conf[$i];
}
}
else if( $filenames_only === true && isset( $song_info["Name"] ) && ( $song_info["Name"] > "0" ))
{
$song_display = $song_info["Name"];
}
else
{
// Let's not regex urls
if( ! preg_match( "/^(http|ftp|https):\/\/.*/", $song ))
{
if (is_array($regex["remove"])){
for( $i= "0"; $i < sizeOf( $regex["remove"] ); $i++ )
{
$song = str_replace( $regex["remove"][$i], '', $song );
}
}
if( $regex["space"] === true )
{
$song = str_replace( '_', ' ', $song );
}
if( $regex["uppercase_first"] === true )
{
$song = ucwords( $song );
}
}
$song_display = $song;
}
if( $wordwrap > "0" )
{
$song_display = wordwrap( $song_display, $wordwrap, "<br />", "1" );
}
return $song_display;
}
?>