= 1073741824)
{
$bytes = number_format($bytes / 1073741824, 2) . ' GB';
}
elseif ($bytes >= 1048576)
{
$bytes = number_format($bytes / 1048576, 2) . ' MB';
}
elseif ($bytes >= 1024)
{
$bytes = number_format($bytes / 1024, 2) . ' KB';
}
elseif ($bytes > 1)
{
$bytes = $bytes . ' bytes';
}
elseif ($bytes == 1)
{
$bytes = $bytes . ' byte';
}
else
{
$bytes = '0 bytes';
}
return $bytes;
}
?>
';
$files = array();
$filepath = "uploads/";
foreach (glob($filepath . "*.mp3") as $file) {
if(strpos($file,'inith') !== false){
$files[] = $file;
}
}
$count = 0;
$songlist = [];
$keyword = "";
if(isset($_GET['search']) == true && $_GET['search'] != ""){
$keyword = $_GET['search'];
$loweredkeyword = mb_strtolower($keyword);
foreach($files as $file) {
$ext = pathinfo($file, PATHINFO_EXTENSION);
$filename = str_replace("." . $ext,"",str_replace("inith","",basename($file)));
$filename = hex2bin($filename);
if (strpos(mb_strtolower($filename),$loweredkeyword) !== false){
array_push($songlist,[$file,$filename,$count]);
$box = str_replace("%AUDIO_FILE_NAME%",$filename,$template);
$box = str_replace("%FILE_SIZE%",formatSizeUnits(filesize($file)),$box);
$box = str_replace("%RAW_FILENAME%",$file,$box);
$box = str_replace("%ID%","AudioID" + (string)$count,$box);
echo $box;
$count += 1;
}
}
if ($count == 0){
//No Search Results
echo '';
}
}else{
foreach($files as $file) {
$ext = pathinfo($file, PATHINFO_EXTENSION);
$filename = str_replace("." . $ext,"",str_replace("inith","",basename($file)));
$filename = hex2bin($filename);
array_push($songlist,[$file,$filename,$count]);
$box = str_replace("%AUDIO_FILE_NAME%",$filename,$template);
$box = str_replace("%FILE_SIZE%",formatSizeUnits(filesize($file)),$box);
$box = str_replace("%RAW_FILENAME%",$file,$box);
$box = str_replace("%ID%","AudioID" + (string)$count,$box);
echo $box;
$count += 1;
}
}
?>
Audio Module / Background Worker Unit