<commit_before><?php
	error_reporting(E_ALL);
 	session_start();
	
	$settings = './settings.php';
	$page = '505.php';
	
	$output = new stdClass();
	$output->error = "missing config file";
	
	if ( file_exists( $settings ) ) {
		
		require_once( $settings );
		
		// TODO //
		// Check that all the required folders have been defined, and that they're existing and writable (if needed) //
		
		// Setup //
		// Include external Libraries //
		if ( $handle = opendir( M_LIBRARIES ) ):
			while ( false !== ( $entry = readdir($handle) ) ):
				if ( $entry != "." && $entry != ".." && ( is_dir( M_LIBRARIES . '/' . $entry ) ) ):
					if ( $handle2 = opendir( M_LIBRARIES . '/' . $entry ) ):
						while ( false !== ( $entry2 = readdir( $handle2 ) ) ):
							if ($entry2 != "." && $entry2 != ".." && (strstr($entry2, '.lib.php') !== false)):
								require_once( M_LIBRARIES . '/' . $entry . '/' . $entry2 );
							endif;
						endwhile;
					endif;
				endif;
			endwhile;
		endif;
		// Include Classes //
		if ( $handle = opendir( M_CLASSES ) ):
			while ( false !== ( $entry = readdir($handle) ) ):
				if ( $entry != "." && $entry != ".." && ( is_dir( M_CLASSES . '/' . $entry ) ) ):
					if ( $handle2 = opendir( M_CLASSES . '/' . $entry ) ):
						while ( false !== ( $entry2 = readdir( $handle2 ) ) ):
							if ($entry2 != "." && $entry2 != ".." && (strstr($entry2, '.class.php') !== false)):
								require_once( M_CLASSES . '/' . $entry . '/' . $entry2 );
							endif;
						endwhile;
					endif;
				endif;
			endwhile;
		endif;
		
		// Routing //
		$page = '404.php';	
		$output->error = "Invalid route.";	
		$parts = null;
		$self = substr( $_SERVER['REQUEST_URI'] , 1 , strlen ( $_SERVER['REQUEST_URI'] ) );
		$format = (isset($_REQUEST['format'])) ? $_REQUEST['format'] : 'html';	
		$request_uri = explode('?', $self);
		
		foreach( $routes as $key => $value ) {
			if ( preg_match( $key , $request_uri[0] ) ) {
				$page = $value;
				break;
			}
		}
			
		if ($page != '404.php' && $page != '505.php') {
			if ( !file_exists( M_SOURCES .'/' . $page ) ) {
				$page = '404.php';
				$output->error = "Source file not found (" . M_SOURCES . '/' . $page . ")";
			} else {
				$output->error = null;
			}
		}
	}
	
	if ( M_DB_HOST !== '' && M_DB_CATALOG !== '') {
		try {
			$DBH = new PDO("mysql:dbname=" . M_DB_CATALOG . ";charset=UTF8;host=" . M_DB_HOST, M_DB_USER, M_DB_PASSWORD);
		} catch (PDOException $e) {
			$page = "505.php";
			$output->error = "unable to connect to the DB: " . $e->getMessage();
		}
	}
	include( M_SOURCES .'/' . $page );
	die();
?>	<commit_msg>no message<commit_after><?php
	error_reporting(E_ALL);
 	session_start();
	
	$settings = './settings.php';
	$page = '505.php';
	
	$output = new stdClass();
	$output->error = "missing config file";
	
	if ( file_exists( $settings ) ) {
		
		require_once( $settings );
		
		// TODO //
		// Check that all the required folders have been defined, and that they're existing and writable (if needed) //
		
		// Setup //
		// Include external Libraries //
		if ( $handle = opendir( M_LIBRARIES ) ):
			while ( false !== ( $entry = readdir($handle) ) ):
				if ( $entry != "." && $entry != ".." && ( is_dir( M_LIBRARIES . '/' . $entry ) ) ):
					if ( $handle2 = opendir( M_LIBRARIES . '/' . $entry ) ):
						while ( false !== ( $entry2 = readdir( $handle2 ) ) ):
							if ($entry2 != "." && $entry2 != ".." && (strstr($entry2, '.lib.php') !== false)):
								require_once( M_LIBRARIES . '/' . $entry . '/' . $entry2 );
							endif;
						endwhile;
					endif;
				endif;
			endwhile;
		endif;
		// Include Classes //
		if ( $handle = opendir( M_CLASSES ) ):
			while ( false !== ( $entry = readdir($handle) ) ):
				if ( $entry != "." && $entry != ".." && ( is_dir( M_CLASSES . '/' . $entry ) ) ):
					if ( $handle2 = opendir( M_CLASSES . '/' . $entry ) ):
						while ( false !== ( $entry2 = readdir( $handle2 ) ) ):
							if ($entry2 != "." && $entry2 != ".." && (strstr($entry2, '.class.php') !== false)):
								require_once( M_CLASSES . '/' . $entry . '/' . $entry2 );
							endif;
						endwhile;
					endif;
				endif;
			endwhile;
		endif;
		
		// Routing //
		$page = '404.php';	
		$output->error = "Invalid route.";	
		$parts = null;
		$self = substr( $_SERVER['REQUEST_URI'] , 1 , strlen ( $_SERVER['REQUEST_URI'] ) );
		$format = (isset($_REQUEST['format'])) ? $_REQUEST['format'] : 'html';	
		$request_uri = explode('?', $self);
		
		foreach( $routes as $key => $value ) {
			if ( preg_match( $key , $request_uri[0] ) ) {
				$page = $value;
				break;
			}
		}
			
		if ($page != '404.php' && $page != '505.php') {
			if ( !file_exists( M_SOURCES .'/' . $page ) ) {
				$page = '404.php';
				$output->error = "Source file not found (" . M_SOURCES . '/' . $page . ")";
			} else {
				$output->error = null;
			}
		}
	}
	
	if ( M_DB_HOST !== '' && M_DB_CATALOG !== '' ) {
		try {
			$DBH = new PDO("mysql:dbname=" . M_DB_CATALOG . ";charset=UTF8;host=" . M_DB_HOST, M_DB_USER, M_DB_PASSWORD);
		} catch (PDOException $e) {
			$page = "505.php";
			$output->error = "unable to connect to the DB: " . $e->getMessage();
		}
	}
	include( M_SOURCES .'/' . $page );
	die();
?>	
{'fraction_non_alphanumeric': 0.21964423820572312, 'fraction_numerical': 0.013534416086620264, 'mean_word_length': 2.4417831004657353, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, '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': '6999600', 'n_tokens_mistral': 2329, 'n_tokens_neox': 1878, 'n_words': 413}