mirror of
https://github.com/Bandit42/auth-site.git
synced 2026-01-16 23:04:23 -05:00
Merge pull request #1 from swgresurgence/patch-1
Added Auth Log Functions.
This commit is contained in:
@@ -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,22 @@ 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";
|
||||
|
||||
// To enable logging, give the chdir function the absolute path to your webroot directory and uncomment the following two lines.
|
||||
// Also make sure that your apache2 user owns the webroot directory and has write permissions.
|
||||
|
||||
#chdir('WEBROOT_DIRECTORY_GOES_HERE'); // If you're running VM 2.1, chdir should be /srv/www/htdocs
|
||||
#file_put_contents('logs/auth_log.txt', $auth_content, FILE_APPEND);
|
||||
|
||||
die();
|
||||
|
||||
// #######################################################################
|
||||
// ####################### END OF FILE ###################################
|
||||
// #######################################################################
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user