def _get_site(host): wss = db.select('select * from websites where domain=?', host) if wss: ws = wss[0] if ws.disabled: logging.debug('website is disabled: %s' % host) raise forbidden() return ws raise notfound()
def do_admin(): global _APP_ID, _APP_SECRET, _ADMIN_PASS i = ctx.request.input() if i.passwd != _ADMIN_PASS: raise forbidden() admin_pass = i.get("new_passwd", "") app_id = i.get("app_id", "") app_secret = i.get("app_secret", "") msg = "" if admin_pass and app_id and app_secret: db.update("delete from settings") db.update("insert into settings (id, value) values (?, ?)", "app_id", app_id) db.update("insert into settings (id, value) values (?, ?)", "app_secret", app_secret) db.update("insert into settings (id, value) values (?, ?)", "admin_pass", admin_pass) msg = "Updated!" _APP_ID = app_id _APP_SECRET = app_secret _ADMIN_PASS = admin_pass return """<html> <body> <p>%s</p> <form action="/admin" method="post"> <p>App ID:</p> <p><input type="text" name="app_id" value="%s" /></p> <p>App Secret:</p> <p><input type="text" name="app_secret" value="%s" /></p> <p>Old Password:</p> <p><input type="text" name="passwd" readonly="readonly" value="%s" /></p> <p>New Password:</p> <p><input type="text" name="new_passwd" value="%s" /></p> <p>WARNING: click submit will update app_id, app_secret and admin password!</p> <p><input type="submit" name="submit" value="Submit" /></p> </form> </body> </html> """ % ( msg, _APP_ID, _APP_SECRET, _ADMIN_PASS, _ADMIN_PASS, )
def do_admin(): global _APP_ID, _APP_SECRET, _ADMIN_PASS i = ctx.request.input() if i.passwd != _ADMIN_PASS: raise forbidden() admin_pass = i.get('new_passwd', '') app_id = i.get('app_id', '') app_secret = i.get('app_secret', '') msg = '' if admin_pass and app_id and app_secret: db.update('delete from settings') db.update('insert into settings (id, value) values (?, ?)', 'app_id', app_id) db.update('insert into settings (id, value) values (?, ?)', 'app_secret', app_secret) db.update('insert into settings (id, value) values (?, ?)', 'admin_pass', admin_pass) msg = 'Updated!' _APP_ID = app_id _APP_SECRET = app_secret _ADMIN_PASS = admin_pass return '''<html> <body> <p>%s</p> <form action="/admin" method="post"> <p>App ID:</p> <p><input type="text" name="app_id" value="%s" /></p> <p>App Secret:</p> <p><input type="text" name="app_secret" value="%s" /></p> <p>Old Password:</p> <p><input type="text" name="passwd" readonly="readonly" value="%s" /></p> <p>New Password:</p> <p><input type="text" name="new_passwd" value="%s" /></p> <p>WARNING: click submit will update app_id, app_secret and admin password!</p> <p><input type="submit" name="submit" value="Submit" /></p> </form> </body> </html> ''' % (msg, _APP_ID, _APP_SECRET, _ADMIN_PASS, _ADMIN_PASS)