A
download courriel.php
Language: PHP
License: GPL
Copyright: (C) 2002 Loc Dayot - Mairie de Pierrefitte (93)
LOC: 585
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
<?php
/*
    Copyright (C) 2002 Loc Dayot - Mairie de Pierrefitte (93)

    EPNadmin - Version 0.6

    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("header.inc.php"); // C'est dans header.inc.php que sont retrouvs les droits issus de la table droits
require_once("constantes.inc.php");             // dfinition des constantes
if (!defined("FCT_COURRIELS"))
{
  echo $fctnonactive;
  exit;
}

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

$ptitr=$scourriel;
$titr = $scourrieltitre;
$datemaj="3 mai 2003";
define("COULEUR", COULEUR_COURRIELS);
require("entete.inc.php");

// Dbut de la page

// Cration d'un sous-domaine ou d'un alias
function form_sousdomaine($operation, $id_sousdomaine=0, $id_domaine=1)
{
global $is_ident, $id_structure, $id_usager, $PHP_SELF,
  $sstrugerante, $snomdesousdom, $saliasdesite, $sdirigeverssite, 
	$scourrielidentifiantpostmaster, $sMotdepasse, $sconfirmer;
  echo "<table border=1>
				<form action=\"$PHP_SELF\">
				<input type=\"hidden\" name=\"operation\" value=\"$operation\">";
 // il s'agit d'un site web de structure
  echo "<tr><td>$sstrugerante* :</td>";
  echo "<td>";
  if (COURRIEL_AUTRES<'w')
    echo "<input type=\"hidden\" name=\"id_stru\" value=\"$id_structure\">".structure($id_structure);
  else
    choix_structure($id_structure, "id_stru");
  echo "</td></tr>\n";

	echo "<tr><td>";
	if ($operation>=221)
		echo "$saliasdesite*";
	else
		echo "$snomdesousdom*";
	echo " :</td><td><input type=\"text\" name=\"sousdomaine\">";
	choix_domaine($id_domaine, "id_domaine");
	echo "</td></tr>";
	if ($operation==201)
		echo "<tr><td>$scourrielidentifiantpostmaster* :</td><td><input type=\"hidden\" name=\"login\" value=\"postmaster\">postmaster</td></tr>
				<tr><td>$sMotdepasse* :</td><td><input name=\"motdepasse\" type=\"password\"></td></tr>
				<tr><td>$sMotdepasse* :<br>(pour confirmation)</td><td><input name=\"motdepasse2\" type=\"password\"></td></tr>";
	else
	{
		echo "<tr><td>$sdirigeverssite :</td><td>";
		choix_sousdomaine($id_sousdomaine, "id_sousdomaine", "courriel");
		echo "</td></tr>\n";
	}
	echo "<tr><td colspan=2 align=center><input type=\"submit\" name=\"Envoyer\" value=\"$sconfirmer\"></td></tr>
				</table>\n";

} // function form_sousdomaine


// --------------------------------------------------------------------------------//


// Dbut de la page
switch ($operation)
{
case 10 : // Liste de tous les sous-domaines de courriels
  echo cadre_debut($scourrielliste);
	if (COURRIELS_AUTRES<"r")
  {
    echo $pasledroit;
		echo cadre_fin();
    break;
  }
  echo "<table border=1>
      <tr><th align=center>$sGestionnaire</th><th align=center>$ssousdomaines</th><th align=center>$sActions</th></tr>";
  $req="SELECT * FROM hebergements
                WHERE type='courriel' OR type='aliascourriel'
                ORDER BY id_structure, sousdomaine";
  $res=executeRequete($req);
  while ($sousdomaine=fetch_object($res)) //->fetchrow(DB_FETCHMODE_OBJECT))
  {
    if ($sousdomaine->id_structure!=$idstranc)
    {
      if ($coul=="")
        $coul=" bgcolor=\"lightgrey\"";
      else
        $coul="";
      $idstranc=$sousdomaine->id_structure;
    }
    echo "<tr$coul><td>";
    echo structure($sousdomaine->id_structure);
    echo "</td><td>";
    if ($sousdomaine->type=="courriel")
      echo "<b>$sousdomaine->sousdomaine</b>";
    else
      echo "$sousdomaine->sousdomaine";
    if ($sousdomaine->type=="aliascourriel")
      echo " -> $sousdomaine->login";
    echo "</td><td>";
    if (($sousdomaine->id_structure==$id_structure && COURRIELS_MOI>="r") || COURRIELS_AUTRES>="r")
      echo "<a href=\"$PHP_SELF?id_sousdomaine=$sousdomaine->id&operation=50\">$info $sparametres</a> "; //"
    if (($sousdomaine->id_structure==$id_structure && COURRIELS_MOI>="w") || COURRIELS_AUTRES>="w")
      echo " - <a href=\"$PHP_SELF?id_sousdomaine=$sousdomaine->id&operation=40\">$modifier $schangermdp</a>";
    if (COURRIELS_AUTRES>="w")
      echo " - <a href=\"$PHP_SELF?id_sousdomaine=$sousdomaine->id&operation=30\">$supprimer $ssupprimer</a>";
    echo "</td></tr>\n";
  }
  echo "</table>\n";

	echo cadre_fin();
  break;

case 11 : // Liste des domaines de courriels
  echo cadre_debut($scourriellistegerepar." ".structure($id_stru));
  if (COURRIELS<="~")
  {
    echo $pasledroit;
		echo cadre_fin();
    break;
  }
  if (COURRIELS_AUTRES>="r" || !$id_stru) $id_stru=$id_structure;
  echo "<table border=1>
      <tr><th align=center>$ssousdomaines</th><th align=center>$sActions</th></tr>";
  $req="SELECT * FROM hebergements
                 WHERE (type=\"courriel\" OR type=\"aliascourriel\") AND ";
  if ($id_structure)
    $req.="id_structure=$id_stru";
  else
    $req.="id_usager=$id_usager";
  $req.="        ORDER BY id_structure, sousdomaine";
  $res=executeRequete($req);
  while ($sousdomaine=fetch_object($res)) //->fetchrow(DB_FETCHMODE_OBJECT))
  {
    echo "<tr><td>$sousdomaine->sousdomaine";
    if ($sousdomaine->type=="aliascourriel")
      echo " -> $sousdomaine->login";
    echo "</td><td>";
    if (($sousdomaine->id_structure==$id_structure && COURRIELS_MOI>="r") || COURRIELS_AUTRES>="r")
      echo "<a href=\"$PHP_SELF?operation=50&id_sousdomaine=$sousdomaine->id\">$info $sparametres</a> ";
    if (COURRIELS_MOI>="w" || COURRIELS_AUTRES>="w")
    {
      if ($sousdomaine->id_structure && $sousdomaine->type!="aliascourriel")
        echo " - <a href=\"$PHP_SELF?operation=40&id_sousdomaine=$sousdomaine->id\">$modifier $schangermdp</a>";
      echo " - <a href=\"$PHP_SELF?operation=30&id_sousdomaine=$sousdomaine->id\">$supprimer $ssupprimer</a></td></tr>\n";
    }
  }
  echo "</table>\n";
  echo cadre_fin();
  break;

case 20 : // Crer un nouveau domaine courriel 
  echo cadre_debut($scourrielcreationsoudom);
  if (COURRIELS_MOI>="w" || COURRIELS_AUTRES>="w")
    form_sousdomaine(201);
  else
    echo $pasledroit;
  echo cadre_fin();
  break;

case 22 : // Crer un alias de domaine courriel
  echo cadre_debut($scourrielcreationalias);
  if (COURRIELS_MOI>="w" || COURRIELS_AUTRES>="w")
    form_sousdomaine(221);
  else
    echo $pasledroit;
  echo cadre_fin();
  break;

case 201 : // Aprs saisie d'un nouveau domaine courriel
  echo cadre_debut($scourrielcreationsoudom);
  if ((COURRIELS_MOI<"w" || $id_stru!=$id_structure) && COURRIELS_AUTRES<"w")
  {
    echo $pasledroit;
		echo cadre_fin();
    break;
  }
  // Vrification des informations
  $mes="";
  // le sous-domaine n'existe-t-il pas dj ?
  $res = recherche("domaines", "id", $id_domaine);
  $domaine = fetch_object($res); //->fetchrow(DB_FETCHMODE_OBJECT);
  $domaine = $domaine->domaine;
  $req = "SELECT * FROM hebergements
                  WHERE sousdomaine='$sousdomaine.$domaine'
                    AND (type='courriel' OR type='aliascourriel')";
  $res = executeRequete($req); //$db->query($req);
  if (fetch_object($res)) //->fetchrow(DB_FETCHMODE_OBJECT))
     $mes.=$scourrieldomdejautilise."<br>";
  // vrification mot de passe
  if ($motdepasse!="" && $motdepasse!=$motdepasse2)
    $mes.=$smauvaismotdepasse."<br>";
  if ($mes!="")
  {
    echo "<p>$mes</p>\n";
		echo cadre_fin();
    exit;
  }

  // Ajouter l'enregistrement dans la base de donnes hbergement
  $motdepassec= md5($motdepasse);
  $req="INSERT INTO hebergements (id_structure, type, sousdomaine, login, motdepasse)
        VALUES ('$id_stru', 'courriel', '$sousdomaine.$domaine', \"$login\", \"$motdepassec\")";
  $res = executeRequete($req);

  // Retourver le numro de l'enregistrement
  $res = recherche("hebergements", "sousdomaine", "$sousdomaine.$domaine");
  $enr = fetch_object($res); //->fetchrow(DB_FETCHMODE_OBJECT);
  $id_hebergement = $enr->id;

  // Ajouter le compte sur la machine serveur
  $motdepassec = crypt($motdepasse, "Sa");
  $comm="vadddomain $sousdomaine.$domaine $motdepasse";
  executecommande("sudo $comm");

  echo "<p>$scourrielcreationok</p>\n";

  //  Envoi d'un courriel pour la demande de cration d'hte virtuel.
	$to=$administrateursitesweb;
	if (! $from=courriel("structures", $id_stru))
	  $from=$administrateursitesweb;
	else
	  $to.=",".$from;

  $corps = sprintf($scourrielcreationcorpsmessage, $sousdomaine.$domaine, structure($id_stru));
  $ok = mail($to, $scourrielcreationobjetmessage, $corps, "From: $from");
  echo "<p>$corps</p>\n";
  echo cadre_fin();
  break;

case 221 : // Aprs saisie d'un nouvel alias de site web
  echo cadre_debut($scourrielcreationalias);
  if ((COURRIELS_MOI<"w" || $id_stru!=$id_structure) && COURRIELS_AUTRES<"w")
  {
    echo $pasledroit;
		echo cadre_fin();
    break;
  }
  // Vrification des informations
  $mes="";
  // le sous-domaine n'existe-t-il pas dj ?
  $res = recherche("domaines", "id", $id_domaine);
  $domaine = fetch_object($res); //->fetchrow(DB_FETCHMODE_OBJECT);
  $domaine = $domaine->domaine;
  $req = "SELECT * FROM hebergements
           WHERE sousdomaine='$sousdomaine.$domaine'
             AND (type='courriel' OR type='aliascourriel')";
  $res = executeRequete($req);
  if (fetch_object($res)) //->fetchrow(DB_FETCHMODE_OBJECT))
     $mes .="$scourrieldomdejautilise<br>";
  if ($mes!="")
  {
    echo "<p>$mes</p>\n";
		echo cadre_fin();
    exit;
  }
  $req = "SELECT * FROM hebergements WHERE id=$id_sousdomaine";
  $res = executeRequete($req);
  $sousdomainedestination=fetch_object($res); //->fetchrow(DB_FETCHMODE_OBJECT);

  // Ajouter l'enregistrement dans la base de donnes hbergement
  $req="INSERT INTO hebergements (id_structure, type, sousdomaine, login)
        VALUES ('$id_stru', 'aliascourriel', '$sousdomaine.$domaine', \"$sousdomainedestination->sousdomaine\")";
  $res = executeRequete($req);

  // Lancer la commande de cration de l'alias
  $comm="vaddaliasdomain $sousdomaine.$domaine $sousdomainedestination->sousdomaine";
  executecommande("sudo $comm");

  echo "<p>$scourrielcreationaliasok</p>\n";

  //  Envoi d'un courriel pour la demande de cration d'hte virtuel.
	$to=$administrateursitesweb;
	if (! $from=courriel("structures", $id_stru))
	  $from=$administrateursitesweb;
	else
	  $to.=",".$from;

  $corps = sprintf($scourrielcreationaliascorpsmessage,
	    $sousdomaine.$domaine, $sousdomainedestination->sousdomaine, structure($id_stru));
  $ok = mail($to, $scourrielcreationaliasobjet, $corps, "From: $from");

	echo cadre_fin();
  break;

case 30 : // Demande de confirmation de destruction d'un domaine de courriel
  echo cadre_debut($courrielsousdomsuppr);
  // On retrouve l'enregistrement du sous domaine
  $res=recherche("hebergements", "id", $id_sousdomaine);
  if (!$sousdomaine=fetch_object($res)) //->fetchrow(DB_FETCHMODE_OBJECT))
  {
    echo "<p>$scourrielintrouvable</p>\n";
		echo cadre_fin();
    break;
  }
  if ((COURRIELS_MOI<"w" || $sousdomaine->id_structure!=$id_structure) && COURRIELS_AUTRES<"w")
  {
    echo $pasledroit;
		echo cadre_fin();
    break;
  }
  echo "<table border=1>";
  echo "<tr><td>$sstrugerante :</td>";
  echo "<td>".structure($sousdomaine->id_structure);
  echo "</td></tr>\n";

  if ($sousdomaine->type=="aliascourriel")
    echo "<tr><td>$saliasdesite :</td><td>$sousdomaine->login</td></tr>\n";
  else
  {
    echo "<tr><td>$snomdesousdom :</td><td>$sousdomaine->sousdomaine</td></tr>\n";
    echo "<tr><td>$sIdentifiant :</td><td>$sousdomaine->login</td></tr>";
  }
  echo "<tr><td colspan=2 align=center>
        <form action=\"$PHP_SELF\" method=\"POST\" enctype=\"multipart/form-data\">
        <input type=\"hidden\" name=\"operation\" value=301>
        <input type=\"hidden\" name=\"id_sousdomaine\" value=$sousdomaine->id>\n";
  echo "<input type=\"submit\" name=\"Supprimer\" value=\"$sconfirmer\">
        </form>
        </td></tr>\n";
  echo "</table>\n";
	echo cadre_fin();
  break;

case 301 : // Destruction de domaine de courriel
  echo cadre_debut($courrielsousdomsuppr);
  // Vrification des informations
  $mes="";
  // le sous-domaine existe-t-il ?
  $res=recherche("hebergements", "id", $id_sousdomaine);
  if (!$sousdomaine=fetch_object($res)); //->fetchrow(DB_FETCHMODE_OBJECT))
  {
    echo "<p>$scourrielintrouvable</p>\n";
		echo cadre_fin();
    break;
  }
  if ((COURRIELS_MOI<"w" || $sousdomaine->id_structure!=$id_structure) && COURRIELS_AUTRES<"w")
  {
    echo $pasledroit;
		echo cadre_fin();
    break;
  }

  if (COURRIELS_AUTRES<"w")
  {
    $req = "DELETE FROM hebergements WHERE id=$id_sousdomaine";
    $res = executeRequete($req);

    //if ($suppr_compte!="on")
    //  break;

    if ($sousdomaine->type=="courriel")
    {
      echo "<p>$scourrielsousdomsuppr</p>";
      $comm="vdeldomain $sousdomaine->sousdomaine";
      $corps = "$courrielsousdomsuppr\n"
               ."$sousdomaine->sousdomaine\n";
    }
    elseif ($sousdomaine->type=="aliascourriel")
    {
      echo "<p>$scourrielaliassuppr</p>";
      $comm="rm $dircomptesvpopmail/domains/$sousdomaine->sousdomaine";
      $corps = "$scourrielaliassuppr\n"
               ."$sousdomaine->sousdomaine => $sousdomaine->login\n";
    }
    //debug($comm);
    executecommande("sudo $comm");
  }
  else
    echo "<p>$scourrielpasledroitmail</p>";


  // Envoi d'un courriel pour demande la suppression du site
	$to=$administrateursitesweb;
	if (! $from=courriel("structures", $id_structure))
	  $from=$administrateursitesweb;
	else
	  $to.=",".$from;
  if (courriel("structures", $sousdomaine->id_structure))
	  $to.=",".courriel("structures", $sousdomaine->id_structure);

  $ok = mail($to, $scourrielcreationaliasobjet, $corps, "From: $from");

  echo "<p>$corps</p>\n";
	echo cadre_fin();
  break;

case 40 : // Changer de mot de passe pour un site (structure uniquement)
  echo "<p>Pas encore implment</p>\n";
  break;

case 50 : // Afficher les paramtres domaine courriel
	// On retrouve l'enregistrement du sous domaine
  $res=recherche("hebergements", "id", $id_sousdomaine);
  if (!$sousdomaine=fetch_object($res)); //->fetchrow(DB_FETCHMODE_OBJECT))
  {                                              
	  echo cadre_debut();
    echo "<p>$scourrielintrouvable</p>\n";
		echo cadre_fin();
    break;
  }
  if ((COURRIELS_MOI<"r" || $sousdomaine->id_structure!=$id_structure) && COURRIELS_AUTRES<"r")
  {
	  echo cadre_debut();
    echo $pasledroit;
		echo cadre_fin();
    break;
  }
  $res=recherche("domaines", "id", $sousdomaine->id_domaine);
  $domaine=fetch_object($res); //->fetchrow(DB_FETCHMODE_OBJECT);

	echo cadre_debut($scourrielparametres.$sousdomaine->sousdomaine);
  echo "<table align=center>\n";
  // recherche des alias de courriels
  $res2=recherche("hebergements", "login", $sousdomaine->sousdomaine);
  while ($alias=fetch_object($res2)) //->fetchrow(DB_FETCHMODE_OBJECT))
    if ($alias->type=="aliascourriel")
      echo "<tr><td align=center>$ssitealiasde : $alias->sousdomaine</td></tr>\n";

  echo "<tr><td><table border=1>";
  echo "<tr><td>Structure grante :</td>";
  echo "<td>".structure($sousdomaine->id_structure);
  echo "</td></tr>\n";

  if ($sousdomaine->type=="aliascourriel")
    echo "<tr><td>$ssitealiasde :</td><td>$sousdomaine->login</td></tr>";
  else
  {
    echo "<tr><th colspan=2 align=center>$scourrieladministration</th></tr>
          <tr><td>$scourrielparlenavigateur :</td>
              <td><a href=\"http://courriel.pierrefitte93.fr/admin\">http://courriel.pierrefitte93.fr/admin</a>
              </td></tr>"; //"
    echo "<tr><td>$sIdentifiant :</td><td>$sousdomaine->login</td></tr>";
    echo "<tr><td>$snomdesousdom :</td><td>$sousdomaine->sousdomaine</td></tr>\n";
    echo "<tr><td>$sMotdepasse :</td><td>Celui que vous avez saisi lors de la cration du domaine</td></tr>";
    echo "<tr><th colspan=2 align=center>$scourrielaccescourrielwebmail</th></tr>
          <tr><td>$scourrielparlenavigateur :</td><td><a href=\"http://courriel.pierrefitte93.fr\">http://courriel.pierrefitte93.fr</a></td></tr>
          <tr><td>$sIdentifiant :</td><td>l'adresse de courriel entire<br>par exemple : postmaster@$sousdomaine->sousdomaine.$domaine->domaine</td></tr>
          <tr><td>$sMotdepasse :</td><td>Le mot de passe saisi lors de la cration <br>du compte par l'administrateur.</td></tr>
          <tr><th colspan=2 align=center>$scourrielclienpop</th></tr>
          <tr><td>$scourrielserveurpop :</td><td>pop.pierrefitte93.fr</td></tr>
          <tr><td>$sIdentifiant :</td><td>$scourrieladressecorrielentiere postmaster@$sousdomaine->sousdomaine.$domaine->domaine</td></tr>
          <tr><td>$sMotdepasse :</td><td>$scourrielmdpsaisi</td></tr>\n";
  } //"
  echo "</table>
      </td></tr></table>\n";   
	echo cadre_fin();
  break;

case 60 : // Modifier le site par dfaut
  echo "<p>Pas encore implment</p>\n";
  break;

case 70 : // Crer une adresse de courriel pour un usager  
  echo cadre_debut($scourrielcreercpteusager);
  if ((COURRIELS_MOI<"w" || $is_ident!="usager") && COURRIELS_AUTRES<"w")
  {
    echo $pasledroit;
		echo cadre_fin();
    break;
  }
  // choix de l'usager

  if (USAGERS_AUTRES>="r")
  {
    if ($code_barre!="" & $id=="")
       $id=substr($code_barre,0,4);
    affiche_liste_usagers($id, $login, $nom, $prenom, "nom", "COURRIEL");
  }
	echo cadre_fin();
  break;

case 71 : // Crer une adresse de courriel pour un usager
  echo cadre_debut($scourrielcreercpteusager);
  if ((COURRIELS_MOI<"w" || $is_ident!="usager") && COURRIELS_AUTRES<"w")
  {
    echo $pasledroit;
		echo cadre_fin();
    break;
  }
  // choix de l'adresse
  $res=recherche("usagers", "id", $id_usager);
  $usager=fetch_object($res);
  $adresse=strtolower("$usager->prenom.$usager->nom");
  echo "<table align=center border=1>
        <form action=\"$PHP_SELF\" method=\"POST\" enctype=\"multipart/form-data\">";
  echo "<input type=\"hidden\" name=\"operation\" value=\"72\">";
  echo "<input type=\"hidden\" name=\"id_usager\" value=\"$id_usager\">";
  echo "<tr><td>$sUsager :</td><td>$usager->prenom $usager->nom</td></tr>\n";
  echo "<tr><td>$sCourriel :</td><td><input type=\"text\" name=\"adresse\" value=\"$adresse\">@</td></tr>";
  // TODO : donner le choix du domaine
  $domaine="arobase.pierrefitte93.fr";
  echo "<tr><td>$sDomaine :</td><td><input type=\"text\" name=\"domaine\" value=\"$domaine\" size=\"30\"></td></tr>";

  if (strlen($usager->motdepasse)<32)
    $mdp=$usager->motdepasse;
  else
    $mdp="";
  echo "<tr><td>$sMotdepasse :</td><td><input type=\"password\" name=\"mdp1\" value=\"$mdp\" size=\"20\"></td></tr>\n";
  echo "<tr><td>$sMotdepasse (2) :</td><td><input type=\"password\" name=\"mdp2\" value=\"$mdp\" size=\"20\"></td></tr>\n";

  echo "<tr><td>$scourrielpardefaut</td><td>
               <input type=\"radio\" name=\"default\" value=\"oui\" checked> $soui
               <input type=\"radio\" name=\"default\" value=\"non\"> $snon
       </td></tr>\n";

  echo "<tr><td colspan='2' align='center'><input type=\"submit\" name=\"Crer\"
        value=\"$scourrielconfcreer\"></td></tr>
        </table>\n"; //'
  echo "</form>\n";
  echo cadre_fin();
  break;

case 72 : // Crer une adresse de courriel pour un usager - aprs formulaire
  echo cadre_debut($scourrielcreercpteusager);
  // Enregistrement de la demande et cration relle.
  if ((COURRIELS_MOI<"w" || $is_ident!="usager") && COURRIELS_AUTRES<"w")
  {
    echo $pasledroit;
		echo cadre_fin();
    break;
  }
  $mes="";
  if (!$id_usager || $id_usager=="") $mes.="$susagermanque<br>";
  $res=recherche("usagers", "id", $id_usager);
  if (!$usager=fetch_object($res)) $mes="$susagerintrouvable<br>";
  if (!$mdp1 || !$mdp2 || $mdp1.$mdp2=="" || $mdp1!=$mdp2)
    $mes="$motdepassedifferents<br>";
  if (!$adresse || $adresse=="") $mes.="$scourrielmanqueadresse<br>";
  if (!$domaine || $domaine=="") $mes.="$scourrielmanquedomaine<br>";
  $courriel="$adresse@$domaine";
  $res=recherche("usagers", "courriel", $courriel);
  if (fetch_object($res)) $mes="$scourrieladdrdejautilisee<br>";
  if ($mes!="")
  {
    echo "<p><<font size=\"3\"></font>$mes</p>\n";
		echo cadre_fin();
    break;
  }
  $comm="sudo vadduser -q 5m $courriel $mdp1";
  $retour=executecommande($comm);
  if ($retour==0)
    printf ("<p>$scourrielcptecree</p>", $courriel);
  else
    printf ("<p><b>$scourrielcptecreenok</b></p>", $courriel);

  // C'est une adresse de courriel par dfault, on peut l'enregistrer dans la base des usagers
  if ($default=="oui")
  {
     $req="UPDATE usagers SET courriel='$courriel' WHERE id=$id_usager";
     if (!$res=executeRequete($req))
       echo "<p>$courrielchgmtcourrielnok</p>\n";
  }
	echo cadre_fin();
  break;

case 80 : // Crer une adresse de courriel sans qu'il y ait d'usager
  echo cadre_debut($scourrielcreercpte);
  if ((COURRIELS_MOI<"w" || $is_ident!="structure") && COURRIELS_AUTRES<"w")
  {
    echo $pasledroit;
		echo cadre_fin();
    break;
  }
  // choix de l'adresse
  $adresse="";
  echo "<table align=center border=1>
        <form action=\"$PHP_SELF\" method=\"POST\" enctype=\"multipart/form-data\">";
  echo "<input type=\"hidden\" name=\"operation\" value=\"82\">";
  echo "<tr><td>$sCourriel</td><td><input type=\"text\" name=\"adresse\" value=\"$adresse\">@</td></tr>";
  echo "<tr><td>$sDomaine</td><td>";
  choix_sousdomaine($id_sousdomaine, "id_sousdomaine", "courriel");
  echo "</td></tr>";
  $mdp="";
  echo "<tr><td>$sMotdepasse :</td><td><input type=\"password\" name=\"mdp1\" value=\"$mdp\" size=\"20\"></td></tr>\n";
  echo "<tr><td>$sMotdepasse (encore) :</td><td><input type=\"password\" name=\"mdp2\" value=\"$mdp\" size=\"20\"></td></tr>\n";

  echo "<tr><td colspan='2' align='center'><input type=\"submit\" name=\"Crer\"
        value=\"$scourrielconfcreer\"></td></tr>
        </table>\n";    //'
  echo "</form>\n";
  echo cadre_fin();
  break;

case 82 : // Crer une adresse de courriel   
  echo cadre_debut($scourrielcreercpte);
  if ((COURRIELS_MOI<"w" || $is_ident!="structure") && COURRIELS_AUTRES<"w")
  {
    echo $pasledroit;                   
		echo cadre_fin();
    break;
  }
  // Enregistrement de la demande et cration relle de compte de courriel (sans usager).
  $mes="";
  if (!$mdp1 || !$mdp2 || $mdp1.$mdp2=="" || $mdp1!=$mdp2)
    $mes="$motdepassedifferents<br>";
  if (!$adresse || $adresse=="") $mes.="$scourrielmanqueadresse<br>";
  if (!$id_sousdomaine || $id_sousdomaine=="") $mes.="$scourrielmanquedomaine<br>";
  $res=recherche("hebergements", "id", $id_sousdomaine);
  if(!$sousdomaine=fetch_object($res))
    $mes.="$ssousdomaineintrouvable<br>";
  if (COURRIELS_AUTRES<"w" && $sousdomaine->id_structure!=$id_structure)
    $mes.=$pasledroit;
  if ($mes!="")
  {
    echo "<p><font size=\"3\"></font>$mes</p>\n";
		echo cadre_fin();
    break;
  }
  $domaine=$sousdomaine->sousdomaine;
  $courriel="$adresse@$domaine";
  $comm="sudo vadduser -q 5m $courriel $mdp1";
  $retour=executecommande($comm);
  if ($retour==0)
    printf ("<p>$scourrielcptecree</p>", $courriel);
  else
    printf ("<p><b>$scourrielcptecreenok</b></p>", $courriel);
  echo cadre_fin();
  break;

case 51 : // Afficher les paramtre courriel perso
default :                                         
  echo cadre_debut($scourrielmon);
  if ($is_ident=="usager" && COURRIELS_MOI>="r")
  { // Il s'agit d'un usager individuel
    $usager=trouveUsager($id_usager);
    $trouve=false;
    $req1="SELECT * FROM domaines";
    $res1=ExecuteRequete($req1);
    while ($domaine=fetch_object($res1))
      if (substr($usager->courriel,- strlen($domaine->domaine) )==$domaine->domaine)
        $trouve=true;
    if ($trouve)
      echo "<table align=center>
          <tr><td colspan=2 align=center>$scourrielaccescourrielwebmail</td></tr>
          <tr><td>$surl :</td><td><a href=\"http://courriel.pierrefitte93.fr\">http://courriel.pierrefitte93.fr</a></td></tr>
          <tr><td>$sIdentifiant :</td><td>$usager->courriel</td></tr>
          <tr><td>$sMotdepasse :</td><td>$scourrielmdpusagesaisi</td></tr>
          <tr><td colspan=2 align=center>$scourrielclienpop</td></tr>
          <tr><td>$scourrielserveurpop :</td><td>pop.pierrefitte93.fr</td></tr>
          <tr><td>$sIdentifiant :</td><td>$usager->courriel</td></tr>
          <tr><td>$sMotdepasse :</td><td>$scourrielmdpusagesaisi</td></tr>
          </table>\n"; //"
    else
      echo "<p>Votre courriel n'est pas hberg sur le serveur.</p>\n";
  }                                                                               
  echo cadre_fin();

}

echo cadre_debut($sActions);
if ($is_ident=="usager" && COURRIELS_MOI>="r")
	printf($scourrielaffmon."<br>", "$PHP_SELF?operation=51");

if (COURRIELS_AUTRES>="w" && USAGERS_AUTRES>="w")
	printf($scourrielaffcreeusager, "$PHP_SELF?operation=70");

if (COURRIELS_MOI>="w" || COURRIELS_AUTRES>="w")
	printf("<br>".$scourrielaffcreer,"$PHP_SELF?operation=80");

if (COURRIELS_MOI>="w" || COURRIELS_AUTRES>="w")
	printf("<br>".$scourrielafflistemes,"$PHP_SELF?operation=11");

if (COURRIELS_AUTRES>="r")
	printf("<br>".$sccourielafflistetous,"$PHP_SELF?operation=10");

if (COURRIELS_MOI>="w" || COURRIELS_AUTRES>="w")
{
	printf("<br>".$scourrielaffcreersoudom, "$PHP_SELF?operation=20");
	printf("<br>".$scourrielaffcreeraliassd, "$PHP_SELF?operation=22");
}
echo cadre_fin();

// Fin de la page

require("basdepage.inc.php");
echo "</body></html>";
require("footer.inc.php");
?>

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