login
This commit is contained in:
parent
500cb439b8
commit
81d750aae9
|
@ -0,0 +1,59 @@
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
CREATE TABLE IF NOT EXISTS "users" (
|
||||||
|
"id" INTEGER,
|
||||||
|
"email" TEXT NOT NULL,
|
||||||
|
"pwd" TEXT NOT NULL,
|
||||||
|
"dostup" TEXT NOT NULL DEFAULT 'u',
|
||||||
|
"activate" INTEGER NOT NULL DEFAULT 1,
|
||||||
|
"site" TEXT NOT NULL,
|
||||||
|
"json" ,
|
||||||
|
PRIMARY KEY("id" AUTOINCREMENT)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS "pages" (
|
||||||
|
"id" INTEGER,
|
||||||
|
"title" TEXT NOT NULL,
|
||||||
|
"txt" TEXT NOT NULL,
|
||||||
|
"user_id" INTEGER,
|
||||||
|
"status" INTEGER NOT NULL DEFAULT 1,
|
||||||
|
"description" TEXT,
|
||||||
|
PRIMARY KEY("id" AUTOINCREMENT)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS "content" (
|
||||||
|
"id" INTEGER,
|
||||||
|
"title" TEXT NOT NULL,
|
||||||
|
"txt" TEXT NOT NULL,
|
||||||
|
"short_txt" TEXT NOT NULL,
|
||||||
|
"user_id" INTEGER,
|
||||||
|
"status" INTEGER NOT NULL DEFAULT 1,
|
||||||
|
"content_category" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"keywords" TEXT,
|
||||||
|
"description" TEXT,
|
||||||
|
"site" TEXT,
|
||||||
|
"json" TEXT,
|
||||||
|
"type" ,
|
||||||
|
"alias" ,
|
||||||
|
PRIMARY KEY("id" AUTOINCREMENT)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS "content_category" (
|
||||||
|
"id" INTEGER,
|
||||||
|
"category" INTEGER,
|
||||||
|
"title" TEXT NOT NULL,
|
||||||
|
"txt" TEXT NOT NULL,
|
||||||
|
"user_id" INTEGER,
|
||||||
|
"status" INTEGER NOT NULL DEFAULT 1,
|
||||||
|
"description" TEXT,
|
||||||
|
"keywords" TEXT,
|
||||||
|
"site" TEXT,
|
||||||
|
"json" TEXT,
|
||||||
|
PRIMARY KEY("id" AUTOINCREMENT)
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS "settings" (
|
||||||
|
"id" INTEGER,
|
||||||
|
"json" TEXT NOT NULL,
|
||||||
|
"site" TEXT NOT NULL,
|
||||||
|
"mod" TEXT NOT NULL,
|
||||||
|
PRIMARY KEY("id" AUTOINCREMENT)
|
||||||
|
);
|
||||||
|
INSERT INTO "users" VALUES (1,'yurec@yurecnt.ru','123','u',1,'localhost','iuhiuhi');
|
||||||
|
INSERT INTO "content" VALUES (1,'Первая страница Flask','text страницы','Краткое описание',1,1,0,NULL,NULL,'localhost',NULL,'page',NULL);
|
||||||
|
COMMIT;
|
|
@ -0,0 +1,3 @@
|
||||||
|
SQLite version 3.37.2 2022-01-06 13:25:41
|
||||||
|
Enter ".help" for usage hints.
|
||||||
|
[?2004hsqlite> ^C[?2004l
[?2004h^C[?2004l
[?2004h^C[?2004l
|
29
index.py
29
index.py
|
@ -6,32 +6,9 @@ from urllib.parse import urlparse
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def main_mod(module='main'):
|
@app.route('/<module>/')
|
||||||
o = urlparse(request.base_url)
|
|
||||||
myhost=o.hostname
|
|
||||||
myhost=o.hostname
|
|
||||||
module2="mod."+module + ".index"
|
|
||||||
mod = __import__(module2)
|
|
||||||
a=getattr(mod, module)
|
|
||||||
b=getattr(a, 'index')
|
|
||||||
if request.method=='POST':
|
|
||||||
do=b.do(id)
|
|
||||||
else:
|
|
||||||
go=b.mod(id, myhost)
|
|
||||||
# help(b)
|
|
||||||
result=b.mod.result
|
|
||||||
print(result)
|
|
||||||
return render_template(myhost + "/" + module+'.html', massiv=result, myhost=myhost)
|
|
||||||
|
|
||||||
@app.route('/<module>')
|
|
||||||
def short_mod(module='main'):
|
|
||||||
module="mod."+module
|
|
||||||
__import__(module)
|
|
||||||
return str(module)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/<module>/<id>', methods=['GET', 'POST'])
|
@app.route('/<module>/<id>', methods=['GET', 'POST'])
|
||||||
def mod(id, module='page'):
|
def mod(id=1, module='page'):
|
||||||
o = urlparse(request.base_url)
|
o = urlparse(request.base_url)
|
||||||
myhost=o.hostname
|
myhost=o.hostname
|
||||||
module2="mod."+module + ".index"
|
module2="mod."+module + ".index"
|
||||||
|
@ -45,7 +22,7 @@ def mod(id, module='page'):
|
||||||
# help(b)
|
# help(b)
|
||||||
result=b.mod.result
|
result=b.mod.result
|
||||||
print(result)
|
print(result)
|
||||||
return render_template(myhost + "/" + module+'.html', massiv=result, myhost=myhost)
|
return render_template(module+'.html', massiv=result, myhost=myhost, module=module)
|
||||||
#return str(module)
|
#return str(module)
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
||||||
|
class mod:
|
||||||
|
result=""
|
||||||
|
def __init__(self, id, myhost):
|
||||||
|
import mod.sqlite.index
|
||||||
|
self.getPage(id, myhost)
|
||||||
|
|
||||||
|
def getPage(self, id, myhost):
|
||||||
|
pass
|
||||||
|
#return result
|
Binary file not shown.
|
@ -36,7 +36,7 @@ class mod:
|
||||||
self.getPage(id, myhost)
|
self.getPage(id, myhost)
|
||||||
|
|
||||||
def getPage(self, id, myhost):
|
def getPage(self, id, myhost):
|
||||||
self.sql.cur.execute("SELECT * FROM content WHERE id=" + id + " AND type='page' AND site='" + myhost + "' LIMIT 1")
|
self.sql.cur.execute("SELECT * FROM content WHERE id=" + str(id) + " AND type='page' AND site='" + myhost + "' LIMIT 1")
|
||||||
result = self.sql.cur.fetchone()
|
result = self.sql.cur.fetchone()
|
||||||
mod.result=result
|
mod.result=result
|
||||||
return result
|
return result
|
||||||
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
0 - нет ошибки
|
||||||
|
1 - не совпадает капча
|
||||||
|
2 - не совпадают пароли
|
||||||
|
3 - юзер уже зарегистрирован
|
||||||
|
4 - не введен адрес почты
|
||||||
|
5 - скрыть ошибку
|
||||||
|
*/
|
||||||
|
function showErr_v2(data) {
|
||||||
|
$("#regResult").addClass("hidden");
|
||||||
|
$("#regResult").removeClass("alert-danger");
|
||||||
|
$("#regResult").removeClass("alert-success");
|
||||||
|
switch (data) {
|
||||||
|
case '0':
|
||||||
|
$("#regResult").text("Вы успешно зарегистрированы!");
|
||||||
|
$("#alert-success").addClass("alert-success");
|
||||||
|
$("#regResult").removeClass("hidden");
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
$("#regResult").text("Не подошел проверочный код!");
|
||||||
|
$("#regResult").addClass("alert-danger");
|
||||||
|
$("#regResult").removeClass("hidden");
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
$("#regResult").text("Пароли не совпадают!");
|
||||||
|
$("#regResult").addClass("alert-danger");
|
||||||
|
$("#regResult").removeClass("hidden");
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
$("#regResult").text("Пользователь с такой почтой уже зарегистрирован");
|
||||||
|
$("#regResult").addClass("alert-danger");
|
||||||
|
$("#regResult").removeClass("hidden");
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
$("#regResult").text("Вы не указали электронную почту");
|
||||||
|
$("#regResult").addClass("alert-danger");
|
||||||
|
$("#regResult").removeClass("hidden");
|
||||||
|
break;
|
||||||
|
case '5'://Скрываем ошибки
|
||||||
|
$("#regResult").addClass("hidden");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* проверка валидности пароля */
|
||||||
|
$('#pwd, #pwd2').keyup(function (event) {
|
||||||
|
showErr_v2(($("#pwd").val() != $("#pwd2").val()) ? "2" : "5");
|
||||||
|
})
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
{% extends "template.html" %}
|
||||||
|
{% block body %}
|
||||||
|
<section class="container">
|
||||||
|
|
||||||
|
<nav aria-label="breadcrumb">
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li class="breadcrumb-item"><a href="/">Главная</a></li>
|
||||||
|
<li class="breadcrumb-item active" aria-current="page">Авторизация</li>
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6" style="border-right: 1px solid lightgray;">
|
||||||
|
|
||||||
|
<h2>Авторизация</h2>
|
||||||
|
<input class="form-control mt-3" name="email" type="email" placeholder="Электронная почта">
|
||||||
|
<input class="form-control mt-3" name="pwd" type="password" placeholder="Пароль">
|
||||||
|
<input class="btn btn-outline-dark mt-3" name="ok" type="submit" value="Войти">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h2>Регистрация</h2>
|
||||||
|
|
||||||
|
<input class="form-control mt-3" name="email" type="email" placeholder="Электронная почта">
|
||||||
|
<input class="form-control mt-3" name="pwd" type="password" placeholder="Пароль" id="pwd">
|
||||||
|
<input class="form-control mt-3" name="pwd2" type="password" placeholder="Повторите пароль" id="pwd2">
|
||||||
|
<input class="btn btn-outline-dark mt-3" name="ok" type="submit" value="Зарегистрироваться">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="alert hidden" role="alert" id="regResult">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "localhost/template.html" %}
|
{% extends "template.html" %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<section class="container">
|
<section class="container">
|
||||||
<div class="row">
|
<div class="row">
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
{% extends "localhost/template.html" %}
|
{% extends "template.html" %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<article class="container">
|
<article class="container">
|
||||||
{{massiv.2}}
|
{{massiv.2}}
|
|
@ -69,11 +69,15 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="/static/js/jquery-3.7.1.min.js.js"></script>
|
||||||
<script src="https://new.yurecnt.ru/api/jquery/plugins/lazyload/jquery.lazyload.min1.9.5.js"></script>
|
<script src="https://new.yurecnt.ru/api/jquery/plugins/lazyload/jquery.lazyload.min1.9.5.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"
|
||||||
integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
|
integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
|
||||||
crossorigin="anonymous"></script>
|
crossorigin="anonymous"></script>
|
||||||
|
|
||||||
|
<script src="/static/js/global.js"></script>
|
||||||
|
<script src="/static/js/{{module}}.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue