Rev 5373 | Rev 9426 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
!read adm/language lang/names.phtml
!read adm/lang/date.phtml.$modu_lang
!read adm/class/classname.phtml $description\
$institution
!read adm/levelname.phtml
wims_prefix=class user tmp n sharing sharable
!read adm/class/limits
wims_helper=chapter=3&open=3_creat#creat
!if $wims_user=$empty
!bound cltype within 0,2,4 default 0
!distribute items $wims_class_regpass into regpass0,regpass2,regpass4
!default regpass0=email
!default regpass2=$regpass0
!default regpass4=deny
regpolicy0=!word 1 of $regpass0
regpolicy2=!word 1 of $regpass2
regpolicy4=!word 1 of $regpass4
!distribute words $regpass0 into regpolicy, regpasswd,regpassmail
!if $wims_user=$empty and $cltype>0 and $regpolicy notwordof deny file
!distribute words $(regpass$cltype) into regpolicy, regpasswd,regpassmail
!endif
regpassmail=!replace internal | by , in $regpassmail
!if $wims_ismanager<2
alltypes=0
!if $regpolicy2 notwordof deny file
alltypes=0,2
!endif
!if $regpolicy4 notwordof deny file and 2 isitemof $alltypes
alltypes=!append item 4 to $alltypes
!endif
!if $regpolicy=deny
error=not_manager
!exit
!endif
!else
alltypes=0,2,4
regpolicy=all
!endif
!if $regpolicy!=file and ($step=$empty or $step=pre) and $wims_ismanager<2
!exit
!endif
!else $wims_user!=$empty
!read adm/class/userdef classes,$wims_class,$wims_user
supervisable=!defof user_supervisable in $userdef
!if $wims_supertype!=2 or ($wims_user!=supervisor and $supervisable!=yes) or \
$wims_class!=$wims_superclass
error=no_subclass
!exit
!endif
!default name_supervisorname=$wims_firstname $wims_lastname
supervisor=$name_supervisorname
!if $wims_user!=supervisor
!default email=!defof user_email in $userdef
!else
!default email=!defof user_email in wimshome/log/classes/$wims_class/supervisor
!endif
!readdef wimshome/log/classes/$wims_class/.def
!default level=$class_level
cltype=1
regpolicy=all
authgood=yes
regid=!defof class_defid in wimshome/log/classes/$wims_class/.def
!for codee=1 to 1000
test=!defof class_defined in wimshome/log/classes/$wims_superclass/$codee/.def
!if $test!=yes
!break
!endif
!next codee
r_code=$wims_superclass/$codee
toomany=no
!endif $wims_user=$empty?
!if $adresse1!=$empty and $regpolicy=passwd
!read lang/mail2.proc.$modu_lang
!endif
!if $regpolicy=passwd and $regpasswd=$empty
regpolicy=all
!endif
test=0
!if $regpolicy iswordof email all passwd
test=1
!endif
!if $regpolicy!=$empty and $regpolicy notwordof\
email all deny passwd file
test=!checkhost $wims_class_regpass
!endif
!if $regpolicy=file
!if $authgood!=yes and ($regid=$empty or $regpass=$empty)
error=getid
!exit
!else
data=!defof $regid in wimshome/log/classes/.ids
!distribute items $data into prefix,regpasswd,r_name,r_expire,r_quota1,r_quota2,r_quota3,r_right
!default r_right=1
alltypes=0,2,4
!if $r_right < 3
alltypes=0,2
!endif
!if $r_right < 2
alltypes=0
!endif
!bound cltype within $alltypes default 0
!if $prefix<1000 or ($authgood!=yes and $regpasswd notsametext $regpass)
error=getid
!exit
!else
test=1
class_defined=yes
!for code2=1 to $r_quota1
deftest=!defof class_defined in wimshome/log/classes/$prefix$[1000+$code2]/.def
!if $deftest!=yes
!break
!endif
!next code2
r_remain=$[$r_quota1-$code2]
!if $deftest=yes
error=class_quota
!exit
!endif
r_code=$prefix$[1000+$code2]
!endif
!endif
defid=$regid
!else
defid=
!endif
!if $regpolicy issametext passwd and $regpasswd notsametext $regpass
error=getpass
!exit
!endif
!if $test<1
error=no_right
!exit
!endif
!if $toomany=$empty
n=!recordcnt wimshome/log/classes/.index
!if $n>=$wims_class_limit
toomany=yes
wims_module_log=Refused toomany
!exit
!endif
toomany=no
!endif
today=!char 1 to 8 of $wims_now
thisyear=!char 1 to 4 of $today
thismonth=!char 5,6 of $today
thisday=!char 7,8 of $today
!default exp_day=15
!default exp_month=08
!if $thismonth>7
!default exp_year=$[$thisyear+1]
!else
!default exp_year=$thisyear
!endif
!default limit=50
!default ilimit=50
!default level=U1
!if $step=$empty or $step=pre
!if ($regpolicy=file and $r_remain<1) or $cltype>0
step=0
!endif
!endif
!if $step=0
!reset code,password,passsup
Cltype=$cltype
!endif
!if $step=1
code=
!if $Cltype isin 24
!reset level,checklist
addcheck=,passsup
!else
addcheck=$empty
!endif
!for i in $(checklist)institution,description,firstname,lastname,email,password$addcheck
$i=!translate ,!$$"< to $ $ in $($i)
$i=!singlespace $($i)
$i=!trim $($i)
!if $($i)=$empty
error=has_empty
!exit
!endif
n=!charcnt $($i)
!if $n<$(min_$i)
error=too_short
error_subject=$i
!exit
!endif
!if $n>$(max_$i)
$i=!char 1 to $(max_$i) of $($i)
warn=too_long
warn_subject=$i
!endif
!next i
!!! can be defined in the file names.phtml.$lang if it is not the good order
!default name_username=$firstname $lastname
supervisor=$name_username
secure=!trim $secure
!if $secure!=$empty
secheck=!checkhost $secure
!if $secheck<1
error=bad_secure
!exit
!endif
!endif
ilevel=!char 1,2 of $level
!if $Cltype notin 24 and $ilevel notitemof $wims_listlevel
error=bad_level
!exit
!endif
!if $Cltype=1
listpwd=password
!else
listpwd=password,passsup
!endif
!for i in $listpwd
ptest=!text select $char_passwd in $($i)
!if $ptest != $($i)
error=bad_pass
error_subject=$i
!exit
!endif
!next i
temoin=!tolower $institution,$description
existing=!recordcnt wimshome/log/classes/.index
!for i=1 to $existing
test=!record $i of wimshome/log/classes/.index
test=!item 3 to -1 of $test
test=!replace , $ by , in $test
test=!tolower $test
!if $test=$temoin
error=existing
!exit
!endif
!next i
exp_day=!char 2,3 of $[100+abs(floor($exp_day))]
exp_month=!char 2,3 of $[100+abs(floor($exp_month))]
exp_year=!char 1 to 4 of $[abs(floor($exp_year))]
!if N isin $exp_day$exp_month$exp_year or \
$exp_day<1 or $exp_month<1 or $exp_year<$thisyear or \
$exp_day>31 or $exp_month>12 or $exp_year>$thisyear+1
error=bad_date
!exit
!endif
expiration=$exp_year$exp_month$exp_day
!if $expiration<=$today
error=anti_date
!exit
!endif
ilimit=$[abs(floor($limit))]
!if NaN isin $ilimit or $ilimit<10
ilimit=10
!endif
!if $ilimit>$wims_class_user_limit
ilimit=$wims_class_user_limit
!endif
email=!word -1 of $email
email=!translate <>,;% to $ $ in $email
!if @ notin $email
error=bad_email
!exit
!endif
mailtest=!translate @ to $\
$ in $email
mailtest=!line 2 of $mailtest
!if . notin $mailtest
error=bad_email
!exit
!endif
pword=$password
!if $Cltype=1
psup=!defof user_password in $userdef
!else
psup=!passcrypt $passsup
!endif
password=
passsup=
datasave=$institution\
$description\
$lastname\
$firstname\
$email
!exit
!endif
!if $step=2
!! the following is only for checking that in $userdef we have a crypted password.
!! is this what we really need to check ??
passsup2=!passcrypt $psup
!!## check that the uppassword is crypted
!if $password!=$pword or $passsup2!=$psup
error=pass_discord
!exit
!endif
!if $regpolicy=file or $wims_user!=$empty
code=$r_code
!else
:newcode
code=!randint 11111,10^7-1
class_defined=
!defread wimshome/log/classes/$code/.def
!if $class_defined=yes
!goto newcode
!endif
!endif
!if $regpolicy=email
!read lang/mail.proc.$modu_lang
typecode=
!exit
!else
typecode=$code
step=3
!endif
!endif
:step3
!if $step=3
!if $code=$empty or $code!=$typecode
error=bad_code
!exit
!endif
!distribute lines $datasave into \
institution,description,lastname,firstname,email
class_defined=
!defread wimshome/log/classes/$code/.def
!if $class_defined=yes
error=duplicate
!exit
!endif
!!lastname=!word -1 of $supervisor
!!firstname=!word 1 to -2 of $supervisor
!!lastname=!char 1 to 30 of $lastname
!!firstname=!char 1 to 50 of $firstname
!default name_username=$firstname $lastname
supervisor=$name_username
!if ! isin $institution$description$supervisor or \
? isin $institution$description$supervisor or \
(+134.59.102. isin +$httpd_REMOTE_ADDR and unice.fr+ notin $email+)
error=abuse
!exit
!endif
# abuse check
check=!deaccent $check
check=!lower $institution, $description, $supervisor
mask=!text mark $char_lower in $check
check=!text select $char_lower in $check
check=!text expand $check using $mask
dictionary=bases/sys/abuse.$lang
check=!exec translator $check
!if abuse iswordof $check
error=abuse
!exit
!endif
!if $wims_class!=$empty
superclass=!append item $class_superclass to $wims_class
superclass=!nonempty items $superclass
cadd_Supervisor=$wims_user
!if $wims_user!=supervisor
wims_supervise=!append item $code to $wims_supervise
!setdef !set user_supervise=$wims_supervise in $userdef
!setdef wims_supervise=$wims_supervise in wimshome/$wims_sesdir/var.stat
!endif
!else
!reset superclass
!endif
!for t in description,institution,email,lang,expiration,\
superclass,defid,secure,cas_auth
cadd_$t=$($t)
!next t
cadd_password=$pword
cadd_limit=$ilimit
cadd_level=$ilevel
cadd_type=$Cltype
cadd_typename=class
cadd_bgcolor=$wims_bgcolor
cadd_bgimg=$wims_bgimg
cadd_css=$(wims_css)
cadd_theme=$(wims_theme)
cadd_theme_icon=$(wims_theme_icon)
!if $cadd_cas_auth!=$empty
cadd_authidp=cas;
!endif
!if $superclass!=$empty
cadd_parent=$superclass
!endif
!for t in firstname,lastname,email
sadd_$t=$($t)
!next t
psup=!passcrypt $psup
sadd_password=$psup
!read adm/class/addclass $code
!defread wimshome/log/classes/$code/.def
!if $class_defined!=yes
error=define_fail
!exit
!endif
!sh $wims_home/log/classes/.build-index
!if $wims_user!=$empty
creator=$wims_class/$wims_user
!if $wims_email=$empty
!setdef !set user_email=$email in $userdef
!endif
!else
creator=$email
!endif
wims_module_log=created $code by $creator
!if $wims_user!=$empty
!restart module=home
!endif
!endif