diff --git a/files/__main__.py b/files/__main__.py index d546dd7662..0137a5ea81 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -16,7 +16,7 @@ import gevent from werkzeug.middleware.proxy_fix import ProxyFix import redis -app = Flask(__name__, template_folder='./templates') +app = Flask(__name__, template_folder='templates') app.wsgi_app = ProxyFix(app.wsgi_app, x_for=3) app.url_map.strict_slashes = False app.jinja_env.cache = {} @@ -35,14 +35,13 @@ app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 86400 app.config["SESSION_COOKIE_NAME"] = "session_" + environ.get("SITE_NAME").strip().lower() app.config["VERSION"] = "1.0.0" app.config['MAX_CONTENT_LENGTH'] = 8 * 1024 * 1024 -app.config["SESSION_COOKIE_SECURE"] = bool(int(environ.get("FORCE_HTTPS", 1))) +app.config["SESSION_COOKIE_SECURE"] = True app.config["SESSION_COOKIE_SAMESITE"] = "Lax" app.config["PERMANENT_SESSION_LIFETIME"] = 60 * 60 * 24 * 365 -app.config["SESSION_REFRESH_EACH_REQUEST"] = True app.config["SLOGAN"] = environ.get("SLOGAN", "").strip() app.config["DEFAULT_COLOR"] = environ.get("DEFAULT_COLOR", "ff0000").strip() app.config["DEFAULT_THEME"] = environ.get("DEFAULT_THEME", "midnight").strip() -app.config["FORCE_HTTPS"] = int(environ.get("FORCE_HTTPS", 1)) if ("localhost" not in app.config["SERVER_NAME"] and "localhost" not in app.config["SERVER_NAME"]) else 0 +app.config["FORCE_HTTPS"] = 1 app.config["UserAgent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36" app.config["HCAPTCHA_SITEKEY"] = environ.get("HCAPTCHA_SITEKEY","").strip() app.config["HCAPTCHA_SECRET"] = environ.get("HCAPTCHA_SECRET","").strip() @@ -51,7 +50,6 @@ app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] = int(environ.get("SPAM_SIMILAR_COUNT app.config["SPAM_URL_SIMILARITY_THRESHOLD"] = float(environ.get("SPAM_URL_SIMILARITY_THRESHOLD", 0.5)) app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"] = float(environ.get("COMMENT_SPAM_SIMILAR_THRESHOLD", 0.5)) app.config["COMMENT_SPAM_COUNT_THRESHOLD"] = int(environ.get("COMMENT_SPAM_COUNT_THRESHOLD", 0.5)) -app.config["VIDEO_COIN_REQUIREMENT"] = int(environ.get("VIDEO_COIN_REQUIREMENT", 0)) app.config["READ_ONLY"]=bool(int(environ.get("READ_ONLY", "0"))) app.config["BOT_DISABLE"]=bool(int(environ.get("BOT_DISABLE", False))) app.config["RATELIMIT_KEY_PREFIX"] = "flask_limiting_" @@ -99,11 +97,7 @@ def before_request(): g.timestamp = int(time.time()) - if not request.path.startswith("/assets") and not request.path.startswith("/images") and not request.path.startswith("/hostedimages"): - session.permanent = True - if not session.get("session_id"): session["session_id"] = secrets.token_hex(16) - - if app.config["FORCE_HTTPS"] and request.url.startswith("http://") and "localhost" not in app.config["SERVER_NAME"]: + if request.url.startswith("http://") and "localhost" not in app.config["SERVER_NAME"]: url = request.url.replace("http://", "https://", 1) return redirect(url, code=301) @@ -127,5 +121,11 @@ def after_request(response): response.headers.add("X-Frame-Options", "deny") return response +@app.route("/", subdomain="www") +@app.route("/", subdomain="old") +@app.route("/", subdomain="www") +@app.route("/", subdomain="old") +def sub_redirect(path): + return redirect(request.full_path) from files.routes import * \ No newline at end of file diff --git a/files/routes/login.py b/files/routes/login.py index da59102137..4e6b708c71 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -134,10 +134,10 @@ def login_post(): else: abort(400) + session.permanent = True session["session_id"] = token_hex(49) session["lo_user"] = account.id session["login_nonce"] = account.login_nonce - session.permanent = True check_for_alts(account.id) @@ -337,9 +337,9 @@ def sign_up_post(v): if "rama" in request.host: send_notification(new_user.id, WELCOME_MSG) + session.permanent = True session["session_id"] = token_hex(49) session["lo_user"] = new_user.id - session.permanent = True g.db.commit() diff --git a/files/templates/admin/badge_grant.html b/files/templates/admin/badge_grant.html index d8b1bf0490..dd285ad6b6 100644 --- a/files/templates/admin/badge_grant.html +++ b/files/templates/admin/badge_grant.html @@ -60,7 +60,7 @@ - + {{v['name']}} {{v['description']}} diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 0e868c3671..432633dac0 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -14,11 +14,11 @@ {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} @@ -90,7 +90,7 @@
- + diff --git a/files/templates/award_modal.html b/files/templates/award_modal.html index b4c0a9be68..f740aec4f7 100644 --- a/files/templates/award_modal.html +++ b/files/templates/award_modal.html @@ -1,4 +1,4 @@ - + diff --git a/files/templates/login_2fa.html b/files/templates/login_2fa.html index ec2aaf581a..5aa3182071 100644 --- a/files/templates/login_2fa.html +++ b/files/templates/login_2fa.html @@ -13,7 +13,7 @@ 2-Step Login - {{'SITE_NAME' | app_config}} - + @@ -93,7 +93,7 @@
- + diff --git a/files/templates/mobile_navigation_bar.html b/files/templates/mobile_navigation_bar.html index 9d3842512e..c68a2fde92 100644 --- a/files/templates/mobile_navigation_bar.html +++ b/files/templates/mobile_navigation_bar.html @@ -68,7 +68,7 @@ - + - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} - + @@ -239,7 +239,7 @@ {% block onload %}{% endblock %} - + - + {% else %} - + {% endif %} - + diff --git a/files/templates/settings_blocks.html b/files/templates/settings_blocks.html index a6098e9d47..28fe70f097 100644 --- a/files/templates/settings_blocks.html +++ b/files/templates/settings_blocks.html @@ -4,7 +4,7 @@ {% block content %} - +
diff --git a/files/templates/settings_profile.html b/files/templates/settings_profile.html index ede61f6d48..10b6c22db3 100644 --- a/files/templates/settings_profile.html +++ b/files/templates/settings_profile.html @@ -701,7 +701,7 @@
- + {% include "emoji_modal.html" %} {% include "gif_modal.html" %} diff --git a/files/templates/settings_security.html b/files/templates/settings_security.html index 33a5743251..57a4a4f7e3 100644 --- a/files/templates/settings_security.html +++ b/files/templates/settings_security.html @@ -4,7 +4,7 @@ {% block content %} - +
diff --git a/files/templates/sign_up.html b/files/templates/sign_up.html index 5aef16a785..75fbb64924 100644 --- a/files/templates/sign_up.html +++ b/files/templates/sign_up.html @@ -4,7 +4,7 @@ - + @@ -13,7 +13,7 @@ - + @@ -24,13 +24,13 @@ - + {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}Sign up - {{'SITE_NAME' | app_config}}{% endif %} - + @@ -140,7 +140,7 @@
- +
@@ -148,10 +148,10 @@ - + {% if hcaptcha %} - + {% endif %} diff --git a/files/templates/sign_up_failed_ref.html b/files/templates/sign_up_failed_ref.html index 795db705c1..ddc5261a97 100644 --- a/files/templates/sign_up_failed_ref.html +++ b/files/templates/sign_up_failed_ref.html @@ -5,7 +5,7 @@ - + @@ -14,7 +14,7 @@ - + @@ -25,13 +25,13 @@ - + {% if ref_user %}{{ref_user.username}} invites you to {{'SITE_NAME' | app_config}}{% else %}{{'SITE_NAME' | app_config}}{% endif %} - + @@ -83,7 +83,7 @@
- + diff --git a/files/templates/submission.html b/files/templates/submission.html index 7c03e35436..147dc51529 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -87,19 +87,19 @@ } - + {% endif %} {% if p.award_count("train") > 1 %} - + {% endif %} {% if p.award_count("train") > 2 %} - + {% endif %} {% if p.award_count("train") > 3 %} - + {% endif %} @@ -337,7 +337,7 @@ {% if p.active_flags %}{{p.active_flags}} Reports{% endif %} {% if p.author.verified %} {% endif %} - {{p.author.username}}{% if p.author.customtitle %}  {% if p.author.quadrant %}{% endif %}{{p.author.customtitle | safe}}{% endif %} + {{p.author.username}}{% if p.author.customtitle %}  {% if p.author.quadrant %}{% endif %}{{p.author.customtitle | safe}}{% endif %}  {{p.age_string}} ({% if p.is_image %}image post{% elif p.is_video %}video post{% elif p.realurl(v) %}{{p.domain}}{% else %}text post{% endif %}) @@ -388,9 +388,9 @@ {% if p.domain == "twitter.com" %} {{p.embed_url | safe}} {% if v and v.theme.split("_")[0] in ["light", "coffee", "4chan"] %} - + {% else %} - + {% endif %} {% elif p.domain in ['youtu.be','youtube.com'] and p.embed_url and p.embed_url.startswith(' {% if offset %} - + {% endif %} {% elif not p.replies and p.deleted_utc == 0 %} @@ -810,32 +810,32 @@ {% endif %} {% if v and (v.id == p.author_id or v.admin_level > 1 and v.admin_level > 2) %} - + {% endif %} {% if v %} - + {% endif %} {% if not v or v.highlightcomments %} - + {% endif %} - + {% if not p.comment_count %} {% include "comments.html" %} {% endif %} {% if p.award_count("shit") %} - - + + {% endif %} {% if p.award_count("fireflies") %} - - + + {% endif %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 799fc6157e..3c312bf54e 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -9,7 +9,7 @@ {% endif %} {% if not v or v.highlightcomments %} - + {% endif %} - - \ No newline at end of file + + + \ No newline at end of file diff --git a/files/templates/submit.html b/files/templates/submit.html index ee2c16f208..db9ceb0d39 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -3,13 +3,13 @@ - + - + {% if request.host == 'pcmemes.net' %} {% set cc='Splash Mountain' %} @@ -25,16 +25,16 @@ {% block stylesheets %} {% if v %} - - {% if v.agendaposter %}{% elif v.css %}{% endif %} + + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - - + + {% endif %} {% endblock %} - + @@ -175,9 +175,9 @@ {% endblock %} - - - + + + {% include "emoji_modal.html" %} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 2c4b5d68c5..c733d492ed 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -97,7 +97,7 @@ - {% if u.customtitle %}

{% if u.quadrant %}{% endif %}{{u.customtitle | safe}}

+ {% if u.customtitle %}

{% if u.quadrant %}{% endif %}{{u.customtitle | safe}}

{% else %}

 				{% endif %}
 
@@ -105,11 +105,11 @@
 
 				
{{u.coins}} -    +    {% if u.procoins %} {{u.procoins}} -    +    {% endif %} {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   {% endif %} @@ -371,7 +371,7 @@ {% if v and v.has_follower(u) and not v.is_nofollow %} Follows you {% endif %} - {% if u.customtitle %}

{% if u.quadrant %}{% endif %}{{u.customtitle | safe}}

+ {% if u.customtitle %}

{% if u.quadrant %}{% endif %}{{u.customtitle | safe}}

{% else %}

 				{% endif %}
@@ -380,11 +380,11 @@
 				
 				
{{u.coins}} -    +    {% if u.procoins %} {{u.procoins}} -    +    {% endif %} {% if u.stored_subscriber_count >=1 and not u.is_nofollow %}{{u.stored_subscriber_count}} follower{{'s' if u.stored_subscriber_count != 1 else ''}}   {% endif %} @@ -696,11 +696,11 @@ {% if v %}
{% if v.patron or u.patron %}0{% else %}0.03{% endif %}
- +
{{u.username}}
{% endif %} - + {% endblock %} diff --git a/files/templates/userpage_comments.html b/files/templates/userpage_comments.html index c4a78d97d0..528274d8e5 100644 --- a/files/templates/userpage_comments.html +++ b/files/templates/userpage_comments.html @@ -110,9 +110,9 @@ {% if v %}
{% if v.patron or u.patron %}0{% else %}0.03{% endif %}
- +
{{u.username}}
{% endif %} - + {% endblock %} \ No newline at end of file diff --git a/files/templates/userpage_private.html b/files/templates/userpage_private.html index 4312d84963..c81bd3d82a 100644 --- a/files/templates/userpage_private.html +++ b/files/templates/userpage_private.html @@ -44,9 +44,9 @@ {% if v %}
{% if v.patron or u.patron %}0{% else %}0.03{% endif %}
- +
{{u.username}}
{% endif %} - + {% endblock %} \ No newline at end of file