Fixed W12

This commit is contained in:
Andrew 2023-03-26 16:58:46 +07:00
parent ee0715c3b2
commit 8680f03b91
19 changed files with 444 additions and 253 deletions

View file

@ -1,19 +1,13 @@
{ {
"name": "nuark/w12", "name": "jenya/laba",
"description": "Work 12 app", "description": "Laba",
"type": "project", "type": "project",
"license": "MIT", "license": "MIT",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Nuark\\W12\\": "src/" "Jenya\\Laba\\": "src/"
} }
}, },
"authors": [
{
"name": "Andrew",
"email": "me@nuark.xyz"
}
],
"require": { "require": {
"pecee/simple-router": "4.3.7.2", "pecee/simple-router": "4.3.7.2",
"twig/twig": "^3.3" "twig/twig": "^3.3"

102
w12/db-init.sql Normal file
View file

@ -0,0 +1,102 @@
-- COMMENT ON SCHEMA public IS 'standard public schema';
--SET default_tablespace = '';
--SET default_table_access_method = heap;
CREATE TABLE public.images (
id integer NOT NULL,
filename character varying(255) NOT NULL,
user_id integer NOT NULL,
published boolean DEFAULT false,
description character varying(255) DEFAULT ''::character varying NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
CREATE SEQUENCE public.images_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.images_id_seq OWNED BY public.images.id;
CREATE SEQUENCE public.images_user_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.images_user_id_seq OWNED BY public.images.user_id;
CREATE TABLE public.menu (
id integer NOT NULL,
user_id integer NOT NULL,
data character varying DEFAULT '[]'::character varying
);
CREATE SEQUENCE public.menu_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.menu_id_seq OWNED BY public.menu.id;
CREATE SEQUENCE public.menu_user_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.menu_user_id_seq OWNED BY public.menu.user_id;
CREATE TABLE public.users (
id integer NOT NULL,
login character varying(255) NOT NULL,
password character varying(255) NOT NULL,
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
CREATE SEQUENCE public.users_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
ALTER TABLE ONLY public.images ALTER COLUMN id SET DEFAULT nextval('public.images_id_seq'::regclass);
ALTER TABLE ONLY public.images ALTER COLUMN user_id SET DEFAULT nextval('public.images_user_id_seq'::regclass);
ALTER TABLE ONLY public.menu ALTER COLUMN id SET DEFAULT nextval('public.menu_id_seq'::regclass);
ALTER TABLE ONLY public.menu ALTER COLUMN user_id SET DEFAULT nextval('public.menu_user_id_seq'::regclass);
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
ALTER TABLE ONLY public.images
ADD CONSTRAINT images_pk PRIMARY KEY (id);
ALTER TABLE ONLY public.menu
ADD CONSTRAINT menu_pk PRIMARY KEY (id);
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pk PRIMARY KEY (id);
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_un UNIQUE (login);
ALTER TABLE ONLY public.images
ADD CONSTRAINT images_fk FOREIGN KEY (user_id) REFERENCES public.users(id);
ALTER TABLE ONLY public.menu
ADD CONSTRAINT menu_fk FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE CASCADE;

View file

@ -53,7 +53,7 @@ SimpleRouter::post('/register', function() {
// if login or password is empty, redirect to register page with error // if login or password is empty, redirect to register page with error
if (empty($login) || empty($password)) { if (empty($login) || empty($password)) {
return response()->redirect('/register?error=Empty login or password given!'); return response()->redirect('/register?error=Проверьте данные формы!');
} }
// try create user if ok - redirect to login page with message // try create user if ok - redirect to login page with message
@ -61,9 +61,9 @@ SimpleRouter::post('/register', function() {
Database::createUser($login, $password); Database::createUser($login, $password);
$user = Database::getUser($login); $user = Database::getUser($login);
Database::createEmptyMenuForUser($user); Database::createEmptyMenuForUser($user);
response()->redirect('/login?message=User created'); response()->redirect('/login?message=Пользователь создан');
} catch (PDOException $e) { } catch (PDOException $e) {
response()->redirect('/register?error=User already exists!'); response()->redirect('/register?error=Пользователь уже существует!');
} }
}); });
@ -89,13 +89,13 @@ SimpleRouter::post('/login', function() {
// if login or password is empty, redirect to register page with error // if login or password is empty, redirect to register page with error
if (empty($login) || empty($password)) { if (empty($login) || empty($password)) {
return response()->redirect('/login?error=Empty login or password given!'); return response()->redirect('/login?error=Проверьте данные формы!');
} }
if (!Database::userExists($login)) { if (!Database::userExists($login)) {
return response()->redirect('/login?error=User does not exist!'); return response()->redirect('/login?error=Пользователь не существует!');
} }
if (!Database::verifyUser($login, $password)) { if (!Database::verifyUser($login, $password)) {
return response()->redirect('/login?error=Wrong password!'); return response()->redirect('/login?error=Неправильный пароль!');
} }
$user = Database::getUser($login); $user = Database::getUser($login);
@ -223,8 +223,9 @@ SimpleRouter::post('/uploadImage', function() {
$source = imagecreatefromjpeg($fullpath); $source = imagecreatefromjpeg($fullpath);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $size[0], $size[1]); imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
$color = imagecolorallocate($thumb, 255, 0, 0); $color = imagecolorallocate($thumb, 0, 255, 0);
imagestring($thumb, 2, 2, 2, "Watermark text :)", $color); $ulogin = getSessionVariable('user')['login'];
imagestring($thumb, 2, 2, 2, "$ulogin @ LABA", $color);
imagejpeg($thumb, 'data/thumb/' . $filename); imagejpeg($thumb, 'data/thumb/' . $filename);
try { try {
@ -290,7 +291,6 @@ SimpleRouter::post('/image/{id}', function($id) {
$description = input()->post('description', '')->value; $description = input()->post('description', '')->value;
$published = boolval(input()->post('published', 0)->value)?"true":"false"; $published = boolval(input()->post('published', 0)->value)?"true":"false";
var_dump($published);
try { try {
Database::updateImage($id, $description, $published); Database::updateImage($id, $description, $published);
} catch (PDOException $e) { } catch (PDOException $e) {
@ -366,12 +366,12 @@ SimpleRouter::post('/import', function() {
if ($xml) { if ($xml) {
try { try {
list($ok, $fail) = Database::importUsersXML($xml); list($ok, $fail) = Database::importUsersXML($xml);
response()->redirect("/import?message=OK: $ok, FAIL: $fail"); response()->redirect("/import?message=OK: $ok, КРАХ: $fail");
} catch (Exception $e) { } catch (Exception $e) {
response()->redirect("/import?error=" . $e->getMessage()); response()->redirect("/import?error=" . $e->getMessage());
} }
} else { } else {
response()->redirect('/import?error=Error happened '); response()->redirect('/import?error=Произошла ошибка');
} }
}); });
@ -421,15 +421,15 @@ SimpleRouter::post('/recover-password', function() use ($twig) {
'login' => $login, 'login' => $login,
'password' => $newPassword, 'password' => $newPassword,
]); ]);
response()->redirect('/recover-password?message=Success! We sent you an email with your new password&mail=' . urlencode($sentMail)); response()->redirect('/recover-password?message=Сообщение с паролем отправлено&mail=' . urlencode($sentMail));
} else { } else {
response()->redirect('/recover-password?error=User not found'); response()->redirect('/recover-password?error=Пользователь не найден!');
} }
} catch (PDOException $e) { } catch (PDOException $e) {
response()->redirect('/recover-password?error=' . $e->getMessage()); response()->redirect('/recover-password?error=' . $e->getMessage());
} }
} else { } else {
response()->redirect('/recover-password?error=Error happened'); response()->redirect('/recover-password?error=Произошла ошибка');
} }
}); });

BIN
w12/laba12.zip Normal file

Binary file not shown.

1
w12/log.txt Normal file
View file

@ -0,0 +1 @@
'admin'

View file

@ -2,9 +2,9 @@
// simple database PDO utilizing the Postgres driver // simple database PDO utilizing the Postgres driver
class Database { class Database {
private static $db; private static $db;
private static $dsn = 'pgsql:host=localhost;port=5432;dbname=w12'; private static $dsn = 'pgsql:host=localhost;port=9001;dbname=db';
private static $username = 'postgres'; private static $username = 'db';
private static $password = 'asarch6122'; private static $password = 'postgres';
private static $options = [ private static $options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
@ -56,11 +56,11 @@ class Database {
} }
public static function generateUserNewPassword($login) { public static function generateUserNewPassword($login) {
$password = bin2hex(random_bytes(8));
$db = self::getDB(); $db = self::getDB();
$query = $db->prepare('UPDATE users SET password = :password WHERE login = :login'); $query = $db->prepare('UPDATE users SET password = :password WHERE login = :login');
$query->bindParam(':login', $login); $query->bindParam(':login', $login);
$query->bindParam(':password', $password); $query->bindParam(':password', $password);
$password = bin2hex(random_bytes(8));
$query->execute(); $query->execute();
return $password; return $password;
} }

View file

@ -1,16 +1,18 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head> {% block title %}Редактирование меню{% endblock %}
<meta charset="UTF-8"> {% block head %}
<meta http-equiv="X-UA-Compatible" content="IE=edge"> {{ parent() }}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <style type="text/css">
<title>Document</title>
</head> </style>
<body> {% endblock %}
<b>{{user.login}}</b>, вы редактируете меню. <a href="/">На главную</a>
<hr> {% block content %}
<b>Меню:</b> <b>{{user.login}}</b>, вы редактируете меню. <a href="/">На главную</a>
<div id="menuHolder"> <hr>
<b>Меню:</b>
<div id="menuHolder">
{% if menu %} {% if menu %}
{% for item in menu %} {% for item in menu %}
<div> <div>
@ -20,16 +22,16 @@
</div> </div>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</div> </div>
<hr> <hr>
<div> <div>
<input class="inputData" type="text" name="url" placeholder="Ссылка"> <input class="inputData" type="text" name="url" placeholder="Ссылка">
<input class="inputData" type="text" name="name" placeholder="Название"> <input class="inputData" type="text" name="name" placeholder="Название">
<button id="addItemBtn">+</button> <button id="addItemBtn">+</button>
</div> </div>
<button id="saveBtn">Сохранить</button> <button id="saveBtn">Сохранить</button>
</body>
<script> <script>
let menu = []; let menu = [];
@ -69,7 +71,7 @@
document.querySelector('input.inputData[name="url"]').value = ''; document.querySelector('input.inputData[name="url"]').value = '';
document.querySelector('input.inputData[name="name"]').value = ''; document.querySelector('input.inputData[name="name"]').value = '';
updateDeleteBtns() updateDeleteBtns();
}); });
saveBtn.addEventListener('click', async function() { saveBtn.addEventListener('click', async function() {
@ -92,8 +94,10 @@
} }
console.log(result); console.log(result);
}); });
updateDeleteBtns();
} }
document.addEventListener('DOMContentLoaded', init); document.addEventListener('DOMContentLoaded', init);
</script> </script>
</html> {% endblock %}

View file

@ -1,20 +1,21 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head> {% block title %}Галерея{% endblock %}
<meta charset="UTF-8"> {% block head %}
<meta http-equiv="X-UA-Compatible" content="IE=edge"> {{ parent() }}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <style type="text/css">
<title>Document</title>
</head> </style>
<body> {% endblock %}
<b>{{user.login}}</b>, вы смотрите свою галерею. <a href="/">На главную</a>
<hr> {% block content %}
{% for image in images %} <b>{{user.login}}</b>, вы смотрите свою галерею. <a href="/">На главную</a>
<hr>
{% for image in images %}
<a href="/image/{{image.id}}"> <a href="/image/{{image.id}}">
<img src="/images?filename={{image.filename}}" alt="{{image.id}}"> <img src="/images?filename={{image.filename}}" alt="{{image.id}}">
</a> </a>
{% else %} {% else %}
<p>Нет изображений</p> <p>Нет изображений</p>
{% endfor %} {% endfor %}
</body> {% endblock %}
</html>

View file

@ -1,26 +1,27 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head> {% block title %}Просмотр изображения{% endblock %}
<meta charset="UTF-8"> {% block head %}
<meta http-equiv="X-UA-Compatible" content="IE=edge"> {{ parent() }}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <style type="text/css">
<title>Document</title>
</head> </style>
<body> {% endblock %}
<b>{{user.login}}</b> осматривает картинку... <a href="/">На главную</a>
<hr> {% block content %}
<img src="/images?type=full&filename={{image.filename}}" alt="{{image.filename}}" style="max-width: 100%"> <b>{{user.login}}</b> осматривает картинку... <a href="/">На главную</a>
<hr> <hr>
<a href="/images?type=thumb&filename={{image.filename}}">Миниатюра</a> <img src="/images?type=full&filename={{image.filename}}" alt="{{image.filename}}" style="max-width: 100%">
<hr> <hr>
<form action="/image/{{image.id}}" method="post"> <a href="/images?type=thumb&filename={{image.filename}}">Миниатюра</a>
<hr>
<form action="/image/{{image.id}}" method="post">
<input type="text" name="description" value="{{image.description}}"> <input type="text" name="description" value="{{image.description}}">
<br> <br>
Опубликовано? Опубликовано?
<input type="checkbox" name="published" value="1" {{image.published ? 'checked' : ''}}> <input type="checkbox" name="published" value="1" {{image.published ? 'checked' : ''}}>
<br> <br>
<input type="submit" value="Сохранить"> <input type="submit" value="Сохранить">
</form> </form>
<a href="/image/{{image.id}}/delete">Удалить</a> <a href="/image/{{image.id}}/delete">Удалить</a>
</body> {% endblock %}
</html>

View file

@ -1,26 +1,27 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head> {% block title %}Импорт пользователей{% endblock %}
<meta charset="UTF-8"> {% block head %}
<meta http-equiv="X-UA-Compatible" content="IE=edge"> {{ parent() }}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <style>
<title>Document</title>
</head> </style>
<body> {% endblock %}
{% if message %}
<div id="message" style="padding: 1rem; border: 2px solid black; background-color: green; color: white">{{message}}</div> {% block content %}
{% endif %} {% if message %}
{% if error %} <div id="message" style="padding: 1rem; border: 2px solid black; background-color: green; color: white">{{message}}</div>
<div id="error" style="padding: 1rem; border: 2px solid black; background-color: red; color: white">{{error}}</div> {% endif %}
{% endif %} {% if error %}
<h4>Import page</h4> <div id="error" style="padding: 1rem; border: 2px solid black; background-color: red; color: white">{{error}}</div>
<p>Drop XML file on page or enter content down here</p> {% endif %}
<form action="/import" method="post"> <h4>Импорт</h4>
<p>Перенесите XML файл дампа на форму или вставьте содерживое в поле</p>
<form action="/import" method="post">
<textarea name="xml" cols="30" rows="10"></textarea> <textarea name="xml" cols="30" rows="10"></textarea>
<br> <br>
<input type="submit" name="submit" value="submit"> <input type="submit" name="submit" value="submit">
</form> </form>
</body>
<script> <script>
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
let dropZone = document.body; let dropZone = document.body;
@ -48,4 +49,4 @@ document.addEventListener("DOMContentLoaded", function() {
}, false); }, false);
}); });
</script> </script>
</html> {% endblock %}

View file

@ -1,11 +1,8 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
{% block title %}Главная страница{% endblock %}
{% block head %}
{{ parent() }}
<style> <style>
#imageDrop { #imageDrop {
display: flex; display: flex;
@ -18,8 +15,9 @@
border-radius: 1rem; border-radius: 1rem;
} }
</style> </style>
</head> {% endblock %}
<body>
{% block content %}
Привет, {{user.login}}! <a href="/logout">Выйти</a> Привет, {{user.login}}! <a href="/logout">Выйти</a>
<hr> <hr>
<b>Меню:</b> <b>Меню:</b>
@ -105,4 +103,4 @@ document.addEventListener("DOMContentLoaded", function() {
}); });
</script> </script>
</html> {% endblock %}

View file

@ -1,27 +1,52 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head> {% block title %}Вход{% endblock %}
<meta charset="UTF-8"> {% block head %}
<meta http-equiv="X-UA-Compatible" content="IE=edge"> {{ parent() }}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <style>
<title>Document</title> body {
</head> display: flex;
<body> flex-direction: column;
align-items: center;
justify-content: center;
padding: 0;
margin: 0;
height: 100vh;
width: 100vw;
background: rgb(15 33 33);
}
.auth-holder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgb(185 255 245);
width: fit-content;
padding: 2rem;
border-radius: 1rem;
}
</style>
{% endblock %}
{% block content %}
<div class="auth-holder">
{% if message %} {% if message %}
<div id="message" style="padding: 1rem; border: 2px solid black; background-color: green; color: white">{{message}}</div> <div id="message" style="padding: 1rem; border: 2px solid black; background-color: green; color: white">{{message}}</div>
{% endif %} {% endif %}
{% if error %} {% if error %}
<div id="error" style="padding: 1rem; border: 2px solid black; background-color: red; color: white">{{error}}</div> <div id="error" style="padding: 1rem; border: 2px solid black; background-color: red; color: white">{{error}}</div>
{% endif %} {% endif %}
<h4>Login page</h4> <h4>Вход</h4>
<form action="/login" method="post"> <form action="/login" method="post">
<input type="text" name="login" placeholder="login"> <input type="text" name="login" placeholder="Логин">
<input type="password" name="password" placeholder="password"> <input type="password" name="password" placeholder="Пароль">
<input type="submit" name="submit" value="submit"> <input type="submit" name="submit" value="Войти">
</form> </form>
<hr> <hr>
<a href="/register">Registration</a> <a href="/register">Зарегистрироваться</a>
<br> <br>
<a href="/recover-password">Recover password</a> <a href="/recover-password">Восстановить пароль</a>
</body> </div>
</html> {% endblock %}

View file

@ -1,12 +1,14 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head> {% block title %}Просмотр таблиц{% endblock %}
<meta charset="UTF-8"> {% block head %}
<meta http-equiv="X-UA-Compatible" content="IE=edge"> {{ parent() }}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <style>
<title>Document</title>
</head> </style>
<body> {% endblock %}
{% block content %}
{% if table %} {% if table %}
<b>{{user.login}}</b>, вы смотрите таблицу <i>{{table}}</i>. <a href="/lookupTables">Отмена</a> <b>{{user.login}}</b>, вы смотрите таблицу <i>{{table}}</i>. <a href="/lookupTables">Отмена</a>
{% else %} {% else %}
@ -46,5 +48,4 @@
<input type="submit" value="Перейти"> <input type="submit" value="Перейти">
</form> </form>
{% endif %} {% endif %}
</body> {% endblock %}
</html>

View file

@ -1,12 +1,13 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head> {% block title %}Гейтвей{% endblock %}
<meta charset="UTF-8"> {% block head %}
<meta http-equiv="X-UA-Compatible" content="IE=edge"> {{ parent() }}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <style>
<title>Document</title>
</head> </style>
<body> {% endblock %}
{% block content %}
Вам нужно <a href="/login">войти</a> или <a href="/register">зарегистрироваться</a> для работы с системой. Вам нужно <a href="/login">войти</a> или <a href="/register">зарегистрироваться</a> для работы с системой.
</body> {% endblock %}
</html>

View file

@ -1,4 +1,4 @@
Hello, {{login}}! Привет, {{login}}!
You have requested password change, so we generated you a new one (without backtics): `<b>{{password}}</b>`. Похоже, ты ззабыл свой пароль, вот тебе новый (без кавычек): `<b>{{password}}</b>`.
<br> <hr>
Please be sure to delete this message after you have logged in. For now you cannot change your password by yourself. Удали это сообщение после входа, чтобы его никто не прочитал!

View file

@ -1,12 +1,37 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head> {% block title %}Восстановление парля{% endblock %}
<meta charset="UTF-8"> {% block head %}
<meta http-equiv="X-UA-Compatible" content="IE=edge"> {{ parent() }}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <style>
<title>Document</title> body {
</head> display: flex;
<body> flex-direction: column;
align-items: center;
justify-content: center;
padding: 0;
margin: 0;
height: 100vh;
width: 100vw;
background: rgb(15 33 33);
}
.auth-holder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgb(185 255 245);
width: fit-content;
padding: 2rem;
border-radius: 1rem;
}
</style>
{% endblock %}
{% block content %}
<div class="auth-holder">
{% if mail %} {% if mail %}
<div id="mail" style="padding: 1rem; border: 2px solid black; background-color: lightsteelblue; color: stellblue">{{mail | raw}}</div> <div id="mail" style="padding: 1rem; border: 2px solid black; background-color: lightsteelblue; color: stellblue">{{mail | raw}}</div>
<br> <br>
@ -19,14 +44,14 @@
<div id="error" style="padding: 1rem; border: 2px solid black; background-color: red; color: white">{{error}}</div> <div id="error" style="padding: 1rem; border: 2px solid black; background-color: red; color: white">{{error}}</div>
<br> <br>
{% endif %} {% endif %}
<h4>Password recovery page</h4> <h4>Восстановление пароля</h4>
<form action="/recover-password" method="post"> <form action="/recover-password" method="post">
<input type="text" name="login" placeholder="login"> <input type="text" name="login" placeholder="Логин">
<input type="submit" name="submit" value="submit"> <input type="submit" name="submit" value="Восстановить">
</form> </form>
<hr> <hr>
<a href="/register">Registration</a> <a href="/register">Зарегистрироваться</a>
<br> <br>
<a href="/login">Login</a> <a href="/login">Войти</a>
</body> </div>
</html> {% endblock %}

View file

@ -1,24 +1,49 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head> {% block title %}Регистрация{% endblock %}
<meta charset="UTF-8"> {% block head %}
<meta http-equiv="X-UA-Compatible" content="IE=edge"> {{ parent() }}
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <style>
<title>Document</title> body {
</head> display: flex;
<body> flex-direction: column;
align-items: center;
justify-content: center;
padding: 0;
margin: 0;
height: 100vh;
width: 100vw;
background: rgb(15 33 33);
}
.auth-holder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgb(185 255 245);
width: fit-content;
padding: 2rem;
border-radius: 1rem;
}
</style>
{% endblock %}
{% block content %}
<div class="auth-holder">
{% if error %} {% if error %}
<div id="error" style="padding: 1rem; border: 2px solid black; background-color: red; color: white">{{error}}</div> <div id="error" style="padding: 1rem; border: 2px solid black; background-color: red; color: white">{{error}}</div>
{% endif %} {% endif %}
<h4>Registration page</h4> <h4>Регистрация</h4>
<form action="/register" method="post"> <form action="/register" method="post">
<input type="text" name="login" placeholder="login"> <input type="text" name="login" placeholder="Логин">
<input type="password" name="password" placeholder="password"> <input type="password" name="password" placeholder="Пароль">
<input type="submit" name="submit" value="submit"> <input type="submit" name="submit" value="Войти">
</form> </form>
<hr> <hr>
<a href="/login">Login</a> <a href="/login">Войти</a>
<br> <br>
<a href="/recover-password">Recover password</a> <a href="/recover-password">Восстановить пароль</a>
</body> </div>
</html> {% endblock %}

View file

@ -1,11 +1,8 @@
<!DOCTYPE html> {% extends "template.twig" %}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
{% block title %}Импорт пользователей{% endblock %}
{% block head %}
{{ parent() }}
<style> <style>
#imageDrop { #imageDrop {
display: flex; display: flex;
@ -18,8 +15,9 @@
border-radius: 1rem; border-radius: 1rem;
} }
</style> </style>
</head> {% endblock %}
<body>
{% block content %}
<b>{{user.login}}</b> что-то ищет 🤔 <a href="/">На главную</a> <b>{{user.login}}</b> что-то ищет 🤔 <a href="/">На главную</a>
<hr> <hr>
<form action="/search" method="get"> <form action="/search" method="get">
@ -46,5 +44,4 @@
<p>Пусто</p> <p>Пусто</p>
{% endif %} {% endif %}
</div> </div>
</body> {% endblock %}
</html>

15
w12/views/template.twig Normal file
View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block head %}
<!--link rel="stylesheet" href="style.css"/-->
<title>{% block title %}{% endblock %}</title>
{% endblock %}
</head>
<body>
<div id="content">{% block content %}{% endblock %}</div>
<div id="footer">{% block footer %}{% endblock %}</div>
</body>
</html>