<commit_before><?php
# Copyright (C) 2008	<NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

helper_ensure_post();

$t_address = $_SERVER['REMOTE_ADDR'];
$t_valid = false;

# Always allow the same machine to check-in
if ( '127.0.0.1' == $t_address || '127.0.1.1' == $t_address ) {
	$t_valid = true;
}

# Check for allowed remote IP/URL addresses
if ( ON == plugin_config_get( 'remote_checkin' ) ) {
	$t_checkin_urls = unserialize( plugin_config_get( 'checkin_urls' ) );

	foreach ( $t_checkin_urls as $t_url ) {
		if ( $t_valid ) break;

		$t_url = trim( $t_url );

		if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $t_url ) ) { # IP
			if ( $t_url == $t_address ) {
				$t_valid = true;
				break;
			}
		} else {
			$t_ip = gethostbyname( $t_url );
			if ( $t_ip == $t_address ) {
				$t_valid = true;
				break;
			}
		}
	}
}

# Not validated by this point gets the boot!
if ( !$t_valid ) {
	die( lang_get( 'plugin_Source_invalid_checkin_url' ) );
}

# Let plugins try to intepret POST data before we do
$t_predata = event_signal( 'EVENT_SOURCE_PRECOMMIT' );

# Expect plugin data in form of array( repo_name, data )
if ( is_array( $t_predata ) && count( $t_predata ) == 2 ) {
	$f_repo_name = $t_predata[0];
	$f_data = $t_predata[1];
} else {
	$f_repo_name = gpc_get_string( 'repo_name' );
	$f_data = gpc_get_string( 'data' );
}

# Try to find the repository by name
$t_repo = SourceRepo::load_by_name( $f_repo_name );

# Repo not found
if ( is_null( $t_repo ) ) {
	die( lang_get( 'plugin_Source_invalid_repo' ) );
}

# Let the plugins handle commit data
$t_changesets = event_signal( 'EVENT_SOURCE_COMMIT', array( $t_repo, $f_data ) );

# Changesets couldn't be loaded apparently
if ( is_null( $t_changesets ) ) {<commit_msg>Expect named array elements from pre-commit event.<commit_after><?php
# Copyright (C) 2008	<NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

helper_ensure_post();

$t_address = $_SERVER['REMOTE_ADDR'];
$t_valid = false;

# Always allow the same machine to check-in
if ( '127.0.0.1' == $t_address || '127.0.1.1' == $t_address ) {
	$t_valid = true;
}

# Check for allowed remote IP/URL addresses
if ( ON == plugin_config_get( 'remote_checkin' ) ) {
	$t_checkin_urls = unserialize( plugin_config_get( 'checkin_urls' ) );

	foreach ( $t_checkin_urls as $t_url ) {
		if ( $t_valid ) break;

		$t_url = trim( $t_url );

		if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $t_url ) ) { # IP
			if ( $t_url == $t_address ) {
				$t_valid = true;
				break;
			}
		} else {
			$t_ip = gethostbyname( $t_url );
			if ( $t_ip == $t_address ) {
				$t_valid = true;
				break;
			}
		}
	}
}

# Not validated by this point gets the boot!
if ( !$t_valid ) {
	die( lang_get( 'plugin_Source_invalid_checkin_url' ) );
}

# Let plugins try to intepret POST data before we do
$t_predata = event_signal( 'EVENT_SOURCE_PRECOMMIT' );

# Expect plugin data in form of array( repo_name, data )
if ( is_array( $t_predata ) && count( $t_predata ) == 2 ) {
	$f_repo_name = $t_predata['repo_name'];
	$f_data = $t_predata['data'];
} else {
	$f_repo_name = gpc_get_string( 'repo_name' );
	$f_data = gpc_get_string( 'data' );
}

# Try to find the repository by name
$t_repo = SourceRepo::load_by_name( $f_repo_name );

# Repo not found
if ( is_null( $t_repo ) ) {
	die( lang_get( 'plugin_Source_invalid_repo' ) );
}

# Let the plugins handle commit data
$t_changesets = event_signal( 'EVENT_SOURCE_COMMIT', array( $t_repo, $f_data ) );

# Changesets couldn't be loaded apparently
if ( is_null( $t_changesets ) ) {
{'fraction_non_alphanumeric': 0.13351375732972484, 'fraction_numerical': 0.012178619756427604, 'mean_word_length': 4.011299435028248, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1843663', 'n_tokens_mistral': 1707, 'n_tokens_neox': 1630, 'n_words': 484}