Example #1
0
def check_security(username, password):
    if username == c.ADMIN and password == c.ADMIN_PASSWORD:
        return True
    if (
        username != ""
        and username == c.read_app_config_value("username")
        and password != ""
        and password == c.read_app_config_value("password")
    ):
        return True
    return False
Example #2
0
def admin_html():
	html = html_template_start('/admin', c.read_app_config_value('title'), c.read_config_value('firmware_version'), main_menu('/admin'))
	html += '<form action="/admin_submit" method="post" onsubmit="select_all_options(\'languages\');">' + c.CR
	html += display_fieldsets(data.ADMIN_FIELDSETS)
	html += '<input type="submit" value="' + _('Save') + '" name="submit"/>' + c.CR
	html += '<input type="reset" value="' + _('Cancel changes') + '" name="cancel" style="margin-top:10px;"/>' + c.CR
	html += '</form>' + c.CR
	html += html_template_end()
	return html
Example #3
0
def configure_html():
	html = html_template_start('/configure', c.read_app_config_value('title'), c.read_config_value('firmware_version'), main_menu('/configure'), c.read_config_value('connection_type'))
	html += '<form action="/configure_submit" method="post" enctype="multipart/form-data">' + c.CR
	html += display_fieldsets(data.CONFIG_FIELDSETS)
	html += '<input type="submit" value="' + _('Save configuration') + '" name="submit"/>' + c.CR
	html += '<input type="reset" value="' + _('Cancel all changes') + '" name="cancel" style="margin-top:10px;"/>' + c.CR
	html += '</form>' + c.CR
	html += html_template_end()
	return html
Example #4
0
def login_html():
    html = html_template_start(
        "/login", c.read_app_config_value("title"), c.read_config_value("firmware_version"), _("Identification")
    )
    html += '<form action="/login_submit" method="post" class="text_align_center">' + c.CR
    html += '<br/><div><input type="text" placeholder="' + _("Username") + '" name="username"/></div><br/>' + c.CR
    html += '<div><input type="password" placeholder="' + _("Password") + '" name="password"/></div>' + c.CR
    html += "<br/>" + c.CR
    html += (
        '<table style="margin:0 auto;">'
        + select_row(_("Interface language"), "language", c.read_app_config_value("language"), "", l.LANGUAGES)
        + "</table>"
        + c.CR
    )
    html += "<br/>" + c.CR
    html += '<input type="submit" value="' + _("Log in") + '"/>' + c.CR
    html += "</form>" + c.CR
    html += html_template_end()
    return html
Example #5
0
def backup_restore_html():
	html = html_template_start('/backup_restore', c.read_app_config_value('title'), c.read_config_value('firmware_version'), main_menu('/backup_restore'))
	html += '<form action="/backup_restore_submit" method="post" enctype="multipart/form-data">' + c.CR
	html += open_fieldset(_('Download/Upload'))
	html += button_row(_('Backup'), '', 'button', _('Download a copy'), 'onclick="download_configuration(\'' + get_config_file_name() + '\');"') + c.CR
	html += input_row(_('Restore'), 'uploaded_file', 'file') + c.CR
	html += '<tr><td><input type="submit" value="' + _('Upload') + '" name="submit"/></td><td></td></tr>' + c.CR
	html += close_fieldset() + '<br/>'
	html += open_fieldset(_('File content'))
	html += '<tr><td class="display_file">'
	html += display_config_file()
	html += '</td></tr>'
	html += close_fieldset()
	html += '</form>' + c.CR
	html += html_template_end()
	return html
Example #6
0
def create_admin_fieldsets():
	row1 = ['input_row', _('Username'), 'username', 'text', c.read_app_config_value('username')]
	row2 = ['input_row', _('Password'), 'password', 'text', c.read_app_config_value('password')]
	row3 = ['select_row', _('Languages'), 'languages', '', 'multiple="multiple" id="languages"', l.LANGUAGES]
	row4 = ['button_row', _('Remove selected language'), '', 'button', _('Remove'), 'onclick="remove_from_select(\'languages\');"']
	row5 = ['span_row', _('Install a new language'), 'class="sub_title"']
	row6 = ['input_row', _('Code'), 'code', 'text', '', '', '', 'Example: en']
	row7 = ['input_row', _('Label'), 'label', 'text', '', '', '', 'Example: English']
	row8 = ['input_row', _('Title'), 'title', 'text', c.read_app_config_value('title'), 'size="40"']
	row9 = ['input_row', _('Host'), 'host', 'text', c.read_app_config_value('host'), 'onkeypress="return ip_keys_only(event);" placeholder="0.0.0.0"', '', 'Default is 0.0.0.0 to listen to all interfaces.']
	row10 = ['input_row', _('Port'), 'port', 'text', c.read_app_config_value('port'), 'onkeypress="return integers_only(event);" placeholder="80"', '', 'Default is 80.']
	row11 = ['input_row', _('Debug'), 'debug', 'checkbox', 'enabled', is_checked(c.read_app_config_value('debug'), 'enabled'), '', _('Enabled')]
	row12 = ['input_row', _('Reloader'), 'reloader', 'checkbox', 'enabled', is_checked(c.read_app_config_value('reloader'), 'enabled'), '', _('Enabled')]
	row13 = ['span_row', '<br/>' + _('Debug and Reloader should be disabled in production mode.') + '<br/>' + _('A restart of the service is needed to activate changes made in this section.'), 'class="note"']
	return [[_('Security'), 'security', [row1, row2]], [_('Interface'), 'interface', [row8, row3, row4, row5, row6, row7]], [_('Service'), 'service', [row9, row10, row11, row12, row13]]]
Example #7
0
def admin_submit():
	write_app_config(request, c.read_app_config_value('language'))
	redirect('/admin')
Example #8
0
def login():
	set_interface_language(c.read_app_config_value('language'))
	c.WEBUSER = "******"
	return login_html()