public function display()
 {
     global $start_time;
     session_start();
     if (!isset($_SESSION['id_utilisateur'])) {
         $_SESSION['id_utilisateur'] = false;
     }
     $this->assign('page', $this->template());
     $this->assign('url_statique', URL_STATIQUE);
     $this->assign('nb_colonies', clicnat_espace_hirondelle::count_colonies($this->db));
     $stats = $this->stats_selection();
     $this->assign('nb_observateurs', $stats['nb_observateurs']);
     $this->assign('nb_citations', $stats['nb_citations']);
     $this->assign('derniere_date', date_format($stats['derniere_date'], "j / m  / Y"));
     $before_func = 'before_' . $this->template();
     if (method_exists($this, $before_func)) {
         if (!in_array($this->template(), ['accueil', 'creer_compte', 'inscription', 'login', 'carte_nids', 'geojson_points', 'colonie_details'])) {
             if (!$_SESSION['id_utilisateur']) {
                 $this->redirect("?t=accueil&acces=false");
                 $this->ajoute_alerte('danger', 'Vous devez vous connecter por accéder à cette partie');
             }
         }
         if ($_SESSION['id_utilisateur']) {
             $this->assign('utl', get_utilisateur($this->db, $_SESSION['id_utilisateur']));
         } else {
             $this->assign('utl', false);
         }
         //test sur le navigateur
         if (ereg("MSIE 6.0", $_SERVER["HTTP_USER_AGENT"]) || ereg("MSIE 7.0", $_SERVER["HTTP_USER_AGENT"]) || ereg("MSIE 8.0", $_SERVER["HTTP_USER_AGENT"])) {
             $this->assign("ie_nav", true);
             $this->ajoute_alerte('warning', 'Votre navigateur est obsolète il se peut que certaines informations et/ou fonctionnalités n\' apparaissent ou ne fonctionnent pas: Internet Explorer 8 fin de support le 12/01/2016, Internet Explorer 7 fin de support le 13/07/2010, Internet Explorer 6 fin de support le 13/04/2010.');
         }
         $this->{$before_func}();
     } else {
         header("HTTP/1.0 404 Not Found");
         throw new Exception('404 Page introuvable');
     }
     parent::display($this->template() . ".tpl");
 }
 public function display($template)
 {
     $f = implode('/', array($this->template_dir, $template));
     if (!file_exists($f)) {
         throw new Exception('404');
     }
     $this->assign_by_ref('msgs', $this->msgs);
     $this->assign('clegmap', get_config()->query_nv('/clicnat/clegooglemap[@id="pointsnoirs"]'));
     $q_jslibs = array('openlayers', 'proj4js', 'jquery', 'jquery-ui', 'jquery-ui-datefr');
     $jslibs = array();
     foreach ($q_jslibs as $qlib) {
         $jslibs[] = get_config()->query_nv("/clicnat/jslib[@lib=\"{$qlib}\"]");
     }
     $this->assign_by_ref('jslibs', $jslibs);
     return parent::display($template);
 }
Example #3
0
 public function display()
 {
     global $start_time;
     $this->session();
     $noauth_templates = array('accueil', 'export_json', 'www_liste', 'www_detail', 'json_sortie');
     try {
         $tpl = $this->template();
         if (!in_array($tpl, $noauth_templates) || $_SESSION[SESS]['auth_ok'] == true) {
             if (!$this->authok()) {
                 throw new ExceptionErrAuth();
             }
             $u = $this->get_user_session();
             $this->assign_by_ref('u', $u);
             # on en a besoin dans le header
             if ($this->is_admin($u->id_utilisateur)) {
                 $this->assign('admin', true);
             } else {
                 $this->assign('admin', false);
             }
         }
         setlocale(LC_ALL, LOCALE);
         $before_func = 'before_' . $this->template();
         if (method_exists($this, $before_func)) {
             $this->{$before_func}();
         }
         if ($tpl != 'accueil') {
             $u = $this->get_user_session();
             $this->assign_by_ref('u', $u);
         }
         $this->assign_by_ref('bobs_msgs', $this->bobs_msgs);
     } catch (ExceptionErrAuth $e) {
         $tpl = 'accueil';
         $this->assign('messageinfo', 'Vous avez été déconnecté ou votre session a expiré');
     } catch (Exception $e) {
         $tpl = 'exception';
         $this->assign('ex', $e);
         try {
             $u = $this->get_user_session();
         } catch (Exception $e) {
         }
         $headers = "From: bobs@picardie-nature.org\r\nContent-Type: text/plain; charset=UTF-8";
         $f = basename($e->getFile()) . ' ligne ' . $e->getLine();
         $msg = "Message : {$e->getMessage()}\nFichier : {$f}\n";
         $msg .= "Query String : {$_SERVER['QUERY_STRING']}\n";
         $msg .= "Origine : {$_SERVER['HTTP_REFERER']}\n";
         $msg .= "Trace :\n";
         foreach ($e->getTrace() as $ele) {
             $msg .= sprintf("\t%-40s %s%s%s()\n", basename($ele['file']) . " +{$ele['line']}", $ele['class'], $ele['type'], $ele['function']);
         }
         mail('*****@*****.**', "BOBS ERREUR - {$u->nom} {$u->prenom} ({$u->id_utilisateur})", $msg, $headers);
         $this->assign('msg', htmlentities($msg, ENT_COMPAT | ENT_HTML401, 'UTF-8'));
     }
     $this->assign('tps_exec_avant_display', sprintf('%0.4f', microtime(true) - $start_time));
     parent::display($tpl . '.tpl');
 }