include('head.inc.php') ; $file = $_SERVER['QUERY_STRING'] ; $login = isset($_SESSION['login']) ? $_SESSION['login'] : "no" ; if($_POST['login_submit'] == 'Login') { $user = $_POST['login_user'] ; $pw = $_POST['login_password'] ; $res = query("SELECT password FROM request WHERE username='$user'") ; if(count($res) == 0 || $res[0]['password'] != crypt($pw, $res[0]['password'])) $login = "failure" ; else $login = "success" ; $_SESSION['login'] = $login ; } if($login == "success") { if (file_exists("files/$file")) { header('Content-Description: File Transfer') ; header('Content-Type: application/octet-stream') ; header('Content-Disposition: attachment; filename='.$file) ; header('Content-Transfer-Encoding: binary') ; header('Expires: 0') ; header('Cache-Control: must-revalidate, post-check=0, pre-check=0') ; header('Pragma: public') ; header('Content-Length: ' . filesize("files/$file")) ; ob_clean() ; flush() ; readfile("files/$file") ; exit ; } else { header('HTTP/1.0 404 Not Found') ; ?>