function validate_input($input) { $input = trim($input); $input = htmlspecialchars($input); $input = stripcslashes($input); $input = stripScripts($input); return $input; }
$playerID = ""; $fp = ""; $file = ""; $rooturl = preg_replace("/^www\\./i", "", $_SERVER['HTTP_HOST']); if (isset($_GET['mp3'])) { // Clean the url/path $mp3 = strip_tags($_GET['mp3']); $mp3 = rawurldecode($mp3); $mp3 = stripScripts($mp3); $sent = substr($mp3, 3); if (!checkCharsOK($sent)) { die; } // Clean player ID $playerID = isset($_GET['pID']) ? strip_tags($_GET['pID']) : ""; $playerID = stripScripts($playerID); $playerID = preg_replace('![^0-9]!', '', $playerID); if ($playerID == '') { die; } // Check it's a valid file type $matches = array(); if (preg_match("!\\.(mp3|mp4|m4a|ogg|oga|wav|webm)\$!i", $mp3, $matches)) { // Decide the mime type $fileExtension = $matches[0]; if ($fileExtension === 'mp3' || $fileExtension === 'mp4' || $fileExtension === 'm4a') { $mimeType = 'audio/mpeg'; } elseif ($fileExtension === 'ogg' || $fileExtension === 'oga') { $mimeType = 'audio/ogg'; } else { $mimeType = 'audio/' . str_replace('.', '', $fileExtension);