home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ac-grenoble.fr
/
2015.02.ftp.ac-grenoble.fr.tar
/
ftp.ac-grenoble.fr
/
pub
/
slis
/
updates_rsync
/
users_pop.cgi
< prev
next >
Wrap
Text File
|
2000-06-07
|
6KB
|
201 lines
#!/usr/bin/perl
# users_pop.cgi - Creation d'utilisateur
# Version 1.4
# This script is part of the SLIS Project initiated by the CARMI-Internet
# (AcadΘmie de Grenoble - France 38).
# Ce script fait partie du projet SLIS dΘmarrΘ par le CARMI-Internet
# (AcadΘmie de Grenoble - France 38).
#
# SLIS : Serveur de communications Linux pour l'Internet Scolaire.
# Copyright (C) 1998 Bruno Bzeznik
#
# 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 (For example ./COPYING);
# if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
# Cambridge, MA 02139, USA.
#
# Please send all comments and bug reports by electronic mail to:
# Bruno Bzeznik <Bruno@ac-grenoble.fr>
# or to <slis@ac-grenoble.fr>
#
# Envoyez vos suggestions et reports de bugs par e-mail α
# Bruno Bzeznik <Bruno@ac-grenoble.fr>
# ou α <slis@ac-grenoble.fr>
#
# Variables
do '/home/hadmin/slis.conf.pl';
use CGI ;
$html = new CGI ;
print $html->header ;
# Lecture de l'entete standard HTML
open (HEAD,"$ENTETE");
print <HEAD> ;
close HEAD ;
# Lecture des parametres administrateur
open (PARAMS,"$BASE/params_admin.txt");
@param= <PARAMS> ;
# Tests de validitΘ
if ($param[2] eq "") {
print "<CENTER>";
print "Vous n'avez pas entré correctement les paramètres administrateur\n";
print "<A HREF=/cgi-bin/params_admin_form.cgi>VEUILLEZ LE FAIRE.</A>\n";
print "</CENTER></BODY></HTML>";
exit;
}
if ($html->param('Prenom') eq "") {
print "<CENTER>";
print "Il faut au moins un NOM et un PRENOM<BR>\n";
print "<A HREF=/users_pop.html>RECOMMENCEZ.</A>\n";
print "</CENTER></BODY></HTML>";
exit;
}
if ($html->param('Prenom') eq "") {
print "<CENTER>";
print "Il faut au moins un NOM et un PRENOM\n";
print "<A HREF=/users_pop.html>RECOMMENCEZ.</A>\n";
print "</CENTER></BODY></HTML>";
exit;
}
# Routine de generation de mots de passe
# Utilisation:
# srand($$|time);
# $passwd = &pw_generate;
sub pw_generate {
local(@passset, $rnd_passwd, $randum_num);
local($randum_num);
# Since 1 ~= l and 0 =~ O, don't generate passwords with them.
# This will just confuse people using ugly fonts.
#
@passset = ('a'..'k', 'm'..'z', '2'..'9');
$rnd_passwd = "";
for ($i = 0; $i < 8; $i++) {
$randum_num = int(rand($#passset + 1));
$rnd_passwd .= @passset[$randum_num];
}
return $rnd_passwd;
}
# Generation du mot de passe et de la chaine cryptΘe.
$passwd = &pw_generate;
$salt= &pw_generate;
$crypted_passwd= crypt($passwd, substr($salt, 0, 2));
open(USERS_POP,">>$QUEUE/users_pop");
# Generation d'un login
$u1=$html->param('Prenom') ;
$u2=$html->param('Nom') ;
$u1=~ s/Θ/e/g ;
$u2=~ s/Θ/e/g ;
$u1=~ s/Φ/e/g ;
$u2=~ s/Φ/e/g ;
$u1=~ s/α/a/g ;
$u2=~ s/α/a/g ;
$u1=~ s/δ/e/g ;
$u2=~ s/δ/e/g ;
$u1=~ s/Ω/e/g ;
$u2=~ s/Ω/e/g ;
$u1=~ s/∙/u/g ;
$u2=~ s/∙/u/g ;
$u1=~ s/⌠/o/g ;
$u2=~ s/⌠/o/g ;
$u1=~ s/÷/o/g ;
$u2=~ s/÷/o/g ;
$u1=~ s/τ/c/g ;
$u2=~ s/τ/c/g ;
$login1=substr $u2,0,7;
$login2=substr $u1,0,1;
$login="$login1"."$login2";
$login=~ y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ ;
# Au cas ou le login existe deja dans /etc/passwd ou dans le fichier en
# cours.
$already1=`cut -d: -f1 /etc/passwd | grep -x $login` ;
$already2=`cut -d: -f1 $QUEUE/users_pop | grep -x $login` ;
$already="$already1"."$already2" ;
$c=0 ;
$login1=substr $login,0,6;
while ($already ne "") {
$c += 1 ;
$login="$login1"."$c";
$already1=`cut -d: -f1 /etc/passwd | grep -x $login` ;
$already2=`cut -d: -f1 $QUEUE/users_pop | grep -x $login` ;
$already="$already1"."$already2" ;
}
# Au cas ou l'alias existe deja dans /etc/aliases ou dans le fichier en
# cours.
$Prenom=$html->param('Prenom');
$Nom=$html->param('Nom');
$Prenom=~ s/Θ/e/g ;
$Nom=~ s/Θ/e/g ;
$Prenom=~ s/Φ/e/g ;
$Nom=~ s/Φ/e/g ;
$Prenom=~ s/α/a/g ;
$Nom=~ s/α/a/g ;
$Prenom=~ s/δ/e/g ;
$Nom=~ s/δ/e/g ;
$Prenom=~ s/Ω/e/g ;
$Nom=~ s/Ω/e/g ;
$Prenom=~ s/∙/u/g ;
$Nom=~ s/∙/u/g ;
$Prenom=~ s/⌠/o/g ;
$Nom=~ s/⌠/o/g ;
$Prenom=~ s/÷/o/g ;
$Nom=~ s/÷/o/g ;
$Prenom=~ s/τ/c/g ;
$Nom=~ s/τ/c/g ;
$already1=`cut -d: -f1 /etc/aliases | grep -x "$Prenom.$Nom"` ;
$already2=`cut -d: -f5 $QUEUE/users_pop | grep -x "$Prenom.$Nom"` ;
$already="$already1"."$already2" ;
$c=0 ;
$alias="$Prenom.$Nom";
$alias1="$Prenom.$Nom";
while ($already ne "") {
$c += 1 ;
$alias="$alias1"."$c";
$already1=`cut -d: -f1 /etc/aliases | grep -x $alias` ;
$already2=`cut -d: -f5 $QUEUE/users_pop | grep -x $alias` ;
$already="$already1"."$already2" ;
}
# Ecriture dans le fichier
print USERS_POP $login,":";
print USERS_POP $passwd,":";
print USERS_POP $crypted_passwd,":";
print USERS_POP $html->param('Prenom')," ";
print USERS_POP $html->param('Nom'),",";
print USERS_POP $html->param('Comm1'),",";
print USERS_POP $html->param('Comm2'),":";
print USERS_POP $alias,"\n";
# Ecriture du resultat
print "<CENTER><H3><I>Les informations ont été enregistrées" ;
print "\n</I></H3><P>Ce compte sera créé lors de la" ;
print " prochaine validation.<P>\n" ;
print "<B><A HREF=/users_pop.html>Créer un autre compte</A></B>\n" ;
# Lecture du pied de page standard
open (FOOT,"$PIED");
print <FOOT> ;
close FOOT ;
close(PARAMS);