Files
EasyCloud/Sources/webAduc/www/index.php
2020-11-20 13:56:16 +01:00

90 lines
2.4 KiB
PHP

<?php
/**
* This file is the entry point of phpAduc.
*
* Ce fichier redirige les demandes vers la page appropriée
*
* PHP version > 7.3
*
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category Main
* @package phpAduc
* @author Serge NOEL <serge.noel@easylinux.fr>
* @copyright 2016-2020 Easylinux
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version GIT: 2.0
* @link ../tests/Documentation Tests/Documentation.odt
*/
// Charge les classes installées par Composer
require_once 'vendor/autoload.php';
// Lire la configuration du site
require_once 'src/config/config.php';
require_once 'src/class/autoload.php';
session_start();
/* Initialisation de Smarty */
$smarty = new Smarty();
// Définir le dossier templates
$smarty->setTemplateDir('src/templates');
$smarty->setConfigDir('src/templates/configs');
// Définir le dossier qui recoit les templates compilés
$smarty->setCompileDir('templates_c');
$smarty->setCacheDir('src/templates_c/cache');
// Lire la page demandée
$Action=filter_input(INPUT_POST,'Action',FILTER_SANITIZE_STRING);
if(!isset($_SESSION['Loggued']) && $Action=="")
{
$Action='Login';
}
error_log("Appel avec $Action");
switch($Action)
{
case 'tryLogin':
error_log('tryLogin ');
$Usr=new userClass();
$sLogin=filter_input(INPUT_POST,'sLogin',FILTER_SANITIZE_STRING);
$sPasswd=filter_input(INPUT_POST,'sPassword',FILTER_SANITIZE_STRING);
if($Usr->isValid($sLogin,$sPasswd))
{
$template='main.smarty';
$component='main';
$_SESSION['loggued']=true;
}
else
{
$template='login.smarty';
$component="";
$smarty->assign('error','Compte ou mot de passe invalide !');
$smarty->assign('Title',"easyCloud");
}
break;
case 'Logout':
unset($_SESSION['Loggued']);
case 'Login':
$template='login.smarty';
$component="";
break;
default:
$component=strtolower($Action);
$template="$component.smarty";
break;
}
if($component!="")
{
require_once("src/components/$component.php");
}
$smarty->assign('Title',"easyCloud");
echo $smarty->display($template);