This commit is contained in:
BlenderDumbass 2024-12-09 20:39:23 +02:00
parent 49cea62407
commit 3008659ce0
2 changed files with 31 additions and 11 deletions

View file

@ -81,6 +81,14 @@ def head(title="", description="", image="", config={}, author=""):
<meta property="og:description" content=\""""+Safe(description)+"""">
<meta property="og:image" content=\""""+image+"""">
<!-- RSS Link -->
<link rel="alternate" title='"""+config.get("title", "My Website")+"""' type="application/rss+xml" href="/rss" />
"""
if author:
html = html + """
<link rel="alternate" title='Just @"""+author+"""' type="application/rss+xml" href="/rss?author="""+author+"""" />
"""
# Author tags.
@ -173,8 +181,17 @@ def validate(cookie):
return Accounts[account]
return {}
def isHuman(cookie):
def isHuman(server):
cookie = server.cookie
# Identifying probable browsers
useragent = False
for i in ["Chrome", "Firefox", "Safari", "Mozilla"]:
if i in server.headers.get("User-Agent"):
useragent = True
break
if not useragent: return False
return ( cookie in ProbablyHumanCookies and cookie in KnownCookies ) or validate(cookie)
def moderates(moderator, user):
@ -849,7 +866,7 @@ def AccountPage(server, account):
html = html + '</center>'
# Protecting emails and stuff from scrubbers
if isHuman(server.cookie):
if isHuman(server):
# Website
@ -885,15 +902,15 @@ def AccountPage(server, account):
try:
mastodon = mastohead(mastodon)
mastolink = mastolink(mastodon)
Mastodon = mastohead(mastodon)
Mastolink = mastolink(mastodon)
html = html + '<center>'
html = html + '<img style="vertical-align: middle" src="/icon/mastodon">'
html = html + '<a href="'+mastolink+'"> '+mastodon+'</a>'
html = html + '<a href="'+Mastolink+'"> '+Mastodon+'</a>'
html = html + '</center>'
except:
pass
except Exception as e:
print(e)
# Matrix
@ -1642,7 +1659,7 @@ def Footer(server):
Accounts = accounts()
if account in Accounts:
if isHuman(server.cookie):
if isHuman(server):
email = Accounts[account].get("email")
if email:
html = html + Button("Contact Admin", "mailto:"+email, "frase")
@ -2073,7 +2090,7 @@ def Error(server, text="Some Error Happened."):
send(server, html, 501)
def FreeCompetitor(free, nonfree):
def FreeCompetitor(free, nonfree, score):
html = """
@ -2084,6 +2101,7 @@ def FreeCompetitor(free, nonfree):
html = html + '<h1><img alt="[icon fc]" src="/icon/fc" style="vertical-align: middle">'
html = html + free.get("names", ["Software"])[0]+'</h1>'
icon = free.get("links", {}).get("icon", "")
if icon:
html = html + '<center><img alt="[thumbnail]" style="min-width:80%;" src="'+icon+'"></center>'
@ -2584,7 +2602,7 @@ def UpdatePublicationRights(server):
def DoComment(server):
# Limiting bots from commenting
if not isHuman(server.cookie):
if not isHuman(server):
AccessDenied(server)
return
@ -3347,7 +3365,7 @@ def Search(server):
if soft[1].get("names", [""])[0] in fcdata.get("found", {}).get("data", {}).get("names", []):
continue
html = html + FreeCompetitor(soft[1], fcdata.get("found", {}).get("data",{}))
html = html + FreeCompetitor(soft[1], fcdata.get("found", {}).get("data",{}), soft[0])

View file

@ -132,6 +132,8 @@ class handler(BaseHTTPRequestHandler):
self.cookie = self.headers.get("Cookie")
if self.cookie: self.cookie = self.cookie[-200:]
#print(self.headers)
# ignore = ["/rss"]
# if not self.cookie and not self.path.startswith(tuple(ignore)):