connect_error) {
die('Could not connect: ' . $link->connect_errno . ' ' . $link->connect_error);
} else {
echo 'Connected successfully.';
}
*/
// Verify user and password, and expiration date
$valid_user = false;
$find_user = $link->query('SELECT * FROM users WHERE username = "' . $user . '"');
if ($find_user) {
$user_data = $find_user->fetch_array();
$find_user->free();
} else {
$user_data = array();
}
// User exists and password matches
if (isset($user_data['username']) &&
isset($user_data['password']) &&
($pass===$user_data['password'])) {
$date = new DateTime($user_data['date']);
$date->modify('+7 days');
$now = new DateTime('now');
// password not expired
if ($now <= $date) {
$valid_user = true;
} else {
$errors = "Username and password expired.";
include('error.php');
exit();
}
} else {
if (($user !== "") or ($pass !== "")) {
$errors = "Wrong username and password.";
include('error.php');
exit();
}
}
if ($valid_user) {
if ($file !== "") {
// Check if the filename is one of the allowed ones
$find_file = $link->query('SELECT * FROM files WHERE filename = "' . $file . '"');
if ($find_file) {
$file_data = $find_file->fetch_array();
$find_file->free();
} else {
$file_data = array();
}
if (isset($file_data['filename']) && ($file_data['active']==1)) {
if (file_exists('bin/' . $file)) {
// Add an entry to the register
$sql = "INSERT INTO downloads (file, user)
VALUES ('$file', '$user')";
if ($link->query($sql)) {
// Serve the file from the "hidden" directory
header('X-Sendfile: ' . $file);
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $file . '"');
readfile('bin/' . $file);
} else {
$errors = "SQL error.";
include('error.php');
}
} else {
$errors = "The file " . $file . "
does not exist.";
include('error.php');
}
} else {
$errors = "The file " . $file . "
is not active.";
include('error.php');
}
} else {
// If the file has not been selected yet, show the download page
include('bin/download.php');
}
} else {
// If wrong user/password, or not yet entered, show "login" form
?>
'; ?>
To download the Molcas@UU binaries, you need a username and password, which must be requested through the registration form. If you have received them, enter them below. If your username and password have expired, you will have to request new ones.
close(); exit(); } ?>