Always listen on localhost:80 to ensure streaming works.
[vuplus_dvbapp-plugin] / webinterface / src / webif.py
index fe08448..f16100f 100644 (file)
@@ -16,12 +16,18 @@ from xml.sax.handler import ContentHandler, feature_namespaces
 from xml.sax.saxutils import escape as escape_xml
 from twisted.python import util
 from urllib2 import quote
+from time import time
 
 #DO NOT REMOVE THIS IMPORT
 #It IS used (dynamically)
 from WebScreens import *
 #DO NOT REMOVE THIS IMPORT
-               
+
+from __init__ import decrypt_block
+from os import urandom
+
+global screen_cache
+screen_cache = {}
 
 # The classes and Function in File handle all ScreenPage-based requests
 # ScreenPages use enigma2 standard functionality to bring contents to a webfrontend
@@ -428,6 +434,8 @@ class webifHandler(ContentHandler):
 
        def startElement(self, name, attrs):
                if name == "e2:screen":
+                       if "external_module" in attrs:
+                               exec "from " + attrs["external_module"] + " import *"
                        self.screen = eval(attrs["name"])(self.session, self.request) # fixme
                        self.screens.append(self.screen)
                        return
@@ -560,3 +568,20 @@ def requestFinish(handler, request):
        request.finish()        
        
        del handler
+
+def validate_certificate(cert, key):
+       buf = decrypt_block(cert[8:], key) 
+       if buf is None:
+               return None
+       return buf[36:107] + cert[139:196]
+
+def get_random():
+       try:
+               xor = lambda a,b: ''.join(chr(ord(c)^ord(d)) for c,d in zip(a,b*100))
+               random = urandom(8)
+               x = str(time())[-8:]
+               result = xor(random, x)
+                               
+               return result
+       except:
+               return None