Subversion Repositories wimsdev

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4015 bpr 1
 
5181 guerimand 2
!read adm/language lang/names.phtml
4015 bpr 3
!read adm/lang/date.phtml.$modu_lang
4039 bpr 4
!read adm/class/classname.phtml $description\
5
$institution
23 reyssat 6
 
7
wims_prefix=class user tmp n sharing sharable
8
!read adm/class/limits
9
wims_helper=chapter=3&open=3_creat#creat
10
!if $wims_user=$empty
11
 !bound cltype within 0,2,4 default 0
12
 !distribute items $wims_class_regpass into regpass0,regpass2,regpass4
13
 !default regpass0=email
14
 !default regpass2=$regpass0
15
 !default regpass4=deny
16
 regpolicy0=!word 1 of $regpass0
17
 regpolicy2=!word 1 of $regpass2
18
 regpolicy4=!word 1 of $regpass4
643 guerimand 19
 !distribute words $regpass0 into regpolicy, regpasswd,regpassmail
23 reyssat 20
 !if $wims_user=$empty and $cltype>0 and $regpolicy notwordof deny file
643 guerimand 21
  !distribute words $(regpass$cltype) into regpolicy, regpasswd,regpassmail
23 reyssat 22
 !endif
643 guerimand 23
 regpassmail=!replace internal | by , in $regpassmail
23 reyssat 24
 !if $wims_ismanager<2
25
  alltypes=0
26
  !if $regpolicy2 notwordof deny file
27
   alltypes=0,2
28
  !endif
29
  !if $regpolicy4 notwordof deny file and 2 isitemof $alltypes
30
  alltypes=!append item 4 to $alltypes
31
  !endif
32
  !if $regpolicy=deny
33
   error=not_manager
34
   !exit
35
  !endif
36
 !else
37
  alltypes=0,2,4
38
  regpolicy=all
39
 !endif
40
 !if $regpolicy!=file and ($step=$empty or $step=pre) and $wims_ismanager<2
41
  !exit
42
 !endif
43
!else		$wims_user!=$empty
44
 !read adm/class/userdef classes,$wims_class,$wims_user
45
 supervisable=!defof user_supervisable in $userdef
46
 !if $wims_supertype!=2 or ($wims_user!=supervisor and $supervisable!=yes) or \
47
	$wims_class!=$wims_superclass
48
  error=no_subclass
49
  !exit
50
 !endif
2568 bpr 51
 !default name_supervisorname=$wims_firstname $wims_lastname
2569 bpr 52
 supervisor=$name_supervisorname
23 reyssat 53
 !if $wims_user!=supervisor
54
  !default email=!defof user_email in $userdef
55
 !endif
56
 !readdef wimshome/log/classes/$wims_class/.def
57
 !default level=$class_level
58
 cltype=1
59
 regpolicy=all
60
 authgood=yes
61
 regid=!defof class_defid in wimshome/log/classes/$wims_class/.def
62
 !for codee=1 to 1000
63
  test=!defof class_defined in wimshome/log/classes/$wims_superclass/$codee/.def
64
  !if $test!=yes
65
   !break
66
  !endif
67
 !next codee
68
 r_code=$wims_superclass/$codee
69
 toomany=no
70
!endif		$wims_user=$empty?
71
 
643 guerimand 72
!if $adresse1!=$empty and $regpolicy=passwd
2346 bpr 73
 !read lang/mail2.proc.$modu_lang
643 guerimand 74
!endif
75
 
23 reyssat 76
!if $regpolicy=passwd and $regpasswd=$empty
77
 regpolicy=all
78
!endif
79
 
80
test=0
81
!if $regpolicy iswordof email all passwd
82
 test=1
83
!endif
84
 
85
!if $regpolicy!=$empty and $regpolicy notwordof\
86
	email all deny passwd file
87
 test=!checkhost $wims_class_regpass
88
!endif
89
!if $regpolicy=file
90
 !if $authgood!=yes and ($regid=$empty or $regpass=$empty)
91
  error=getid
92
  !exit
93
 !else
94
  data=!defof $regid in wimshome/log/classes/.ids
95
  !distribute items $data into prefix,regpasswd,r_name,r_expire,r_quota1,r_quota2,r_quota3,r_right
96
  !default r_right=1
97
  alltypes=0,2,4
98
  !if $r_right < 3
99
   alltypes=0,2
100
  !endif
101
  !if $r_right < 2
102
   alltypes=0
103
  !endif
104
  !bound cltype within $alltypes default 0
105
  !if $prefix<1000 or ($authgood!=yes and $regpasswd notsametext $regpass)
106
   error=getid
107
   !exit
108
  !else
109
   test=1
110
   class_defined=yes
111
   !for code2=1 to $r_quota1
112
    deftest=!defof class_defined in wimshome/log/classes/$prefix$[1000+$code2]/.def
113
    !if $deftest!=yes
114
     !break
115
    !endif
116
   !next code2
117
   r_remain=$[$r_quota1-$code2]
118
   !if $deftest=yes
119
    error=class_quota
120
    !exit
121
   !endif
122
   r_code=$prefix$[1000+$code2]
123
  !endif
124
 !endif
125
 defid=$regid
126
!else
127
 defid=
128
!endif
129
 
130
!if $regpolicy issametext passwd and $regpasswd notsametext $regpass
131
 error=getpass
132
 !exit
133
!endif
5181 guerimand 134
 
23 reyssat 135
!if $test<1
136
 error=no_right
137
 !exit
138
!endif
139
!if $toomany=$empty
140
 n=!recordcnt wimshome/log/classes/.index
141
 !if $n>=$wims_class_limit
142
  toomany=yes
143
  wims_module_log=Refused toomany
144
  !exit
145
 !endif
146
 toomany=no
147
!endif
148
 
149
today=!char 1 to 8 of $wims_now
150
thisyear=!char 1 to 4 of $today
151
thismonth=!char 5,6 of $today
152
thisday=!char 7,8 of $today
153
!default exp_day=15
154
!default exp_month=08
155
!if $thismonth>7
156
 !default exp_year=$[$thisyear+1]
157
!else
158
 !default exp_year=$thisyear
159
!endif
160
!default limit=50
161
!default ilimit=50
162
!default level=U1
163
!if $step=$empty or $step=pre
164
 !if ($regpolicy=file and $r_remain<1) or $cltype>0
165
  step=0
166
 !endif
167
!endif
168
 
169
!if $step=0
170
 !reset code,password,passsup
171
 Cltype=$cltype
172
!endif
4803 guerimand 173
 
23 reyssat 174
!if $step=1
175
 code=
486 guerimand 176
 !if $Cltype isin 24
23 reyssat 177
  !reset level,checklist
4803 guerimand 178
  addcheck=,passsup
179
 !else
180
  addcheck=$empty
23 reyssat 181
 !endif
4803 guerimand 182
 
183
 !for i in $(checklist)institution,description,firstname,lastname,email,password$addcheck
23 reyssat 184
  $i=!translate ,!$$"< to $     $ in $($i)
185
  $i=!singlespace $($i)
186
  $i=!trim $($i)
187
  !if $($i)=$empty
188
   error=has_empty
189
   !exit
190
  !endif
191
  n=!charcnt $($i)
192
  !if $n<$(min_$i)
193
   error=too_short
194
   error_subject=$i
195
   !exit
196
  !endif
197
  !if $n>$(max_$i)
198
   $i=!char 1 to $(max_$i) of $($i)
199
   warn=too_long
200
   warn_subject=$i
201
  !endif
202
 !next i
2568 bpr 203
 !!! can be defined in the file names.phtml.$lang if it is not the good order
204
 !default name_username=$firstname $lastname
205
 supervisor=$name_username
23 reyssat 206
 secure=!trim $secure
207
 !if $secure!=$empty
208
  secheck=!checkhost $secure
209
  !if $secheck<1
210
   error=bad_secure
211
   !exit
212
  !endif
213
 !endif
214
 ilevel=!char 1,2 of $level
486 guerimand 215
 !if $Cltype notin 24 and $ilevel notitemof $levelid
23 reyssat 216
  error=bad_level
217
  !exit
218
 !endif
4803 guerimand 219
 !if $Cltype=1
220
  listpwd=password
221
 !else
222
  listpwd=password,passsup
223
 !endif
224
 !for i in $listpwd
23 reyssat 225
  ptest=!text select $char_passwd in $($i)
226
  !if $ptest != $($i)
227
   error=bad_pass
228
   error_subject=$i
229
   !exit
230
  !endif
231
 !next i
232
 temoin=!tolower $institution,$description
233
 existing=!recordcnt wimshome/log/classes/.index
234
 !for i=1 to $existing
235
  test=!record $i of wimshome/log/classes/.index
236
  test=!item 3 to -1 of $test
237
  test=!replace , $ by , in $test
238
  test=!tolower $test
239
  !if $test=$temoin
240
   error=existing
241
   !exit
242
  !endif
243
 !next i
244
 exp_day=!char 2,3 of $[100+abs(floor($exp_day))]
245
 exp_month=!char 2,3 of $[100+abs(floor($exp_month))]
246
 exp_year=!char 1 to 4 of $[abs(floor($exp_year))]
247
 !if N isin $exp_day$exp_month$exp_year or \
248
	$exp_day<1 or $exp_month<1 or $exp_year<$thisyear or \
249
	$exp_day>31 or $exp_month>12 or $exp_year>$thisyear+1
250
  error=bad_date
251
  !exit
252
 !endif
253
 expiration=$exp_year$exp_month$exp_day
254
 !if $expiration<=$today
255
  error=anti_date
256
  !exit
257
 !endif
258
 ilimit=$[abs(floor($limit))]
259
 !if NaN isin $ilimit or $ilimit<10
260
  ilimit=10
261
 !endif
262
 !if $ilimit>$wims_class_user_limit
263
  ilimit=$wims_class_user_limit
264
 !endif
265
 email=!word -1 of $email
266
 email=!translate <>,;% to $     $ in $email
267
 !if @ notin $email
268
  error=bad_email
269
  !exit
270
 !endif
271
 mailtest=!translate @ to $\
272
$ in $email
273
 mailtest=!line 2 of $mailtest
274
 !if . notin $mailtest
275
  error=bad_email
276
  !exit
277
 !endif
278
 pword=$password
4803 guerimand 279
 !if $Cltype=1
280
  psup=!defof user_password in $userdef
281
 !else
282
  psup=!passcrypt $passsup
283
 !endif
23 reyssat 284
 password=
285
 passsup=
286
 datasave=$institution\
287
$description\
2568 bpr 288
$lastname\
289
$firstname\
23 reyssat 290
$email
291
 !exit
292
!endif
293
 
294
!if $step=2
5343 czzmrn 295
!! the following is only for checking that in $userdef we have a crypted password.
296
!! is this what we really need to check ??
4803 guerimand 297
 passsup2=!passcrypt $psup
298
 !if $password!=$pword or $passsup2!=$psup
23 reyssat 299
  error=pass_discord
300
  !exit
301
 !endif
302
 !if $regpolicy=file or $wims_user!=$empty
303
  code=$r_code
304
 !else
305
  :newcode
306
  code=!randint 11111,10^7-1
307
  class_defined=
308
  !defread wimshome/log/classes/$code/.def
309
  !if $class_defined=yes
310
   !goto newcode
311
  !endif
312
 !endif
313
 !if $regpolicy=email
2346 bpr 314
  !read lang/mail.proc.$modu_lang
23 reyssat 315
  typecode=
316
  !exit
317
 !else
318
  typecode=$code
319
  step=3
320
 !endif
321
!endif
322
 
323
:step3
324
!if $step=3
325
 !if $code=$empty or $code!=$typecode
326
  error=bad_code
327
  !exit
328
 !endif
329
 !distribute lines $datasave into \
2568 bpr 330
   institution,description,lastname,firstname,email
23 reyssat 331
 class_defined=
332
 !defread wimshome/log/classes/$code/.def
333
 !if $class_defined=yes
334
  error=duplicate
335
  !exit
336
 !endif
2568 bpr 337
 !!lastname=!word -1 of $supervisor
338
 !!firstname=!word 1 to -2 of $supervisor
339
 !!lastname=!char 1 to 30 of $lastname
340
 !!firstname=!char 1 to 50 of $firstname
341
 !default name_username=$firstname $lastname
342
 supervisor=$name_username
23 reyssat 343
 !if ! isin $institution$description$supervisor or \
344
	? isin $institution$description$supervisor or \
345
	(+134.59.102. isin +$httpd_REMOTE_ADDR and unice.fr+ notin $email+)
346
  error=abuse
347
  !exit
348
 !endif
349
 # abuse check
350
 check=!deaccent $check
351
 check=!lower $institution, $description, $supervisor
352
 mask=!text mark $char_lower in $check
353
 check=!text select $char_lower in $check
354
 check=!text expand $check using $mask
2569 bpr 355
 dictionary=bases/sys/abuse.$lang
23 reyssat 356
 check=!exec translator $check
357
 !if abuse iswordof $check
358
  error=abuse
359
  !exit
360
 !endif
361
 !if $wims_class!=$empty
362
  superclass=!append item $class_superclass to $wims_class
363
  superclass=!nonempty items $superclass
364
  !if $wims_user!=supervisor
365
   wims_supervise=!append item $code to $wims_supervise
366
   !setdef !set user_supervise=$wims_supervise in $userdef
367
   !setdef wims_supervise=$wims_supervise in wimshome/$wims_sesdir/var.stat
368
  !endif
369
 !else
370
  !reset superclass
371
 !endif
372
 !for t in description,institution,email,lang,expiration,\
5074 bpr 373
	superclass,defid,secure,cas_auth
23 reyssat 374
  cadd_$t=$($t)
375
 !next t
376
 cadd_password=$pword
377
 cadd_limit=$ilimit
378
 cadd_level=$ilevel
379
 cadd_type=$Cltype
380
 cadd_typename=class
381
 cadd_bgcolor=$wims_bgcolor
382
 cadd_bgimg=$wims_bgimg
1170 bpr 383
 cadd_css=$(wims_css)
1364 bpr 384
 cadd_theme=$(wims_theme)
385
 cadd_theme_icon=$(wims_theme_icon)
5074 bpr 386
 !if $cadd_cas_auth!=$empty
387
   cadd_authidp=cas;
388
 !endif
23 reyssat 389
 !if $superclass!=$empty
390
  cadd_parent=$superclass
391
 !endif
392
 !for t in firstname,lastname,email
393
  sadd_$t=$($t)
394
 !next t
395
 psup=!passcrypt $psup
396
 sadd_password=$psup
397
 !read adm/class/addclass $code
398
 !defread wimshome/log/classes/$code/.def
399
 !if $class_defined!=yes
400
  error=define_fail
401
  !exit
402
 !endif
403
 !sh $wims_home/log/classes/.build-index
404
 !if $wims_user!=$empty
405
  creator=$wims_class/$wims_user
4917 guerimand 406
  !if $wims_email=$empty
407
   !setdef !set user_email=$email in $userdef
408
  !endif
23 reyssat 409
 !else
410
  creator=$email
411
 !endif
412
 wims_module_log=created $code by $creator
4802 guerimand 413
 !if $wims_user!=$empty
414
  !restart module=home
415
 !endif
23 reyssat 416
!endif
417