[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - Registration * 4 * http://www.eGroupWare.org * 5 * This application written by Joseph Engo <jengo@phprgoupware.org> * 6 * Modified by Jason Wies (Zone) <zone@users.sourceforge.net> * 7 * Modified by Loic Dachary <loic@gnu.org> * 8 * Modified by Pim Snel <pim@egroupware.org> * 9 * -------------------------------------------- * 10 * Funding for this program was provided by http://www.checkwithmom.com * 11 * -------------------------------------------- * 12 * This program is free software; you can redistribute it and/or modify it * 13 * under the terms of the GNU General Public License as published by the * 14 * Free Software Foundation; either version 2 of the License, or (at your * 15 * option) any later version. * 16 \**************************************************************************/ 17 18 /* $Id: class.boreg.inc.php 20049 2005-11-29 12:08:25Z nelius_weiss $ */ 19 20 class boreg 21 { 22 var $template; 23 var $bomanagefields; 24 var $fields; 25 var $so; 26 var $lang_code; 27 var $reg_id; 28 var $public_functions = array( 29 'step1' => True, 30 'step2' => True, 31 'step4' => True, 32 'lostpw1' => True, 33 'lostpw2' => True, 34 'lostpw3' => True, 35 'lostid1' => True, 36 ); 37 38 function boreg() 39 { 40 $this->so =& CreateObject ('registration.soreg'); 41 $this->bomanagefields =& CreateObject ('registration.bomanagefields'); 42 $this->fields = $this->bomanagefields->get_field_list (); 43 44 $_reg_id=$_GET['reg_id']?$_GET['reg_id']:$_POST['reg_id']; 45 $this->reg_id=$_reg_id?$_reg_id:''; 46 47 // replace the old lang_code with this 48 // $_lang_code=($_GET['lang_code']?$_GET['lang_code']:$_POST['lang_code']); 49 // $this->lang_code=($_lang_code?$_lang_code:''); 50 51 } 52 53 function step1() 54 { 55 //global $config; 56 57 $r_reg=$_REQUEST['r_reg']; 58 59 $so =& CreateObject('registration.soreg'); 60 $ui =& CreateObject('registration.uireg'); 61 62 if($_POST['langchanged']=='true') 63 { 64 $ui->step1('',$r_reg,$o_reg); 65 exit; 66 } 67 68 if (! $r_reg['loginid']) 69 { 70 $errors[] = lang('You must enter a username'); 71 } 72 73 if (! is_array($errors) && $so->account_exists($r_reg['loginid'])) 74 { 75 $errors[] = lang('Sorry, that username is already taken.'); 76 } 77 78 if (is_array($errors)) 79 { 80 $ui->step1($errors,$r_reg,$o_reg); 81 } 82 else 83 { 84 $GLOBALS['egw']->session->appsession('loginid','registration',$r_reg['loginid']); 85 86 87 $ui->step2(); 88 } 89 } 90 91 function step2() 92 { 93 global $config, $r_reg, $o_reg; 94 95 $r_reg=$_POST['r_reg']; 96 $o_reg=$_POST['o_reg']; 97 98 $lang_to_pass=$r_reg['lang_code']; 99 $ui =& CreateObject('registration.uireg'); 100 $ui->set_lang_code($lang_to_pass); 101 102 //where is this for???? 103 if ($config['password_is'] == 'http') 104 { 105 $r_reg['passwd'] = $r_reg['passwd_confirm'] = $_SERVER['PHP_AUTH_PW']; 106 } 107 108 if (($config['display_tos']) && ! $r_reg['tos_agree']) 109 { 110 $missing_fields[] = 'tos_agree'; 111 } 112 113 while (list($name,$value) = each($r_reg)) 114 { 115 if (! $value) 116 { 117 $missing_fields[] = $name; 118 } 119 $fields[$name] = $value; 120 } 121 122 reset($r_reg); 123 124 if ($r_reg['adr_one_countryname'] == ' ') 125 { 126 $missing_fields[] = 'adr_one_countryname'; 127 } 128 129 if ($r_reg['passwd'] != $r_reg['passwd_confirm']) 130 { 131 $errors[] = lang("The passwords you entered don't match"); 132 $missing_fields[] = 'passwd'; 133 $missing_fields[] = 'passwd_confirm'; 134 } 135 136 reset ($this->fields); 137 while (list (,$field_info) = each ($this->fields)) 138 { 139 $name = $field_info['field_name']; 140 $text = $field_info['field_text']; 141 $values = explode (',', $field_info['field_values']); 142 $required = $field_info['field_required']; 143 $type = $field_info['field_type']; 144 145 if ($required == 'Y') 146 { 147 $a = $r_reg; 148 } 149 else 150 { 151 $a = $o_reg; 152 } 153 154 $post_value = $a[$name]; 155 156 if ($type == 'email') 157 { 158 if ($post_value && (!ereg ('@', $post_value) || ! ereg ("\.", $post_value))) 159 { 160 if ($required == 'Y') 161 { 162 $errors[] = lang('You have entered an invalid email address'); 163 $missing_fields[] = $name; 164 } 165 } 166 } 167 168 if ($type == 'birthday') 169 { 170 if (!checkdate ((int) $a[$name . '_month'], (int) $a[$name . '_day'], (int) $a[$name . '_year'])) 171 { 172 if ($required == 'Y') 173 { 174 $errors[] = lang ('You have entered an invalid birthday'); 175 $missing_fields[] = $name; 176 } 177 } 178 else 179 { 180 $a[$name] = sprintf ('%s/%s/%s', $a[$name . '_month'], $a[$name . '_day'], $a[$name . '_year']); 181 } 182 } 183 184 if ($type == 'dropdown') 185 { 186 if ($post_value) 187 { 188 while (list (,$value) = each ($values)) 189 { 190 if ($value == $post_value) 191 { 192 $ok = 1; 193 } 194 } 195 196 if (!$ok) 197 { 198 $errors[] = lang ('You specified a value for %1 that is not a choice',$text); 199 200 $missing_fields[] = $name; 201 } 202 } 203 } 204 } 205 206 while (is_array($o_reg) && list($name,$value) = each($o_reg)) 207 { 208 $fields[$name] = $value; 209 } 210 211 if (is_array ($o_reg)) 212 { 213 reset($o_reg); 214 } 215 216 if (is_array($missing_fields)) 217 { 218 $errors[] = lang('You must fill in all of the required fields'); 219 } 220 221 if (! is_array($errors)) 222 { 223 $so =& CreateObject('registration.soreg'); 224 // only send mail if activation requires it 225 $reg_id = $so->step2($fields,$config['activate_account'] == 'email'); 226 } 227 228 if (is_array($errors)) 229 { 230 $ui->step2($errors,$r_reg,$o_reg,$missing_fields); 231 } 232 else 233 { 234 $GLOBALS['egw']->redirect($GLOBALS['egw']->link('/registration/index.php','menuaction=registration.uireg.ready_to_activate&lang_code='.$lang_to_pass.'®_id=' . $reg_id)); 235 } 236 } 237 238 function step4() 239 { 240 $so =& CreateObject('registration.soreg'); 241 $ui =& CreateObject('registration.uireg'); 242 243 $reg_info = $so->valid_reg($this->reg_id); 244 245 if (! is_array($reg_info)) 246 { 247 $vars['error_msg']=lang('Sorry, we are having a problem activating your account. Note that links sent by e-mail are only valid during two hours. If you think this delay was expired, just retry. Otherwise, please contact the site administrator.'); 248 $ui->simple_screen('error_confirm.tpl','',$vars); 249 return False; 250 } 251 252 $so->create_account($reg_info['reg_lid'],$reg_info['reg_info']); 253 $so->delete_reg_info($this->reg_id); 254 setcookie('sessionid'); 255 setcookie('kp3'); 256 setcookie('domain'); 257 $ui->welcome_screen(); 258 } 259 260 // 261 // username 262 // 263 function lostpw1() 264 { 265 //var $r_reg; 266 267 $r_reg = $_REQUEST['r_reg'] ; 268 $so =& CreateObject('registration.soreg'); 269 270 if (! $r_reg['loginid']) 271 { 272 $errors[] = lang('You must enter a username'); 273 } 274 if (! is_array($errors) && !$GLOBALS['egw']->accounts->exists($r_reg['loginid'])) 275 { 276 $errors[] = lang('Sorry, that username does not exist.'); 277 } 278 279 if(! is_array($errors)) 280 { 281 $error = $so->lostpw1($r_reg['loginid']); 282 if($error) 283 { 284 $errors[] = $error; 285 } 286 } 287 288 $ui =& CreateObject('registration.uireg'); 289 if (is_array($errors)) 290 { 291 $ui->lostpw1($errors,$r_reg); 292 } 293 else 294 { 295 // Redirect them so they don't hit refresh and make a mess 296 $GLOBALS['egw']->redirect($GLOBALS['egw']->link('/registration/index.php','menuaction=registration.uireg.email_sent_lostpw')); 297 } 298 } 299 300 // 301 // link sent by mail 302 // 303 function lostpw2() 304 { 305 306 $so =& CreateObject('registration.soreg'); 307 $ui =& CreateObject('registration.uireg'); 308 $reg_info = $so->valid_reg($this->reg_id); 309 310 if (! is_array($reg_info)) 311 { 312 $ui->simple_screen('error_confirm.tpl'); 313 return False; 314 } 315 316 $so->lostpw2($reg_info['reg_lid']); 317 318 $ui->lostpw3('', '', $reg_info['reg_lid']); 319 return True; 320 } 321 322 // 323 // new password 324 // 325 function lostpw3() 326 { 327 //var $r_reg; 328 $r_reg = $_REQUEST['r_reg'] ; 329 330 $lid = $GLOBALS['egw']->session->appsession('loginid','registration'); 331 if(!$lid) { 332 $error[] = lang('Wrong session'); 333 } 334 335 if ($r_reg['passwd'] != $r_reg['passwd_2']) 336 { 337 $errors[] = lang('The two passwords are not the same'); 338 } 339 340 if (! $r_reg['passwd']) 341 { 342 $errors[] = lang('You must enter a password'); 343 } 344 345 if(! is_array($errors)) 346 { 347 $so =& CreateObject('registration.soreg'); 348 $so->lostpw3($lid, $r_reg['passwd']); 349 } 350 351 $ui =& CreateObject('registration.uireg'); 352 353 if (is_array($errors)) 354 { 355 $ui->lostpw3($errors, $r_reg, $lid); 356 } 357 else 358 { 359 $ui->lostpw4(); 360 } 361 362 return True; 363 } 364 365 function check_select_username () 366 { 367 global $config; 368 369 if ($config['username_is'] == 'choice') 370 { 371 return True; 372 } 373 elseif ($config['username_is'] == 'http') 374 { 375 if (!$_SERVER['PHP_AUTH_USER']) 376 { 377 return "HTTP username is not set"; 378 } 379 else 380 { 381 $GLOBALS['egw']->redirect ($GLOBALS['egw']->link ('/registration/index.php', 'menuaction=registration.boreg.step1&r_reg[loginid]=' . $_SERVER['PHP_AUTH_USER'])); 382 } 383 } 384 385 return True; 386 } 387 388 function lostid1() 389 { 390 //var $config; 391 $r_reg = $_REQUEST['r_reg'] ; 392 $so =& CreateObject('registration.soreg'); 393 394 if (! $r_reg['email']) 395 { 396 $errors[] = lang('You must enter an email account'); 397 } 398 if (! is_array($errors)) 399 { 400 $userids=$GLOBALS['egw']->accounts->name2id($email,'account_email'); 401 if (count($userids) == 0) 402 { 403 $errors[] = lang('Sorry, no account exists for '.$r_reg['email']); 404 } 405 } 406 407 if(! is_array($errors)) 408 { 409 $error = $so->lostid1($r_reg['email']); 410 if($error) 411 { 412 $errors[] = $error; 413 } 414 } 415 416 $ui =& CreateObject('registration.uireg'); 417 if (is_array($errors)) 418 { 419 $ui->lostid1($errors,$r_reg); 420 } 421 else 422 { 423 $ui->email_sent_lostid($r_reg['email']); 424 } 425 } 426 427 function check_select_password () 428 { 429 global $config; 430 431 if ($config['password_is'] == 'choice') 432 { 433 return True; 434 } 435 elseif ($config['password_is'] == 'http') 436 { 437 if (!$_SERVER['PHP_AUTH_PW']) 438 { 439 return "HTTP password is not set"; 440 } 441 else 442 { 443 return False; 444 } 445 } 446 447 return True; 448 } 449 450 function check_challenge() 451 { 452 return True; 453 } 454 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |