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