<?php
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

include ('../bootstrap/helper.php');
include ('../app/Lib/Config.php');

use App\Lib;

if (post('CPANEL_DOMAIN') and post('CPANEL_USERNAME') and post('CPANEL_PASSWORD')) {
    $data =[
        'APP_NAME'=>'Hmail',
        'CPANEL_DOMAIN'=>post('CPANEL_DOMAIN'),
        'CPANEL_USERNAME'=>post('CPANEL_USERNAME'),
        'CPANEL_PASSWORD'=>post('CPANEL_PASSWORD')
    ];
    $apiKey = base64_encode(md5(uniqid(rand(), true)));
    if(Lib\Config::appSettings($data, $apiKey)){
        header('location:' . base_url() . '../login');
    }else{
        $_SESSION['installMsg'] = 'Installation not completed';
    }
}