<commit_before><?php
$path = __FILE__;
define("ROOT", str_replace("lib/" . basename(__FILE__), "", $path));

/**
 * Helper class for some often used commands
 */
class Helper {
	/**
	 * Loads the default page header
	 * @param String $selectedMenu Menu that got preselected
	 */	
	public static function loadHeader($selectedMenu) {
		include ROOT.'controller/components/headerController.php';
		HeaderController::header($selectedMenu);
	}
	
	/**
	 * Loads the default page footer
	 */
	public static function loadFooter() {
		include ROOT.'view/pagewrappers/footer.php';
		die();
	}
	
	/**
	 * Returns the escaped parameter (HTML special chars & SQL special chars)
	 * @param String $name The name of the parameter
	 */
	public static function getParameter($name) {
		$raw = "";
		if (isset($_POST[$name])) {
			$raw = $_POST[$name];
		}
		elseif (isset($_GET[$name])) {
			$raw = $_GET[$name];
		}
		else {
			return null;
		}
		$raw = htmlspecialchars($raw, ENT_COMPAT | ENT_HTML5 , "UTF-8");
		$string = Database::escapeString($raw);
		return $string;
	}
	
	/**
	 * Checks if the current user is logged in, else it redirects to to login page
	 */
	public static function checkLoggedIn() {
		Helper::loadModel("SessionService");
		if (!SessionService::checkSession()) {
			Helper::redirectTo(WEBROOT."login");
		}
	}
	
	/**
	 * Redirects to another URL
	 * @param String $url
	 */
	public static function redirectTo($url) {
		echo '<meta http-equiv="refresh" content="0; url='.$url.'" />';
		die();
	}
	
	/**
	 * Load a specific model class
	 * @param String $name
	 */
	public static function loadModel($name) {
		require ROOT . "model/" . $name . ".php";
	}
}<commit_msg>Load all models only once<commit_after><?php
$path = __FILE__;
define("ROOT", str_replace("lib/" . basename(__FILE__), "", $path));

/**
 * Helper class for some often used commands
 */
class Helper {
	/**
	 * Loads the default page header
	 * @param String $selectedMenu Menu that got preselected
	 */	
	public static function loadHeader($selectedMenu) {
		include ROOT.'controller/components/headerController.php';
		HeaderController::header($selectedMenu);
	}
	
	/**
	 * Loads the default page footer
	 */
	public static function loadFooter() {
		include ROOT.'view/pagewrappers/footer.php';
		die();
	}
	
	/**
	 * Returns the escaped parameter (HTML special chars & SQL special chars)
	 * @param String $name The name of the parameter
	 */
	public static function getParameter($name) {
		$raw = "";
		if (isset($_POST[$name])) {
			$raw = $_POST[$name];
		}
		elseif (isset($_GET[$name])) {
			$raw = $_GET[$name];
		}
		else {
			return null;
		}
		$raw = htmlspecialchars($raw, ENT_COMPAT | ENT_HTML5 , "UTF-8");
		$string = Database::escapeString($raw);
		return $string;
	}
	
	/**
	 * Checks if the current user is logged in, else it redirects to to login page
	 */
	public static function checkLoggedIn() {
		Helper::loadModel("SessionService");
		if (!SessionService::checkSession()) {
			Helper::redirectTo(WEBROOT."login");
		}
	}
	
	/**
	 * Redirects to another URL
	 * @param String $url
	 */
	public static function redirectTo($url) {
		echo '<meta http-equiv="refresh" content="0; url='.$url.'" />';
		die();
	}
	
	/**
	 * Load a specific model class
	 * @param String $name
	 */
	public static function loadModel($name) {
		require_once ROOT . "model/" . $name . ".php";
	}
	
	/**
	 * Return the current url cutted into pices after each "/"
	 * @return Array Url cutted into pices after each "/"
	 */
	public static function getUrlParams() {
		$absoluteURL = str_replace(WEBROOT, "", $_SERVER["REQUEST_URI"]);
		return explode("/", $absoluteURL);
	}
}
{'fraction_non_alphanumeric': 0.15371946198188308, 'fraction_numerical': 0.0016469942355201758, 'mean_word_length': 3.659846547314578, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '2926720', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1130, 'n_words': 325}