summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/config/core_default.xml6
-rw-r--r--module/web/ServerThread.py4
-rw-r--r--module/web/cnl/views.py2
-rw-r--r--module/web/pyload/views.py38
-rw-r--r--module/web/settings.py20
-rw-r--r--module/web/templates/default/settings.html133
6 files changed, 82 insertions, 121 deletions
diff --git a/module/config/core_default.xml b/module/config/core_default.xml
index d1c059060..ab247be08 100644
--- a/module/config/core_default.xml
+++ b/module/config/core_default.xml
@@ -18,12 +18,6 @@
<host type="ip" name="IP">0.0.0.0</host>
<port type="int" name="Port">8001</port>
<template type="str" name="Template">default</template>
- <local type="bool" name="Local">True</local>
- <ssl type="bool" name="SSL">False</ssl>
- <username type="str" name="Username">None</username>
- <adress type="ip" name="Adress">None</adress>
- <extport type="int" name="Extern Port">None</extport>
- <pw type="str" name="Password">None</pw>
</webinterface>
<log name="Log">
<file_log type="bool" name="File Log">True</file_log>
diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py
index aa1f67244..c4efc61dc 100644
--- a/module/web/ServerThread.py
+++ b/module/web/ServerThread.py
@@ -10,10 +10,14 @@ from cStringIO import StringIO
import threading
import sys
+core = None
+
class WebServer(threading.Thread):
def __init__(self, pycore):
+ global core
threading.Thread.__init__(self)
self.pycore = pycore
+ core = pycore
self.running = True
self.server = pycore.config['webinterface']['server']
self.https = pycore.config['webinterface']['https']
diff --git a/module/web/cnl/views.py b/module/web/cnl/views.py
index aeb6174a7..69a2ce4e8 100644
--- a/module/web/cnl/views.py
+++ b/module/web/cnl/views.py
@@ -19,7 +19,7 @@ except:
def local_check(function):
def _dec(view_func):
def _view(request, * args, ** kwargs):
- if request.META['REMOTE_ADDR'] == '127.0.0.1' or request.META['REMOTE_ADDR'] == 'localhost':
+ if request.META.get('REMOTE_ADDR', "0") in ('127.0.0.1','localhost') or request.META.get('HTTP_HOST','0') == '127.0.0.1:9666':
return view_func(request, * args, ** kwargs)
else:
return HttpResponseServerError()
diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py
index 6dbbd22c6..db04f8c67 100644
--- a/module/web/pyload/views.py
+++ b/module/web/pyload/views.py
@@ -170,5 +170,41 @@ def collector(request):
@check_server
def config(request):
conf = settings.PYLOAD.get_config_data()
+
+ if request.META.get('REQUEST_METHOD', "GET") == "POST":
+
+ errors = []
+
+ for key, value in request.POST.iteritems():
+ if not "|" in key: continue
+ skey, okey = key.split("|")[:]
+ if conf.has_key(skey):
+ if conf[skey]['options'].has_key(okey):
+ try:
+ if str(conf[skey]['options'][okey]['value']) != value:
+ settings.PYLOAD.set_conf_val(skey, okey, value)
+ except:
+ errors.append("%s | %s" % (skey, okey))
+ else:
+ continue
+ else:
+ continue
+
+ messages = []
+
+ if errors:
+ messages.append(_("Error occured when setting the following options:"))
+ messages.append("")
+ messages += errors
+ else:
+ messages.append(_("All options set correctly."))
+
+ return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': {}, 'errors': messages}, [status_proc]))
+
+
+ for section in conf.iterkeys():
+ for option in conf[section]['options'].iterkeys():
+ if conf[section]['options'][option]['input']:
+ conf[section]['options'][option]['input'] = conf[section]['options'][option]['input'].split(";")
- return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': conf}, [status_proc]))
+ return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': conf, 'messages': []}, [status_proc]))
diff --git a/module/web/settings.py b/module/web/settings.py
index bbea1690b..3ab5ff20e 100644
--- a/module/web/settings.py
+++ b/module/web/settings.py
@@ -6,7 +6,6 @@ TEMPLATE_DEBUG = DEBUG
import os.path
import sys
-import xmlrpclib
SERVER_VERSION = "0.3.2"
@@ -22,13 +21,19 @@ config = XMLConfigParser(os.path.join(PYLOAD_DIR,"module","config","core.xml"))
#DEBUG = config.get("general","debug")
+try:
+ import module.web.ServerThread
+ if not module.web.ServerThread.core:
+ raise Exception
+ PYLOAD = module.web.ServerThread.core.server_methods
+except:
+ import xmlrpclib
+ ssl = ""
-ssl = ""
+ if config.get("ssl", "activated"):
+ ssl = "s"
-if config.get("ssl", "activated"):
- ssl = "s"
-
-server_url = "http%s://%s:%s@%s:%s/" % (
+ server_url = "http%s://%s:%s@%s:%s/" % (
ssl,
config.get("remote", "username"),
config.get("remote", "password"),
@@ -36,7 +41,8 @@ server_url = "http%s://%s:%s@%s:%s/" % (
config.get("remote", "port")
)
-PYLOAD = xmlrpclib.ServerProxy(server_url, allow_none=True)
+ PYLOAD = xmlrpclib.ServerProxy(server_url, allow_none=True)
+
TEMPLATE = config.get('webinterface','template')
DL_ROOT = os.path.join(PYLOAD_DIR, config.get('general','download_folder'))
diff --git a/module/web/templates/default/settings.html b/module/web/templates/default/settings.html
index d3d906c47..4d2d2a591 100644
--- a/module/web/templates/default/settings.html
+++ b/module/web/templates/default/settings.html
@@ -27,126 +27,47 @@
{% block content %}
-{{ conf }}
+{% for message in errors %}
+<b>{{message}}</b><br>
+{% endfor %}
+<form id="horizontalForm" action="" method="POST">
-<h3>Coming Soon.</h3>
-
-<form id="horizontalForm" action="">
-
- {% for key, section in conf.items %}
+ {% for skey, section in conf.items %}
<fieldset>
<legend>
{{section.name}}
</legend>
- {% for key, option in section.options.items %}
+ {% for okey, option in section.options.items %}
- <label for="{{option.name}}">
+ <label for="{{skey}}|{{okey}}">
{{option.name}}
- <input id="{{option.name}}" name="{{option.name}}" type="text" value="{{option.value}}"/>
+ {% ifequal option.type "bool" %}
+ <select id="{{skey}}|{{okey}}" name="{{skey}}|{{okey}}">
+ <option {% if option.value %} selected="selected" {% endif %}value="True">{% trans "on" %}</option>
+ <option {% if not option.value %} selected="selected" {% endif %}value="False">{% trans "off" %}</option>
+ </select>
+ {% else %}
+ {% if option.input %}
+ <select id="{{skey}}|{{okey}}" name="{{skey}}|{{okey}}">
+ {% for entry in option.input %}
+ <option {% ifequal option.value entry %} selected="selected" {% endifequal %}>{{entry}}</option>
+ {% endfor %}
+ </select>
+ {% else %}
+ <input id="{{skey}}|{{okey}}" name="{{skey}}|{{okey}}" type="text" value="{{option.value}}"/>
+ {% endif %}
+ {% endifequal %}
</label>
{% endfor %}
</fieldset>
{% endfor %}
-
- <fieldset>
- <legend>
- Name
- </legend>
- <label class="first" for="title1">
- Title
- <select id="title1" name="title1">
- <option selected="selected">Mr.</option>
-
- <option>Mrs.</option>
- <option>Ms.</option>
- <option>Dr.</option>
- <option>Viscount</option>
- </select>
- </label>
- <label for="firstName1">
-
- First name
- <input id="firstName1" name="firstName1" type="text" value="First name" />
- </label>
- <label for="lastName1">
- Last name
- <input id="lastName1" name="lastName1" type="text" value="Last name" />
- </label>
- <div class="clearer"></div>
- </fieldset>
- <fieldset>
-
- <legend>
- Address
- </legend>
- <label class="first" for="street1">
- Street
- <input id="street1" name="street1" type="text" value="Street" />
- </label>
- <label for="city1">
- City
- <input id="city1" name="city1" type="text" value="City" />
-
- </label>
- <label for="state1">
- State
- <input id="state1" name="state1" type="text" value="State" />
- </label>
- <label for="postcode1">
- Postcode
- <input id="postcode1" name="postcode1" type="text" value="Postcode" />
- </label>
- <label for="country1">
-
- Country
- <input id="country1" name="country1" type="text" value="Country" />
- </label>
- <div class="clearer"></div>
- </fieldset>
- <fieldset>
- <legend>
- Payment details
- </legend>
- <fieldset class="radio">
-
- <legend>
- Credit card
- </legend>
- <label for="cardType1A">
- <input id="cardType1A" name="card1" type="radio" />
- American Express
- </label>
- <label for="cardType1B">
- <input id="cardType1B" name="card1" type="radio" />
- Mastercard
- </label>
-
- <label for="cardType1C">
- <input id="cardType1C" name="card1" type="radio" />
- Visa
- </label>
- <label for="cardType1D">
- <input id="cardType1D" name="card1" type="radio" />
- Blockbuster Card
- </label>
- <div class="clearer"></div>
- </fieldset>
-
- <label for="cardNum1">
- Card number
- <input id="cardNum1" name="cardNum1" type="text" value="Card number" />
- </label>
- <label for="expiry1">
- Expiry date
- <input id="expiry1" name="city1" type="text" value="City" />
- </label>
- <input class="submit" type="submit" value="Submit my details" />
- <div class="clearer"></div>
-
- </fieldset>
+ {% if conf %}
+ <input class="submit" type="submit" value="{% trans "Submit" %}" />
+ <div class="clearer"></div>
+ {% endif %}
</form>