/**
 * function that alllows the install to add a user
 */
function web_install_add_user()
{
    $layout = new layout('zimpleza');
    $errors = array();
    if (isset($_POST['submit'])) {
        $_POST = html::specialEncode($_POST);
        if (empty($_POST['pass1'])) {
            $errors[] = 'Please enter a password';
        }
        if ($_POST['pass1'] != $_POST['pass2']) {
            $errors[] = 'Not same passwords';
        }
        if (empty($_POST['email'])) {
            $errors[] = 'Please enter an email';
        }
        if (!empty($errors)) {
            html::errors($errors);
        } else {
            $db = new db();
            $_POST = html::specialDecode($_POST);
            $values = array();
            $values['email'] = $_POST['email'];
            $values['password'] = md5($_POST['pass1']);
            // MD5
            $values['username'] = $_POST['email'];
            $values['verified'] = 1;
            $values['admin'] = 1;
            $values['super'] = 1;
            $values['type'] = 'email';
            $db->insert('account', $values);
            http::locationHeader("/account/login/index", 'Account created. You may log in');
            //web_install_add_user();
        }
    }
    web_install_user_form();
}