-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from TEAM-7-SAD/SPD-82-preloader
Spd 82 preloader
- Loading branch information
Showing
32 changed files
with
279 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Ignore | ||
src/includes/error-logs.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
include_once str_replace('/', DIRECTORY_SEPARATOR, 'file-utilities.php'); | ||
include_once FileUtils::normalizeFilePath('default-timezone.php'); | ||
|
||
error_reporting(E_ALL); | ||
ini_set("display_errors", 0); | ||
|
||
function logErrors($errno, $errstr, $errfile, $errline) { | ||
|
||
// Relative file path | ||
$log_directory = __DIR__ . "/error-logs.txt"; | ||
$timestamp = date('Y-m-d g:i a'); | ||
$log_message = "$timestamp Error: [$errno] $errstr - $errfile: $errline"; | ||
error_log($log_message . PHP_EOL, 3, $log_directory); | ||
|
||
} | ||
|
||
set_error_handler("logErrors"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* File function utilities. | ||
* | ||
*/ | ||
class FileUtils | ||
{ | ||
/** | ||
* Replace forward slashes with appropriate directory separator in a file path for current operating system. | ||
* | ||
* @param string $path The file path to transform. | ||
* @return string The transformed file path. | ||
*/ | ||
public static function normalizeFilePath($path) | ||
{ | ||
|
||
return str_replace('/', DIRECTORY_SEPARATOR, $path); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
include_once str_replace('/', DIRECTORY_SEPARATOR, 'file-utilities.php'); | ||
require_once FileUtils::normalizeFilePath('session-handler.php'); | ||
require_once FileUtils::normalizeFilePath('db-connector.php'); | ||
include_once FileUtils::normalizeFilePath('error-reporting.php'); | ||
|
||
if(isset($_POST['sign_in_btn'])) { | ||
|
||
$username = $_POST['username']; | ||
$password = $_POST['password']; | ||
|
||
if(empty($username) || empty($password)) { | ||
$_SESSION['error_message'] = 'Please do not leave the input fields empty.'; | ||
header("Location: ../login.php"); | ||
exit(); | ||
} | ||
|
||
// Query the user table for the entered username | ||
$stmt = $db->prepare("SELECT id, username, password FROM user WHERE BINARY username = ?"); | ||
$stmt->bind_param('s', $username); | ||
$stmt->execute(); | ||
$result = $stmt->get_result(); | ||
|
||
// Check if a user of this username exists | ||
if($result->num_rows > 0) { | ||
$row = $result->fetch_assoc(); | ||
|
||
// Verify if password match the entered username | ||
if (password_verify($password, $row['password'])) { | ||
$_SESSION['id'] = $row['id']; | ||
session_regenerate_id(true); | ||
header("location: ../index.php"); | ||
exit(); | ||
} | ||
// If username and password mismatched, display this | ||
else { | ||
$_SESSION['error_message'] = 'Username and password mismatched.'; | ||
header("Location: ../login.php"); | ||
exit(); | ||
} | ||
} | ||
// If there is no user with the username, display this | ||
else { | ||
$_SESSION['error_message'] = 'User is not found.'; | ||
header("Location: ../login.php"); | ||
exit(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
include_once str_replace('/', DIRECTORY_SEPARATOR, 'file-utilities.php'); | ||
require_once FileUtils::normalizeFilePath('session-handler.php'); | ||
include_once FileUtils::normalizeFilePath('error-reporting.php'); | ||
|
||
session_destroy(); | ||
header("location: ../login.php"); | ||
exit(); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="spinner-wrapper"> | ||
<div class="spinner-border text-tiger-orange" role="status"> | ||
<span class="visually-hidden"></span> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.