<commit_before><?php

	error_reporting(E_ALL ^ E_NOTICE);

	function __errorHandler($errno=NULL, $errstr, $errfile=NULL, $errline=NULL, $errcontext=NULL){
		return;
	}

	function tableContainsField($table, $field){
		$sql = "DESC `{$table}` `{$field}`";
		$results = Frontend::instance()->Database->fetch($sql);

		return (is_array($results) && !empty($results));
	}

	function writeConfig($dest, $conf, $mode){

		$string	 = "<?php" . PHP_EOL;

		$string .= PHP_EOL . "\t\$settings = array(";
		foreach($conf['settings'] as $group => $data){
			$string .= str_repeat(PHP_EOL, 3) . "\t\t###### ".strtoupper($group)." ######";
			$string .= PHP_EOL . "\t\t'$group' => array(";
			foreach($data as $key => $value){
				$string .= PHP_EOL . "\t\t\t'$key' => ".(strlen($value) > 0 ? "'".addslashes($value)."'" : 'null').",";
			}
			$string .= PHP_EOL . "\t\t),";
			$string .= PHP_EOL . "\t\t########";
		}
		$string .= PHP_EOL . "\t);" . PHP_EOL;

		return General::writeFile($dest . '/config.php', $string, $mode);

	}

	function loadOldStyleConfig(){
		$config = preg_replace(array('/^<\?php/i', '/\?>$/i', '/if\(\!defined\([^\r\n]+/i', '/require_once[^\r\n]+/i'), NULL, file_get_contents('manifest/config.php'));

		if(@eval($config) === false){
			throw new Exception('Failed to load existing config');
		}

		return $settings;
	}
<commit_msg>Fix update.php clearing the config, closes #870<commit_after><?php

	error_reporting(E_ALL ^ E_NOTICE);

	function __errorHandler($errno=NULL, $errstr, $errfile=NULL, $errline=NULL, $errcontext=NULL){
		return;
	}

	function tableContainsField($table, $field){
		$sql = "DESC `{$table}` `{$field}`";
		$results = Frontend::instance()->Database->fetch($sql);

		return (is_array($results) && !empty($results));
	}

	function writeConfig($dest, $conf, $mode){

		$string	 = "<?php" . PHP_EOL;

		$string .= PHP_EOL . "\t\$settings = array(";
		foreach($conf as $group => $data){
			$string .= str_repeat(PHP_EOL, 3) . "\t\t###### ".strtoupper($group)." ######";
			$string .= PHP_EOL . "\t\t'$group' => array(";
			foreach($data as $key => $value){
				$string .= PHP_EOL . "\t\t\t'$key' => ".(strlen($value) > 0 ? "'".addslashes($value)."'" : 'null').",";
			}
			$string .= PHP_EOL . "\t\t),";
			$string .= PHP_EOL . "\t\t########";
		}
		$string .= PHP_EOL . "\t);" . PHP_EOL;

		return General::writeFile($dest . '/config.php', $string, $mode);

	}

	function loadOldStyleConfig(){
		$config = preg_replace(array('/^<\?php/i', '/\?>$/i', '/if\(\!defined\([^\r\n]+/i', '/require_once[^\r\n]+/i'), NULL, file_get_contents('manifest/config.php'));

		if(@eval($config) === false){
			throw new Exception('Failed to load existing config');
		}

		return $settings;
	}

{'fraction_non_alphanumeric': 0.25700589970501475, 'fraction_numerical': 0.0025811209439528023, 'mean_word_length': 4.0055350553505535, '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': '6555239', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1005, 'n_words': 190}