function calcul_gagnant() { $loterie_participants = new loterie_participants($this->id); $list = $loterie_participants->get_list(); // Nbr totalement aléatoire // initialisation avec srand. http://fr.php.net/manual/fr/function.srand.php list($usec, $sec) = explode(' ', microtime()); srand((double) $sec + (double) $usec * 100000); // liste des trolls participant à la loterie $n = rand(1, count($list)); $this->id_gagnant = $list[$n][id_troll_loteriep]; if ($this->id_gagnant != "") { return $this->id_gagnant; } else { return false; } }
function loterie_interface_gain_enregistre($id_troll, $id_loterie) { $loterie = new loterie($id_loterie); if ($_SESSION[admin] != 'authenticated') { if ($id_troll != $loterie->get_id_gagnant()) { afficher_contenu_tableau("Erreur. Vous n'êtes pas admin, ou vous n'avez pas gagné cette loterie, ou la loterie n'est pas close"); die(' '); } } $loterie_participants = new loterie_participants($id_loterie); $list = $loterie_participants->get_list(); for ($i = 1; $i <= count($list); $i++) { if ($_POST["remise_" . $list[$i][id_troll_loteriep]] == "oui") { $loterie_participant = new loterie_participant($list[$i][id_troll_loteriep], $id_loterie); $loterie_participant->set_date_remise_db(); } } $text = "Mise à jour effectuée.<br>"; $text .= "<input type='button' value='Retour Liste' class='mh_form_submit'"; $text .= " onClick='Javascript:document.location.href=\"/loteries/loterie.php?gain=liste\"'>"; afficher_contenu_tableau($text); }