<?php 
/**
	This process should run every week to ensure that people activate their accounts.
**/
include("user_func.php");

$loginLink = SableSystem::getSableLinkPath('login/index.php');		
$msg = "Your account could not be confirmed. ".
		"The link may possibly have been corrupted or this account may have already been unsubscribed. ".
		"Please contact support for further assistance.";
$hdr = '<h3 class="title"><i class="fa fa-frown-o" aria-hidden="true"></i>&nbsp;Oops...</h3>';

$userHash = base64_decode($_SESSION['caller']['args'][1]);
$sql = 'select user_request_id, user_code from user__request where hash = "'.$userHash.'"';

$row = $sableDB->getRow($sql);
$userCode 	= $row['user_code'];
$requestId 	= $row['user_request_id'];

if ($userCode)
{
	$email		= SableDBFunctions::getUserEmailFromCode($userCode);
	$userName	= SableDBFunctions::getUserDisplayName($email);	

	$now = date('Y-m-d H:i:s');
	$sql = "update user set user_active = 0, deleted = '1' where user_code = '" . $userCode . "'";
	$result = $sableDB->updateQuery($sql);

	if ($result)
	{
		$hdr = '<h3 class="title"><i class="fa fa-check" aria-hidden="true"></i>&nbsp;Successfully Unsubscribed</h3>';
		$msg = "The account for <strong>".$userName."</strong> has been successfully unsubscribed.</p>";
	}
}
?>
<!--// header -->
<form id="Login" name="Login">
	<div class="forms">
        <p></p>
        <div class="container forms">
            <div class="forms-grids">
                <div class="col-md-12 forms-grid">
                <?php echo($hdr); ?>
                </div> 
            </div>
        </div>
        <p></p>
        <div class="container">  
            <div class="forms-grids">
                <div class="col-md-12 forms-grid">
                    <? echo($msg); ?>
                    <p></p>
                </div>
            </div>
        </div>
	</div>
 </form>
