<commit_before><?php
require_once('Config.php');
require_once('Dispather.php');

class UndefinedException extends Exception {
	public function __construct($message='', $code=0) {
		parent::__construct($message, $code);
	}
}

class Bootstrap {
	private $dispather;

	private function __construct() {
		$this->dispather=new Dispather();
		set_exception_handler(array($this, 'handleException'));
	}

	public function handleException(Exception $e) {
		if($e instanceof UndefinedException) {
			error_log($e->getMessage());
			header("HTTP/1.1 404 Not Found");
			header("Status: 404 Not Found");
		}
		else{
			error_log($e->getMessage().' '.$e->getTraceAsString());
			header('HTTP/1.1 503 Service Temporarily Unavailable');
			header('Status: 503 Service Temporarily Unavailable');
		}
		die();
	}

	private function handleRequest() {
		if (get_magic_quotes_gpc ()) {
			$in = array (&$_GET, &$_POST, &$_COOKIE, &$_FILES );
			while ( (list ( $k, $v ) = each ( $in )) !== false ) {
				foreach ( $v as $key => $val ) {
					if (! is_array ( $val )) {
						$in [$k] [$key] = stripslashes ( $val );
						continue;
					}
					$in [] = & $in [$k] [$key];
				}
			}
			unset ( $in );
		}

		if(!isset($_GET['url']) || empty($_GET['url']))
			throw new UndefinedException('No found parameter: url');
		$url=$_GET['url'];
		if(substr($url,0,1)=='/')
			$url=substr($url,1);
		$urlArray = array();
		$urlArray = explode('/',$url);
		if(count($urlArray)<2)
			throw new UndefinedException('Bad parameter size: url');
		unset($_GET['url']);

		$module=$urlArray[0];
		$action=$urlArray[1];
		$key=null;
		$params=array();
		for($i=2;$i<count($urlArray);++$i) {
			if(empty($urlArray[$i]))
				continue;
			if(is_null($key))
				$key=$urlArray[$i];
			else {
				$params[$key]=$urlArray[$i];
				$key=null;
			}
		}
		unset($urlArray);
		$this->dispather->dispath($module,$action,array_merge($params,$_POST));
	}

	private static $instance=null;

	public static function execute() {
		if(is_null(self::$instance))
			self::$instance=new Bootstrap();
		self::$instance->handleRequest();
	}
}<commit_msg>Add base code.<commit_after><?php
require_once('Config.php');
require_once('Dispather.php');

class UndefinedException extends Exception {
	public function __construct($message='', $code=0) {
		parent::__construct($message, $code);
	}
}

class Bootstrap {
	private $dispather;

	private function __construct() {
		$this->dispather=new Dispather();
		set_exception_handler(array($this, 'handleException'));
	}

	public function handleException(Exception $e) {
		if($e instanceof UndefinedException) {
			error_log($e->getMessage());
			header("HTTP/1.1 404 Not Found");
			header("Status: 404 Not Found");
		}
		else{
			error_log($e->getMessage().' '.$e->getTraceAsString());
			header('HTTP/1.1 503 Service Temporarily Unavailable');
			header('Status: 503 Service Temporarily Unavailable');
		}
		die();
	}

	private function handleRequest() {
		if (get_magic_quotes_gpc ()) {
			$in = array (&$_GET, &$_POST, &$_COOKIE, &$_FILES );
			while ( (list ( $k, $v ) = each ( $in )) !== false ) {
				foreach ( $v as $key => $val ) {
					if (! is_array ( $val )) {
						$in [$k] [$key] = stripslashes ( $val );
						continue;
					}
					$in [] = & $in [$k] [$key];
				}
			}
			unset ( $in );
		}

		if(!isset($_GET['url']) || empty($_GET['url']))
			throw new UndefinedException('No found parameter: url');
		$url=$_GET['url'];
		if(substr($url,0,1)=='/')
			$url=substr($url,1);
		$urlArray = array();
		$urlArray = explode('/',$url);
		if(count($urlArray)<2)
			throw new UndefinedException('Bad parameter size: url');
		unset($_GET['url']);

		$module=$urlArray[0];
		$action=$urlArray[1];
		$key=null;
		$params=array();
		for($i=2;$i<count($urlArray);++$i) {
			if(empty($urlArray[$i]))
				continue;
			if(is_null($key))
				$key=$urlArray[$i];
			else {
				$params[$key]=$urlArray[$i];
				$key=null;
			}
		}
		unset($urlArray);
		$this->dispather->dispath($module,$action,array_merge($params,$_GET,$_POST));
	}

	private static $instance=null;

	public static function execute() {
		if(is_null(self::$instance))
			self::$instance=new Bootstrap();
		self::$instance->handleRequest();
	}
}
{'fraction_non_alphanumeric': 0.2048652516098259, 'fraction_numerical': 0.011447650846649178, 'mean_word_length': 4.308860759493671, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6928147', 'n_tokens_mistral': 1730, 'n_tokens_neox': 1474, 'n_words': 282}