<commit_before><?php
ob_start();
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link href="../admin/assets/css/style.css" rel="stylesheet" />
	<title>Verbalizer</title>
</head>
<body class="login">
	<div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-6 col-sm-offset-3 outer">
                <div class="inner">
<?php

// if file exists, include to show error message
if (file_exists(dirname(__FILE__).'/define.php')) {
    include(dirname(__FILE__).'/define.php');
}

// if settings are already defined, tell user to delete define.php
if (!defined("DB_HOST") || !defined("DB_USER") || !defined("DB_PASS") || !defined("DB_DATABASE")) {

    //otherwise begin installation
    if (!isset($_POST['submit'])) {
        ?>

		<h1>Installing Verbalizer</h1>
		<p>Take some time to configure the website. We need your database settings. It will not be saved anywhere except on your computer. If you need help regarding the settings, contact your web administrator.</p>
		<form action="install.php" method="post">
			<label for="dbhost">Server</label>
			<input type="text" name="dbhost" id="dbhost" placeholder="e.g localhost" value="localhost" />
			<label for="dbuser">Database username</label>
			<input type="text" name="dbuser" id="dbuser" placeholder="e.g root, user, etc" />
			<label for="dbpass">Database password</label>
			<input type="password" name="dbpass" id="dbpass" placeholder="for new servers, this normally blank" />
			<label for="dbdb">Database</label>
			<input type="text" name="dbdb" id="dbdb" placeholder="enter the database name you have chosen" />
			<input type="submit" value="Try!" id="submit" name="submit" />
		</form>
			
	<?php

    } else {
        // execute after button is pressed
        $dbhost = filter_var($_POST['dbhost'], FILTER_SANITIZE_STRING);
        $dbuser = filter_var($_POST['dbuser'], FILTER_SANITIZE_STRING);
        $dbpass = trim($_POST['dbpass']);
        $dbdb = filter_var($_POST['dbdb'], FILTER_SANITIZE_STRING);

        // needs to do some string regexp here probably
        if (empty($dbhost) || empty($dbuser) || empty($dbdb)) {
            echo "<h1>Error</h1><p>All fields need to be filled out.</p>";
            exit;
        }

        $file = fopen("define.php", "w");
        $write = "<?php\ndefine('DB_HOST', \"$dbhost\");\ndefine('DB_USER', \"$dbuser\");\ndefine('DB_PASS', \"$dbpass\");\ndefine('DB_DATABASE', \"$dbdb\");\n";
        if (fwrite($file, $write)) {
            fclose($file);
            // success!
            // create tables

            $db = new mysqli($dbhost, $dbuser, $dbpass, $dbdb);
            if ($db->connect_errno > 0) {
                unlink("define.php");
                header("Location: install.php?error");
                exit;
            }

            $sql .= "CREATE TABLE IF NOT EXISTS `vb_post` (
                `id` int(11) NOT NULL AUTO_INCREMENT,
                `title` varchar(255) NOT NULL,
                `content` text NOT NULL,
                `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                `authorID` int(11) DEFAULT NULL,
                `authorName` varchar(255) NOT NULL,
                `public` tinyint(1) NOT NULL DEFAULT '1',
                PRIMARY KEY (`id`),
                UNIQUE KEY `id` (`id`),
                KEY `id_2` (`id`)
                ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;";

            $sql .= "CREATE TABLE IF NOT EXISTS `vb_user` (
                `id` int(11) NOT NULL AUTO_INCREMENT,
                `name` varchar(255) NOT NULL,
                `postcount` int(11) NOT NULL DEFAULT '0',
                `password` varchar(255) NOT NULL,
                `age` int(11) NOT NULL,
                `city` varchar(255) NOT NULL,
                `website` varchar(255) NOT NULL,
                `aliases` varchar(255) NOT NULL,
                `bio` text NOT NULL,
                `pagination` varchar(255) NOT NULL DEFAULT 'false',
                `posts_per_page` int(11) NOT NULL DEFAULT '5',
                PRIMARY KEY (`id`)
                ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8";
<commit_msg>new meta table established<commit_after><?php
ob_start();
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link href="../admin/assets/css/style.css" rel="stylesheet" />
	<title>Verbalizer</title>
</head>
<body class="login">
	<div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-6 col-sm-offset-3 outer">
                <div class="inner">
<?php

// if file exists, include to show error message
if (file_exists(dirname(__FILE__).'/define.php')) {
    include(dirname(__FILE__).'/define.php');
}

// if settings are already defined, tell user to delete define.php
if (!defined("DB_HOST") || !defined("DB_USER") || !defined("DB_PASS") || !defined("DB_DATABASE")) {

    //otherwise begin installation
    if (!isset($_POST['submit'])) {
        ?>

		<h1>Installing Verbalizer</h1>
		<p>Take some time to configure the website. We need your database settings. It will not be saved anywhere except on your computer. If you need help regarding the settings, contact your web administrator.</p>
		<form action="install.php" method="post">
			<label for="dbhost">Server</label>
			<input type="text" name="dbhost" id="dbhost" placeholder="e.g localhost" value="localhost" />
			<label for="dbuser">Database username</label>
			<input type="text" name="dbuser" id="dbuser" placeholder="e.g root, user, etc" />
			<label for="dbpass">Database password</label>
			<input type="password" name="dbpass" id="dbpass" placeholder="for new servers, this normally blank" />
			<label for="dbdb">Database</label>
			<input type="text" name="dbdb" id="dbdb" placeholder="enter the database name you have chosen" />
			<input type="submit" value="Try!" id="submit" name="submit" />
		</form>
			
	<?php

    } else {
        // execute after button is pressed
        $dbhost = filter_var($_POST['dbhost'], FILTER_SANITIZE_STRING);
        $dbuser = filter_var($_POST['dbuser'], FILTER_SANITIZE_STRING);
        $dbpass = trim($_POST['dbpass']);
        $dbdb = filter_var($_POST['dbdb'], FILTER_SANITIZE_STRING);

        // needs to do some string regexp here probably
        if (empty($dbhost) || empty($dbuser) || empty($dbdb)) {
            echo "<h1>Error</h1><p>All fields need to be filled out.</p>";
            exit;
        }

        $file = fopen("define.php", "w");
        $write = "<?php\ndefine('DB_HOST', \"$dbhost\");\ndefine('DB_USER', \"$dbuser\");\ndefine('DB_PASS', \"$dbpass\");\ndefine('DB_DATABASE', \"$dbdb\");\n";
        if (fwrite($file, $write)) {
            fclose($file);
            // success!
            // create tables

            $db = new mysqli($dbhost, $dbuser, $dbpass, $dbdb);
            if ($db->connect_errno > 0) {
                unlink("define.php");
                header("Location: install.php?error");
                exit;
            }

            $sql = "CREATE TABLE IF NOT EXISTS `vb_meta` (
                `id` int(11) NOT NULL AUTO_INCREMENT,
                `vb_key` varchar(255) NOT NULL,
                `vb_value` varchar(255) NOT NULL,
                `description` text NOT NULL,
                PRIMARY KEY (`id`)
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";

            $sql .= "CREATE TABLE IF NOT EXISTS `vb_post` (
                `id` int(11) NOT NULL AUTO_INCREMENT,
                `title` varchar(255) NOT NULL,
                `content` text NOT NULL,
                `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
                `authorID` int(11) DEFAULT NULL,
                `authorName` varchar(255) NOT NULL,
                `public` tinyint(1) NOT NULL DEFAULT '1',
                PRIMARY KEY (`id`),
                UNIQUE KEY `id` (`id`),
                KEY `id_2` (`id`)
                ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;";

            $sql .= "CREATE TABLE IF NOT EXISTS `vb_user` (
                `id` int(11) NOT NULL AUTO_INCREMENT,
                `name` varchar(255) NOT NULL,
                `postcount` int(11) NOT NULL DEFAULT '0',
                `password` varchar(255) NOT NULL,
                `age` int(11) NOT NULL,
                `city` varchar(255) NOT NULL,
                `website` varchar(255) NOT NULL,
                `aliases` varchar(255) NOT NULL,
                `bio` text NOT NULL,
                PRIMARY KEY (`id`)
                ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8";

            $sql .= "INSERT INTO `vb_meta` (`id`, `vb_key`, `vb_value`, `description`) VALUES
                (1, 'active', 'true', 'Blog active or not. If not, redirecting to views/deactivated.php'),
                (2, 'pagination', 'false', 'Set pagination on or off'),
                (3, 'posts_per_page', '5', 'Posts per page'),
                (4, 'comments', 'false', 'Comments enabled or disabled');";

{'fraction_non_alphanumeric': 0.1545135075774215, 'fraction_numerical': 0.013397759718866682, 'mean_word_length': 2.4032137518684604, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 85, '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': '7100528', 'n_tokens_mistral': 3008, 'n_tokens_neox': 2738, 'n_words': 741}