<?php
function validate_filename($subdir,$artist_name,$album_title,$track,$song_title,$file_extension)
{
global $musiclib;
if ($musiclib['config']['filename_format'] == 2)
{
$filename = $musiclib['config']['music_path'].$subdir."/"
.$artist_name."/".$album_title."/"
.$track.$musiclib['config']['separator']
.$song_title.".".$file_extension;
}
else
{
$filename = $musiclib['config']['music_path'].$subdir."/"
.$artist_name."/".$album_title."/"
.$track.$musiclib['config']['separator']
.$artist_name.$musiclib['config']['separator']
.$song_title.".".$file_extension;
}
$validation = file_exists($filename);
if ($validation == false)
{
echo $filename." Failed Validation.<br />Check that filename is formatted correctly.<br />";
}
return $validation;
}
function validate_misc_filename($subdir,$path,$filename,$file_extension)
{
global $musiclib;
$file = $musiclib['config']['music_path'].$subdir."/".$path."/".$filename.".".$file_extension;
$validation = file_exists($file);
if ($validation == false)
{
echo $file." Failed Validation.<br />Check that filename is formatted correctly.<br />";
}
return $validation;
}
function generate_filename($mode,$row)
{
global $musiclib;
/* if ($row['repository'] == '2' or $mode == 'misc')
{
*/
if ($row['path'])
{
$filename = '/'.$row['path'].'/'.$row['filename'].'.'.$row['file_extension'];
}
else
{
$filename = '/'.$row['filename'].'.'.$row['file_extension'];
}
/*
}
else
{
if ($musiclib['config']['filename_format'] == 2)
{
$filename = '/'.$row['artist_name'].'/'.$row['album_title'].'/'
.$row['track'].$musiclib['config']['separator']
.$row['song_title'].'.'.$row['file_extension'];
}
else
{
$filename = '/'.$row['artist_name'].'/'.$row['album_title'].'/'
.$row['track'].$musiclib['config']['separator']
.$row['artist_name'].$musiclib['config']['separator']
.$row['song_title'].'.'.$row['file_extension'];
}
}
*/
return $filename;
}
function pick_library()
{
global $musiclib;
// Check user prefs
# to be implemented
if (!$user_pref)
{
$libraries = explode(' ',$musiclib['config']['libraries']);
return $libraries[0];
}
}
function generate_music_url($mode,$row)
{
global $musiclib;
if ($row['repository'] == '2' or $mode == 'misc')
{
$filename = str_replace(" ","%20",$musiclib['config']['music_url']
.'/'.$musiclib['config']['misc_subdir']
.generate_filename($mode,$row));
}
else
{
$filename = str_replace(" ","%20",$musiclib['config']['music_url']
.'/'.$musiclib['config']['albums_subdir']
.generate_filename($mode,$row));
}
return $filename;
}
function listAlbums($query, $showNumbers, $showTimesPlayed)
{
global $musiclib;
global $PHP_SELF;
global $REQUEST_URI;
global $action;
global $searchFor;
global $beginningWith;
global $startAt;
global $listAll;
global $genre;
global $status;
global $songsperpage;
$searchFor = stripslashes($searchFor);
if (!eregi("LIMIT", $query)) {
$result = $GLOBALS['phpgw']->db->query($query,__LINE__,__FILE__);
$NumberRows = $GLOBALS['phpgw']->db->num_rows();
if (!isset($startAt)) $startAt = "0";
if (isset($action)) $extraArg .= "&action=$action";
if (isset($searchFor)) $extraArg .= "&searchFor=" . urlencode($searchFor);
if (isset($beginningWith)) $extraArg .= "&beginningWith=$beginningWith";
if (isset($listAll)) $extraArg .= "&listAll=$listAll";
# if (isset($genre)) $extraArg .= "&genre=$genre";
if (!isset($songsperpage)) $songsperpage = 50;
if ($startAt >= $songsperpage)
{
$prevLink = "<a href=\"";
$prevLink .= $GLOBALS['phpgw']->link($PHP_SELF,"startAt=".($startAt-$songsperpage).$extraArg);
$prevLink .= "\">Previous Page <<</a> ";
}
if (($startAt + $songsperpage) < $NumberRows)
{
$nextLink = " <a href=\"";
$nextLink .= $GLOBALS['phpgw']->link($PHP_SELF,"startAt=".($startAt+$songsperpage).$extraArg);
$nextLink .= "\">>> Next Page</a>";
}
if (($startAt + $songsperpage) > $NumberRows)
{
$stopAt = $NumberRows;
}
else
{
$stopAt = ($startAt + $songsperpage);
}
#$query .= " LIMIT $startAt, $songsperpage";
#echo "<h2>Showing records $startAt to $stopAt of $NumberRows records found</h2>";
#$navText = "<p class=navText\">$prevLink $nextLink</p>";
}
#echo $navText;
$result = $GLOBALS['phpgw']->db->query($query,__LINE__,__FILE__);
$NumberRows = $GLOBALS['phpgw']->db->num_rows();
# echo "<br> NumberRows: ".$NumberRows;
if ($NumberRows == "0")
{
echo "<h2>Nothing found</h2>";
return;
}
else
{
echo "<FORM name=listform action=".$GLOBALS['phpgw']->link("/musiclib/add_to_playlist.php","mode=album")." method=\"post\">";
echo "<table cellpadding=3 border=0 cellspacing=1>\n";
echo "<tr>\n";
# if ($showNumbers == "yes") { echo "<th>Nr</th>\n"; }
echo "<th><sub>[Add to<br>Playlist]</sub></th>";
echo "<th>Artist<br><sub>[Search by Artist]</sub></th>\n";
echo "<th>Album<br><sub>[Show Songs on Album]</sub></th>\n";
echo "<th>Listen</th>\n";
//if ($showTimesPlayed == "yes") { echo "<th>Times Played</th>\n"; }
#echo "<th>Vote</th>\n";
#echo "<th>CD #</th>\n";
echo "</tr>\n";
}
$count=0;
while($GLOBALS['phpgw']->db->next_record())
{
$row = $GLOBALS['phpgw']->db->Record;
$count++;
if ($row['album_id'])
{
$album_id = $row['album_id'];
}
else
{
$album_id = $row['id'];
}
$artist_id = $row['artist_id'];
$artist = $row['artist_name'];
$album = $row['album_title'];
$times_played = $row['times_played'];
$listed_nr++;
/*
$kiesKleurtje = $kiesKleurtje + 0.5;
if ($kiesKleurtje == (int) $kiesKleurtje) {
$bgcolor = "#c0c0c0";
} else {
$bgcolor = "#dfdfdf";
}
*/
# print_r($row);
echo "<tr><td align=center>\n
<INPUT name=\"add_to_playlist_array[]\" type=\"checkbox\" ;
value=\"".$album_id."\" tabindex=\"".$count."\"></td>\n";
echo "<td><a href=".$GLOBALS['phpgw']->link("/musiclib/searches.php"
,"action=doSearch&id=".$artist_id."&search=songartistid&artist=".urlencode($artist))
.">$artist</a></td>
<td><a href=".$GLOBALS['phpgw']->link("/musiclib/searches.php"
,"action=doSearch&search=songalbumid&id=".$album_id."&artist=".urlencode($artist)."&album=".urlencode($album))
.">$album</a></td>
<td><a href=".$GLOBALS['phpgw']->link("/musiclib/listen.php"
,"mode=album&id=".$album_id)
.">(Listen to Album)</a></td></tr>";
//if ($showTimesPlayed == "yes") { echo "<td>$timesPlayed</td>\n"; }
/* $voteUrl = "voteFor=$song_id";
$voteUrl = "$PHP_SELF?$voteUrl";
if (isset($action)) $voteUrl .= "&action=$action";
if (isset($aantal)) $voteUrl .= "&aantal=$aantal";
if (isset($genre)) $voteUrl .= "&genre=$genre";
if (isset($searchFor)) $voteUrl .= "&searchFor=" . urlencode($searchFor);
if (isset($beginningWith)) $voteUrl .= "&beginningWith=$beginningWith";
if (isset($listAll)) $voteUrl .= "&listAll=$listAll";
if (isset($startAt)) $voteUrl .= "&startAt=$startAt";
*/
#echo "<td><a title=\"$filename\" href=\"$voteUrl\">Vote</a>";
// this is the CD Number option
//echo "<td>";
//if (isset($cd_number))
//{
// echo "$cd_number<br>";
//}
//include("config.inc.php");
//$accountid = get_account_id();
//if ($accountid == $admin1 or $accountid == $admin2)
//if ($status > 1)
//{
// echo "[";
// echo "<a href=\"admin_del_from_db.php?song_id=$song_id\" title=\"Delete\">Delete</a>";
// echo "]";
// echo "<br>[";
// echo "<a href=\"admin_edit_record.php?song_id=$song_id\" title=\"Edit\">Edit</a>";
// echo "]</td>\n";
//}
}
print_checkall_js();
print_checkall_options();
echo "<tr><td colspan=2>Playist: ";
print_playlist_selectbox();
echo "</td>";
echo "<td colspan=2><BUTTON name=\"submit\" value=\"submit\" type=SUBMIT>
Add to Playlist</BUTTON>
<BUTTON name=\"reset\" type=\"RESET\">
Clear</BUTTON></td>";
echo "</tr></table><br>";
echo "</form>";
echo $navText;
}
function listSongs($query, $showNumbers, $showTimesPlayed)
{
global $musiclib;
global $PHP_SELF;
global $REQUEST_URI;
global $action;
global $search;
global $searchFor;
global $beginningWith;
global $startAt;
global $listAll;
global $genre;
global $status;
global $songsperpage;
$searchFor = stripslashes($searchFor);
if (!eregi("LIMIT", $query))
{
$result = $GLOBALS['phpgw']->db->query($query,__LINE__,__FILE__);
$NumberRows = $GLOBALS['phpgw']->db->num_rows();
if (!isset($startAt)) $startAt = "0";
if (isset($action)) $extraArg .= "&action=$action";
if (isset($searchFor)) $extraArg .= "&searchFor=" . urlencode($searchFor);
if (isset($beginningWith)) $extraArg .= "&beginningWith=$beginningWith";
if (isset($listAll)) $extraArg .= "&listAll=$listAll";
if (isset($genre)) $extraArg .= "&genre=$genre";
if (!isset($songsperpage)) $songsperpage = 50;
if ($startAt >= $songsperpage)
{
$prevLink = "<a href=\"";
$prevLink .= $GLOBALS['phpgw']->link($PHP_SELF,"startAt=".($startAt-$songsperpage).$extraArg);
$prevLink .= "\">Previous Page <<</a> ";
}
if (($startAt + $songsperpage) < $NumberRows)
{
$nextLink = " <a href=\"";
$nextLink .= $GLOBALS['phpgw']->link($PHP_SELF,"startAt=".($startAt+$songsperpage).$extraArg);
$nextLink .= "\">>> Next Page</a>";
}
if (($startAt + $songsperpage) > $NumberRows)
{
$stopAt = $NumberRows;
}
else
{
$stopAt = ($startAt + $songsperpage);
}
# This was removed to prevent page overflow
#$query .= " LIMIT $startAt, $songsperpage";
#echo "<h2>Showing records $startAt to $stopAt of $NumberRows records found</h2>";
#$navText = "<p class=navText\">$prevLink $nextLink</p>";
}
#echo $navText;
$result = $GLOBALS['phpgw']->db->query($query,__LINE__,__FILE__);
$NumberRows = $GLOBALS['phpgw']->db->num_rows();
if ($NumberRows == "0") {
echo "<h2>Nothing found</h2>";
return;
} else {
# this prints the javascript necessary to use check/uncheck all
print_checkall_js();
echo "<FORM name=listform action=".$GLOBALS['phpgw']->link("/musiclib/add_to_playlist.php","mode=song")." method=\"post\">";
echo "<table cellpadding=3 border=0 cellspacing=1>\n";
echo "<INPUT name=\"searchFor\" type=\"hidden\"
value=\"".$searchFor."\"></td>\n";
echo "<INPUT name=\"search\" type=\"hidden\"
value=\"".$search."\"></td>\n";
echo "<tr>\n";
# if ($showNumbers == "yes") { echo "<th>Nr</th>\n"; }
echo "<th><sub>[Add to<br>Playlist]</sub></th>";
echo "<th>Artist<br><sub>[Search by Artist]</sub></th>";
echo "<th>Album<br><sub>[Listen to Album]</sub></th>";
echo "<th>Track #</th>\n";
echo "<th>Song Title<br><sub>[Listen to Song]</sub></th>";
//if ($showTimesPlayed == "yes") { echo "<th>Times Played</th>\n"; }
#echo "<th>Vote</th>\n";
#echo "<th>CD #</th>\n";
echo "</tr>\n";
}
$count = 0;
while($GLOBALS['phpgw']->db->next_record()) {
$row = $GLOBALS['phpgw']->db->Record;
$count++;
$song_id = $row['id'];
$album_id = $row['album_id'];
$artist_id = $row['artist_id'];
$artist = $row['artist_name'];
$album = $row['album_title'];
$song_title = $row['song_title'];
$times_played = $row['times_played'];
$track = $row['track'];
# $listed_nr++;
/*
$kiesKleurtje = $kiesKleurtje + 0.5;
if ($kiesKleurtje == (int) $kiesKleurtje)
{
$bgcolor = "#c0c0c0";
}
else
{
$bgcolor = "#dfdfdf";
}
*/
echo "<tr>\n";
# if ($showNumbers == "yes") { echo "<td>$listed_nr</td>\n"; }
echo "<td align=center>\n
<INPUT name=\"add_to_playlist_array[]\" type=\"checkbox\" ;
value=\"".$song_id."\" tabindex=\"".$count."\"></td>\n";
echo "<td><a href=\"";
echo $GLOBALS['phpgw']->link("/musiclib/searches.php"
,"action=doSearch&id=".$artist_id."&search=albumartistid&artist=".urlencode($artist));
echo "\">$artist</a></td>\n";
echo "<td><a href=".$GLOBALS['phpgw']->link("/musiclib/listen.php"
,"mode=album&id=".$album_id)
.">$album</a></td>\n";
echo "<td>$track</td>\n";
echo "<td><a href=".$GLOBALS['phpgw']->link("/musiclib/listen.php","mode=song&id=".$song_id)
.">$song_title</a></td>\n";
///if ($showTimesPlayed == "yes") { echo "<td>$timesPlayed</td>\n"; }
// this is the CD Number option
//echo "<td>";
//if (isset($cd_number))
//{
// echo "$cd_number<br>";
//}
//include("config.inc.php");
//$accountid = get_account_id();
//if ($accountid == $admin1 or $accountid == $admin2)
//if ($status > 1)
//{
// echo "[";
// echo "<a href=\"admin_del_from_db.php?song_id=$song_id\" title=\"Delete\">Delete</a>";
// echo "]";
// echo "<br>[";
// echo "<a href=\"admin_edit_record.php?song_id=$song_id\" title=\"Edit\">Edit</a>";
// echo "]</td>\n";
//}
echo "</tr>\n";
}
echo "</table>";
echo "<table>";
print_checkall_options();
echo "<tr><td>Playist: ";
print_playlist_selectbox();
echo "</td>";
echo "<td><BUTTON name=\"submit\" value=\"submit\" type=SUBMIT>
Add to Playlist</BUTTON>
<BUTTON name=\"reset\" type=\"RESET\">
Clear</BUTTON></td>";
echo "</tr></table><br>";
echo "</form>";
echo $navText;
}
function list_music($mode,$table,$query, $showNumbers, $showTimesPlayed)
{
global $musiclib;
global $PHP_SELF;
global $REQUEST_URI;
global $action;
global $search;
global $searchFor;
global $beginningWith;
global $startAt;
global $listAll;
global $genre;
global $status;
global $songsperpage;
$searchFor = stripslashes($searchFor);
if (!eregi("LIMIT", $query))
{
$result = $GLOBALS['phpgw']->db->query($query,__LINE__,__FILE__);
$NumberRows = $GLOBALS['phpgw']->db->num_rows();
if (!isset($startAt)) $startAt = "0";
if (isset($action)) $extraArg .= "&action=$action";
if (isset($searchFor)) $extraArg .= "&searchFor=" . urlencode($searchFor);
if (isset($beginningWith)) $extraArg .= "&beginningWith=$beginningWith";
if (isset($listAll)) $extraArg .= "&listAll=$listAll";
if (isset($genre)) $extraArg .= "&genre=$genre";
if (!isset($songsperpage)) $songsperpage = 50;
if ($startAt >= $songsperpage)
{
$prevLink = "<a href=\"";
$prevLink .= $GLOBALS['phpgw']->link($PHP_SELF,"startAt=".($startAt-$songsperpage).$extraArg);
$prevLink .= "\">Previous Page <<</a> ";
}
if (($startAt + $songsperpage) < $NumberRows)
{
$nextLink = " <a href=\"";
$nextLink .= $GLOBALS['phpgw']->link($PHP_SELF,"startAt=".($startAt+$songsperpage).$extraArg);
$nextLink .= "\">>> Next Page</a>";
}
if (($startAt + $songsperpage) > $NumberRows)
{
$stopAt = $NumberRows;
}
else
{
$stopAt = ($startAt + $songsperpage);
}
# This was removed to prevent page overflow
#$query .= " LIMIT $startAt, $songsperpage";
#echo "<h2>Showing records $startAt to $stopAt of $NumberRows records found</h2>";
#$navText = "<p class=navText\">$prevLink $nextLink</p>";
}
#echo $navText;
$result = $GLOBALS['phpgw']->db->query($query,__LINE__,__FILE__);
$NumberRows = $GLOBALS['phpgw']->db->num_rows();
if ($NumberRows == "0") {
echo "<h2>Nothing found</h2>";
return;
} else {
# this prints the javascript necessary to use check/uncheck all
print_checkall_js();
echo "<FORM name=listform action=".$GLOBALS['phpgw']->link("/musiclib/add_to_playlist.php","mode=".$mode)." method=\"post\">";
echo "<table class=music cellpadding=3 border=0 cellspacing=1>\n";
echo "<INPUT name=\"searchFor\" type=\"hidden\"
value=\"".$searchFor."\"></td>\n";
echo "<INPUT name=\"search\" type=\"hidden\"
value=\"".$search."\"></td>\n";
echo "<tr>\n";
# if ($showNumbers == "yes") { echo "<th>Nr</th>\n"; }
switch ($mode)
{
case 'song':
echo "<th><sub>[Add to<br>Playlist]</sub></th>";
echo "<th>Artist<br><sub>[Search by Artist]</sub></th>";
echo "<th>Album<br><sub>[Listen to Album]</sub></th>";
echo "<th>Track #</th>\n";
echo "<th>Song Title<br><sub>[Listen to Song]</sub></th>";
break;
case 'album':
echo "<th><sub>[Add to<br>Playlist]</sub></th>";
echo "<th>Artist<br><sub>[Search by Artist]</sub></th>\n";
echo "<th>Album<br><sub>[Show Songs on Album]</sub></th>\n";
echo "<th>Listen</th>\n";
break;
case 'misc':
echo "<th><sub>[Add to<br>Playlist]</sub></th>";
echo "<th>Path<br><sub>[Browse Path]</sub></th>\n";
echo "<th>Filename<br><sub>[Listen]</sub></th>\n";
}
//if ($showTimesPlayed == "yes") { echo "<th>Times Played</th>\n"; }
echo "</tr>\n";
}
$count = 0;
while($GLOBALS['phpgw']->db->next_record())
{
$row = $GLOBALS['phpgw']->db->Record;
$count++;
switch ($mode)
{
case 'song':
$song_id = $row['id'];
$album_id = $row['album_id'];
$artist_id = $row['artist_id'];
$artist = $row['artist_name'];
$album = $row['album_title'];
$song_title = $row['song_title'];
$times_played = $row['times_played'];
$track = $row['track'];
break;
case 'album':
if ($row['album_id'])
{
$album_id = $row['album_id'];
}
else
{
$album_id = $row['id'];
}
$artist_id = $row['artist_id'];
$artist = $row['artist_name'];
$album = $row['album_title'];
$times_played = $row['times_album_played'];
break;
case 'misc':
$id = $row['id'];
$path = $row['path'];
$filename = $row['filename'];
$file_extension = $row['file_extension'];
$times_played = $row['times_played'];
}
echo "<tr>\n";
# if ($showNumbers == "yes") { echo "<td>$listed_nr</td>\n"; }
if ($mode == 'misc')
{
echo "<td align=center>\n
<INPUT name=\"add_to_playlist_array[]\" type=\"checkbox\"
value=\"".$id."\" tabindex=\"".$count."\"></td>\n";
}
else if ($mode =='album')
{
echo "<td align=center>\n
<INPUT name=\"add_to_playlist_array[]\" type=\"checkbox\"
value=\"".$album_id."\" tabindex=\"".$count."\"></td>\n";
}
else
{
echo "<td align=center>\n
<INPUT name=\"add_to_playlist_array[]\" type=\"checkbox\"
value=\"".$song_id."\" tabindex=\"".$count."\"></td>\n";
}
switch ($mode)
{
case 'song':
echo "<td><a href=\"";
echo $GLOBALS['phpgw']->link("/musiclib/searches.php"
,"mode=album&action=doSearch&id=".$artist_id."&search=albumartistid&artist=".urlencode($artist));
echo "\">$artist</a></td>\n";
echo "<td><a href=".$GLOBALS['phpgw']->link("/musiclib/listen.php"
,"mode=album&id=".$album_id)
.">$album</a></td>\n";
echo "<td>$track</td>\n";
echo "<td><a href=".$GLOBALS['phpgw']->link("/musiclib/listen.php","mode=song&id=".$song_id)
.">$song_title</a></td>\n";
break;
case 'album':
echo "<td><a href=".$GLOBALS['phpgw']->link("/musiclib/searches.php"
,"mode=song&action=doSearch&id=".$artist_id."&search=songartistid&artist=".urlencode($artist))
.">$artist</a></td>
<td><a href=".$GLOBALS['phpgw']->link("/musiclib/searches.php"
,"mode=song&action=doSearch&search=songalbumid&id=".$album_id."&artist=".urlencode($artist)."&album=".urlencode($album))
.">$album</a></td>
<td><a href=".$GLOBALS['phpgw']->link("/musiclib/listen.php"
,"mode=album&id=".$album_id)
.">(Listen to Album)</a></td></tr>";
break;
case 'misc':
echo "<td><a href=".$GLOBALS['phpgw']->link("/musiclib/searches.php"
,"mode=misc&action=doSearch&search=miscpath&searchFor=".urlencode($path))
.">";
if (!$path)
{
echo "/";
}
else
{
echo $path;
}
echo "</a></td><td><a href=".$GLOBALS['phpgw']->link("/musiclib/listen.php"
,"mode=misc&id=".$id)
.">".$filename."</a></td></tr>";
}
///if ($showTimesPlayed == "yes") { echo "<td>$times_played</td>\n"; }
echo "</tr>\n";
}
echo "</table>";
echo "<table>";
print_checkall_options();
echo "<tr><td>Playist: ";
print_playlist_selectbox();
echo "</td>";
?>
<input type="hidden" name="search" value="<? echo $search; ?>">
<input type="hidden" name="searchFor" value="<? echo $searchFor; ?>">
<input type="hidden" name="action" value="<? echo $action; ?>">
<?php
echo "<td><BUTTON name=\"submit\" value=\"submit\" type=SUBMIT>
Add to Playlist</BUTTON>
<BUTTON name=\"reset\" type=\"RESET\">
Clear</BUTTON></td>";
echo "</tr></table><br>";
echo "</form>";
echo $navText;
}
function count_table($repository,$table)
{
global $musiclib;
if ($table == $musiclib['tables']['songs']) {
$query = "SELECT COUNT(*) FROM ".$table." WHERE repository=".$repository;
} else {
$query = "SELECT COUNT(*) FROM ".$table;
}
$result = $GLOBALS['phpgw']->db->query($query,__LINE__,__FILE__);
$GLOBALS['phpgw']->db->next_record();
$row = $GLOBALS['phpgw']->db->Record;
return $row[0];
}
function misc_data_file_split($musicfile)
{
global $musiclib;
$musicfile = addslashes($musicfile);
# echo $musicfile."<br>";
$filenameSplit = split("/", $musicfile);
$filenameWithoutPath = $filenameSplit[sizeOf($filenameSplit)-1];
$filenameWithoutPathSplit = split('\.', $filenameWithoutPath);
# print_r($filenameSplit);
# echo "\n<b>$filenameWithoutPath</b>\n";
# echo "\n<b>$filenameWithoutPathSplit[0]</b>\n";
# echo "\n<b>$filenameWithoutPathSplit[1]</b>\n";
# form path
for ($i=3;$i < count($filenameSplit)-1; $i++)
{
if (!$misc_data['path'])
{
$misc_data['path'] = $filenameSplit[$i];
}
else
{
$misc_data['path'] .= "/".$filenameSplit[$i];
}
}
# form filename
for ($i=0;$i < count($filenameWithoutPathSplit)-1; $i++)
{
if (!$misc_data['filename'])
{
$misc_data['filename'] = $filenameWithoutPathSplit[$i];
}
else
{
$misc_data['filename'] .= ".".$filenameWithoutPathSplit[$i];
}
}
$misc_data['file_extension'] = $filenameWithoutPathSplit[sizeOf($filenameWithoutPathSplit)-1];
return $misc_data;
}
function music_data_file_split($musicfile)
{
global $musiclib;
# this gets us the path, filename and file_extension
$music_data = misc_data_file_split($musicfile);
$musicfile = addslashes($musicfile);
$filenameSplit = split("/", $musicfile);
$music_data['artist'] = substr($filenameSplit[3],0);
$music_data['album'] = substr($filenameSplit[4],0);
# echo $artist[$n]." - ".$album[$n];
# $splitSong = split($musiclib['config']['separator'], $music_data['filename']);
# print_r($splitSong);
// 01 - Artist - Song.mp3
if (substr_count($music_data['filename'],$musiclib['config']['separator']) >= 2)
{
$splitSong = split($musiclib['config']['separator'],$music_data['filename'],3);
$music_data['track'] = substr($splitSong[0], 0);
$music_data['song_title'] = substr($splitSong[2], 0);
}
// 01-Artist-Song.mp3
else if (substr_count($music_data['filename'],trim($musiclib['config']['separator'])) >= 2)
{
$splitSong = split(trim($musiclib['config']['separator']),$music_data['filename'],3);
$music_data['track'] = substr($splitSong[0], 0);
$music_data['song_title'] = substr($splitSong[2], 0);
}
// 01 - Song.mp3
else if (substr_count($music_data['filename'],$musiclib['config']['separator']) >= 1)
{
$splitSong = split($musiclib['config']['separator'],$music_data['filename'],2);
$music_data['track'] = substr($splitSong[0], 0);
$music_data['song_title'] = substr($splitSong[1], 0);
}
// 01-Song.mp3
else if (substr_count($music_data['filename'],trim($musiclib['config']['separator'])) >= 1)
{
$splitSong = split(trim($musiclib['config']['separator']),$music_data['filename'],2);
$music_data['track'] = substr($splitSong[0], 0);
$music_data['song_title'] = substr($splitSong[1], 0);
}
else
{
echo 'Filename could not be split correctly: '.$musicfile;
$music_data = false;
}
#print_r($music_data);
return $music_data;
}
?>