<?php
/*
* Generated by CRUDigniter v3.2
* www.crudigniter.com
*/
class Login extends CI_Controller{
function __construct()
{
parent::__construct();
$this->load->model('User_model');
}
/*
* Listing of acces
*/
function index()
{
$this->load->view("login");
if($this->session->userdata("auth") != false){
redirect("Dashboard/index");
}
}
function connect(){
// if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['recaptcha_response'])) {
// Build POST request:
// $recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify';
// $recaptcha_secret = '6Ld1G5sUAAAAAM7IcmYS_8LTRI0XFLY4NRGKU_ud';
// $recaptcha_response = $_POST['recaptcha_response'];
// Make and decode POST request:
// $recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response);
// $recaptcha = json_decode($recaptcha);
// Take action based on the score returned:
// if (isset($recaptcha->score) && $recaptcha->score >= 0.5) {
$this->load->model('Contrat_model');
$user = $this->User_model->connect($this->input->post("login"),$this->input->post("password"));
if(isset($user[0])){
//$url = 'http://DB-GHX.Groupe-Hammami.com:7048/GP_HAMMAMI/ODataV4/Company(\'005-SCPC\')/P_SoldeCongeEmployeeW?$format=json';
// $this->Contrat_model->update_solde($url);
// $url = 'http://db-ghx.groupe-hammami.com:7048/GP_HAMMAMI/ODataV4/Company(\'020-TMS\')/P_SoldeCongeEmployeeW?$format=json';
// $this->Contrat_model->update_solde($url);
$this->session->set_userdata("auth",$user[0]);
redirect("dashboard/index");
}else{
redirect("login/index");
}
// } else {
// redirect("login/index");
// }
// }
}
function logout(){
$this->session->unset_userdata(["auth"]);
$this->session->sess_destroy();
redirect("Login/index");
}
}