Ejemplo n.º 1
0
def open_main_server():
    thisscript = os.environ.get('SCRIPT_NAME', '')
    loginaction = None
    theform = cgi.FieldStorage()
    scriptpath = os.path.dirname(os.path.realpath(__file__)) + os.sep
    userdir = scriptpath + "users" + os.sep
    loginaction, userconfig = login(theform, userdir, thisscript, loginaction)
    user = userconfig["username"]
    admin = userconfig["admin"]

    print "Content-type:application/json\r\n\r\n"
    if action == "list":
        list_rules()
    elif action == "listschemas":
        list_schemas()
    elif user == "demo":
        print json.dumps({
            'Result': 'Error',
            'Message': 'Demo user may not make changes.'
        })
    elif action == "create":
        create_rule()
    elif action == "update":
        update_rule()
    elif action == "delete":
        delete_rule()
    else:
        print json.dumps({
            'Result': 'Error',
            'Message': 'Unknown action: "' + str(action) + '"'
        })
Ejemplo n.º 2
0
def open_main_server():
    thisscript = os.environ.get('SCRIPT_NAME', '')
    action = None
    theform = cgi.FieldStorage()
    scriptpath = os.path.dirname(os.path.realpath(__file__)) + os.sep
    userdir = scriptpath + "users" + os.sep
    action, userconfig = login(theform, userdir, thisscript, action)
    print load_landing(theform)
Ejemplo n.º 3
0
def open_main_server():
	thisscript = os.environ.get('SCRIPT_NAME', '')
	action = None
	theform = cgi.FieldStorage()
	scriptpath = os.path.dirname(os.path.realpath(__file__)) + os.sep
	userdir = scriptpath + "users" + os.sep
	action, userconfig = login(theform, userdir, thisscript, action)
	user = userconfig["username"]
	admin = userconfig["admin"]
	print load_landing(user,admin,theform)
Ejemplo n.º 4
0
def open_main_server():
	thisscript = os.environ.get('SCRIPT_NAME', '')
	action = None
	theform = cgi.FieldStorage()
	scriptpath = os.path.dirname(os.path.realpath(__file__)) + os.sep
	userdir = scriptpath + "users" + os.sep
	action, userconfig = login(theform, userdir, thisscript, action)
	admin = userconfig["admin"]
	if admin == "3":
		print "Content-type:text/html\r\n\r\n"
		print load_validation_rules()
Ejemplo n.º 5
0
def structure_main_server():
	thisscript = os.environ.get('SCRIPT_NAME', '')
	action = None
	theform = cgi.FieldStorage()
	scriptpath = os.path.dirname(os.path.realpath(__file__)) + os.sep
	userdir = scriptpath + "users" + os.sep
	action, userconfig = login(theform, userdir, thisscript, action)
	user = userconfig["username"]
	admin = userconfig["admin"]
	kwargs={}
	for key in theform:
		kwargs[key] = theform[key].value
	print structure_main(user, admin, 'server', **kwargs)
Ejemplo n.º 6
0
def open_main_server():
    thisscript = os.environ.get('SCRIPT_NAME', '')
    action = None
    theform = cgi.FieldStorage()
    scriptpath = os.path.dirname(os.path.realpath(__file__)) + os.sep
    userdir = scriptpath + "users" + os.sep
    action, userconfig = login(theform, userdir, thisscript, action)
    user = userconfig["username"]
    admin = userconfig["admin"]

    print("Content-type:text/html\n\n")
    if admin == "3":
        print(load_admin(user, admin, theform))
    elif admin == "0" or admin == "1":
        print(load_user_config(user, admin, theform))
Ejemplo n.º 7
0
def structure_main_server():
    thisscript = os.environ.get('SCRIPT_NAME', '')
    action = None
    theform = cgi.FieldStorage()
    scriptpath = os.path.dirname(os.path.realpath(__file__)) + os.sep
    userdir = scriptpath + "users" + os.sep
    action, userconfig = login(theform, userdir, thisscript, action)
    user = userconfig["username"]
    admin = userconfig["admin"]
    kwargs = {}
    for key in theform:
        kwargs[key] = theform[key].value
    output = structure_main(user, admin, 'server', **kwargs)

    if "screenshot" in theform:
        print("Content-type: image/png")
        print('Content-Disposition: attachment; filename="image.png"\n')
        print(output)
    else:
        print(output)
Ejemplo n.º 8
0
def open_main_server():
    thisscript = os.environ.get('SCRIPT_NAME', '')
    action = None
    theform = cgi.FieldStorage()
    #print(theform)
    scriptpath = os.path.dirname(os.path.realpath(__file__)) + os.sep
    userdir = scriptpath + "users" + os.sep
    action, userconfig = login(theform, userdir, thisscript, action)
    user = userconfig["username"]
    admin = userconfig["admin"]

    print("Content-type:text/html\n\n")
    try:
        print(load_page(user, admin, theform).encode("utf8"))
    except Exception as e:
        print("""<html><body><h1>Loading Error</h1>
		<p>For some reason, this page failed to load.</p>
		<p>Please send this to your system administrator:</p>
		<pre>""")
        traceback.print_exc(e, file=sys.stdout)
        print("""</pre></body></html>""")
Ejemplo n.º 9
0
    print(cpout)


if __name__ == "__main__":
    #print("Content-type:text/html\r\n\r\n")

    import cgitb
    #cgitb.enable()
    from paths import ether_url

    thisscript = os.environ.get('SCRIPT_NAME', '')
    action = None
    theform = cgi.FieldStorage()
    scriptpath = os.path.dirname(os.path.realpath(__file__)) + os.sep
    userdir = scriptpath + "users" + os.sep
    action, userconfig = login(theform, userdir, thisscript, action)
    user = userconfig["username"]
    admin = userconfig["admin"]

    export_stylesheet = "--default--"

    if "extension" in theform:
        extension = theform.getvalue("extension")
    else:
        extension = "sgml"
    if "stylesheet" in theform:
        export_stylesheet = theform.getvalue("stylesheet")
    else:
        export_stylesheet = None
    if "status" in theform:
        status = theform.getvalue("status")