function _trip_update($ufile) { $total = $ufile->tu_type->tt_price; $opt = new Modele('trip_option_userfile'); $opt->find(array('too_userfiles' => $ufile->getKey())); while ($opt->next()) { $total += $opt->tou_option->too_price; } $chq = new Modele('trip_cheq'); $totalPay = 0; $totalCaution = 0; $chq->find(array('tq_file' => $ufile->getKey())); while ($chq->next()) { if ($chq->raw_tq_type == 'PAYMENT') { $totalPay += $chq->tq_amount; } else { $totalCaution += $chq->tq_amount; } } if ($totalPay >= $total && $ufile->raw_tu_payment != 'YES') { $ufile->tu_payment = 'YES'; } if ($totalCaution >= $ufile->tu_trip->tr_caution && $ufile->raw_tu_caution != 'YES') { $ufile->tu_caution = 'YES'; } if ($ufile->raw_tu_payment == 'YES' && $ufile->raw_tu_caution == 'YES' && $ufile->tu_step == 5) { $ufile->tu_step = 9; } }
/** * Controleur page d'index admin * Permet l'affichage de la page d'administration des droits d'accès. */ function admin_index() { global $pdo, $tpl; $sql = $pdo->prepare('SELECT * FROM acces WHERE acl_action != "index" AND acl_action != "admin" ORDER BY acl_action ASC, acl_page ASC'); $sql->execute(); $conf = array(); while ($line = $sql->fetch()) { if (!isset($conf[$line['acl_action']])) { $conf[$line['acl_action']] = array(); } $conf[$line['acl_action']][] = $line; } $groups = new Modele('sections'); $groups->find(); while ($groups->next()) { $tpl->append('grps', $groups->toArray()); } $aclGrps = new Modele('access_groups'); $aclGrps->find(); $aclGrpsRslt = array(); while ($aclGrps->next()) { if (!isset($aclGrpsRslt[$aclGrps->raw_ag_access])) { $aclGrpsRslt[$aclGrps->raw_ag_access] = array(); } $aclGrpsRslt[$aclGrps->raw_ag_access][] = $aclGrps->raw_ag_group; } $tpl->assign('aclGrps', $aclGrpsRslt); $tpl->assign('acls', $conf); $tpl->display('admin_index.tpl'); quit(); }
function bulletin_viewbulletin() { global $pdo, $root; $mdl = new Modele("bulletin_user"); $mdl->fetch($_GET['id']); require $root . 'libs' . DS . 'bulletins' . DS . $mdl->bu_period->period_generator . DS . 'bulletin.php'; bulletin_view_user($_GET['id']); quit(); }
function developer_edit() { $mdl = new Modele('api_clients'); $mdl->fetch($_REQUEST['appli']); if (isset($_POST['callback'])) { $mdl->ac_callback = $_POST['callback']; redirect('developer', 'view', array('appli' => $_REQUEST['appli'], 'hsuccess' => '1')); } $mdl->assignTemplate('cli'); display(); }
function note_viewp() { global $tpl; $period = new Modele('periods'); $period->fetch($_REQUEST['period']); $tpl->assign('period', $period); $mdl = new Modele('marks'); $mdl->find(array('mark_user' => $_SESSION['user']['user_id'], 'mark_period' => $period->getKey())); while ($mdl->next()) { $tpl->append('marks', new Modele($mdl)); } display(); }
function bocal_update() { global $srcdir; include $srcdir . '/libs/bocal.php'; $mdl = new Modele('event_bocal'); $mdl->find(); $boc = new Bocal(); while ($mdl->next()) { $boc->getTicket($mdl->eb_ticket); $boc->updateDB($mdl->getKey()); } echo "ok"; }
function admin_modeles_modinst() { global $tpl; $modele = new Modele($_GET['modele']); $modele->fetch($_GET['key']); $tpl->assign('result', ''); if (isset($_POST['action'])) { if ($modele->modFrom($_POST)) { $tpl->assign('result', 'success'); } else { $tpl->assign('result', 'error'); } } $tpl->assign('modele', $modele); $tpl->assign('edit', $modele->edit()); $tpl->display('adminmodeles_modinst.tpl'); quit(); }
/** * Create connection and return connection PDO object */ private static function getDatabase() { if (self::$bdd === null) { $dsn = Configuration::get("dsn"); $login = Configuration::get("login"); $mdp = Configuration::get("mdp"); self::$bdd = new PDO($dsn, $login, $mdp, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } return self::$bdd; }
function twofactors_set() { global $tpl, $srcdir; $usr = new Modele('users'); $usr->fetch($_SESSION['user']['user_id']); if ($_POST['activation'] == "true") { require_once $srcdir . '/libs/GoogleAuthenticator/GoogleAuthenticator.php'; $otp = new GoogleAuthenticator(); if (!$otp->checkCode($_SESSION['user']['GoogleAuthenticator'], $_POST['code'])) { $tpl->assign('hsuccess', "GoogleAuthentificator code invalide"); modexec("index", "profile"); quit(); } $usr->user_otp = $_SESSION['user']['GoogleAuthenticator']; } else { $usr->user_otp = ""; } $_SESSION['user']['user_otp'] = $usr->user_otp; redirect("index", "profile", array('hsuccess' => 1)); }
/** * Renvoie un objet de connexion à la BDD en initialisant la connexion au besoin * * @return PDO Objet PDO de connexion à la BDD */ private static function getBdd() { if (self::$bdd === null) { // Récupération des paramètres de configuration BD $dsn = Configuration::get("dsn"); $login = Configuration::get("login"); $mdp = Configuration::get("mdp"); // Création de la connexion self::$bdd = new PDO($dsn, $login, $mdp, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } return self::$bdd; }
/** * Renvoie un objet de connexion à la BDD en initialisant la connexion au besoin * * @return PDO Objet PDO de connexion à la BDD */ public static function getBdd() { if (self::$bdd === null) { // Récupération des paramètres de configuration BD $dsn = Configuration::get("dsn"); $login = Configuration::get("login"); $mdp = Configuration::get("mdp"); /* $dbHost = getenv('OPENSHIFT_MYSQL_DB_HOST'); $dbName = getenv('OPENSHIFT_GEAR_NAME'); $login = getenv('OPENSHIFT_MYSQL_DB_USERNAME'); $mdp = getenv('OPENSHIFT_MYSQL_DB_PASSWORD'); */ // $dsn = 'mysql:host=' . $dbHost . ';dbname='. $dbName .';charset=utf8'; // Création de la connexion self::$bdd = new PDO($dsn, $login, $mdp, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } return self::$bdd; }
public function get_id_from_classe($classe){ $this->sql = "SELECT id FROM classes where classe ='".$classe."'"; $this->res = mysqli_query($GLOBALS["mysqli"], $this->sql); $id=parent::set_array('array',$this->res); return($id[0]['id']); }
?> </form> </div> <div class="row"> <div class="col s10 offset-s2"> <table id="tableau" class="bordered highlight"> <thead> <tr> <th>Libelle</th> <th>Mot de passe</th> <th>Actions</th> </tr> </thead> <tbody> <?php foreach (Modele::recupererMotsDePassesDe($_SESSION['chiffree']['email']) as $ligne) { echo '<tr>'; echo '<td>' . Chiffrement::dechiffrer($ligne['libelle']) . '</td>'; echo '<td><input type="password" value="' . Chiffrement::dechiffrer($ligne['valeur']) . '" disabled/></td>'; echo ' <td> <a class="waves-effect waves-light btn-floating blue visibility"><i class="material-icons right">visibility</i></a> <a class="waves-effect waves-light btn-floating red accent-4" href="/action?delete=' . $ligne['id'] . '"><i class="material-icons right">delete</i></a> </td>'; echo '</tr>'; } ?> </tbody> </table> </div> </div>
<?php session_start(); $_SESSION = array(); require_once '../autoload.php'; if (Controller::tokenEstBienFormate($_GET['token']) && Controller::formulaireEstValide($_POST)) { if (Controller::tokenVeritable($_POST['email'], $_GET['token'])) { $donneesChiffrees = Ordonnanceur::genererDonneesHachees($_POST); if (Modele::activerUtilisateur($donneesChiffrees)) { Token::supprimer($_POST['email']); Ordonnanceur::connexionReussie($_POST, $donneesChiffrees); } else { Ordonnanceur::finDeTransaction(' Causes possibles : <ul> <li>Les informations saisies dans le formulaire ne sont pas valides.</li> <li>Mauvais token associé à cet utilisateur.</li> </ul> '); } } else { Ordonnanceur::finDeTransaction(' Causes possibles : <ul> <li>Les informations saisies dans le formulaire ne sont pas valides</li> <li>Mauvais token associé à cet utilisateur.</li> <li>Le token a expiré.</li> </ul> '); } }
function user_setcompta() { $usr = new Modele('users'); $usr->fetch($_GET['user']); if ($_GET['account'] == 0) { $usr->user_compta = 0; redirect("user", "view", array('hsuccess' => 1, 'user' => $usr->getKey())); } $mdlAcc = new Modele('user_accounts'); $mdlAcc->fetch($_GET['account']); if ($mdlAcc->raw_ua_user == $usr->getKey()) { $usr->user_compta = $mdlAcc->getKey(); redirect("user", "view", array('hsuccess' => 1, 'user' => $usr->getKey())); } redirect("user", "view", array('hsuccess' => 0, 'user' => $usr->getKey())); }
public function __construct() { parent::__construct(); }
<?php include "../Modeles/Modele.php"; include "../Modeles/Modele_extend.php"; include 'Controleur_class/Controleur_class_moniteur.php'; include 'Controleur_class/Controleur_class_VueConnexionMoniteur.php'; include '../Vues/Vue_connexion_moniteur.html'; $unModel = new Modele("localhost", "auto_ecole_ppe", "root", ""); $unModel->renseigner("moniteur", "nummoniteur"); if (isset($_POST['connexion'])) { $mail = $_POST['mailmoniteur']; $mdp = $_POST['mdpmoniteur']; try { $resultat = $unModel->selectwhereconnexion($mail); if ($resultat == false) { echo "Requette non effectuée.<br/>"; } foreach ($resultat as $key => $value) { if ($value == $mdp) { header('Location: Controleur_moniteur.php'); } } } catch (EXEPTION $e) { echo "Erreur" . $e; } }
function wifi_add() { global $tpl; if (isset($_POST['save'])) { $f = fopen($_FILES['file']['tmp_name'], 'r'); $tokens = array(); $roll = null; while (!feof($f)) { $l = fgets($f); if (preg_match('`# Voucher Tickets [0-9]*..[0-9]* for Roll ([0-9]*)`', $l, $pmatch)) { $roll = $pmatch[1]; } elseif ($l[0] != "#") { $token = trim($l, "\t\n\r\v\" "); if (strlen($token)) { $tokens[] = $token; } } } fclose($f); unlink($_FILES['file']['tmp_name']); if (count($tokens) == 0 || $roll == null) { echo "Erreur de parsing"; $tpl->assign('hsuccess', false); } else { $mdl = new Modele('wifi_tokenGroup'); if ($mdl->addFrom(array('wtg_roll' => $roll, 'wtg_duration' => $_POST['duration'], 'wtg_date' => date('Y-m-d')))) { $id = $mdl->getKey(); $tkn = new Modele('wifi_tokens'); foreach ($tokens as $token) { $tkn->addFrom(array('wt_token' => $token, 'wt_group' => $id)); } $tpl->assign('hsuccess', true); } else { echo 'Erreur insertion WTG.'; $tpl->assign('hsuccess', false); } } } display(); }
function admin_note_downbulletin() { global $pdo, $root; $mdl = new Modele("periods"); $mdl->fetch($_GET['id']); $mdl->assignTemplate('bulletin'); require $root . 'libs' . DS . 'bulletins' . DS . $mdl->period_generator . DS . 'bulletin.php'; bulletin_download($_GET['id']); quit(); }
function tripadm_add_caution() { global $tpl; $ufile = _tripadm_load(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $mod = new Modele("trip_cheq"); $args = array_merge($_POST, array('tq_file' => $ufile->getKey(), 'tq_type' => 'CAUTION', 'tq_date' => strftime('%F %T'))); if ($mod->addFrom($args)) { _trip_update($ufile); redirect('tripadm', 'order', array('file' => $ufile->getKey(), 'hsuccess' => 1)); } else { $tpl->assign('hsuccess', false); } } display(); }
function api_userinfo() { $usr = _api_getUser(); if ($usr === null) { return; } $infos = array('sub' => $usr->user_id, 'name' => $usr->user_name, 'given_name' => $usr->user_firstname, 'family_name' => $usr->user_lastname, 'nickname' => $usr->user_name, 'email' => $usr->user_email, 'email_verified' => false, 'gender' => $usr->user_sexe == 'GIRL' ? 'female' : 'male', 'birthdate' => $usr->user_born, 'phone_number' => $usr->user_phone, 'phone_number_verified' => false, 'acl' => $usr->raw_user_role, 'groups' => array()); $sections = new Modele('user_sections'); $sections->find(array('us_user' => $usr->getKey())); while ($sections->next()) { $infos['groups'][] = array('gid' => $sections->us_section->section_id, 'name' => $sections->us_section->section_name, 'role' => $sections->raw_us_type); } echo json_encode($infos); quit(); }
function section_admin_ml_noadmin() { global $tpl, $srcdir, $pdo; include $srcdir . '/libs/GoogleApi.php'; $api = new GoogleApi(); $mdl = new Modele('sections'); $mdl->fetch($_REQUEST['section']); $mdl->assignTemplate('section'); $lnk = new Modele('section_ml'); $lnk->find(array('sm_section' => $_REQUEST['section'], 'sm_ml' => $_REQUEST['ml'])); $mbr = $api->getGroupMemberDetails($_REQUEST['ml'], $_REQUEST['member']); if (!$lnk->next() || strpos($_REQUEST['member'], 'save_') === 0 || $mbr->type == "GROUP") { modexec('syscore', 'forbidden'); } $api->setGroupMemberLevel($lnk->sm_ml, $_REQUEST['member'], 'MEMBER'); redirect("section", "admin_ml", array("hsuccess" => 1, "section" => $_REQUEST['section'], "ml" => $lnk->sm_ml)); }
private function get_db_top_exclusions($du,$au,$filtre_cat=Null,$filtre_mes=Null,$filtre_san=Null,$filtre_role=Null) { $this->sql="SELECT ssan.login, count(se.id_exclusion) AS nb FROM s_exclusions se INNER JOIN s_sanctions ssan ON se.id_sanction=ssan.id_sanction INNER JOIN s_incidents sin ON ssan.id_incident=sin.id_incident INNER JOIN s_protagonistes sp ON (sp.id_incident=ssan.id_incident AND sp.login=ssan.login) "; //if($filtre_role)$this->sql.=' LEFT JOIN s_protagonistes sp ON ssan.id_incident=sp.id_incident'; if($filtre_mes)$this->sql.=' INNER JOIN s_traitement_incident str (ON ssan.id_incident=str.id_incident AND ssan.login=str.login_ele) INNER JOIN s_mesures smes ON str.id_mesure=smes.id '; $this->sql.=' WHERE sin.date BETWEEN \''.$du. '\' AND \''.$au.'\' '; if($filtre_role) $this->sql.=" AND (sp.qualite IN ('".parent::make_list_for_request_in($filtre_role)."') OR sp.qualite IS NULL) AND ssan.login=sp.login"; if($filtre_san) { $this->sql.=" AND (ssan.nature IN ('".parent::make_list_for_request_in($filtre_san)."'))"; } if($filtre_mes) { $this->sql.=" AND smes.type='prise' "; $this->sql.=" AND (str.id_mesure IN ('".parent::make_list_for_request_in($filtre_mes)."'))"; } if($filtre_cat) { $this->sql.=" AND ( sin.id_categorie IN ('".parent::make_list_for_request_in($filtre_cat)."')"; if (in_array('Null',$filtre_cat)) $this->sql.="OR sin.id_categorie is null)"; else $this->sql.=")"; } $this->sql.=' GROUP BY ssan.login '; $this->sql.=' ORDER BY count(se.id_exclusion) DESC LIMIT 10 '; $this->res=mysqli_query($GLOBALS["mysqli"], $this->sql); if($this->res) { while($this->row=mysqli_fetch_object($this->res)) { $this->top_exclusions[]=$this->row; } } return($this->top_exclusions); }
/** * Uninstall ACLs */ private function _uninstallAcls() { if (!isset($this->defs['acces'])) { return; } foreach ($this->defs['acces'] as $action => $pages) { foreach ($pages as $page => $acl) { $mdl = new Modele('acces'); $mdl->find(array('acl_page' => $page, 'acl_action' => $action)); if ($mdl->next()) { $mdl->delete(); } } } }
function index_wizard() { global $tpl; $mdl = new Modele('users'); $mdl->fetch($_SESSION['user']['user_id']); $fields = null; if ($mdl->user_born == null) { $fields = array('user_phone', 'user_sexe', 'user_born'); $tpl->assign('pcent', 25); _index_wizard_edit($mdl, $fields); } if ($fields == null && $mdl->raw_user_type == 0) { $fields = array('user_type'); $tpl->assign('pcent', 50); _index_wizard_edit($mdl, $fields); } if ($fields == null && stripos($mdl->user_type->ut_name, 'EXTERNE') === false && $mdl->user_promo == 0) { $fields = array('user_promo', 'user_login'); $tpl->assign('pcent', 85); _index_wizard_edit($mdl, $fields); } if ($fields == null) { // tous les champs sont OK redirect('index', 'index', array('hsuccess' => 1)); } $tpl->assign('form', $mdl->edit($fields)); display(); }
function ml_removeSection() { $mdl = new Modele('section_ml'); $mdl->fetch($_REQUEST['lnk']); $ml = $mdl->sm_ml; $suc = $mdl->delete(); redirect("ml", "view", array('ml' => $ml)); }
function cards_delbundle() { $bdl = new Modele('cardbundle'); $bdl->fetch($_GET['bundle']); $crd = new Modele('card'); $crd->find(array('card_bundle' => $bdl->getKey())); while ($crd->next()) { $crd->card_bundle = null; $crd->card_status = 'WAIT'; } $bdl->delete(); redirect('cards'); }
public function update(Modele $mod) { $req = $this->_db->prepare("UPDATE modele SET nomModele=:nom, qteStock=:qte, prix=:px, tauxRemise=:tx WHERE idModele=:id"); $req->execute(array(":nom" => $mod->getNomModele(), ":qte" => $mod->getQteStock(), ":px" => $mod->getPrix(), ":tx" => $mod->getTauxRemise(), ":id" => $mod->getIdModele())); }
function bulletin_view_user($id) { global $tpl, $srcdir; $mdl = new Modele('bulletin_user'); $mdl->fetch($id); $bulletin = array('bu' => $mdl, 'data' => unserialize($mdl->bu_data), 'spice' => 0); foreach ($bulletin['data'] as $mark) { $bulletin['spice'] += $mark['duration']; } $tpl->assign('bulletin', $bulletin); $tpl->display($srcdir . '/libs/bulletins/epitech/user.tpl'); }
<?php // vous ne devez rien modifier dans ce script qui vous permet de tester votre classe Modele header("Content-type: text/html; charset=utf-8"); require_once "modele.php"; // test pour la question I) try { $modele = new Modele(); $listePseudos = $modele->getPseudos(); ?> <h1> Liste des pseudos dans la base </h1> <?php foreach ($listePseudos as $pseudo) { echo $pseudo["pseudo"]; echo "<br/>"; } echo "<br/>"; ?> <h1> le pseudo existe t'il ? </h1> <?php if ($modele->exists("lebofred")) { echo "OK" . "<br/>"; } else { echo "Non" . "<br/>"; } // test pour la question II) // à décommenter pour la question II) for ($i = 0; $i < 6; $i++) { $modele->majSalon("lebofred", "coucou, je suis lebofred " . $i); $modele->majSalon("titi44", "coucou, je suis titi44 " . $i);