Beispiel #1
0
 function get_ranking($top = 10)
 {
     global $db;
     $database = new myPDO($db[4][dbhost], $db[4][dbuser], $db[4][dbpw], $db[4][dbname], 'sqlsrv', 1433);
     $sql = "select top {$top} * from  Chars where Family in (0,1) order by K1 desc";
     $data = $database->executionQuery($sql);
     $re[1] = $data;
     $sql = "select top {$top} * from  Chars where Family in (2,3) order by K1 desc";
     $data = $database->executionQuery($sql);
     $re[2] = $data;
     return $re;
 }
    /**
     * Enregistre le stage dans la base de donnée.
     * 
     */
    public function save()
    {
        $pdo = myPDO::getInstance();
        //Vérifie si le stage exite pas déjà.
        if ($this->id != null) {
            $req = $pdo->prepare(<<<SQL
              UPDATE Stage
              SET titre, dateFin, dateDebut, description, domaine, nbPoste, gratification, dateCreation
              WHERE numEntreprise = ?
              AND titre = ?
              AND dateFin= ? 
              AND  dateDebut= ? 
              AND  description= ? 
              AND domaine= ? AND  nbPoste = ? 
              AND gratification= ?
              AND dateCreation = now()
SQL
);
            $update = $req->execute(array($this->entreprise->getId(), $this->titre, $this->dateFin, $this->dateDebut, $this->description, $this->domaine, $this->nbPoste, $this->gratification));
            if ($update) {
                $this->notifyObs();
            }
        } else {
            $req1 = $pdo->prepare(<<<SQL
              INSERT INTO Stage (numStage, titre, dateFin, dateDebut, description, domaine, nbPoste, gratification, numEntreprise, dateCreation)
              VALUES('',?,?,?,?,?,?,?,?, now())
SQL
);
            $ins = $req1->execute(array($this->titre, $this->dateFin, $this->dateDebut, $this->description, $this->domaine, $this->nbPoste, $this->gratification, $this->entreprise->getId()));
            // Si la BD a été modidé, on prévient l'entrepreneur
            if ($ins) {
                $this->notifyObs();
            }
        }
    }
    /**
     * Usine à Commentaire. Crée un Commentaire selon l'ID passé en paramètre
     * @param  int $id : l'ID du commentaire à créer
     * @param  Gestionnaire $gestionnaire : le gestionnaire courant
     * @return Commentaire : le commentaire voulu / null s'il n'existe pas
     */
    public static function createFromID($id, $gestionnaire, $film)
    {
        $pdo = myPDO::getInstance();
        $stmt = $pdo->prepare(<<<SQL
    SELECT *
    FROM commentaire
    WHERE id = :id
SQL
);
        $stmt->execute(array("id" => $id));
        $stmt->setFetchMode(PDO::FETCH_CLASS, 'Commentaire');
        if (($object = $stmt->fetch()) !== false) {
            $object->membre = $gestionnaire->getMembre($object->id_membre);
            $object->film = $film;
            // Test si le membre connecté a lu ce comm
            if (isset($_SESSION["membre"]) && $_SESSION["membre"] instanceof Membre) {
                $stmt2 = $pdo->prepare(<<<SQL
        SELECT id_comm
        FROM lecture_comm
        WHERE id_comm = :id_comm
        AND id_membre = :id_membre
SQL
);
                $stmt2->execute(array("id_comm" => $object->id, "id_membre" => $_SESSION["membre"]->getID()));
                if (($foo = $stmt2->fetch()) !== false) {
                    $object->lu = true;
                } else {
                    $object->lu = false;
                }
            }
            return $object;
        }
    }
 /**
  * Fixer la configuration de la connexion à la BD.
  * @param string $dsn DNS pour la connexion BD.
  * @param string $username Utilisateur pour la connexion BD.
  * @param string $password Mot de passe pour la connexion BD.
  * @param array $driver_options Options du pilote BD.
  *
  * @return void
  */
 public static function setConfiguration($dsn, $username = '', $password = '', array $driver_options = array())
 {
     self::$_DSN = $dsn;
     self::$_username = $username;
     self::$_password = $password;
     self::$_driverOptions = $driver_options + self::$_driverOptions;
 }
    /**
     * Usine à commentaire. Construit tous les commentaires d'un entreprise
     * @throws si le parametre n'est pas une instance de la class entreprise
     */
    public static function createFromEntreprise($idEntreprise)
    {
        $pdo = myPDO::getInstance();
        $req = $pdo->prepare(<<<SQL
          SELECT numCommentaire AS 'id', loginEnseignant, contenu, dateEnvoi
          FROM Commentaire
          WHERE numEntreprise= ?
SQL
);
        $req->execute(array($idEntreprise));
        $listCommentaire = $req->fetchAll(PDO::FETCH_CLASS, "Commentaire");
        return $listCommentaire;
    }
    /**
     * Constructeur d'une Convention en fonction de son login
     * @param login de Convention
     * @return une instance de Convention sinon renvoi null
     */
    public static function createFromAdmin($numAdmin)
    {
        if (strlen($numAdmin) == 8) {
            $pdo = myPDO::getInstance();
            $rq1 = $pdo->prepare(<<<SQL
\t\t\t\tSELECT numConvention ,valide, loginEnseignant, numStage, loginEtudiant
\t\t\t\tFROM Convention
\t\t\t\tWHERE numAdmin = ?
SQL
);
            $rq1->execute(array($numAdmin));
            $rq1->setFetchMode(PDO::FETCH_CLASS, __CLASS__);
            return $rq1->fetchAll();
        }
    }
    public function valideAffectation($num)
    {
        $pdo = myPDO::getInstance();
        $rq1 = $pdo->prepare(<<<SQL
\t\t\tSELECT loginEnseignant AS 'enseignant'
\t\t\tFROM Convention
\t\t\tWHERE numConvention = ?
SQL
);
        $rq1->execute(array($num));
        $rq1->setFetchMode(PDO::FETCH_CLASS, __CLASS__);
        if (($rq1 = $rq1->fetch()) !== false) {
            $sql = "UPDATE Convention SET valide=1 WHERE id=?";
            $stmt = $conn->prepare($sql);
            $stmt->execute($rq1);
        }
    }
Beispiel #8
0
    /**
     * Usine à fabriquer des Stage
     * @param  int  $idEtudiant   : l'ID de l'étudiant
     * @param  int  $idOffre      : l'ID de l'offre
     * @param  int  $idEnseignant : l'ID de l'enseignant
     * @return Stage
     */
    public static function createFromIDs($idEtudiant, $idOffre, $idEnseignant)
    {
        $pdo = myPDO::getInstance();
        $stmt = $pdo->prepare(<<<SQL
    SELECT *
    FROM STAGE
    WHERE idEtu = :idEtu
    AND idOffre = :idOffre
    AND idEns = :idEns
SQL
);
        $stmt->execute(array("idEtu" => $idEtudiant, "idOffre" => $idOffre, "idEns" => $idEnseignant));
        $stmt->setFetchMode(PDO::FETCH_CLASS, 'Stage');
        if (($object = $stmt->fetch()) !== false) {
            $object->entrepriseCorrespondante = Entreprise::createFromID(OffreStage::createFromID($idOffre)->getEntrepriseId());
            return $object;
        }
    }
    /**
     * Permet à un entrepreneur de s'inscrire dans la base de donnée
     * @throws si l'adresse mail est déja utilsé dans la base de donnée.
     */
    public static function inscription($nom, $prenom, $mail, $pass, $tel = null, $fonction = "")
    {
        $pdo = myPDO::getInstance();
        $req = $pdo->prepare(<<<SQL
\t    \tSELECT 'a'
\t    \tFROM Entrepreneur
\t    \tWHERE mail = ?
SQL
);
        $req->execute(array($mail));
        if ($req->fetch() != false) {
            throw new MailUtiliser("Cette adresse mail est déja utilisé.");
        }
        $req1 = $pdo->prepare(<<<SQL
\t\t\tINSERT INTO Entrepreneur (numEntrepreneur,prenom,nom,mail,fonction,pass,tel)
\t\t\tVALUES('',?,?,?,?,?,?)
SQL
);
        $ins = $req1->execute(array($prenom, $nom, $mail, $fonction, sha1($pass), $tel));
    }
Beispiel #10
0
 /**
  * Usine à fabriquer des OffreStage.
  * @param int $id : l'ID de l'offre
  */
 public static function createFromID($id)
 {
     $offre = new OffreStage();
     // On récupère l'offre de stage
     $pdo = myPDO::getInstance();
     $pdostat = $pdo->prepare("SELECT * FROM OFFRESTAGE WHERE idOffre=:id ORDER BY datePublication DESC");
     $pdostat->execute(array(':id' => $id));
     $pdostat->setFetchMode(PDO::FETCH_CLASS, __CLASS__);
     if (($obj = $pdostat->fetch()) !== false) {
         $offre = $obj;
     }
     // On récupère l'es id'
     $pdostat = $pdo->prepare("SELECT * FROM STAGE WHERE idOffre=:id");
     $pdostat->execute(array(':id' => $id));
     $pdostat->setFetchMode(PDO::FETCH_CLASS, __CLASS__);
     while (($obj = $pdostat->fetch()) !== false) {
         $offre->stagesCorrespondants[] = $obj;
     }
     $offre->datePublication = date('d/m/Y', strtotime($offre->datePublication));
     $offre->dateDeb = date('d/m/Y', strtotime($offre->dateDeb));
     $offre->dateFin = date('d/m/Y', strtotime($offre->dateFin));
     return $offre;
 }
Beispiel #11
0
 public function update_elements_champs($array, $id_element)
 {
     global $thisSite;
     $PDO = new myPDO();
     $temp = array();
     $this->get_champs();
     foreach ($array as $k => $row) {
         if (is_numeric($k)) {
             if (in_array($k, $this->list_champ_crypte)) {
                 $temp[$k] = crypt_string('KEY', $row);
             } else {
                 $temp[$k] = $row;
             }
         }
     }
     // UPDATE les valeurs saisie par l'utilisateur elements_champs
     foreach ($temp as $key => $data) {
         $result = $PDO->free_requete("UPDATE " . $thisSite->PREFIXE_TBL_CLI . "elements_champs \n                                SET valeur = '{$data}'\n                                WHERE " . $thisSite->PREFIXE_TBL_CLI . "elements_champs.id_element = {$id_element}\n                                AND " . $thisSite->PREFIXE_TBL_CLI . "elements_champs.id = {$key}");
     }
     /* decrypter le valeurs pour le rendre à la vue */
     foreach ($temp as $kk => $vv) {
         if (in_array($kk, $this->list_champ_crypte)) {
             $temp[$kk] = decrypt_string('KEY', $vv);
         }
     }
     $this->valeurs = $temp;
 }
Beispiel #12
0
    /**
     * Faire lire tous les commentaires à ce membre
     * @return void
     */
    public function lireTousCommentaires()
    {
        $pdo = myPDO::getInstance();
        $stmt = $pdo->prepare(<<<SQL
    SELECT MAX(id) AS max_comm
    FROM commentaire
SQL
);
        $stmt->execute();
        $nbComm = $stmt->fetch()["max_comm"];
        for ($i = 1; $i <= $nbComm; $i++) {
            $this->lireCommentaire($i);
        }
    }
Beispiel #13
0
    public function applyChanges($post)
    {
        $pdo = myPDO::getInstance();
        if (isset($post["email"])) {
            $stmt = $pdo->prepare(<<<SQL
        SELECT email
        FROM PERSONNE
        UNION
        SELECT email
        FROM ENTREPRISE
SQL
);
            $stmt->execute();
            while (($obj = $stmt->fetch()) !== false) {
                if ($obj["email"] == $post["email"]) {
                    $post["email"] = "";
                }
            }
        }
        $stmt = $pdo->prepare(<<<SQL
    UPDATE PERSONNE
    SET email = ?,
        numRue = ?,
        rue = ?,
        ville = ?,
        CP = ?,
        sha1mdp = ?
    WHERE idPers = ?
SQL
);
        $stmt->execute(array(isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email, isset($post["num_rue"]) && $post["num_rue"] != "" ? $post["num_rue"] : $this->numRue, isset($post["nom_rue"]) && $post["nom_rue"] != "" ? $post["nom_rue"] : $this->rue, isset($post["ville"]) && $post["ville"] != "" ? $post["ville"] : $this->ville, isset($post["code_postal"]) && $post["code_postal"] != "" ? $post["code_postal"] : $this->CP, isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp, $this->idEtu));
        $this->email = isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email;
        $this->numRue = isset($post["num_rue"]) && $post["num_rue"] != "" ? $post["num_rue"] : $this->numRue;
        $this->rue = isset($post["nom_rue"]) && $post["nom_rue"] != "" ? $post["nom_rue"] : $this->rue;
        $this->ville = isset($post["ville"]) && $post["ville"] != "" ? $post["ville"] : $this->ville;
        $this->CP = isset($post["code_postal"]) && $post["code_postal"] != "" ? $post["code_postal"] : $this->CP;
        $this->sha1mdp = isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp;
        if (isset($_FILES)) {
            $stmt = $pdo->prepare(<<<SQL
      UPDATE ETUDIANT
      SET cheminCV = ?
      WHERE idEtu = ?
SQL
);
            $nameFile = SHA1("cv" . $this->idEtu);
            $stmt->execute(array($nameFile . ".pdf", $this->idEtu));
            $this->cheminCV = $nameFile . ".pdf";
            if (file_exists($nameFile . ".pdf")) {
                unlink("../CV/" . $nameFile . ".pdf");
            }
            move_uploaded_file($_FILES['CV']['tmp_name'], "../CV/" . $nameFile . ".pdf");
        }
    }
Beispiel #14
0
<?php

require_once "../inc/config.inc.php";
session_start();
$idOffre = (int) $_POST["idOffre"];
if (isset($_SESSION["membre"]) && $_SESSION["membre"] instanceof Entreprise) {
    if (isset($_POST["idOffre"]) && isset($_POST["intitule"]) && isset($_POST["domaine"]) && isset($_POST["nbPlaces"]) && isset($_POST["competences"]) && isset($_POST["date_deb"]) && isset($_POST["date_fin"]) && !empty($_POST["intitule"]) && !empty($_POST["domaine"]) && !empty($_POST["nbPlaces"]) && !empty($_POST["competences"]) && !empty($_POST["date_deb"]) && !empty($_POST["date_fin"])) {
        if (is_numeric($_POST["nbPlaces"])) {
            if (in_array(OffreStage::createFromID($idOffre), $_SESSION["membre"]->getOffresProposees())) {
                $pdo = myPDO::getInstance();
                $stmt = $pdo->prepare(<<<SQL
          UPDATE OFFRESTAGE
          SET idEnt = :idEnt, intitule = :intitule,
          domaine = :domaine, nbPlaces = :nbPlaces,
          descOffre = :descOffre, cptRequis = :cptRequis,
          dateDeb = :dateDeb, dateFin = :dateFin
          WHERE idOffre = :idOffre
SQL
);
                $stmt->execute(array("idEnt" => $_SESSION["membre"]->getID(), "intitule" => $_POST["intitule"], "domaine" => $_POST["domaine"], "nbPlaces" => $_POST["nbPlaces"], "descOffre" => $_POST["description"], "cptRequis" => $_POST["competences"], "dateDeb" => $_POST["date_deb"], "dateFin" => $_POST["date_fin"], "idOffre" => $idOffre));
                $message = "Offre modifiée. <a href=\"listeOffresEntreprise.php\">Retour à la liste des offres</a>";
                // MAJ de l'objet en session :
                $_SESSION["membre"] = Entreprise::createFromID($_SESSION["membre"]->getID());
            } else {
                $message = "Vous n'avez pas le droit de modifier cette offre <a href=\"index.php\">Retour</a>";
            }
        } else {
            $message = "Le nombre de places doit être un nombre entier. <a href=\"modiferOffre.php?id={$idOffre}\">Retour</a>";
        }
    } else {
        $message = "Tous les champs sont obligatoires. <a href=\"modiferOffre.php?id={$idOffre}\">Retour</a>";
    /**
     * Méthode statique, accès au nombre total de films présents dans la BD
     * @return int : le nombre de films dans la BD
     */
    public static function nbTotalFilms()
    {
        $pdo = myPDO::getInstance();
        $stmt = $pdo->prepare(<<<SQL
      SELECT COUNT(id) AS nb_films
      FROM film
SQL
);
        $stmt->execute();
        $data = $stmt->fetch();
        return $data["nb_films"];
    }
Beispiel #16
0
        return false;
    }
    return true;
}
function user_is_active($user_id)
{
    global $con;
    $last_activity = $con->myQuery("SELECT is_active FROM users  WHERE id=?", array($user_id))->fetchColumn();
    if (!empty($last_activity)) {
        return true;
    } else {
        return false;
    }
}
/* END SPECIFIC TO WEBAPP */
$con = new myPDO('ams', 'root', '');
if (isLoggedIn()) {
    if (!user_is_active($_SESSION[WEBAPP]['user']['id'])) {
        refresh_activity($_SESSION[WEBAPP]['user']['id']);
        session_destroy();
        session_start();
        Alert("Your account has been deactivated.", "danger");
        redirect('frmlogin.php');
        die;
    }
    if (is_active($_SESSION[WEBAPP]['user']['id'])) {
        refresh_activity($_SESSION[WEBAPP]['user']['id']);
    } else {
        //echo 'You have been inactive.';
        // die;
        refresh_activity($_SESSION[WEBAPP]['user']['id']);
Beispiel #17
0
    /**
     * Ajoute un commentaire sur ce film
     * @param  int $membre      : l'ID du membre qui ajoute ce Commentaire
     * @param  String $contenu  : le contenu du Commentaire
     * @param  boolean $spoiler : ce commentaire est-il un spoiler
     * @return void
     */
    public function ajoutCommentaire($membre, $contenu, $spoiler = false)
    {
        $pdo = myPDO::getInstance();
        $stmt = $pdo->prepare(<<<SQL
          INSERT INTO commentaire (id_film, id_membre, commentaire, spoiler, date_publication)
          VALUES (:idfilm, :idmembre, :commentaire, :spoiler, now())
SQL
);
        $stmt->execute(array("idfilm" => $this->id, "idmembre" => $membre, "commentaire" => $contenu, "spoiler" => $spoiler));
        $idComm = $pdo->lastInsertId();
        $membre_obj = Membre::createFromID($membre);
        $membre_obj->lireCommentaire($idComm);
    }
    /**
     * Retourne la liste des tous les enseignants
     * 
     */
    public function getAll()
    {
        $pdo = myPDO::getInstance();
        $req1 = $pdo->prepare(<<<SQL
\t\tSELECT *
\t\tFROM Enseignant
SQL
);
        $rq1->execute(array());
        $rq1->setFetchMode(PDO::FETCH_CLASS, __CLASS__);
        return $rq1->fetchAll();
    }
Beispiel #19
0
    public function applyChanges($post)
    {
        $pdo = myPDO::getInstance();
        if (isset($post["email"])) {
            $stmt = $pdo->prepare(<<<SQL
        SELECT email
        FROM PERSONNE
        UNION
        SELECT email
        FROM ENTREPRISE
SQL
);
            $stmt->execute();
            while (($obj = $stmt->fetch()) !== false) {
                if ($obj["email"] == $post["email"]) {
                    $post["email"] = "";
                }
            }
        }
        $stmt = $pdo->prepare(<<<SQL
    UPDATE PERSONNE
    SET email = ?,
        numRue = ?,
        rue = ?,
        ville = ?,
        CP = ?,
        sha1mdp = ?
    WHERE idPers = ?
SQL
);
        $stmt->execute(array(isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email, isset($post["num_rueEns"]) && $post["num_rueEns"] != "" ? $post["num_rueEns"] : $this->numRue, isset($post["nom_rueEns"]) && $post["nom_rueEns"] != "" ? $post["nom_rueEns"] : $this->rue, isset($post["villeEns"]) && $post["villeEns"] != "" ? $post["villeEns"] : $this->ville, isset($post["code_postalEns"]) && $post["code_postalEns"] != "" ? $post["code_postalEns"] : $this->CP, isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp, $this->idEns));
        $stmt = $pdo->prepare(<<<SQL
   UPDATE ENSEIGNANT
   SET domainPredom = ?
   WHERE idEns = ?
SQL
);
        $stmt->execute(array(isset($post["domainePredom"]) && $post["domainePredom"] != "" ? $post["domainePredom"] : $this->domainePredom, $this->idEns));
        $this->email = isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email;
        $this->numRue = isset($post["num_rueEns"]) && $post["num_rueEns"] != "" ? $post["num_rueEns"] : $this->numRue;
        $this->rue = isset($post["nom_rueEns"]) && $post["nom_rueEns"] != "" ? $post["nom_rueEns"] : $this->rue;
        $this->ville = isset($post["villeEns"]) && $post["villeEns"] != "" ? $post["villeEns"] : $this->ville;
        $this->CP = isset($post["code_postalEns"]) && $post["code_postalEns"] != "" ? $post["code_postalEns"] : $this->CP;
        $this->sha1mdp = isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp;
        $this->domainePredom = isset($post["domaine"]) && $post["domaine"] != "" ? $post["domaine"] : $this->domainePredom;
    }
Beispiel #20
0
    public function applyChanges($post)
    {
        $pdo = myPDO::getInstance();
        if (isset($post["email"])) {
            $stmt = $pdo->prepare(<<<SQL
        SELECT email
        FROM PERSONNE
        UNION
        SELECT email
        FROM ENTREPRISE
SQL
);
            $stmt->execute();
            while (($obj = $stmt->fetch()) !== false) {
                if ($obj["email"] == $post["email"]) {
                    $post["email"] = "";
                }
            }
        }
        $stmt = $pdo->prepare(<<<SQL
    UPDATE ENTREPRISE
    SET email = ?,
        siteWebEnt = ?,
        description = ?,
        numRueEnt = ?,
        rueEnt = ?,
        villeEnt = ?,
        CPEnt = ?,
        sha1mdp = ?
    WHERE idEnt = ?
SQL
);
        $stmt->execute(array(isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email, isset($post["siteWebEnt"]) && $post["siteWebEnt"] != "" ? $post["siteWebEnt"] : $this->siteWebEnt, isset($post["description"]) && $post["description"] != "" ? $post["description"] : $this->description, isset($post["num_rueEnt"]) && $post["num_rueEnt"] != "" ? $post["num_rueEnt"] : $this->numRueEnt, isset($post["nom_rueEnt"]) && $post["nom_rueEnt"] != "" ? $post["nom_rueEnt"] : $this->rueEnt, isset($post["villeEnt"]) && $post["villeEnt"] != "" ? $post["villeEnt"] : $this->villeEnt, isset($post["code_postalEnt"]) && $post["code_postalEnt"] != "" ? $post["code_postalEnt"] : $this->CPEnt, isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp, $this->idEnt));
        $this->email = isset($post["email"]) && $post["email"] != "" ? $post["email"] : $this->email;
        $this->siteWebEnt = isset($post["siteWebEnt"]) && $post["siteWebEnt"] != "" ? $post["siteWebEnt"] : $this->siteWebEnt;
        $this->description = isset($post["description"]) && $post["description"] != "" ? $post["description"] : $this->description;
        $this->numRueEnt = isset($post["num_rueEnt"]) && $post["num_rueEnt"] != "" ? $post["num_rueEnt"] : $this->numRueEnt;
        $this->rueEnt = isset($post["nom_rueEnt"]) && $post["nom_rueEnt"] != "" ? $post["nom_rueEnt"] : $this->rueEnt;
        $this->villeEnt = isset($post["villeEnt"]) && $post["villeEnt"] != "" ? $post["villeEnt"] : $this->villeEnt;
        $this->CPEnt = isset($post["code_postalEnt"]) && $post["code_postalEnt"] != "" ? $post["code_postalEnt"] : $this->CPEnt;
        $this->sha1mdp = isset($post["mdp"]) && $post["mdp"] != "" ? SHA1($post["mdp"]) : $this->sha1mdp;
    }
    /**
     * Détermine le type d'un utilisateur
     * @param  String $login : le login de l'utilisateur
     * @return String : le type de l'utilisateur
     */
    private function typeUtilisateur($login)
    {
        $pdo = myPDO::getInstance();
        // On récupère l'id de la Personne
        $stmt = $pdo->prepare(<<<SQL
    SELECT idPers
    FROM PERSONNE
    WHERE login = :log
SQL
);
        $stmt->execute(array(':log' => $login));
        $stmt->setFetchMode(PDO::FETCH_CLASS, '');
        if (($object = $stmt->fetch()) !== false) {
            // On regarde si l'id correpond...
            $stmt2 = $pdo->prepare(<<<SQL
      SELECT *
      FROM ENSEIGNANT
      WHERE idEns = :id
SQL
);
            $stmt2->execute(array(':id' => $object['idPers']));
            if (($obj = $stmt2->fetch()) !== false) {
                // ...à un enseignant...
                return "enseignant";
            } else {
                // ...ou à un étudiant
                return "etudiant";
            }
        } else {
            // si le login n'existe pas dans Personne alors il est dans Entreprise
            return "entreprise";
        }
    }
Beispiel #22
0
<?php

require_once 'myPDO.class.php';
// myPDO::setConfiguration('mysql:host=alexmichqgalex.mysql.db;dbname=alexmichqgalex;charset=utf8', 'alexmichqgalex', 'alexBD32651');
myPDO::setConfiguration('mysql:host=localhost;dbname=films;charset=utf8', 'root', '');
    /**
     * Permet à un etudiant de s'inscrire dans la base de donnée, seul le login est obligatoire
     * @throws si le login est déja utilsé dans la base de donnée.
     */
    public static function inscription($login, $nom = "", $prenom = "", $mail = "", $tel = "")
    {
        $pdo = myPDO::getInstance();
        $req = $pdo->prepare(<<<SQL
\t    \tSELECT 'a'
\t    \tFROM Etudiant
\t    \tWHERE loginEtudiant = ?
SQL
);
        $req->execute(array($login));
        if ($req->fetch() != false) {
            $req1 = $pdo->prepare(<<<SQL
\t\t\tUPDATE Etudiant
\t\t\tSET prenom = ?,nom = ?,mail= ?,tel= ?
\t\t\tWHERE loginEtudiant = ?
SQL
);
            $req1->execute(array($prenom, $nom, $mail, $tel, $login));
        } else {
            $req1 = $pdo->prepare(<<<SQL
\t\t\tINSERT INTO Etudiant (loginEtudiant,prenom,nom,mail,tel)
\t\t\tVALUES(?,?,?,?,?)
SQL
);
            $ins = $req1->execute(array($login, $prenom, $nom, $mail, $tel));
        }
    }
<?php

require_once 'class/myPDO.class.php';
//myPDO::setConfiguration('mysql:host=mysql;dbname=infs3_prj09;charset=utf8', 'infs3_prj09', 'azerty01');
//myPDO::setConfiguration("mysql:host=mysql;dbname=laudy001", "pecca001", "lol");
myPDO::setConfiguration('mysql:host=localhost;dbname=infs3_prj09;charset=utf8', 'root', '');
$p->appendCssUrl("style/searchEngine.css");
$p->appendJsUrl("js/request.js");
//inclusion de la barre de navigation
include_once "navbar.inc.php";
$p->appendContent(<<<HTML
<div class="panel panel-default">
  <!-- Default panel contents -->
  <div class="panel-heading">Panel heading</div>

  <!-- Table -->
  <table class="table">
  <tr><th scope="col">N°</th><th scope="col">Numéro convention</th><th scope="col">Entreprise</th><th scope="col">Enseignant réferent</th></tr>
HTML
);
require_once 'myPDO.include.php';
$db = myPDO::getInstance();
$stmt = $db->prepare(<<<SQL
\t\t\t  SELECT c.numConvention, e.nom, c.loginEnseignant
\t\t\t  FROM Convention c, Stage s, Entreprise e
\t\t\t  WHERE c.numStage = s.numStage AND s.numEntreprise = e.numEntreprise
\t\t\t  ORDER BY 1;
SQL
);
$stmt->setFetchMode(PDO::FETCH_CLASS, __CLASS__);
$stmt->execute();
$res = null;
$i = 1;
while (($res[] = $stmt->fetch()) !== false) {
    $p->appendContent(<<<HTML
<tr><th scope="row">{$i}</th><td>{$res['0']}</td><td>{$res['1']}</td><td>{$res['2']}</td></tr>
HTML