Initial commit for newdesigngestionnaire project
This commit is contained in:
37
flexcode/include/Modele.php
Executable file
37
flexcode/include/Modele.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
abstract class Modele
|
||||
{
|
||||
private static $bdd;
|
||||
|
||||
protected function executerRequete($sql, $params = null)
|
||||
{
|
||||
if ($params == null) {
|
||||
$resultat = self::getBdd()->query($sql); // exécution directe
|
||||
}
|
||||
else {
|
||||
$resultat = self::getBdd()->prepare($sql); // requête préparée
|
||||
$resultat->execute($params);
|
||||
}
|
||||
return $resultat;
|
||||
}
|
||||
private static function getBdd()
|
||||
{
|
||||
if (self::$bdd === null) {
|
||||
//$dsn = 'mysql:host=51.91.79.74;port=30306;dbname=intersante;charset=utf8';
|
||||
//$login = 'intersante';
|
||||
//$mdp = 'FAW2CYFi@dsnm79';
|
||||
$dsn = 'mysql:host=145.239.10.133;port=30306;dbname=intersante;charset=utf8';
|
||||
$login = 'vitalis';
|
||||
$mdp = '6ok8-Iev1-uoun';
|
||||
|
||||
// self::$bdd = new PDO($dsn, $login, $mdp,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
|
||||
}
|
||||
return self::$bdd;
|
||||
}
|
||||
|
||||
protected function dernierId()
|
||||
{
|
||||
return self::getBdd()->lastInsertId();
|
||||
}
|
||||
}
|
||||
365
flexcode/include/function.php
Executable file
365
flexcode/include/function.php
Executable file
@@ -0,0 +1,365 @@
|
||||
<?php
|
||||
|
||||
require_once 'include/Modele.php';
|
||||
|
||||
// require_once 'include/Modele.php';
|
||||
// require_once '../Framework/Modele.php';
|
||||
|
||||
class fingertable extends Modele
|
||||
{
|
||||
public function getPerifique()
|
||||
{
|
||||
$sql = "SELECT * FROM device ORDER BY device_name ASC";
|
||||
$liste = $this->executerRequete($sql);
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getPerifiqueAcSn($vc)
|
||||
{
|
||||
$sql = "SELECT * FROM device WHERE (vc=?)";
|
||||
$liste = $this->executerRequete($sql, array($vc));
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getPerifiqueBySn($sn)
|
||||
{
|
||||
$sql = "SELECT * FROM device WHERE (sn=?)";
|
||||
$liste = $this->executerRequete($sql, array($sn));
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function ajouterPerifique($device_name, $sn, $vc, $ac, $vkey)
|
||||
{
|
||||
$sql = "insert into device (device_name, sn, vc, ac, vkey) values (?, ?, ?, ?, ?)";
|
||||
$result = $this->executerRequete($sql, array($device_name, $sn, $vc, $ac, $vkey));
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function supprimerPerifique($sn)
|
||||
{
|
||||
$sql = 'DELETE FROM device WHERE (sn=?)';
|
||||
$result = $this->executerRequete($sql, array($sn));
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function ajouterUtilisateur($user_name)
|
||||
{
|
||||
$sql = "insert into user (user_name) values (?)";
|
||||
$result = $this->executerRequete($sql, array($user_name));
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function supprimerUtilisateur($user_id)
|
||||
{
|
||||
$sql = 'DELETE FROM user WHERE (user_id=?)';
|
||||
$result = $this->executerRequete($sql, array($user_id));
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function supprimerEmpreinte($user_id)
|
||||
{
|
||||
$sql = 'DELETE FROM finger WHERE (user_id=?)';
|
||||
$result = $this->executerRequete($sql, array($user_id));
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getUtilisateur()
|
||||
{
|
||||
$sql = 'SELECT * FROM user ORDER BY user_name ASC';
|
||||
$liste = $this->executerRequete($sql);
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getSubstituts($user_id)
|
||||
{
|
||||
$sql = "call sp_p_get_substituts_finger(?);";
|
||||
$liste = $this->executerRequete($sql, array($user_id));
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getUtilisateurId($user_id)
|
||||
{
|
||||
$sql = 'SELECT * FROM user WHERE (user_id=?)';
|
||||
$liste = $this->executerRequete($sql, array($user_id));
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getListeUtilisateur()
|
||||
{
|
||||
$sql = 'SELECT a.* FROM user AS a JOIN finger AS b ON a.user_id=b.user_id';
|
||||
$liste = $this->executerRequete($sql);
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function periferiqueCheckSn($sn)
|
||||
{
|
||||
$sql = "SELECT count(sn) as ct FROM device WHERE (sn=?)";
|
||||
$liste = $this->executerRequete($sql, array($sn));
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function checkNomUser($user_name)
|
||||
{
|
||||
$sql = "SELECT user_name FROM user WHERE (user_name=?)";
|
||||
$liste = $this->executerRequete($sql, array($user_name));
|
||||
// $arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
// return $arr;
|
||||
return $liste;
|
||||
}
|
||||
|
||||
function getEmpreinteUtilisateur($user_id)
|
||||
{
|
||||
$sql = "SELECT * FROM finger WHERE (user_id=?)";
|
||||
$liste = $this->executerRequete($sql, array($user_id));
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function getNbEmpreinteUtilisateur($user_id)
|
||||
{
|
||||
$sql = "SELECT count(finger_id) as ct FROM finger WHERE (user_id=?)";
|
||||
$liste = $this->executerRequete($sql, array($user_id));
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function ObtenirLog()
|
||||
{
|
||||
$sql = 'SELECT * FROM log ORDER BY log_time DESC';
|
||||
$liste = $this->executerRequete($sql);
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function creerLog($user_name, $time, $sn)
|
||||
{
|
||||
$sql = "insert into log (user_name, data) values (?, ?)";
|
||||
$data = date('d/m/Y H:i:s', strtotime($time))." (Heure locale) | ".$sn." (SN)";
|
||||
$result = $this->executerRequete($sql, array($user_name, $data));
|
||||
return $result;
|
||||
}
|
||||
|
||||
function ajouterEmpreinte($user_id, $finger_data)
|
||||
{
|
||||
$sql = "insert into finger (user_id, finger_data) values (?,?)";
|
||||
$result = $this->executerRequete($sql, array($user_id, $finger_data));
|
||||
return $result;
|
||||
}
|
||||
|
||||
function ObtenirEmpreinteId($user_id)
|
||||
{
|
||||
$sql = 'SELECT MAX(finger_id) as fid FROM finger WHERE (user_id=?)';
|
||||
$liste = $this->executerRequete($sql, array($user_id));
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
function initialiserJeton($user_id)
|
||||
{
|
||||
// $idJeton = uniqid();
|
||||
|
||||
$sql = "call sp_p_init_finger(?);";
|
||||
$this->executerRequete($sql, array($user_id));
|
||||
}
|
||||
|
||||
function majJeton($user_id, $succes)
|
||||
{
|
||||
$sql = "call sp_p_maj_finger(?, ?);";
|
||||
$this->executerRequete($sql, array($user_id, $succes));
|
||||
}
|
||||
|
||||
function verifierFinger($user_id)
|
||||
{
|
||||
$sql = "call sp_p_check_finger(?);";
|
||||
$liste = $this->executerRequete($sql, array($user_id));
|
||||
$arr = $liste->fetchAll(PDO::FETCH_ASSOC);
|
||||
return $arr;
|
||||
}
|
||||
} // FIN CLASS fingertable
|
||||
|
||||
// Début fonctions
|
||||
|
||||
function getDevice() {
|
||||
$fingertable = new fingertable();
|
||||
return $fingertable->getPerifique();
|
||||
}
|
||||
|
||||
function getDeviceAcSn($vc) {
|
||||
$fingertable = new fingertable();
|
||||
return $fingertable->getPerifiqueAcSn($vc);
|
||||
}
|
||||
|
||||
function getDeviceBySn($sn) {
|
||||
$fingertable = new fingertable();
|
||||
return $fingertable->getPerifiqueBySn($sn);
|
||||
}
|
||||
|
||||
function getUser() {
|
||||
$fingertable = new fingertable();
|
||||
return $fingertable->getUtilisateur();
|
||||
}
|
||||
|
||||
|
||||
function getSurrogates($user_id)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
return $fingertable->getSubstituts($user_id);
|
||||
}
|
||||
|
||||
function getUserId($user_id)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
return $fingertable->getUtilisateurId($user_id);
|
||||
}
|
||||
|
||||
function deviceCheckSn($sn) {
|
||||
$fingertable = new fingertable();
|
||||
$data = $fingertable->periferiqueCheckSn($sn);
|
||||
|
||||
$ct=$data['0']['ct'];
|
||||
|
||||
if (($ct!='0') && ($ct!=''))
|
||||
{
|
||||
return "Ce N° de série existe déjà!";
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function checkUserName($user_name)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$_user = $fingertable->checkNomUser($user_name);
|
||||
$row = $_user->rowCount();
|
||||
|
||||
if ($row>0) {
|
||||
return "Cet utilisateur existe déjà!";
|
||||
} else {
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
||||
function getUserFinger($user_id)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
return $fingertable->getEmpreinteUtilisateur($user_id);
|
||||
}
|
||||
|
||||
function getLog()
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
return $fingertable->ObtenirLog();
|
||||
}
|
||||
|
||||
function createLog($user_name, $time, $sn)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$result1 = $fingertable->creerLog($user_name, $time, $sn);
|
||||
|
||||
if ($result1) {
|
||||
return 1;
|
||||
} else {
|
||||
return "Error insert log data!";
|
||||
}
|
||||
}
|
||||
|
||||
function addDevice($device_name, $sn, $vc, $ac, $vkey)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$result = $fingertable->ajouterPerifique($device_name, $sn, $vc, $ac, $vkey);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function deleteDevice($sn)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$result = $fingertable->supprimerPerifique($sn) ;
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
function addUser($user_name)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$result = $fingertable->ajouterUtilisateur($user_name) ;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function deleteUser($user_id)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$result = $fingertable->supprimerUtilisateur($user_id) ;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function deleteFinger($user_id)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$result = $fingertable->supprimerEmpreinte($user_id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getListUsers()
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
return $fingertable->getListeUtilisateur();
|
||||
}
|
||||
|
||||
function addFinger($user_id, $finger_data)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$result = $fingertable->ajouterEmpreinte($user_id, $finger_data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getFingerId($user_id)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$result = $fingertable->ObtenirEmpreinteId($user_id) ;
|
||||
return $result;
|
||||
}
|
||||
|
||||
function getFingerCountUser($user_id)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$result = $fingertable->getNbEmpreinteUtilisateur($user_id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function initJeton($user_id)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$fingertable->initialiserJeton($user_id);
|
||||
}
|
||||
|
||||
function updateJeton($user_id, $succes)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$fingertable->majJeton($user_id, $succes);
|
||||
}
|
||||
|
||||
function checkFinger($user_id)
|
||||
{
|
||||
$fingertable = new fingertable();
|
||||
$result = $fingertable->verifierFinger($user_id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function est_anglophone()
|
||||
{
|
||||
return (isset($_SESSION['lang']) && $_SESSION['lang']=="en_US");
|
||||
}
|
||||
|
||||
?>
|
||||
16
flexcode/include/global.php
Executable file
16
flexcode/include/global.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*ini_set("display_errors", 0);
|
||||
error_reporting(0);*/
|
||||
|
||||
// $base_path = "flexcode/";
|
||||
|
||||
$long_link = "http://localhost/intersantebicor/";
|
||||
|
||||
/* Modifié le 11/11/2018 pour augmenter le temp d'essai
|
||||
// $time_limit_ver = "10";
|
||||
$time_limit_reg = "20";
|
||||
*/
|
||||
|
||||
$time_limit_ver = "40";
|
||||
$time_limit_reg = "40";
|
||||
?>
|
||||
Reference in New Issue
Block a user