<commit_before><?php

function encrypt_pass ($plain) {
	$base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
	$salt = <PASSWORD>$';
	for ($i = 0; $i < 9; $i++) {
		$salt .= $base[rand (0, 61)];
	}
	return crypt ($plain, $salt . '$');
}

if (basename (getcwd ()) == 'conf') {
	chdir ('..');
}
require_once ('lib/Functions.php');
require_once ('lib/Database.php');

$conf = parse_ini_file ('conf/config.php', true);
date_default_timezone_set($conf['General']['timezone']);

if (! db_open ($conf['Database'])) {
	die (db_error ());
}

$sqldata = sql_split (file_get_contents ('conf/install_' . $conf['Database']['driver'] . '.sql'));

foreach ($sqldata as $sql) {
	if (! db_execute ($sql)) {
		echo 'Error: ' . db_error () . "\n";
	}
}

$date = gmdate ('Y-m-d H:i:s');

if (! db_execute (
	'insert into user (id, email, password, session_id, expires, name, type, signed_up, updated, userdata) values (1, ?, ?, null, ?, "<PASSWORD>", "admin", ?, ?, ?)',
	$conf['General']['master_username'],
	encrypt_pass ($conf['General']['master_password']),
	$date,
	$date,
	$date,
	json_encode (array ())
)) {
	echo 'Error: ' . db_error () . "\n";
}

?><commit_msg>Updated createdb to create a versions entry for index<commit_after><?php

function encrypt_pass ($plain) {
	$base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
	$salt = <PASSWORD>$';
	for ($i = 0; $i < 9; $i++) {
		$salt .= $base[rand (0, 61)];
	}
	return crypt ($plain, $salt . '$');
}

if (basename (getcwd ()) == 'conf') {
	chdir ('..');
}
require_once ('lib/Functions.php');
require_once ('lib/Database.php');
require_once ('lib/Model.php');
require_once ('apps/admin/models/Webpage.php');
require_once ('apps/admin/models/Versions.php');
require_once ('apps/user/models/User.php');

$conf = parse_ini_file ('conf/config.php', true);
date_default_timezone_set($conf['General']['timezone']);

if (! db_open ($conf['Database'])) {
	die (db_error ());
}

// import the database schema
$sqldata = sql_split (file_get_contents ('conf/install_' . $conf['Database']['driver'] . '.sql'));

foreach ($sqldata as $sql) {
	if (! db_execute ($sql)) {
		echo 'Error: ' . db_error () . "\n";
	}
}

// create first admin user
$date = gmdate ('Y-m-d H:i:s');
if (! db_execute (
	'insert into user (id, email, password, session_id, expires, name, type, signed_up, updated, userdata) values (1, ?, ?, null, ?, "Admin User", "admin", ?, ?, ?)',
	$conf['General']['master_username'],
	encrypt_pass ($conf['General']['master_password']),
	$date,
	$date,
	$date,
	json_encode (array ())
)) {
	echo 'Error: ' . db_error () . "\n";
}

$user = new User (1);

// create versions entry for the index page
$wp = new Webpage ('index');
Versions::add ($wp);

?>
{'fraction_non_alphanumeric': 0.22295562889622295, 'fraction_numerical': 0.0121012101210121, 'mean_word_length': 4.917570498915401, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 8, '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': '4465584', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1036, 'n_words': 230}