'; $searchquery = strtolower($searchquery); // Escape the regex special characters $searchquery = escapeRegex($searchquery); // Search in the directory $repertory = '../store/music/'; $scan = scandir($repertory); foreach($scan as $current) { // This file match our query! if(is_file($repertory.$current) && $current && preg_match('/(^|\s|\[)('.$searchquery.')(.+)?(\.(og(g|a)|mp3|wav))$/i', strtolower($current))) { // Get the basic informations $title = preg_replace('/^(.+)(\.)(og(g|a)|mp3|wav)$/i', '$1', $current); $url = $location.'store/music/'.$current; $ext = getFileExt($current); $id = md5($url); // Get the MIME type if($ext == 'mp3') $type = 'audio/mpeg'; else if($ext == 'wav') $type = 'audio/x-wav'; else $type = 'audio/ogg'; // Get the advanced informations $locked_title = $title; $artist = ''; $source = ''; $title_regex = '/^(([^-]+) - )?([^\[]+)( \[(.+))?$/i'; $artist_regex = '/^(.+) - (.+)$/i'; $source_regex = '/^(.+) \[(.+)\]$/i'; if(preg_match($title_regex, $locked_title)) $title = preg_replace($title_regex, '$3', $locked_title); if(preg_match($artist_regex, $locked_title)) $artist = preg_replace($artist_regex, '$1', $locked_title); if(preg_match($source_regex, $locked_title)) $source = preg_replace($source_regex, '$2', $locked_title); // Generate the XML $xml .= ''.htmlspecialchars($title).''.htmlspecialchars($artist).''.htmlspecialchars($source).''.htmlspecialchars($id).''.htmlspecialchars($url).''.$type.''; } } // End $xml .= ''; // Return the path to the file exit($xml); } ?>