Added Auth Log Functions.

- Added section organization.
- Added definitions for IP Addresses and Station ID's
- Added Content for Auth Logs.
This commit is contained in:
SWG: Resurgence
2019-09-06 09:52:23 -05:00
committed by GitHub
parent 78fd3f5b5a
commit a99621bc6b

View File

@@ -1,6 +1,19 @@
<?php
header('Content-Type: text/html; charset=utf-8');
// #######################################################################
// ####################### SET PHP ENVIRONMENT ###########################
// #######################################################################
ini_set('display_errors', 1);
date_default_timezone_set('America/Chicago');
include 'includes/db_connect.php';
// #######################################################################
// ########################### FUNCTIONS #################################
// #######################################################################
function getUserByEmailAndPassword($username, $password) {
global $mysqli;
$result = $mysqli->query("SELECT * FROM user_account WHERE username = '$username'") or die(mysql_error());
@@ -24,12 +37,23 @@ function checkhashSSHA($salt, $password) {
return $hash;
}
// #######################################################################
// ######################### POST GET ITEMS ##############################
// #######################################################################
$username = $mysqli->real_escape_string($_POST['user_name']);
$password = $mysqli->real_escape_string($_POST['user_password']);
$ip = urldecode($_POST['ip']);
$suid = urldecode($_POST['stationID']);
$user = getUserByEmailAndPassword($username, $password);
// #######################################################################
// ####################### FINAL GET ID ##################################
// #######################################################################
if ($user != false) {
if($user['accesslevel'] == "banned") {
$response['message'] = "Account banned";
$response['message'] = "Your account has been banned. For further information regarding the ban of your account or to submit a Ban Appeal, contact a member of CSR Staff.";
} else {
$response['message'] = "success";
}
@@ -38,4 +62,18 @@ else {
$response['message'] = "Account does not exist or password was incorrect";
}
echo json_encode($response);
// #######################################################################
// ####################### AUTHENTICATION LOGS ###########################
// #######################################################################
$auth_content = '[' . date('m/d/Y h:i:s a') . '] ' . 'Username: ' . $username . ', Station ID: ' . $suid . ', IP: ' . $ip . "\n";
chdir('WEBHOST_DIRECTORY_FOR_LOG_FILE ');
file_put_contents('logs/auth_log.txt', $auth_content, FILE_APPEND);
echo $result;
die();
// #######################################################################
// ####################### END OF FILE ###################################
// #######################################################################
?>