<commit_before>#!/usr/bin/python
# 
# V1-0 by <NAME> <joerg DOT stephan AT ymail DOT com>
# https://github.com/johestephan/mypyapachefw.git
# Copyright (c) 2014,2015 <NAME> under BSD licence
#

import sys
import re
import datetime
from optparse import OptionParser
from geoip import geolite2
import sqlite3

def sqllogit(data):
	try:
		# logging to sqlite3
		conn = sqlite3.connect('./mypyfwa.db')
		conn.execute(''' INSERT INTO log VALUES (?,?,?,?,?); ''', data) 
		conn.commit()
		conn.close()

		return 1
	except:
		return 0


def GETcheck(request, IP, CC):
    try:
	weightcounter = request.count("/")
	if weightcounter > 7:
		print str(datetime.datetime.now()) + " " + request + " RecursiveCounter: " + str(weightcounter) + " Blocked: " + IP
                sqllogit( (str(datetime.datetime.now()),request,IP,CC,"Path") )
		return True
	else:
		return False
    except:<commit_msg>syslog changes<commit_after>#!/usr/bin/python
# 
# V1-0 by <NAME> <joerg DOT stephan AT ymail DOT com>
# https://github.com/johestephan/mypyapachefw.git
# Copyright (c) 2014,2015 <NAME> under BSD licence
#

import sys
import re
import datetime
from optparse import OptionParser
from geoip import geolite2
import sqlite3
sys.path.append('../modules/')
import syslogit

def sqllogit(data):
	try:
		# logging to sqlite3
		conn = sqlite3.connect('./mypyfwa.db')
		conn.execute(''' INSERT INTO log VALUES (?,?,?,?,?); ''', data) 
		conn.commit()
		conn.close()
		
		print syslogit.logit("mypyfwa", data)
		return 1
	except:
		return 0


def GETcheck(request, IP, CC):
    try:
	weightcounter = request.count("/")
	if weightcounter > 7:
		print str(datetime.datetime.now()) + " " + request + " RecursiveCounter: " + str(weightcounter) + " Blocked: " + IP
                sqllogit( (str(datetime.datetime.now()),request,IP,CC,"Path") )
		return True
	else:
		return False
    except:
{'fraction_non_alphanumeric': 0.1460794844253491, 'fraction_numerical': 0.018259935553168637, 'mean_word_length': 3.838961038961039, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2836526', 'n_tokens_mistral': 720, 'n_tokens_neox': 637, 'n_words': 168}