Регистрация
Фронт (стили+страница), полировка стр. логина, микроправки и микрооптимизации
This commit is contained in:
1 parent
4e1c36d670
commit
c48f837738
11 files changed
+161
-27
No files matched your search
@@ -15,6 +15,9 @@ function NTFY_AddNotice (string $text, string $type = "fail") {
|
||||
case "fail":
|
||||
$NTFY_NoticesStack[] = "<div class=\"notification_fail\"><p>$text</p></div>";
|
||||
break;
|
||||
case "success":
|
||||
$NTFY_NoticesStack[] = "<div class=\"notification_success\"><p>$text</p></div>";
|
||||
break;
|
||||
default:
|
||||
die("invalid notification type: $type");
|
||||
}
|
||||
|
||||
@@ -9,14 +9,20 @@ require_once("front/notifications.php");
|
||||
|
||||
|
||||
|
||||
// Redirecting to main page if already logged in
|
||||
if ($LOGGED_IN) {
|
||||
header("Location: .");
|
||||
exit();
|
||||
}
|
||||
|
||||
// If there is attempt to login in
|
||||
if (isset($_POST["login"]) || isset($_POST["password"])) {
|
||||
$result = User_Login_Method($_POST);
|
||||
|
||||
if ($result->IsError()) {
|
||||
if ($result->IsError()) { // Something happened
|
||||
NTFY_AddNotice("Failed to log into account! Check your credentials and try again.<br>" . $result->GetError());
|
||||
} else {
|
||||
header("Location: index.php");
|
||||
} else { // All OK
|
||||
header("Location: .");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
@@ -31,7 +37,7 @@ NTFY_EchoAllNotices();
|
||||
<form class="login" action="./?do=login" accept-charset="UTF-8" method="post">
|
||||
<div>
|
||||
<label for="login">Username</label><br>
|
||||
<input type="text" name="login" id="login">
|
||||
<input type="text" name="login" id="login" <?php if (isset($_POST["login"])) { echo "value=\"" . $_POST["login"] . "\""; } ?>>
|
||||
</div>
|
||||
<div>
|
||||
<label for="password">Password</label><br>
|
||||
|
||||
+10
-11
@@ -4,21 +4,28 @@
|
||||
|
||||
|
||||
$MARKUP_CURRENT_PAGE = "class=\"current\"";
|
||||
$MARKUP_CURRENT_PAGE_LOGIN = "";
|
||||
$MARKUP_CURRENT_PAGE_LOGIN = "";
|
||||
$MARKUP_CURRENT_PAGE_REGISTER = "";
|
||||
|
||||
if ($WHAT_PAGE_IS_CURRENT["login"])
|
||||
$MARKUP_CURRENT_PAGE_LOGIN = $MARKUP_CURRENT_PAGE;
|
||||
$MARKUP_CURRENT_PAGE_LOGIN = $MARKUP_CURRENT_PAGE;
|
||||
if ($WHAT_PAGE_IS_CURRENT["register"])
|
||||
$MARKUP_CURRENT_PAGE_REGISTER = $MARKUP_CURRENT_PAGE;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<nav class="main">
|
||||
<ul>
|
||||
<li>
|
||||
<p><a title="Main site page" href="./?do=main">Index</p></a>
|
||||
</li>
|
||||
<span>|</span>
|
||||
<li <?php echo $MARKUP_CURRENT_PAGE_LOGIN; ?>>
|
||||
<p><a title="Login in existing account" href="./?do=login">Login</p></a>
|
||||
</li>
|
||||
<span>|</span>
|
||||
<li>
|
||||
<li <?php echo $MARKUP_CURRENT_PAGE_REGISTER; ?>>
|
||||
<p><a title="Create new account" href="./?do=register">Register</p></a>
|
||||
</li>
|
||||
<span>|</span>
|
||||
@@ -38,14 +45,6 @@ if ($WHAT_PAGE_IS_CURRENT["login"])
|
||||
<p><a title="Contacts" href="./?do=show_contacts">Contacts</p></a>
|
||||
</li>
|
||||
<span>|</span>
|
||||
<li>
|
||||
<p><a title="Terms of service" href="./?do=show_tos">ToS</p></a>
|
||||
</li>
|
||||
<span>|</span>
|
||||
<li>
|
||||
<p><a title="Privacy policy" href="./?do=there_are_my_data">Privacy</p></a>
|
||||
</li>
|
||||
<span>|</span>
|
||||
<li>
|
||||
<p><a title="A site map" href="./?do=view_sitemap">Site map</p></a>
|
||||
</li>
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
// Registration page
|
||||
|
||||
|
||||
// Includes
|
||||
require_once("api/_config.php");
|
||||
require_once("api/user/create.php");
|
||||
require_once("front/pages/main_nav.php");
|
||||
require_once("front/notifications.php");
|
||||
|
||||
|
||||
|
||||
$REGISTRATION_IS_OPEN = $Config["registration"]["active"];
|
||||
|
||||
// Redirecting to main page if already logged in
|
||||
if ($LOGGED_IN) {
|
||||
header("Location: .");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If there is attempt to register
|
||||
if ((isset($_POST["login"]) || isset($_POST["password"])) && $REGISTRATION_IS_OPEN) {
|
||||
// If ToS arent accepted
|
||||
if ($_POST["tos_check"] !== "tos_check") {
|
||||
NTFY_AddNotice("You MUST accept Terms of Service!", "fail");
|
||||
} else { // Ok, noice
|
||||
if ($_POST["password"] === $_POST["password2"]) {
|
||||
$result = User_Create_Method($_POST);
|
||||
|
||||
if ($result->IsError()) { // Something happened
|
||||
NTFY_AddNotice("Failed to create account! Reason:<br>" . $result->GetError(), "fail");
|
||||
} else { // All OK
|
||||
NTFY_AddNotice("Account registered! You can log in <a href=\"./?do=login\">here</a>", "success");
|
||||
}
|
||||
} else {
|
||||
NTFY_AddNotice("Password mismatch! Check and try again", "fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NTFY_EchoAllNotices();
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<div class="visualbox">
|
||||
<h1>Register</h1>
|
||||
<?php
|
||||
if ($REGISTRATION_IS_OPEN) {
|
||||
?>
|
||||
<form class="login" action="./?do=register" accept-charset="UTF-8" method="post">
|
||||
<div>
|
||||
<label for="login">Your desired username:</label><br>
|
||||
<input type="text" name="login" id="login" spellcheck="false" <?php if (isset($_POST["login"])) { echo "value=\"" . $_POST["login"] . "\""; } ?>>
|
||||
</div>
|
||||
<div>
|
||||
<label for="password">Password:</label><br>
|
||||
<input type="password" name="password" id="password"><br>
|
||||
<label for="password2">Repeat password:</label><br>
|
||||
<input type="password" name="password2" id="password2">
|
||||
</div>
|
||||
<?php
|
||||
if ($Config["registration"]["need_email"]) { // TODO: move description to ToS
|
||||
?>
|
||||
<div>
|
||||
<label for="email">E-Mail address <span style="font-size: 50%;">(we will send you penis enlargement ads)</span>:</label><br>
|
||||
<input type="text" name="email" id="email" inputmode="email" <?php if (isset($_POST["email"])) { echo "value=\"" . $_POST["email"] . "\""; } ?>>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ($Config["registration"]["need_invite"]) {
|
||||
?>
|
||||
<div>
|
||||
<label for="invite_id">Invite code:</label><br>
|
||||
<input type="text" name="invite_id" id="invite_id" spellcheck="false" <?php if (isset($_POST["invite_id"])) { echo "value=\"" . $_POST["invite_id"] . "\""; } ?>>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div>
|
||||
<input type="checkbox" name="tos_check" id="tos_check" value="tos_check">
|
||||
<label for="tos_check">I've read and accept your boring Terms of Service</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Submit">
|
||||
</div>
|
||||
</form>
|
||||
<div class="loginmisc">
|
||||
<p>Already have an account? <a href="./?do=login">Login here</a></p>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
echo "<h2 style=\"color: red;\">Registrations are closed!</h2>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
+14
-1
@@ -60,6 +60,10 @@ div.visualbox {
|
||||
backdrop-filter: blur(6px);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Notifications */
|
||||
|
||||
div.notification_fail {
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
@@ -73,6 +77,16 @@ div.notification_fail p {
|
||||
color: red;
|
||||
}
|
||||
|
||||
div.notification_success {
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 5px green;
|
||||
text-shadow: 0 0 2px black, 0 0 6px black;
|
||||
backdrop-filter: blur(6px);
|
||||
background-color: #0f03;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Input */
|
||||
@@ -124,5 +138,4 @@ input[type=submit]:focus {
|
||||
/* Checkbox */
|
||||
input[type=checkbox] {
|
||||
cursor: pointer;
|
||||
background-color: red;
|
||||
}
|
||||
@@ -36,8 +36,8 @@ nav.main ul {
|
||||
|
||||
nav.main ul li {
|
||||
display: inline-block;
|
||||
margin-left: 1.75vw;
|
||||
margin-right: 1.75vw;
|
||||
margin-left: 2.5vw;
|
||||
margin-right: 2.5vw;
|
||||
}
|
||||
|
||||
nav.main ul li a {
|
||||
@@ -72,6 +72,10 @@ form.login a {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
form.login label[for="tos_check"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
div.loginmisc {
|
||||
margin-top: 4px;
|
||||
margin-bottom: 4px;
|
||||
|
||||
Reference in new issue
Block a user