def __init__(self, session, path=""):
		BaseController.__init__(self, path=path, session=session)

		self.putChild2("web", WebController(session))
		self.putGZChild("api", ApiController(session))
		self.putGZChild("ajax", AjaxController(session))
		self.putChild2("file", FileController())
		self.putChild2("grab", grabScreenshot(session))
		if os.path.exists(getPublicPath('mobile')):
			self.putChild2("mobile", MobileController(session))
			self.putChild2("m", static.File(getPublicPath() + "/mobile"))
		for static_val in ('js', 'css', 'static', 'images', 'fonts'):
			self.putChild2(static_val, static.File(six.ensure_binary(getPublicPath() + '/' + static_val)))
		for static_val in ('themes', 'webtv', 'vxg'):
			if os.path.exists(getPublicPath(static_val)):
				self.putChild2(static_val, static.File(six.ensure_binary(getPublicPath() + '/' + static_val)))

		if os.path.exists('/usr/bin/shellinaboxd'):
			self.putChild2("terminal", proxy.ReverseProxyResource(b'::1', 4200, b'/'))
		self.putGZChild("ipkg", IpkgController(session))
		self.putChild2("autotimer", ATController(session))
		self.putChild2("epgrefresh", ERController(session))
		self.putChild2("bouqueteditor", BQEController(session))
		self.putChild2("transcoding", TranscodingController())
		self.putChild2("wol", WOLClientController())
		self.putChild2("wolsetup", WOLSetupController(session))
		if PICON_PATH:
			self.putChild2("picon", static.File(six.ensure_binary(PICON_PATH)))
		try:
			from Plugins.Extensions.OpenWebif.controllers.NET import NetController
			self.putChild2("net", NetController(session))
		except:  # noqa: E722
			pass
Beispiel #2
0
	def P_boxinfo(self, request):
		info = getInfo(self.session, need_fullinfo=True)

		if fileExists(getPublicPath("/images/boxes/" + type + ".png")):
			info["boximage"] = type + ".png"
		elif fileExists(getPublicPath("/images/boxes/" + type + ".jpg")):
			info["boximage"] = type + ".jpg"
		else:
			info["boximage"] = "unknown.png"
		return info
Beispiel #3
0
 def P_webtv(self, request):
     streaming_port = int(config.OpenWebif.streamport.value)
     if config.OpenWebif.auth_for_streaming.value:
         session = GetSession()
         if session.GetAuth(request) is not None:
             auth = ':'.join(session.GetAuth(request)) + "@"
         else:
             auth = '-sid:' + str(session.GetSID(request)) + "@"
     else:
         auth = ''
     vxgenabled = False
     if fileExists(getPublicPath("/vxg/media_player.pexe")):
         vxgenabled = True
     transcoding = TRANSCODING
     transcoder_port = 0
     if transcoding:
         try:
             transcoder_port = int(
                 config.plugins.transcodingsetup.port.value)
             if getMachineBuild() in ('inihdp', 'hd2400', 'et10000',
                                      'et13000', 'sf5008', 'ew7356',
                                      'formuler1tc', 'tiviaraplus',
                                      '8100s'):
                 transcoder_port = int(config.OpenWebif.streamport.value)
         except Exception:
             transcoder_port = 0
     return {
         "transcoder_port": transcoder_port,
         "vxgenabled": vxgenabled,
         "auth": auth,
         "streaming_port": streaming_port
     }
Beispiel #4
0
 def P_settings(self, request):
     ret = {"result": True}
     ret['configsections'] = getConfigsSections()['sections']
     if config.OpenWebif.webcache.theme.value:
         if os.path.exists(getPublicPath('themes')):
             ret['themes'] = config.OpenWebif.webcache.theme.choices
         else:
             ret['themes'] = ['original', 'clear']
         ret['theme'] = config.OpenWebif.webcache.theme.value
     else:
         ret['themes'] = []
         ret['theme'] = 'original'
     if config.OpenWebif.webcache.moviedb.value:
         ret['moviedbs'] = config.OpenWebif.webcache.moviedb.choices
         ret['moviedb'] = config.OpenWebif.webcache.moviedb.value
     else:
         ret['moviedbs'] = []
         ret['moviedb'] = EXT_EVENT_INFO_SOURCE
     ret['zapstream'] = config.OpenWebif.webcache.zapstream.value
     ret['showpicons'] = config.OpenWebif.webcache.showpicons.value
     ret['showchanneldetails'] = config.OpenWebif.webcache.showchanneldetails.value
     ret['showiptvchannelsinselection'] = config.OpenWebif.webcache.showiptvchannelsinselection.value
     ret['screenshotchannelname'] = config.OpenWebif.webcache.screenshotchannelname.value
     ret['showallpackages'] = config.OpenWebif.webcache.showallpackages.value
     ret['allowipkupload'] = config.OpenWebif.allow_upload_ipk.value
     loc = getLocations()
     ret['locations'] = loc['locations']
     if os.path.exists(VIEWS_PATH + "/responsive"):
         ret['responsivedesign'] = config.OpenWebif.responsive_enabled.value
     return ret
Beispiel #5
0
 def P_webtv(self, request):
     if config.OpenWebif.auth_for_streaming.value:
         session = GetSession()
         if session.GetAuth(request) is not None:
             auth = ':'.join(session.GetAuth(request)) + "@"
         else:
             auth = '-sid:' + str(session.GetSID(request)) + "@"
     else:
         auth = ''
     vxgenabled = False
     if fileExists(getPublicPath("/vxg/media_player.pexe")):
         vxgenabled = True
     transcoding = getHaveTranscoding()
     transcoder_port = 0
     if transcoding:
         try:
             transcoder_port = int(
                 config.plugins.transcodingsetup.port.value)
             if getBoxType() in ("sezammarvel", "xpeedlx3", "atemionemesis",
                                 "mbultra", "beyonwizt4", "hd2400",
                                 "et10000", "et13000", "beyonwizu4",
                                 "sf5008", "x2plus", "formuler1",
                                 "tiviaraplus", "e4hdultra", "protek4k"):
                 transcoder_port = int(config.OpenWebif.streamport.value)
         except StandardError:
             transcoder_port = 0
     return {
         "transcoder_port": transcoder_port,
         "vxgenabled": vxgenabled,
         "auth": auth
     }
Beispiel #6
0
 def P_webtv(self, request):
     streaming_port = int(config.OpenWebif.streamport.value)
     if config.OpenWebif.auth_for_streaming.value:
         session = GetSession()
         if session.GetAuth(request) is not None:
             auth = ':'.join(session.GetAuth(request)) + "@"
         else:
             auth = '-sid:' + str(session.GetSID(request)) + "@"
     else:
         auth = ''
     vxgenabled = False
     if fileExists(getPublicPath("/vxg/media_player.pexe")):
         vxgenabled = True
     transcoding = TRANSCODING
     transcoder_port = 0
     if transcoding:
         try:
             transcoder_port = int(
                 config.plugins.transcodingsetup.port.value)
             if BoxInfo.getItem("platform") in (
                     "inihdp",
                     "8100s") or type in ("hd2400", "et10000", "et13000",
                                          "beyonwizu4", "sf5008", "x2plus",
                                          "formuler1", "tiviaraplus"):
                 transcoder_port = int(config.OpenWebif.streamport.value)
         except Exception:
             transcoder_port = 0
     return {
         "transcoder_port": transcoder_port,
         "vxgenabled": vxgenabled,
         "auth": auth,
         "streaming_port": streaming_port
     }
	def P_index(self, request):
		if config.OpenWebif.responsive_enabled.value and os.path.exists(VIEWS_PATH + "/responsive"):
			return {}
		mode = getUrlArg(request, "mode", "")
		uagent = request.getHeader('User-Agent')
		if uagent and mode != 'fullpage' and os.path.exists(getPublicPath('mobile')):
			if uagent.lower().find("iphone") != -1 or uagent.lower().find("ipod") != -1 or uagent.lower().find("blackberry") != -1 or uagent.lower().find("mobile") != -1:
				request.setHeader("Location", "/mobile/")
				request.setResponseCode(http.FOUND)
				return ""
		return {}
	def P_index(self, request):
		if config.OpenWebif.responsive_enabled.value and os.path.exists(VIEWS_PATH + "/responsive"):
			return {}
		# TODO: enable this if modern UI is finished for mobile
		# setMobile()
		mode = getUrlArg(request, "mode", "")
		uagent = request.getHeader('User-Agent')
		# TODO: enable this if modern UI is finished for mobile
		#if os.path.exists(VIEWS_PATH + "/responsive"):
		#	if uagent.lower().find("iphone") != -1 or uagent.lower().find("ipod") != -1 or uagent.lower().find("blackberry") != -1 or uagent.lower().find("mobile") != -1:
		#		setMobile(True)
		#		return {}

		# TODO: remove this if mobile parts removed
		if uagent and mode != 'fullpage' and os.path.exists(getPublicPath('mobile')):
			if uagent.lower().find("iphone") != -1 or uagent.lower().find("ipod") != -1 or uagent.lower().find("blackberry") != -1 or uagent.lower().find("mobile") != -1:
				request.setHeader("Location", "/mobile/")
				request.setResponseCode(http.FOUND)
				return ""
		return {}
    def prepareMainTemplate(self, request):
        # here will be generated the dictionary for the main template
        ret = getCollapsedMenus()
        ret['configsections'] = getConfigsSections()['sections']
        ret['showname'] = getShowName()['showname']
        ret['customname'] = getCustomName()['customname']
        ret['boxname'] = getBoxName()['boxname']
        if not ret['boxname'] or not ret['customname']:
            ret['boxname'] = getInfo()['brand'] + " " + getInfo()['model']
        ret['box'] = getBoxType()
        ret["remote"] = REMOTE
        if hasattr(eEPGCache, 'FULL_DESCRIPTION_SEARCH'):
            ret['epgsearchcaps'] = True
        else:
            ret['epgsearchcaps'] = False
        extras = [{'key': 'ajax/settings', 'description': _("Settings")}]

        ip = getIP()
        if ip != None:
            if fileExists(
                    resolveFilename(
                        SCOPE_PLUGINS,
                        "Extensions/LCD4linux/WebSite.pyo")) or fileExists(
                            resolveFilename(
                                SCOPE_PLUGINS,
                                "Extensions/LCD4linux/WebSite.py")):
                lcd4linux_key = "lcd4linux/config"
                if fileExists(
                        resolveFilename(SCOPE_PLUGINS,
                                        "Extensions/WebInterface/plugin.pyo")
                ) or fileExists(
                        resolveFilename(SCOPE_PLUGINS,
                                        "Extensions/WebInterface/plugin.py")):
                    try:
                        lcd4linux_port = "http://" + ip + ":" + str(
                            config.plugins.Webinterface.http.port.value) + "/"
                        lcd4linux_key = lcd4linux_port + 'lcd4linux/config'
                    except:  # nosec # noqa: E722
                        lcd4linux_key = None
                if lcd4linux_key:
                    extras.append({
                        'key': lcd4linux_key,
                        'description': _("LCD4Linux Setup"),
                        'nw': '1'
                    })

        oscamwebif, port, oscamconf, variant = self.oscamconfPath()

        # Assume http until we know better ...
        proto = "http"

        # config file exists
        if oscamwebif and oscamconf is not None:
            # oscam defaults to NOT to start the web interface unless a section for it exists, so reset port to None until we find one
            port = None
            data = open(oscamconf, "r").readlines()
            for i in data:
                if "httpport" in i.lower():
                    port = i.split("=")[1].strip()
                    if port[0] == '+':
                        proto = "https"
                        port = port[1:]

        if oscamwebif and port is not None:
            url = "%s://%s:%s" % (proto, request.getRequestHostname(), port)
            if variant == "oscam":
                extras.append({
                    'key': url,
                    'description': _("OSCam Webinterface"),
                    'nw': '1'
                })
            elif variant == "ncam":
                extras.append({
                    'key': url,
                    'description': _("NCam Webinterface"),
                    'nw': '1'
                })

        url1 = "http://%s:8000" % request.getRequestHostname()
        extras.append({'key': url1, 'description': _("FileLoad"), 'nw': '1'})

        if HASAUTOTIMER:
            extras.append({'key': 'ajax/at', 'description': _('AutoTimers')})

        if fileExists(
                resolveFilename(
                    SCOPE_PLUGINS,
                    "Extensions/OpenWebif/controllers/views/ajax/bqe.tmpl")
        ) or fileExists(
                resolveFilename(
                    SCOPE_PLUGINS,
                    "Extensions/OpenWebif/controllers/views/ajax/bqe.pyo")):
            extras.append({
                'key': 'ajax/bqe',
                'description': _('BouquetEditor')
            })

        try:
            from Plugins.Extensions.EPGRefresh.EPGRefresh import epgrefresh  # noqa: F401
            extras.append({'key': 'ajax/epgr', 'description': _('EPGRefresh')})
        except ImportError:
            pass

        try:
            # this will currenly only works if NO Webiterface plugin installed
            # TODO: test if webinterface AND openwebif installed

            # 'nw'='1' -> target _blank
            # 'nw'='2' -> target popup
            # 'nw'=None -> target _self

            # syntax
            # addExternalChild( (Link, Resource, Name, Version, HasGUI, WebTarget) )
            # example addExternalChild( ("webadmin", root, "WebAdmin", 1, True, "_self") )

            from Plugins.Extensions.WebInterface.WebChilds.Toplevel import loaded_plugins
            for plugins in loaded_plugins:
                if plugins[0] in ["fancontrol", "iptvplayer"]:
                    try:
                        extras.append({
                            'key': plugins[0],
                            'description': plugins[2],
                            'nw': '2'
                        })
                    except KeyError:
                        pass
                elif len(plugins) > 4:
                    if plugins[4] == True:
                        try:
                            if len(plugins) > 5 and plugins[5] == "_self":
                                extras.append({
                                    'key': plugins[0],
                                    'description': plugins[2]
                                })
                            else:
                                extras.append({
                                    'key': plugins[0],
                                    'description': plugins[2],
                                    'nw': '1'
                                })
                        except KeyError:
                            pass

        except ImportError:
            pass

        if os.path.exists('/usr/bin/shellinaboxd') and (fileExists(
                resolveFilename(
                    SCOPE_PLUGINS,
                    "Extensions/OpenWebif/controllers/views/ajax/terminal.tmpl"
                )
        ) or fileExists(
                resolveFilename(
                    SCOPE_PLUGINS,
                    "Extensions/OpenWebif/controllers/views/ajax/terminal.pyo")
        )):
            extras.append({
                'key': 'ajax/terminal',
                'description': _('Terminal')
            })

        ret['extras'] = extras
        theme = 'original'
        if config.OpenWebif.webcache.theme.value:
            theme = config.OpenWebif.webcache.theme.value
        if not os.path.exists(getPublicPath('themes')):
            if not (theme == 'original' or theme == 'clear'):
                theme = 'original'
                config.OpenWebif.webcache.theme.value = theme
                config.OpenWebif.webcache.theme.save()
        ret['theme'] = theme
        moviedb = config.OpenWebif.webcache.moviedb.value if config.OpenWebif.webcache.moviedb.value else EXT_EVENT_INFO_SOURCE
        config.OpenWebif.webcache.moviedb.value = moviedb
        config.OpenWebif.webcache.moviedb.save()
        ret['moviedb'] = moviedb
        imagedistro = getInfo()['imagedistro']
        ret['vti'] = "1" if imagedistro in ("VTi-Team Image") else "0"
        ret['webtv'] = os.path.exists(getPublicPath('webtv'))
        ret['stbLang'] = STB_LANG
        return ret
Beispiel #10
0
	def prepareMainTemplate(self, request):
		# here will be generated the dictionary for the main template
		ret = getCollapsedMenus()
		ret['configsections'] = getConfigsSections()['sections']
		ret['showname'] = getShowName()['showname']
		ret['customname'] = getCustomName()['customname']
		ret['boxname'] = getBoxName()['boxname']
		if not ret['boxname'] or not ret['customname']:
			ret['boxname'] = getInfo()['brand'] + " " + getInfo()['model']
		ret['box'] = getBoxType()
		ret["remote"] = REMOTE
		if hasattr(eEPGCache, 'FULL_DESCRIPTION_SEARCH'):
			ret['epgsearchcaps'] = True
		else:
			ret['epgsearchcaps'] = False
		extras = [{'key': 'ajax/settings', 'description': _("Settings")}]
		ifaces = iNetwork.getConfiguredAdapters()
		if len(ifaces):
			ip_list = iNetwork.getAdapterAttribute(ifaces[0], "ip")  # use only the first configured interface
			if ip_list:
				ip = "%d.%d.%d.%d" % (ip_list[0], ip_list[1], ip_list[2], ip_list[3])

				if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/LCD4linux/WebSite.pyo")):
					lcd4linux_key = "lcd4linux/config"
					if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/WebInterface/plugin.pyo")):
						try:
							lcd4linux_port = "http://" + ip + ":" + str(config.plugins.Webinterface.http.port.value) + "/"
							lcd4linux_key = lcd4linux_port + 'lcd4linux/config'
						except:  # noqa: E722
							lcd4linux_key = None
					if lcd4linux_key:
						extras.append({'key': lcd4linux_key, 'description': _("LCD4Linux Setup"), 'nw': '1'})

		oscamwebif, port, oscamconf, variant = self.oscamconfPath()

		# Assume http until we know better ...
		proto = "http"

		# config file exists
		if oscamwebif and oscamconf is not None:
			# oscam defaults to NOT to start the web interface unless a section for it exists, so reset port to None until we find one
			port = None
			data = open(oscamconf, "r").readlines()
			for i in data:
				if "httpport" in i.lower():
					port = i.split("=")[1].strip()
					if port[0] == '+':
						proto = "https"
						port = port[1:]

		if oscamwebif and port is not None:
			url = "%s://%s:%s" % (proto, request.getRequestHostname(), port)
			if variant == "oscam":
				extras.append({'key': url, 'description': _("OSCam Webinterface"), 'nw': '1'})
			elif variant == "ncam":
				extras.append({'key': url, 'description': _("NCam Webinterface"), 'nw': '1'})

		try:
			from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer  # noqa: F401
			extras.append({'key': 'ajax/at', 'description': _('AutoTimer')})
		except ImportError:
			pass

		if fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/bqe.tmpl")) or fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/bqe.pyo")):
			extras.append({'key': 'ajax/bqe', 'description': _('BouquetEditor')})

		try:
			from Plugins.Extensions.EPGRefresh.EPGRefresh import epgrefresh  # noqa: F401
			extras.append({'key': 'ajax/epgr', 'description': _('EPGRefresh')})
		except ImportError:
			pass

		try:
			# this will currenly only works if NO Webiterface plugin installed
			# TODO: test if webinterface AND openwebif installed
			from Plugins.Extensions.WebInterface.WebChilds.Toplevel import loaded_plugins
			for plugins in loaded_plugins:
				if plugins[0] in ["fancontrol", "iptvplayer", "serienrecorderui"]:
					try:
						extras.append({'key': plugins[0], 'description': plugins[2], 'nw': '2'})
					except KeyError:
						pass
		except ImportError:
			pass

		if os.path.exists('/usr/bin/shellinaboxd') and (fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/terminal.tmpl")) or fileExists(resolveFilename(SCOPE_PLUGINS, "Extensions/OpenWebif/controllers/views/ajax/terminal.pyo"))):
			extras.append({'key': 'ajax/terminal', 'description': _('Terminal')})

		ret['extras'] = extras
		theme = 'original'
		if config.OpenWebif.webcache.theme.value:
			theme = config.OpenWebif.webcache.theme.value
		if not os.path.exists(getPublicPath('themes')):
			if not (theme == 'original' or theme == 'clear'):
				theme = 'original'
				config.OpenWebif.webcache.theme.value = theme
				config.OpenWebif.webcache.theme.save()
		ret['theme'] = theme

		moviedb = config.OpenWebif.webcache.moviedb.value if config.OpenWebif.webcache.moviedb.value else 'IMDb'
		config.OpenWebif.webcache.moviedb.value = moviedb
		config.OpenWebif.webcache.moviedb.save()
		ret['moviedb'] = moviedb
		imagedistro = getInfo()['imagedistro']
		ret['vti'] = imagedistro in ("vti") and 1 or 0
		ret['webtv'] = os.path.exists(getPublicPath('webtv'))
		return ret