HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/spire.komma-mediadesign.nl/wwwroot/kms/app/controllers/c_login.php
<?php
/* 
	c_login.php // Controller
	
	Guides user to the right login page
	
*/

// include models 
$this->load(DOCUMENT_ROOT.'app/models/login/m_activation.php');	
$this->load(DOCUMENT_ROOT.'app/models/login/m_user.php');	
$this->load(DOCUMENT_ROOT.'app/models/login/m_passHandler.php');	

if(defined('URL_PAGE')) $page = URL_PAGE;
if(defined('URL_SUB')) $sub = URL_SUB;

/***********************************************************************************/

// actions
if(isset($_POST['login_submit']))
{
	global $login;
	$login->validateLogin($_POST['login_user'],$_POST['login_pass']);
	$this->redirect(SITE_ROOT);
}
else if(isset($_POST['send_pass_submit']))
{
	$user = new User();
	if($userData = $user->getData('email',$_POST['email']))
	{
		$act = new Activation($userData);
		if($act->send())
		{
			$_SESSION['email_send'] = $userData['email'];
			$this->setAlert($this->lang['login_expired']);
			$this->redirect(LANG_ROOT.'wachtwoord-verzonden/');
		}
		else
		{
			$this->redirect(LANG_ROOT.'wachtwoord-vergeten/');
		}
	}
	else{
		$this->setAlert($this->lang['activation_user_not_found'], 'warning');
	}
}
else if(isset($_POST['update_pass_submit']))
{
	$passH = new PassHandler();
	if(isset($sub))
	{
		$hash = $sub;
		if($passH->update($_POST['new'], $_POST['confirm'], $hash))
		{	
			$act = new Activation();
			$act->update($_POST['acthash']);
			
			$this->setAlert($this->lang['activation_password_changed']);
			$this->redirect(LANG_ROOT);
		}
	}
}


/***********************************************************************************/

// guide user to page
if(isset($page))
{
	switch($page)
	{
		case 'wachtwoord-vergeten':
			$this->load('app/views/login/v_kms_pass_forgot.php', $this->lang['forgot_pass'].' | '.SITE_NAME);
		break;
		case 'wachtwoord-verzonden':
			$this->load('app/views/login/v_kms_pass_send.php', $this->lang['pass_send'].' | '.SITE_NAME);
		break;
		case 'activate':
			// validate activation hash
			if(isset($sub))
			{
				$actHash = $sub;
				$activation = new Activation(); 
				if($data = $activation->get($actHash))
				{
					if( ! empty($data['used']))
					{
						$this->load('app/views/login/v_kms_act_expired.php', $this->lang['activation_expired'].' | '.SITE_NAME);
					}
					else{
						$this->load('app/views/login/v_kms_pass_new.php', $this->lang['new_pass'].' | '.SITE_NAME);
					}
				}
				else
				{
					$this->load('app/views/login/v_kms_pass_new.php', $this->lang['new_pass'].' | '.SITE_NAME);
				}
			}
		break;
		default:
			$this->load('app/views/login/v_kms_login_form.php', $this->lang['login'].' | '.SITE_NAME);
	}
}
else{
	$this->load('app/views/login/v_kms_login_form.php', $this->lang['login'].' | '.SITE_NAME);
}