prepare("SELECT id, exten_for_external, exten_for_ext_pass, conf_extension FROM external_users WHERE exten_for_external = ? AND exten_for_ext_pass = ? AND conf_extension = ?"); $query->bind_param("sss", $vconfExtension, $extenPassEnc, $recSipUser); $query->execute(); $extqueryres = $query->get_result()->fetch_array(); if (!$extqueryres) { http_response_code(400); exit(); } else { // Process the download if (is_file($fileToDownload)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($fileToDownload) . '"'); header('Expires: 0'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($fileToDownload)); flush(); readfile($fileToDownload); exit(); } else { http_response_code(404); exit(); } } } else { header("Location: ../login.php"); } ?>