private function stats_selection()
 {
     $stats = [];
     $utilisateur = new bobs_utilisateur($this->db, 4080);
     $id_selection = $utilisateur->selection_creer("compte_colonies_hiro");
     $selection = new bobs_selection($this->db, $id_selection);
     $extraction = new bobs_extractions($this->db);
     $extraction->ajouter_condition(new bobs_ext_c_tag(CLICNAT_HIRONDELLE_TAG));
     $extraction->dans_selection($id_selection);
     $stats["nb_observateurs"] = count($selection->get_observateurs());
     $stats["nb_citations"] = $selection->n();
     $stats["derniere_date"] = new DateTime('1900-00-00');
     foreach ($selection->get_citations() as $citation) {
         $date_obs = new DateTime($citation->date_modif);
         if ($date_obs > $stats["derniere_date"]) {
             $stats["derniere_date"] = $date_obs;
         }
     }
     $selection->drop();
     return $stats;
 }
Beispiel #2
0
 public function before_accueil()
 {
     $_POST['act'] = array_key_exists('act', $_POST) ? self::cls($_POST['act']) : null;
     $_POST['username'] = array_key_exists('username', $_POST) ? self::cls($_POST['username']) : null;
     $_POST['password'] = array_key_exists('password', $_POST) ? self::cls($_POST['password']) : null;
     if ($this->authok()) {
         $u = $this->get_user_session();
         if (isset($_GET['supprimer_brouillon'])) {
             $sortie = new clicnat_sortie($this->db, $_GET['supprimer_brouillon']);
             if ($sortie->id_utilisateur_propose == $u->id_utilisateur) {
                 $sortie->supprimer();
                 $this->redirect('?t=accueil');
             }
         }
         $this->assign_by_ref('sans_dates', clicnat_sortie::sans_dates($this->db, $u->id_utilisateur));
         $this->assign_by_ref('en_attente', clicnat_sortie_date::en_attente($this->db, $u->id_utilisateur));
         $this->assign_by_ref('pas_retenues', clicnat_sortie_date::pas_retenues($this->db, $u->id_utilisateur));
         $this->assign_by_ref('valides', clicnat_sortie_date::valides($this->db, $u->id_utilisateur));
         $this->assign_by_ref('annulees', clicnat_sortie_date::annulees($this->db, $u->id_utilisateur));
     }
     if ($_POST['act'] == 'login') {
         if (empty($_POST['username'])) {
             return;
         }
         $u = bobs_utilisateur::by_login($this->db, $_POST['username']);
         if ($u && $u->auth_ok($_POST['password'])) {
             $this->assign('username', $u->username);
             $this->assign('id_utilisateur', $u->id_utilisateur);
             $this->assign('auth_ok', true);
             $this->bobs_msgs[] = 'Bienvenue';
             $redir = '?t=accueil';
             if (!empty($_POST['redir'])) {
                 $redir = str_replace('"', '', $_POST['redir']);
             }
             $this->assign('redir', $redir);
             $_SESSION[SESS]['auth_ok'] = true;
             $_SESSION[SESS]['id_utilisateur'] = $u->id_utilisateur;
             bobs_log(sprintf("login user id %d ok", $u->id_utilisateur));
             $this->redirect($redir);
         } else {
             $_SESSION[SESS]['auth_ok'] = false;
             $this->assign('auth_ok', false);
             $this->bobs_msgs[] = "Nom d'utilisateur ou mot de passe incorrect";
             return;
         }
     } else {
         if (isset($_GET['fermer'])) {
             $this->assign('auth_ok', false);
             $this->bobs_msgs[] = "Vous êtes déconnecté";
             $_SESSION[SESS]['auth_ok'] = false;
             session_destroy();
             return;
         }
     }
 }