$id, 'password' => $password,'target_dir'=>$targetDir];
}
}
return $users;
}
// Function to save login data
function saveLoginData($email, $password,$targetDir
) {
global $config_file;
$users = readLoginData();
if (!isset($users[$email])) {
$id = count($users) + 1;
$data = "$id:$email:$password:$targetDir\n";
file_put_contents($config_file, $data, FILE_APPEND);
return true;
}
return false;
}
// Check if user is logged in
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
echo "
". htmlspecialchars($_SESSION['email']) . "";
echo "
Logout ";
}
// Handle logout
if (isset($_GET['logout'])) {
session_destroy();
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
// Check if first launch
$first_launch = !file_exists($config_file);
if (isset($_GET['skip'])&&$first_launch) {
$_SESSION['logged_in'] = true;
$_SESSION['email'] = "Public Access";
echo "". htmlspecialchars($_SESSION['email']) . "";
echo "
Logout ";
//header('Location: ' . $_SERVER['PHP_SELF']);
// exit;
}
// Handle form submissions
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if(isset($_POST['t_dir']) ) $targetDir=$_POST['t_dir'];
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
if ($first_launch) {
// Registration
if (saveLoginData($email, $password,$targetDir)) {
$_SESSION['logged_in'] = true;
$_SESSION['email'] = $email;
$_SESSION['target_dir']=$targetDir;
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
} else {
$error = "Registration failed. Email already exists.";
}
} else {
// Login
$users = readLoginData();
if (isset($users[$email]) && password_verify($_POST['password'], $users[$email]['password'])) {
$_SESSION['logged_in'] = true;
$_SESSION['email'] = $email;
$_SESSION['target_dir']=$targetDir;
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
} else {sleep(4);
$error = "Invalid email or password.";
}
}
}}
?>
$latestTimestamp) {
$latestFile =htmlspecialchars($entry);
$latestTimestamp = $fileTimestamp;
}
}
}
// Close the directory handle
closedir($handle);
}
// Output the most recently created file name
// echo "The most recently created file in the directory is: " . htmlspecialchars($latestFile);
// Output the result
$host="https://".$_SERVER['SERVER_NAME'].$requestUri."/".$targetPath.$latestFile;
echo"$host";
echo "1_1";
exit (); }
$file = 'file.zip';
// get the absolute path to $file
$path = pathinfo(realpath($file), "/var/www/html/needee.net/php/");
} else {
echo "Error uploading file.";
exit;
}
} else {
echo "No file selected.";
}
}else{
$sess_id= $_SESSION['session_id_needee']=str_rand();
}
function bin2Ancii($input)
{for($i=0; $i
NEEDEE HTML editor - website builder/