Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-3.0-05-17-21' into relea…
Browse files Browse the repository at this point in the history
…se-3.0-05-17-21
  • Loading branch information
tnathu-ai committed May 17, 2021
2 parents c5d62f9 + 3e76384 commit d2800f2
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
1 change: 1 addition & 0 deletions private/logs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

8 changes: 8 additions & 0 deletions private/reg-validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ function verify_password($credential, $verify_pwd): bool {
}


/**
* Remove all non-digit characters in phone number
* @param string $tel
* phone number
* @return string
* phone number with only digits
*/
function remove_chars_tel(string $tel): string {
return preg_replace("/-|[.]| /", "", $tel);
}
Expand All @@ -129,6 +136,7 @@ function remove_chars_tel(string $tel): string {
function unique_registration(array $data, string $email, string $tel, string $username): bool {
if (count($data) !== 0) {
foreach ($data as $data_fields) {
// remove all non-digit characters to check if phone numbers are identical
$user_tel = remove_chars_tel($tel);
$all_digit_tel = remove_chars_tel($data_fields["tel"]);

Expand Down
20 changes: 10 additions & 10 deletions public/admin/auth/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
];


// GET query logic
if (isset($_GET["q"])) {
// Log out logic
if (isset($_GET["q"]) && $_GET["q"] === "logout") {
$_SESSION["admin_logged_in"] = false;
new_logs_entry("../../../private/logs.txt", "Admin logged out");
}
}


// Automatic redirect to Administrator's Dashboard page if user already logged in
if (isset($_SESSION["admin_logged_in"]) && $_SESSION["admin_logged_in"]) {
redirect_to(url_for("/admin/"));
Expand All @@ -43,16 +53,6 @@
}
}
// End of authentication logic


// GET query logic
if (isset($_GET["q"])) {
// Log out logic
if (isset($_GET["q"]) && $_GET["q"] === "logout") {
$_SESSION["admin_logged_in"] = false;
new_logs_entry("../../../private/logs.txt", "Admin logged out");
}
}


include(SHARED_PATH . "/top.php");
Expand Down
25 changes: 25 additions & 0 deletions public/css/install.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ main h1 {
margin: 20px 0 0 0;
}

.install-success-msg {
text-align: -webkit-center;
text-align: -moz-center;
text-align: center;
position: fixed;
top: 90px;
display: block;
width: 100%;
background-color: #c4e0c4;
opacity: 0.9;
color: #004e00;
border: 1px solid #118811;
padding: 25px 50px;
transform-origin: top;
animation: fadeInExpand 0.5s;
}

.install-instructions {
padding: 0 50px;
margin-bottom: 100px;
Expand All @@ -32,6 +49,8 @@ footer {
padding: 0;
}


/* Responsive install.php */
@media only screen and (max-width: 950px) {
nav {
-webkit-justify-content: center;
Expand All @@ -44,3 +63,9 @@ footer {
padding: 50px 0 0 0;
}
}

@media only screen and (max-width: 767px) {
.install-success-msg {
top: 60px;
}
}
10 changes: 10 additions & 0 deletions public/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require_once "../private/csv.php";

$updated = false;
if (isset($_POST["submit"])) {
$admin_credentials = [
[
Expand All @@ -11,6 +12,7 @@
];

write_csv("../private/database/admin.csv", $admin_credentials, true);
$updated = true;
}

?>
Expand All @@ -36,6 +38,14 @@
</nav>
</header>

<?php

if ($updated) {
echo "<div class='install-success-msg'>Administrative credentials updated. Please delete this file (/install.php) for the application to start working with the updated credentials.</div>";
}

?>

<main>
<h1 class="text-align-center">INSTALL</h1>
<section class="install-instructions">
Expand Down

0 comments on commit d2800f2

Please sign in to comment.