<commit_before><?
// The source code packaged with this file is Free Software, Copyright (C) 2007 by
// <NAME> :: Suki_ :: <david at sukiweb dot net>.
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
// 		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".

function check_ban_proxy() {
	return check_ban($_SERVER['REMOTE_ADDR'], 'proxy');
}

function check_ban($ban_text, $ban_type, $check_valid = true, $first_level = false) {
	global $db, $globals;	
	
	$ban_text = $db->escape($ban_text);
	$ban_type = $db->escape($ban_type);
	
	// If check_valid == false does not check for validity of the address
	// in order to avoid problems with bad links in external pages
	switch ($ban_type) {
		case 'email':
		case 'hostname':
		case 'punished_hostname':
			// Clean protocol and path/arguments
			$ban_text = preg_replace('/^(https*|ftp):\/\//', '', $ban_text);
			$ban_text = preg_replace('/(\/[^\/\?]+)[\/\?]+.*$/', '$1', $ban_text);
			if ($check_valid  && ! preg_match('/^([\w_\-\.]+\.[\w]{2,4}(\/[a-z\.]+\/*){0,1}|[\w]{2,5})$/', $ban_text)) {
				$globals['ban_message'] = _('No es un dominio correcto');
				return true;
			}
			$where= " ban_text IN (".subdomains_list($ban_text, $first_level).") AND ban_type='$ban_type' AND (ban_expire IS null OR ban_expire > now()); ";
			break;
		case 'ip':<commit_msg>Elimina el . final en nombres de hosts.<commit_after><?
// The source code packaged with this file is Free Software, Copyright (C) 2007 by
// <NAME> :: Suki_ :: <david at sukiweb dot net>.
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
// 		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".

function check_ban_proxy() {
	return check_ban($_SERVER['REMOTE_ADDR'], 'proxy');
}

function check_ban($ban_text, $ban_type, $check_valid = true, $first_level = false) {
	global $db, $globals;	
	
	$ban_text = $db->escape($ban_text);
	$ban_type = $db->escape($ban_type);
	
	// If check_valid == false does not check for validity of the address
	// in order to avoid problems with bad links in external pages
	switch ($ban_type) {
		case 'email':
		case 'hostname':
		case 'punished_hostname':
			// Clean protocol and path/arguments
			$ban_text = preg_replace('/^(https*|ftp):\/\//', '', $ban_text);
			$ban_text = preg_replace('/(\/[^\/\?]+)[\/\?]+.*$/', '$1', $ban_text);
			$ban_text = preg_replace('/\.*$/', '', $ban_text);
			if ($check_valid  && ! preg_match('/^([\w_\-\.]+\.[\w]{2,4}(\/[a-z\.]+\/*){0,1}|[\w]{2,5})$/', $ban_text)) {
				$globals['ban_message'] = _('No es un dominio correcto');
				return true;
			}
			$where= " ban_text IN (".subdomains_list($ban_text, $first_level).") AND ban_type='$ban_type' AND (ban_expire IS null OR ban_expire > now()); ";
			break;
		case 'ip':
{'fraction_non_alphanumeric': 0.1914036265950302, 'fraction_numerical': 0.007387508394895903, 'mean_word_length': 3.8836065573770493, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2344325', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1032, 'n_words': 294}