<?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");
?>