-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
133 lines (112 loc) · 4.37 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import re, os, io, sys, ast, ssl, csv, json, base64, configparser, requests, sqlite_utils, pytz, pgpy, pycountry, qrcode, qrcode.image.svg, logging
from datetime import datetime as DT , timezone as TZ, timedelta as TD
from sqlite_utils.utils import sqlite3
from flask import Flask, Blueprint, request, make_response, Response, jsonify, redirect, url_for, render_template, flash, abort, send_from_directory
from flask_login import UserMixin, LoginManager, login_required, current_user, login_user, logout_user
from flask_ckeditor import CKEditor, upload_success, upload_fail, CKEditorField
from werkzeug.middleware.proxy_fix import ProxyFix
from system.setup import login
from system.panel import set_password, check_password, panel_api, register, sing_in, sing_out, img_uploader
from system.page_loader import page_loader
from modules.apis import api_loader
from modules.plugins.blogger.blog import blog_api
session = requests.session()
session.proxies = {}
session.proxies['http'] = 'socks5h://localhost:9050'
session.proxies['https'] = 'socks5h://localhost:9050'
app = Flask(__name__)
app.secret_key = b'82d52ae6cdbed6a5s9c15s19a5sc9a5s12f4043ebde05d2'
app.wsgi_app = ProxyFix(app.wsgi_app)
app.config["TEMPLATES_AUTO_RELOAD"] = True
ckeditor = CKEditor(app)
app.config['CKEDITOR_PKG_TYPE'] = 'full-all'
app.config['CKEDITOR_FILE_UPLOADER'] = 'uploads'
app.config['CKEDITOR_HEIGHT'] = 900
modules_bp = Blueprint('modules', __name__, template_folder='templates', static_folder='static')
app.register_blueprint(modules_bp)
if app.testing:
app.config['WTF_CSRF_ENABLED'] = False
login.init_app(app)
login.login_view = '/login'
@app.route('/', methods=["GET", "POST"])
def index():
if request.remote_addr == '127.0.0.1' or request.remote_addr == 'localhost':
pass
else:
sqlite_utils.Database('db/_sec.db')['req_rec'].insert({'ip': request.remote_addr, "user_agents": str(request.user_agent), "crt_date": str(DT.now())}, alter=True)
ip_recs = list(sqlite_utils.Database('db/_sec.db')['req_rec'].rows_where("ip = ?", [request.remote_addr]))
count_recs = len(ip_recs)
if int(count_recs) < 100:
pass
else:
rm_recs = count_recs - 100
sqlite_utils.Database('db/_sec.db')['req_rec'].delete(where="data_colum > :rm_recs", rm_recs=rm_recs)
if request.method == 'GET':
pag = request.args.get('pag')
if pag is not None:
return render_template('layout.html', pag=pag)
else:
return render_template('layout.html', pag="home")
@app.errorhandler(404)
def error_page(error):
return render_template("error.html", title=error), 404
### REGISTER
@app.route('/regist', methods=["GET", "POST"])
def reg_ac():
return register()
### LOGIN
@app.route('/login', methods=["GET", "POST"])
def log_in():
return sing_in()
### LOG OUT
@app.route('/logout')
def log_out():
return sing_out()
### CLT PANEL
@app.route('/panel', methods=["GET", "POST"])
@login_required
def panel():
return panel_api()
@app.route('/panel/blogger', methods=["GET", "POST"])
@login_required
def blogger_mod():
return blog_api()
### CMS PANEL API
@app.route('/settings/<config>', methods=["GET", "POST"])
@login_required
def user_conf(config):
if request.method == "POST":
if config == 'update_profile':
print('demo')
return 'TEST Today' + str(DT.now())
@app.route('/dashboard', methods=["GET", "POST"])
@login_required
async def dashboard():
return await page_loader("dashboard")
@app.route("/api/<version>/", methods=["GET", "POST"])
async def apis(version):
return await api_loader(version)
### OUTER WEB PAGE REFIRECT INDEX
@app.route("/<page>/", methods=["GET", "POST"])
async def pageLader(page):
if page is not None:
return await page_loader(page)
else:
return redirect('/')
### ckEditor Upload example ***
# @app.route('/files/<path:filename>')
# def uploaded_files(filename):
# path = '/the/uploaded/directory'
# return send_from_directory(path, filename)
# @app.route('/upload', methods=['POST'])
# def upload():
# f = request.files.get('upload')
# # Add more validations here
# extension = f.filename.split('.')[-1].lower()
# if extension not in ['jpg', 'gif', 'png', 'jpeg']:
# return upload_fail(message='Image only!')
# f.save(os.path.join('/the/uploaded/directory', f.filename))
# url = url_for('uploaded_files', filename=f.filename)
# return upload_success(url, filename=f.filename) # return upload_success call
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5001, debug=True)