<commit_before><?php
/* 

###################################################################
	KRAFTWERK PARENT CLASS 
	
	This is the main control class for the kraftwerk application

###################################################################
*/
class Kraftwerk {

	// CONFIG STRUCT
	var $CONSTANTS 				= array();	
	
	// COMPOMENT DIRECTORIES
	// These will be appended to by the core if the hosting directory is different than "/" as set in config/config.php
	var $LIB_DIR				= "/kraftwerk/lib";
	var $CONFIG_GLOBAL_DIR		= "/kraftwerk/config";
	var $CONTROLLERS_DIR		= "/kraftwerk/application/controllers";
	var $MODELS_DIR				= "/kraftwerk/application/models";
	var $VIEWS_DIR				= "/kraftwerk/application/views";
	var $COGS_DIR				= "/kraftwerk/cogs";
	
	// OTHER STRUCTS
	var $CORE_LIB_LOADED 		= array();
	var $CONFIG_LOADED 			= array();
	var $COGS_LOADED 			= array();
	var $MODELS_LOADED 			= array();
	var $CONTROLLERS_LOADED 	= array();
	var $CURRENT_CONTROLLER     = NULL;
	var $CURRENT_ACTION		    = NULL;
	
	var $CONFIG 				= "";
	
	// PUBLIC VARIABLES AND OBJECTS
	public $logger				= "";
	
	/* 
		CONSTRUTOR
	*/
	public function __construct() {
		$this->loadComponents();
		$this->loadLogger();
		$this->loadExceptionHandler();
		$this->loadPathes();
	}
	
	/* 
		LOAD CONFIG FILES
		Loads the global config files
		VOID
	*/
	public function loadComponents() {
		global $kw_config;
		
		// load libs
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->LIB_DIR);
		
		// load cogs/dependencies
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->COGS_DIR . "/connectors");
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->COGS_DIR . "/core");
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->COGS_DIR . "/custom");
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->COGS_DIR . "/extensions");
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->COGS_DIR . "/utility");
		
		// load the models
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $kw_config->MODELS_DIR);
		
		//$kw_config->CONTROLLERS_LOADED 		= $this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $kw_config->CONTROLLERS_DIR);
	}
	
	/* LOAD CLASSES */
	public function loadComponentDirectory($comp_dir) {
		$comps = $this->compsToArray($comp_dir);
		//var_dump($comps);
		for($i=0; $i<count($comps); $i++) {
			//print $comps[$i] . "\n";
			include_once($comps[$i]);
		}
		return $comps;
	}

	/* RECURSIVELY LOAD CLASS DIRECTORIES */
	public function compsToArray($directory) {
		$extension = "php";
		$comps = array();
		if ($handle = opendir($directory)) {<commit_msg>changes to Kraftwerk core class<commit_after><?php
/* 

###################################################################
	KRAFTWERK PARENT CLASS 
	
	This is the main control class for the kraftwerk application

###################################################################
*/
class Kraftwerk {

	// CONFIG STRUCT
	var $CONSTANTS 				= array();	
	
	// COMPOMENT DIRECTORIES
	// These will be appended to by the core if the hosting directory is different than "/" as set in config/config.php
	var $LIB_DIR				= "/kraftwerk/lib";
	var $CONFIG_GLOBAL_DIR		= "/kraftwerk/config";
	var $CONTROLLERS_DIR		= "/kraftwerk/application/controllers";
	var $MODELS_DIR				= "/kraftwerk/application/models";
	var $VIEWS_DIR				= "/kraftwerk/application/views";
	var $COGS_DIR				= "/kraftwerk/cogs";
	
	// OTHER STRUCTS
	var $CORE_LIB_LOADED 		= array();
	var $CONFIG_LOADED 			= array();
	var $COGS_LOADED 			= array();
	var $MODELS_LOADED 			= array();
	var $CONTROLLERS_LOADED 	= array();
	var $CURRENT_CONTROLLER     = NULL;
	var $CURRENT_ACTION		    = NULL;
	
	var $CONFIG 				= "";
	
	// PUBLIC VARIABLES AND OBJECTS
	public $logger				= "";
	
	/* 
		CONSTRUTOR
	*/
	public function __construct() {
		$this->loadComponents();
		$this->loadLogger();
		$this->loadExceptionHandler();
		$this->loadPathes();
	}
	
	/* 
		LOAD CONFIG FILES
		Loads the global config files
		VOID
	*/
	public function loadComponents() {
		global $kw_config;
		
		// load libs
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->LIB_DIR);
		
		// load cogs/dependencies
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->COGS_DIR . "/connectors");
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->COGS_DIR . "/core");
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->COGS_DIR . "/custom");
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->COGS_DIR . "/extensions");
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $this->COGS_DIR . "/utility");
		
		// load the models
		$this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $kw_config->MODELS_DIR);
		
		//$kw_config->CONTROLLERS_LOADED 		= $this->loadComponentDirectory(realpath($_SERVER['DOCUMENT_ROOT']) . $kw_config->hosted_dir . $kw_config->CONTROLLERS_DIR);
	}
	
	/* LOAD CLASSES */
	public function loadComponentDirectory($comp_dir) {
		$comps = $this->compsToArray($comp_dir);
		for($i=0; $i<count($comps); $i++) {
			include_once($comps[$i]);
		}
		return $comps;
	}

	/* RECURSIVELY LOAD CLASS DIRECTORIES */
	public function compsToArray($directory) {
		$extension = "php";
		$comps = array();
		if ($handle = opendir($directory)) {
{'fraction_non_alphanumeric': 0.19451073985680192, 'fraction_numerical': 0.00034094783498124785, 'mean_word_length': 4.3974241030358785, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 63, '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': '6590973', 'n_tokens_mistral': 2200, 'n_tokens_neox': 1993, 'n_words': 362}