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 | |
291 | !exit |
||
292 | !endif |
||
293 | |||
294 | !if $step=2 |
||
4803 | guerimand | 295 | passsup2=!passcrypt $psup |
296 | !if $password!=$pword or $passsup2!=$psup |
||
23 | reyssat | 297 | error=pass_discord |
298 | !exit |
||
299 | !endif |
||
300 | !if $regpolicy=file or $wims_user!=$empty |
||
301 | code=$r_code |
||
302 | !else |
||
303 | :newcode |
||
304 | code=!randint 11111,10^7-1 |
||
305 | class_defined= |
||
306 | !defread wimshome/log/classes/$code/.def |
||
307 | !if $class_defined=yes |
||
308 | !goto newcode |
||
309 | !endif |
||
310 | !endif |
||
311 | !if $regpolicy=email |
||
2346 | bpr | 312 | !read lang/mail.proc.$modu_lang |
23 | reyssat | 313 | typecode= |
314 | !exit |
||
315 | !else |
||
316 | typecode=$code |
||
317 | step=3 |
||
318 | !endif |
||
319 | !endif |
||
320 | |||
321 | :step3 |
||
322 | !if $step=3 |
||
323 | !if $code=$empty or $code!=$typecode |
||
324 | error=bad_code |
||
325 | !exit |
||
326 | !endif |
||
327 | !distribute lines $datasave into \ |
||
2568 | bpr | 328 | institution,description,lastname,firstname,email |
23 | reyssat | 329 | class_defined= |
330 | !defread wimshome/log/classes/$code/.def |
||
331 | !if $class_defined=yes |
||
332 | error=duplicate |
||
333 | !exit |
||
334 | !endif |
||
2568 | bpr | 335 | !!lastname=!word -1 of $supervisor |
336 | !!firstname=!word 1 to -2 of $supervisor |
||
337 | !!lastname=!char 1 to 30 of $lastname |
||
338 | !!firstname=!char 1 to 50 of $firstname |
||
339 | !default name_username=$firstname $lastname |
||
340 | supervisor=$name_username |
||
23 | reyssat | 341 | !if ! isin $institution$description$supervisor or \ |
342 | ? isin $institution$description$supervisor or \ |
||
343 | (+134.59.102. isin +$httpd_REMOTE_ADDR and unice.fr+ notin $email+) |
||
344 | error=abuse |
||
345 | !exit |
||
346 | !endif |
||
347 | # abuse check |
||
348 | check=!deaccent $check |
||
349 | check=!lower $institution, $description, $supervisor |
||
350 | mask=!text mark $char_lower in $check |
||
351 | check=!text select $char_lower in $check |
||
352 | check=!text expand $check using $mask |
||
2569 | bpr | 353 | dictionary=bases/sys/abuse.$lang |
23 | reyssat | 354 | check=!exec translator $check |
355 | !if abuse iswordof $check |
||
356 | error=abuse |
||
357 | !exit |
||
358 | !endif |
||
359 | !if $wims_class!=$empty |
||
360 | superclass=!append item $class_superclass to $wims_class |
||
361 | superclass=!nonempty items $superclass |
||
362 | !if $wims_user!=supervisor |
||
363 | wims_supervise=!append item $code to $wims_supervise |
||
364 | !setdef !set user_supervise=$wims_supervise in $userdef |
||
365 | !setdef wims_supervise=$wims_supervise in wimshome/$wims_sesdir/var.stat |
||
366 | !endif |
||
367 | !else |
||
368 | !reset superclass |
||
369 | !endif |
||
370 | !for t in description,institution,email,lang,expiration,\ |
||
5074 | bpr | 371 | superclass,defid,secure,cas_auth |
23 | reyssat | 372 | cadd_$t=$($t) |
373 | !next t |
||
374 | cadd_password=$pword |
||
375 | cadd_limit=$ilimit |
||
376 | cadd_level=$ilevel |
||
377 | cadd_type=$Cltype |
||
378 | cadd_typename=class |
||
379 | cadd_bgcolor=$wims_bgcolor |
||
380 | cadd_bgimg=$wims_bgimg |
||
1170 | bpr | 381 | cadd_css=$(wims_css) |
1364 | bpr | 382 | cadd_theme=$(wims_theme) |
383 | cadd_theme_icon=$(wims_theme_icon) |
||
5074 | bpr | 384 | !if $cadd_cas_auth!=$empty |
385 | cadd_authidp=cas; |
||
386 | !endif |
||
23 | reyssat | 387 | !if $superclass!=$empty |
388 | cadd_parent=$superclass |
||
389 | !endif |
||
390 | !for t in firstname,lastname,email |
||
391 | sadd_$t=$($t) |
||
392 | !next t |
||
393 | psup=!passcrypt $psup |
||
394 | sadd_password=$psup |
||
395 | !read adm/class/addclass $code |
||
396 | !defread wimshome/log/classes/$code/.def |
||
397 | !if $class_defined!=yes |
||
398 | error=define_fail |
||
399 | !exit |
||
400 | !endif |
||
401 | !sh $wims_home/log/classes/.build-index |
||
402 | !if $wims_user!=$empty |
||
403 | creator=$wims_class/$wims_user |
||
4917 | guerimand | 404 | !if $wims_email=$empty |
405 | !setdef !set user_email=$email in $userdef |
||
406 | !endif |
||
23 | reyssat | 407 | !else |
408 | creator=$email |
||
409 | !endif |
||
410 | wims_module_log=created $code by $creator |
||
4802 | guerimand | 411 | !if $wims_user!=$empty |
412 | !restart module=home |
||
413 | !endif |
||
23 | reyssat | 414 | !endif |
415 |