Commit 0110f150 authored by Andreas Valder's avatar Andreas Valder
Browse files

Merge branch 'master' of git.fsmpi.rwth-aachen.de:videoagwebsite/videoagwebsite

parents 267ea0ab 69810f43
......@@ -26,3 +26,4 @@ SQLITE_INIT_DATA = True
#LDAP_HOST = 'ldaps://rumo.fsmpi.rwth-aachen.de'
#ICAL_URL = 'https://user:password@mail.fsmpi.rwth-aachen.de/SOGo/....ics'
ERROR_PAGE = 'static/500.html'
RWTH_IP_RANGES = ['134.130.0.0/16', '137.226.0.0/16', '134.61.0.0/16', '192.35.229.0/24', '2a00:8a60::/32']
......@@ -11,6 +11,7 @@ import sched
import traceback
import string
from socket import gethostname
from ipaddress import ip_address, ip_network
app = Flask(__name__)
......@@ -142,6 +143,12 @@ def checkperm(perms, username=None, password=None):
elif perm['type'] == 'rwth':
if session.get('rwthintern', False):
return True
if 'X-Real-IP' not in request.headers:
continue
ip = ip_address(request.headers['X-Real-IP'])
for net in config['RWTH_IP_RANGES']:
if ip in ip_network(net):
return True
return False
@app.template_filter()
......@@ -321,7 +328,7 @@ def index():
LEFT JOIN courses on (courses.id = lectures.course_id)
WHERE (? OR (courses.visible AND courses.listed AND lectures.visible AND videos.visible))
GROUP BY videos.lecture_id
ORDER BY MAX(videos.time_updated) DESC
ORDER BY MAX(videos.time_created) DESC
LIMIT 6 ''',ismod())
livestreams = query('''SELECT streams.handle AS live, lectures.*, "course" AS sep, courses.*
FROM streams
......@@ -341,7 +348,7 @@ def index():
@app.route('/courses')
@register_navbar('Videos', icon='film')
def courses():
courses = query('SELECT * FROM courses WHERE (? OR (visible AND listed)) ORDER BY title', ismod())
courses = query('SELECT * FROM courses WHERE (? OR (visible AND listed)) ORDER BY semester, title', ismod())
for course in courses:
if course['semester'] == '':
course['semester'] = 'zeitlos'
......@@ -574,7 +581,6 @@ def auth(): # For use with nginx auth_request
if 'X-Original-Uri' not in request.headers:
return 'Internal Server Error', 500
url = request.headers['X-Original-Uri'].lstrip(config['VIDEOPREFIX'])
ip = request.headers.get('X-Real-IP', '')
if request.cookies.get('tracking', '') and request.cookies['tracking'].isdigit():
cookie = int(request.cookies['tracking'])
else:
......
......@@ -63,7 +63,7 @@
</a>
</div>
<ul class="{% if not ismod() %}courses-list {% endif %}list-group panel-collapse collapse in" id="{{g.grouper|tagid}}">
{% for i in g.list|sort(attribute='title') %}
{% for i in g.list %}
{% if groupedby == 'semester' %}
{{ course_list_item(i) }}
{% else %}
......
......@@ -121,7 +121,7 @@
</ul>
{% else %}
<div class="panel-body">
<p>In den nächsten 7 Tagen wird noch nichts aufgenommen oder gestreamt.</p>
<p>In den nächsten 7 Tagen sind keine Aufnahmen oder Livestreams geplant.</p>
</div>
{% endif %}
</div>
......
......@@ -125,7 +125,7 @@ $(function() {
{% macro video_download_btn(videos) %}
{% if not ismod() %}
<span class="btn btn-default dropdown-toggle{% if videos|length is equalto 0 %} disabled{% endif %}" type="button" data-toggle="dropdown">Download <span class="caret"></span></span>
<span class="btn btn-default dropdown-toggle{% if not videos|selectattr('downloadable')|list and not ismod() %} disabled{% endif %}" type="button" data-toggle="dropdown">Download <span class="caret"></span></span>
<ul class="dropdown-menu">
{% for v in videos|sort(attribute='prio', reverse=True) if (v.downloadable or ismod() ) %}
<li><a href="{{ config.VIDEOPREFIX }}/{{v.path}}">{{v.format_description}} ({{v.file_size|filesizeformat(true)}})</a></li>
......
#!/bin/env python3
import requests
import sys
failed = 0
def checkurl(path, ignore=False, status=200):
global failed
for prefix in ['http://videoag.fsmpi.rwth-aachen.de', 'https://videoag.fsmpi.rwth-aachen.de', 'https://video.fsmpi.rwth-aachen.de', 'https://video.rwth-aachen.de', 'https://rwth.video']:
req = requests.head(prefix+path, allow_redirects=True)
if req.status_code != status:
if ignore:
print('[urlcheck_legacy]', 'Warning:', req.status_code, prefix+path)
else:
print('[urlcheck_legacy]', 'Error:', req.status_code, prefix+path)
failed += 1
checkurl('/')
checkurl('/site/feed.php?newcourses')
checkurl('/?view=faq')
checkurl('/site/feed.php?all')
checkurl('/?course=16ws-progra')
checkurl('/?view=player&lectureid=7319')
checkurl('/pub/16ws-progra/16ws-progra-161019-1080p.mp4')
checkurl('/site/feed.php?16ws-afi')
checkurl('/site/embed.php?vid=6088')
checkurl('/site/embed.php?lecture=7319')
if failed:
sys.stderr.write('[urlcheck_legacy] '+str(failed)+' checks failed')
sys.exit(1)
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment