download header.inc.php
Language: PHP
License: GPL
Copyright: (C) 2001, 2002 Bertand Pallie, Loc Dayot - Mairie de Pierrefitte (93)
LOC: 250
Project Info
epnadmin
Server: Savannah NonGNU
Type: cvs
...epnadmin\epnadmin\epnadmin\
   6cartes.inc.php
   add_message.sh
   add_message_file.sh
   animateur.php
   ...eurs-disponibilites.php
   animateurs-horaires.php
   animateurs.inc.php
   autoeval.js
   barcode.inc.php
   basdepage.inc.php
   camembert.inc.php
   cartes.inc.php
   common.initial.sql
   config.php
   configuration.php
   constantes.inc.php
   courriel.php
   dateheure.inc.php
   debug.inc.php
   domaines.php
   en.lang.inc.php
   entete.inc.php
   epnadmin.css
   epnadminv.css
   exemple.sql
   fonctions.inc.php
   footer.inc.php
   fr.initial.sql
   fr.lang.inc.php
   header.inc.php
   horaires.php
   i25object.inc.php
   image.inc.php
   index.php
   initial.sql
   initiations.inc.php
   initiations.php
   inscription_session.php
   localisations.php
   logiciels.php
   materiels.php
   menu2.js
   mysql.inc.php
   parcours.inc.php
   parcours.php
   positionnement.php
   prets.php
   print.php
   questions.php
   remove_message.sh
   reservations.inc.php
   reservations.php
   session.php
   sessions.inc.php
   siteweb.inc.php
   siteweb.php
   stats.php
   structure.sql
   structures.inc.php
   structures.php
   table_horaire.php
   table_horaire_session.php
   tableaux.inc.php
   tarifs.php
   themes.php
   usagers.inc.php
   usagers.php
   usages.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<?php
/*
    Copyright (C) 2001, 2002 Bertand Pallie, Loc Dayot - Mairie de Pierrefitte (93)

    EPNadmin - Version 0.6 - 05/05/2003

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://epnadmin.pierrefitte93.fr/
*/

require_once("constantes.inc.php");             // dfinition des constantes
//require_once("fonctions.inc.php");              // concernant des fonctions transversales inclassables
require_once("mysql.inc.php");                  // concernant mysql
//require_once("sessions.inc.php");             // concernant les sessions et initiations
//require_once("usagers.inc.php");              // concernant la gestion des usagers
//require_once("reservations.inc.php");         // concernant les rservations des postes en accs individuel par des usagers
//require_once("tableaux.inc.php");             // Concernant l'affichage transpos d'un tableau
//require_once("siteweb.inc.php");              // concernant les pages perso des usagers et les sites web des structures
//require_once("dateheure.inc.php");            // concernant la manipulation des heures et des dates, formulaire, conversion...
//require_once("structures.inc.php");           // concernant les structures
//require_once("initiations.inc.php");          // concernant les initiations et les thmes
//require_once("parcours.inc.php");             // concernant les parcours des usagers et leur positionnement

mysql_connecte($mysql_serveur, $mysql_identifiant, $mysql_motdepasse, $mysql_base, TRUE);

function form_login($mes, $logon)
{
global $PHP_SELF, $logo, $operation,
   $sidentification, $stitreidentification, $sidentstru,
	 $sMonidentifiant, $sMonmotdepasse, $envoyer,
	 $sidentusager, $sidentanimateur, $sidentvisiteur,
   $feuillestyle, $scriptmenus;

  $config=FALSE;
  // Retrouver les fonctionnalits actives de l'application
  $req1="SELECT id_fonction, fonction, actif, couleur
          FROM droits
          LEFT JOIN fonctions ON id_fonction=fonctions.id
          WHERE id_structure='0'";
  if ($res1 = executeRequete($req1))
    while ($fonctionnalite = fetch_object($res1))
      if ($fonctionnalite->actif=="y")
      {
        define(strtoupper("FCT_".$fonctionnalite->fonction), strtoupper($fonctionnalite->actif));
        define(strtoupper("COULEUR_".$fonctionnalite->fonction), strtoupper($fonctionnalite->couleur));
        $config=TRUE;
      }

  if (!$config)
    $logon=1;

  echo "<html><head>
    <title>$sidentification - epnadmin</title>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"$feuillestyle\" title=\"dfaut\">
    <script type=\"text/javascript\" src=\"$scriptmenus\"></script>
    </head>
    <body>\n";
    //<a href=\"/\"><img src=\"$logo\" border=\"0\" align=left></a>";
  $ctitre="yellow";
  echo "<h1 id=\"titre\">$stitreidentification</h1>
  <script>
  var couleurfondtitre=\"$ctitre\";
  </script>\n";
//	echo cadre("<font size=\"+2\" face=\"verdana\">$stitreidentification</font>", "", "align=center", "yellow");
	echo "<br>";

  switch ($logon)
  {
  case 1 : // Structure
    echo cadre($sidentstru, "
      <form name=\"ident_structure\" method=\"post\" action=\"$PHP_SELF\">
        <table align=\"center\">
          <input type=\"hidden\" name=\"logon\" value=\"$logon\">
          <input type=\"hidden\" name=\"operation\" value=\"$operation\">
          <tr><td>$sMonidentifiant :</td><td><input type=\"text\" name=\"identifiant1\"></td></tr>
          <tr><td>$sMonmotdepasse :</td><td><input type=\"password\" name=\"mot_de_passe\"></td></tr>
          <tr><td align=center colspan=2><input type='submit' name='Valider'
              value=\"$envoyer\"></td></tr>
        </table>
      </form>
      <i><font size=\"-1\">Si vous n'&ecirc;tes pas une structure, mais que vous voulez quand m&ecirc;me
      <br> essayer les services r&eacute;serv&eacute;s aux structures,
      <br>vous pouvez vous identifier avec &quot;<b>admin</b>&quot; et comme mot de passe &quot;admin&quot;.</font></i>",
			"align=center", COULEUR_STRUCTURES);
    break;

  case 2 : // Usager
    echo cadre($sidentusager, "
      <form name=\"ident_usager\" method=\"post\" action=\"$PHP_SELF\">
        <table align=\"center\">
          <input type=\"hidden\" name=\"operation\" value=\"$operation\">
          <input type=\"hidden\" name=\"logon\" value=\"$logon\">
          <tr><td>Mon identifiant :</td><td><input type=\"text\" name=\"identifiant2\"></td></tr>
          <tr><td>Mon mot de passe :</td><td><input type=\"password\" name=\"mot_de_passe\"></td></tr>
          <tr><td align=center colspan=2><input type='submit' name='Valider'
              value=\"$envoyer\"></td></tr>
        </table>
      </form>
      <br>
      <i><font size=\"-1\">Si vous n'&ecirc;tes pas un usager, mais que vous voulez quand m&ecirc;me
      <br> essayer les services r&eacute;serv&eacute;s aux usagers,
      <br>vous pouvez vous identifier avec &quot;<b>test</b>&quot;
        et comme mot de passe &quot;test&quot;.</font></i>\n",
				"align=center", COULEUR_USAGERS);
    break;

  case 3 : // Animateur
    echo cadre($sidentanimateur, "
      <form name=\"ident_animateur\" method=\"post\" action=\"$PHP_SELF\">
        <table align=\"center\">
          <input type=\"hidden\" name=\"logon\" value=\"$logon\">
          <input type=\"hidden\" name=\"operation\" value=\"$operation\">
          <tr><td>Mon identifiant :</td><td><input type=\"text\" name=\"identifiant3\"></td></tr>
          <tr><td>Mon mot de passe :</td><td><input type=\"password\" name=\"mot_de_passe\"></td></tr>
          <tr><td align=center colspan=2><input type='submit' name='Valider'
              value=\"$envoyer\"></td></tr>
        </table>
      </form>
      <br>
      <i><font size=\"-1\">Si vous n'&ecirc;tes pas une structure, mais que vous voulez quand m&ecirc;me
      <br> essayer les services r&eacute;serv&eacute;s aux structures,
      <br>vous pouvez vous identifier avec &quot;<b>anim</b>&quot; et comme mot de passe &quot;anim&quot;.</font></i>",
				"align=center", COULEUR_ANIMATEURS);
    break;
	case 4 :
  default : // Visiteur
    echo cadre($sidentvisiteur, "
      <form name=\"ident_visiteur\" method=\"post\" action=\"$PHP_SELF\">
        <table align=\"center\">
          <input type=\"hidden\" name=\"logon\" value=\"4\">
          <input type=\"hidden\" name=\"operation\" value=\"$operation\">
          <input type=\"hidden\" name=\"identifiant4\" value=\"visiteur\">
          <tr><td align=center colspan=2><input type='submit' name='Valider'
              value=\"$envoyer\"></td></tr>
        </table>
      </form>\n",
			"align=center", "yellow");
    break;
  } // switch

  if (($logon!=1) && defined("FCT_STRUCTURES"))
    echo "<a href=\"$PHP_SELF?logon=1&operation=$operation\">S'identifier en tant que structure.</a><br>\n";
  if (($logon!=2) && defined("FCT_USAGERS"))
    echo "<a href=\"$PHP_SELF?logon=2&operation=$operation\">S'identifier en tant qu'usager individuel.</a><br>\n";
  if (($logon!=3) && defined("FCT_ANIMATEURS"))
    echo "<a href=\"$PHP_SELF?logon=3&operation=$operation\">S'identifier en tant qu'animateur.</a><br>\n";
  if ($logon!=4)
    echo "<a href=\"$PHP_SELF?logon=4&operation=$operation\">Visiteur sans identification.</a><br>\n";

  if ($mes>"")
    echo "<p>Identification impossible : $mes</p>";
		/* TODO
          <p></p>
          <p><a href=\"courriel.php?operation=1\">Un problme avec votre identification ?</a></p>\n";
					*/
  //echo "</body></html>";
} // function


if (!$logoff || $logoff==0)
{
  session_start();
}
else   // L'usager vient de se dlogguer
{
  $logon=$logoff;
  session_start();
  session_destroy();
  $is_ident="";             // !="" si identifi
  $isadmin="";              // == "oui" si la structure identifie a les droits d'administration comptes usagers
                            // == "super" si la structure identifie a tous les droits
  $id_structure="";         // id de la structure qui regarde, rien si usager
  $id_usager="";            // id de l'usager qui regarde, rien si structure
  $id_animateur="";
}

if(!$is_ident || $is_ident=="")
{ // pas encore identifi
  // Identification en tant que
  $mes="";
  $identifiant= "identifiant".$logon;
  $identifiant=$$identifiant;
  if ($logon!=4 && $identifiant)
    if ($identifiant!="")
    {
      switch ($logon)
      {
      case 1 : $resultat = recherche("structures", "login", $identifiant); break;
      case 2 : $resultat = recherche("usagers", "login", $identifiant); break;
      case 3 : $resultat = recherche("animateurs", "login", $identifiant); break;
      } // switch
      if ($resultat && $enr=fetch_object($resultat))
      {
        $id=$enr->id;
        $pass = $enr->motdepasse;
        if ($pass!=$mot_de_passe && $pass!=md5($mot_de_passe))
          $mes="Mot de passe incorrect.";
      }
      else
        $mes="Identifiant inconnu.";
    }
    else
      $mes="Identifiant absent.";

  if($mes!="" || !$logon || !$identifiant)
  { // mauvaise identification ou pas encore faite.
    echo "<div id=\"texte\" onmouseover=\"CacherMenus();\">\n";
    form_login($mes, $logon);
    require("basdepage.inc.php");
    require("footer.inc.php");
    exit;
  }

  switch ($logon)
  {
  case 1 :
    $is_ident = "structure";
    $id_structure=$id;
    session_register("id_structure");     // celle qui regarde
    break;
  case 2 :
    $is_ident = "usager";
    $id_usager=$id;
    session_register("id_usager");     // celle qui regarde
    break;
  case 3 :
    $is_ident = "animateur";
    $id_animateur=$id;
    session_register("id_animateur");     // celle qui regarde
    break;
  case 4 :
    $is_ident = "visiteur";
    $id_visiteur=TRUE; $id=-4;
    session_register("id_visiteur");     // celle qui regarde
    break;
  } // switch
  session_register("is_ident");     // identification ok

  { // Enregistrement dans le journal
    $req="INSERT INTO journal VALUES (NOW(),\"$is_ident\", $id)";
    $res=executeRequete($req);
  }

} // if $is_ident


/*  Ici on va dfinir comme constantes toutes les fonctionalits et tous les droits
    de la structure ou de l'usager. Tous ces lments sont tirs des tables
    fonctions et droits.

    Cinq cas :

    id_structure==0
      - C'est celui de la totalit de l'application qui est dfinie, qui permet
        de rendre actif ou non des fonctionnalits.

    id_structure>0
      - Il s'agit des droits de chacune des structures.

    id_structure==-1
      - C'est celui des droits des usagers, ils sont tous identiques.

    id_structure==-2
      - C'est celui des droits des animateurs, ils sont tous identiques. (Quand a existera !)

    id_structure==-3
      - C'est celui des droits par dfaut des structures.

    id_structure==-4
      - C'est celui des droits des visiteurs non identifis.

    Dans la mesure o cet enregistrement ne se fait que lors de l'identification,
    aux changements de droits dans la base, il faudra penser  se r-identifier.
*/


//debug($is_ident);
switch ($is_ident)
{
case "usager" :     $nstructure=-1; break;
case "structure" :  $nstructure=$id_structure; break;
case "animateur" :  $nstructure=-2; break;
case "visiteur" :   $nstructure=-4; break;
default :           debug("Problme grave de droits dans header.inc.php"); exit;
} // switch

//debug($nstructure);

// On regarde si a existe, sinon, on prend les fonctionnalits de l'application

// Retrouver les fonctionnalits actives de l'application
$req1="SELECT id_fonction, fonction, actif, couleur
        FROM droits
        LEFT JOIN fonctions ON id_fonction=fonctions.id
        WHERE id_structure='0'";

if ($res1 = executeRequete($req1))
  while ($fonctionnalite = fetch_object($res1))
  {
    $config=TRUE;
    if ($fonctionnalite->actif=="y")
    {
      define(strtoupper("FCT_".$fonctionnalite->fonction), $fonctionnalite->actif);
      define(strtoupper("COULEUR_".$fonctionnalite->fonction), $fonctionnalite->couleur);
      /*  Dans le cas de la dfinition des fonctionnalits, les constantes sont prcdes de FCT_
          Par exemple, si la fonction de gestion des usagers est activ, FCT_USAGERS vaudra ACTIF. */
      //debug(strtoupper("FCT_".$fonctionnalite->fonction)." => ".strtoupper($fonctionnalite->actif));
      //debug(strtoupper("COULEUR_".$fonctionnalite->fonction)." => ".strtoupper($fonctionnalite->couleur));

      // Pour chaque fonctionnalit, on regarde les droit.
      $variable=$fonctionnalite->fonction;
      $req2="SELECT moi, autres FROM droits
              WHERE id_structure='$nstructure' AND id_fonction='$fonctionnalite->id_fonction'";
      $res2= executeRequete($req2);
      if ($droit = fetch_object($res2))
      {
        define(strtoupper($variable), "~".$droit->moi.$droit->autres);
        define(strtoupper($variable)."_MOI", $droit->moi);
        define(strtoupper($variable)."_AUTRES", $droit->autres);
        /* Dans le cas des droits de la structure,
           si la structure a le droits de voir (et uniquement de voir)
           les informations sur les usagers, on aura : USAGERS=="10". */
        //debug(strtoupper($variable)." -> "."~".$droit->moi.$droit->autres);
      }
      elseif ($nstructure>0) // Si c'est une structure et qu'on n'a rien, on prend la config par dfaut
      {
        $req3="SELECT moi, autres FROM droits
              WHERE id_structure='-3' AND id_fonction='$fonctionnalite->id_fonction'";
        $res3= executeRequete($req3);
        if ($droit = fetch_object($res3))
        {
          define(strtoupper($variable), "~".$droit->moi.$droit->autres);
          define(strtoupper($variable)."_MOI", $droit->moi);
          define(strtoupper($variable)."_AUTRES", $droit->autres);
        }
      }  // elseif
    } // if !=inactif
  } // while

if (!$config && $PHP_SELF!="config.php")
{
  echo "<p>C'est apparemment la toute premire utilisation.</p>";
  echo "<p><a href=\"config.php?premiere=1&is_ident=structure&id_structure=$id_structure\">Aller vers l'assistant de configuration</a></p>";
  echo "<p><a href=\"$PHP_SELF?logoff=1\">Reessayer</a><p></p>";
  exit;
}

?>

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us