<?php

require_once('config.php');

if(check_activation()){
    header('Location: '.baseUrl('dashboard.php'));
    die();
}

require_once('classes/user.php');
$user_class = new User();

$errors_activation = '';
$key = '';
$license = '';

if (isset($_POST['activation_key'])) {

    if ($_POST['activation_key'] == "" || $_POST['licence'] == "") {
        $errors_activation = "Please Enter Licence and Item Purchase Code.";
    }else{
        $key = $_POST['activation_key'];
        $license = $_POST['licence'];

        $result = $user_class->activate($key, $license);
        if(isset($result['success'])){
            $_SESSION['activated'] = $result['success'];
            header('Location: '.baseUrl('dashboard.php'));
            die();
        }else{
            $errors_activation = $result['error'];
        }
    }
}

include('templates/activation.php');