示例#1
0
	def start_request (self):
		Session.start_request(self)

		request = get_request()
		t = time.time()
		request.response.set_charset('utf-8')
		# Determine IP of originator, keep Squid in mind :-)
		try:
			self.ip = request.environ['HTTP_X_FORWARDED_FOR']
		except:
			self.ip = request.environ['REMOTE_ADDR']
		self.port = request.environ['REMOTE_PORT']


		#session = sessions.setdefault(ip,
		#	configlets.Holder(
		#		firstaccess=t,
		#		user=None,
		#		phone='',
		#		language='en',
		#		level=-1,		# Try to auto-login, based on IP
		#	))

		# level==-1 means we should auto-login
		# This works by searching for the first CfgOptUser configlet where
		# the 'pc' variable matches the request originating IP:
		if self.level == -1:
			# Only try auto-login once, so set it to lowest level
			self.level = 0

			users = backend.getConfiglets(name="CfgOptUser")
			if len(users) == 0:
				# be Admin if there are no users configured
				self.user  = "******"
				self.level = 4
				self.language = 'en'
				sys.stderr.write ("[%s] Logging in with user 'programmer' from ip %s, port %s\n" % (time.asctime(time.localtime()), self.ip, self.port))
			else:
				for user in users:
					if user.pc == self.ip:
						self.user = user.name
						self.level = int(user.level)
						self.phone = user.phone
						self.language = user.language
						break
						
		language.setLanguage(self.language)				
示例#2
0
    def start_request(self, request):
        t = time.time()

        # Determine IP of originator, keep Squid in mind :-)
        try:
            ip = request.environ["HTTP_X_FORWARDED_FOR"]
        except:
            ip = request.environ["REMOTE_ADDR"]

            # Search session object, if none found, create one with default values
        global sessions
        session = sessions.setdefault(
            ip,
            configlets.Holder(
                firstaccess=t, user=None, phone="", language="en", level=-1  # Try to auto-login, based on IP
            ),
        )

        # level==-1 means we should auto-login
        # This works by searching for the first CfgOptUser configlet where
        # the 'pc' variable matches the request originating IP:
        if session.level == -1:
            # Only try auto-login once, so set it to lowest level
            session.level = 0

            users = backend.getConfiglets(name="CfgOptUser")
            if len(users) == 0:
                # be Admin if there are no users configured
                session.user = "******"
                session.level = 4
                session.language = "en"
            else:
                for user in users:
                    if user.pc == ip:
                        session.user = user.name
                        session.level = int(user.level)
                        session.phone = user.phone
                        session.language = user.language
                        break

        language.setLanguage(session.language)
        session.lastaccess = t
        request.session = session
示例#3
0
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#


"""
Generate docs for cfg_*.py
"""

import sys, os

DESTAR_DOC_LANGUAGE = os.getenv("DESTAR_DOC_LANGUAGE", default="en")

import language

language.setLanguage(DESTAR_DOC_LANGUAGE)

import panelutils, backend

backend.createDocs()

sys.exit(0)
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#


import sys, os, string, time
import language,queueutils
from datetime import datetime
from time import strptime
language.setLanguage('en')


try:
	from pysqlite2 import dbapi2 as sqlite
except ImportError:
	print _("Note: you should install python-pysqlite2 to have Queue Stats functionality")

try:
	db1_fn = "/var/log/asterisk/master.db"
	if not os.access(db1_fn, os.O_RDWR):
		raise ImportError
	db1 = sqlite.connect(db1_fn)
	db1.isolation_level = None
except:
	print _("Note: you don't seem to have access to %s. See INSTALL.txt for details.") % db1_fn
示例#5
0
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#


import sys, os, string, time
import language
from datetime import datetime
from time import strptime

language.setLanguage("en")
from config import *

try:
    import MySQLdb as mysql
except ImportError:
    print _("Note: you should install python mysql libs to have CDR Stats in MySQL")

try:
    if not os.access("/usr/lib/asterisk/modules/cdr_addon_mysql.so", os.F_OK):
        raise ImportError
    needModule("cdr_addon_mysql")
except:
    print _("Note: you need the cdr_addon_mysql module to have CDR and Stats functionalities")

try: