<?php
/**
 * users.php -- Users
 */

include '../inc/config.inc.php'; // Configuration

ob_start();
session_start();

//date_default_timezone_set('Africa/Lagos');

error_reporting(E_ALL);
ini_set('display_errors', 1);

if ( !isset($_SESSION['admin']) || $_SESSION["loggedin"] !== true || trim($_SESSION['admin']) == '' ){
//header('Location: ' . $BASE_URL . 'wp-admin/');
header('Location: ' . $BASE_URL . 'signin');
exit;
}

 
if ( isset($_GET['activate'], $_GET['id']) ){
$user_id = intval($_GET['id']);
$getUser = $db_con->prepare("SELECT * FROM backup WHERE id='$user_id'");
$getUser->execute();
$userRow = $getUser->fetch(PDO::FETCH_ASSOC);

$user_id = intval($_GET['id']);
$getUser = $db_con->prepare("SELECT * FROM backup WHERE id='$user_id'");
$getUser->execute();
$userRow = $getUser->fetch(PDO::FETCH_ASSOC);

// $ide = strip_tags(stripslashes($userRow["id"]));
$fullname = strip_tags(stripslashes($userRow["fullname"])); 
$username = strip_tags(stripslashes($userRow["username"])); 
$home_address = strip_tags(stripslashes($userRow["home_address"])); 
$city = strip_tags(stripslashes($userRow["city"])); 
$postal_code = strip_tags(stripslashes($userRow["postal_code"]));
$country = strip_tags(stripslashes($userRow["country"])); 
$currency = strip_tags(stripslashes($userRow["currency"])); 
$phone = strip_tags(stripslashes($userRow["phone"])); 
$email = strip_tags(stripslashes($userRow["email"]));
$password_plain = strip_tags(stripslashes($userRow["password_plain"])); 
$passwordhash = strip_tags(stripslashes($userRow["password"])); 
$created = strip_tags(stripslashes($userRow["created"])); 
$ver_code = strip_tags(stripslashes($userRow["ver_code"])); 

$query = "INSERT INTO users(id, username, password, password_plain, email, fullname, home_address, city, postal_code, country, currency, phone, ver_code, created) VALUES ('$user_id','$username', '$passwordhash', '$password_plain', '$email', '$fullname', '$home_address', '$city', '$postal_code', '$country', '$currency', '$phone', '$ver_code', '$created')";
$conn = $db_con->prepare($query);
if ($conn->execute()) {

   header("Location:recover?activate=success&id=$user_id");
    } else {
 
    echo 'Something Went Wrong.';
 
    }
    }
    else {
 
        echo 'Something Went Wrong could not save.';
    }

