<?php session_start();
	/*
	 *
	 * 2003 - 2023 @ Yal Publicidad - Weby+
	 * www.yalpublicidad.com
	 * online@yalpublicidad.com
	 *
	 * @ login.php
	 *
	 */
	
	include_once( dirname(__DIR__) . '/.ypanel.php');
	/** No cache */	
		yPanel::no_cache();
	
	/*
	 * Cerrar Sesion
	 */
		if( isset( $_GET['sess'] ) ){
			if( yPanel::eliminar_sesion() ){
				header('location: ../../' );
			}else{
				header('location: ../../?err-logout' );
			}
			exit;
		}
	
	/** Verifico si se ha iniciado sesion por POST */
	if( $_POST ) {
			if( valCaptcha($_POST['token']) ){ //$_POST['token'] == yPanel::captcha( true )	
				$user = strtolower( $_POST['user'] );
				$pass = $_POST['pass'];	
				// -- * Verifico si recibo campos vacios
				if( $user==NULL || $pass==NULL ){
					echo 5;
				}else{
					$sess = yPanel::isess( $user, $pass );
					if( $sess === 'u_invalido' ){
						echo 3;
					}elseif( $sess === 'p_invalido' ){
						echo 4;
					}else{
						echo $sess;
					}					
				}	
			}else{
				echo 6;
			}
	}else{
		header('location: ../../' );
	}
?>