diff --git a/website/web/__init__.py b/website/web/__init__.py index 9eb4f05b..59b5080e 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -555,6 +555,10 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None): cache = lookyloo.capture_cache(tree_uuid) except MissingUUID: status = lookyloo.get_capture_status(tree_uuid) + splash_up, splash_message = lookyloo.splash_status() + if not splash_up: + flash(f'The capture module is not reachable ({splash_message}).', 'error') + flash('The request will be enqueued, but capturing may take a while and require the administrator to wake up.', 'error') if status == CaptureStatus.UNKNOWN: flash(f'Unable to find this UUID ({tree_uuid}).', 'error') return redirect(url_for('index')) @@ -752,11 +756,12 @@ def search(): @app.route('/capture', methods=['GET', 'POST']) def capture_web(): - if request.form.get('url'): - if flask_login.current_user.is_authenticated: - user = flask_login.current_user.get_id() - else: - user = src_request_ip(request) + if flask_login.current_user.is_authenticated: + user = flask_login.current_user.get_id() + else: + user = src_request_ip(request) + + if request.method == 'POST' and request.form.get('url'): capture_query: Dict[str, Union[str, bytes, int, bool]] = {'url': request.form['url']} # check if the post request has the file part if 'cookies' in request.files and request.files['cookies'].filename: @@ -792,6 +797,12 @@ def capture_web(): perma_uuid = lookyloo.enqueue_capture(capture_query, source='web', user=user, authenticated=flask_login.current_user.is_authenticated) time.sleep(30) return redirect(url_for('tree', tree_uuid=perma_uuid)) + elif request.method == 'GET' and request.args.get('url'): + url = unquote_plus(request.args['url']).strip() + capture_query = {'url': url} + perma_uuid = lookyloo.enqueue_capture(capture_query, source='web', user=user, authenticated=flask_login.current_user.is_authenticated) + return redirect(url_for('tree', tree_uuid=perma_uuid)) + user_agents: Dict[str, Any] = {} if use_own_ua: user_agents = get_user_agents('own_user_agents') diff --git a/website/web/genericapi.py b/website/web/genericapi.py index 2bedac25..06d7beeb 100644 --- a/website/web/genericapi.py +++ b/website/web/genericapi.py @@ -344,7 +344,12 @@ class SubmitCapture(Resource): if 'url' not in request.args or not request.args.get('url'): return 'No "url" in the URL params, nothting to capture.', 400 - to_query = {'url': request.args['url'], 'listing': int(request.args['listing'])} + try: + listing = int(request.args['listing']) + except Exception: + listing = 1 + + to_query = {'url': request.args['url'], 'listing': listing} if request.args.get('user_agent'): to_query['user_agent'] = request.args['user_agent'] if request.args.get('referer'): diff --git a/website/web/templates/tree_wait.html b/website/web/templates/tree_wait.html index 6dea1936..20adf3d8 100644 --- a/website/web/templates/tree_wait.html +++ b/website/web/templates/tree_wait.html @@ -1,7 +1,9 @@ {% extends "main.html" %} +{% from 'bootstrap/utils.html' import render_messages %} {% block title %}Ongoing capture...{% endblock %} {% block content %} +{{ render_messages(container=True, dismissible=True) }}