def routes(db, path=None): if path == 'favicon.ico': return html = None client_ua = get_ua(request) client_ip = get_ip(request) if bin.config.SERVER_DEBUG: print "LOL > %s" % path for ua in bin.config.SERVER_FORBIDDEN_UA: if ua in client_ua.lower(): return pv_blocked(db, "GTFO BOT") for ip in bin.config.SERVER_FORBIDDEN_IP: if ip in client_ip: return pv_blocked(db, "Banned, jammer joh.") if path: uri = ParseUrl(path) for forbidden in bin.config.DUSHI_FORBIDDEN_URIS: if forbidden in uri.domain: return pv_blocked(db, "EPIC WAF stopped y0 h4x. GTFO. Ga Facebook hacken ofzo :-)") for blocked in bin.config.DUSHI_BLOCKED_URIS: if blocked in uri.domain: return pv_blocked(db, "Deze pagina is geblokkeerd swa, jmmr. lafjoe xoxoxo hvj wjnmk knzj jbma ntb wva wobbi veeadj nwly (K)(L)") html = Http().fetch(uri, headers={'User-Agent': client_ua}) if not html: return pv_error(db, "Ja, dat kan niet. %s is geen saffie webbie jwt." % urllib2.unquote(path)) if html: html_dushi = WebDushi(dushi_db).fetch(uri=uri, html=html.content, cache=cache) if html_dushi: dushi_logo = bin.config.DUSHI_SOURCELOGO if 'content-type' in html.headers: if html.headers['content-type'] == 'text/plain': response.headers['Content-Type'] = 'text/plain' dushi_logo = '' stats = get_stat(db, "webdushi") stats.value += 1 wl = WebLog(fulluri=uri.fulluri, domain=uri.domain, ip=client_ip, date=datetime.now()) db.add(wl) db.commit() return """%s%s""" % (dushi_logo, html_dushi) else: return pv_error(db, msg="Fout bij het convertere van de pagina vrind sorry :##") else: return pv_error(db, msg="Fout bij het opvragen van die webbie. Shit is fokkedop.") else: cfg = { 'SERVER_URI': bin.config.SERVER_URI, 'request': request } if request.query_string.startswith('s='): if not request.query_string[2:]: return pv_error(db, msg="ALS JE OP NIETS ZOEKT GA IK STUK A SAGBI.") data = Google(request.query_string).search() for k,v in data.iteritems(): for kk,vv in v.iteritems(): if kk == 'content' or kk == 'title': data[k][kk] = dushi.jwt(vv) stats = get_stat(db, "pv_google") stats.value += 1 db.commit() return jinja2_template('google.html', cfg=cfg, data=data if data else [], title='Goog0l - %s' % urllib2.unquote(request.query_string)) elif request.path == '/': html = 'index' elif request.path >= 1: page = request.path[1:] if page == 'massageboat': cfg['BOAT_MSG_MAX'] = bin.config.BOAT_MSG_MAX cfg['BOAT_MSGBOX_DEFMSG'] = bin.config.BOAT_MSGBOX_DEFMSG cfg['BOAT_POST_RATE'] = bin.config.BOAT_POST_RATE elif page == 'over': stats = db.query(Stats).all() cfg['stats'] = {} for stat in stats: cfg['stats'][stat.key] = stat.value elif page == 'voorbeelden': webbies = db.query(WebLog).limit(2).all() elif page == 'aapje': params = request.params.dict if 'dushi' in params: data = ''.join(params.get('dushi')) if data: response.headers['Content-Type'] = 'text/plain' stats = get_stat(db, "pv_aapje_get") stats.value += 1 db.commit() return dushi.jwt(data) html = page else: return redirect('wat') stats = get_stat(db, "pv_%s" % html) if stats: stats.value += 1 db.commit() else: print "%s not found in db.stats" % html return jinja2_template('%s.html' % html, cfg=cfg, title='Dushi - %s' % html.title())
def _banned_ip(self, request): ip = get_ip(request) return True if ip in config.SERVER_FORBIDDEN_IP else False