Main Page | Directories | File List | File Members

register.php File Reference

Go to the source code of this file.

Functions

 register_valid ()

Variables

nbsp


Function Documentation

register_valid  ) 
 

Definition at line 34 of file register.php.

References $confirm_hash, $G_USER, $GLOBALS, $message, $result, account_emailvalid(), account_namevalid(), account_pwvalid(), db_error(), db_insertid(), db_numrows(), db_query(), exit_error(), form_check(), form_clean(), and sendmail_mail().

00035 {
00036   global $G_USER;
00037 
00038   #### Check for duplicates
00039   if (!form_check($_POST['form_id']))
00040     { return 0; }
00041 
00042   ##### Make sure every parameters are given
00043   if (!$_POST['form_loginname'])
00044     {
00045       fb(_("You must supply a username."),1);
00046       return 0;
00047     }
00048   if (!$_POST['form_pw'])
00049     {
00050       fb(_("You must supply a password."),1);
00051       return 0;
00052     }
00053   if (!$_POST['form_email'])
00054     {
00055       fb(_("You must supply a valid email address."),1);
00056       return 0;
00057     }
00058   if (!$_POST['form_realname'])
00059     {
00060       fb(_("You must supply a non-empty real name."),1);
00061       return 0;
00062     }
00063 
00064   # Remove quotes from the realname, we do not want to allow that but
00065   # it is not a blocker issue.
00066   $GLOBALS['form_realname'] = strtr($_POST['form_realname'], "\'\"\,", "     ");
00067 
00068   if ($GLOBALS['sys_use_pamauth'] != "yes" && $_POST['form_usepam'] !=1)
00069     {
00070       # Only do password sanity checks if user does not want
00071       # to authenticate via PAM
00072       if (!$_POST['form_pw'])
00073         {
00074           fb(_("You must supply a password."),1);
00075           return 0;
00076         }
00077       if ($_POST['form_pw'] != $_POST['form_pw2'])
00078         {
00079           fb(_("Passwords do not match."),1);
00080           return 0;
00081         }
00082       if (!account_pwvalid($_POST['form_pw']))
00083         {
00084           # feedback included by the check function
00085           return 0;
00086         }
00087     }
00088 
00089   if (!account_namevalid($_POST['form_loginname']))
00090     {
00091       # feedback included by the check function
00092       return 0;
00093     }
00094 
00095 
00096   if (!account_emailvalid($_POST['form_email']))
00097     {
00098       # feedback included by the check function
00099       return 0;
00100     }
00101 
00102 
00103   ##### Avoid duplicates
00104 
00105   if (db_numrows(db_query("SELECT user_id FROM user WHERE "
00106                           . "user_name LIKE '".addslashes($_POST[form_loginname])."'")) > 0)
00107     {
00108       fb(_("That username already exists."),1);
00109       return 0;
00110     }
00111   if (db_numrows(db_query("SELECT group_list_id FROM mail_group_list WHERE "
00112                           . "list_name LIKE '".addslashes($_POST[form_loginname])."'")) > 0)
00113     {
00114       fb(_("That username is blocked to avoid conflict with mailing-list addresses."),1);
00115       return 0;
00116     }
00117 
00118   ####
00119 
00120 
00121   if ($GLOBALS['sys_use_krb5'] == "yes")
00122     {
00123       $krb5ret = krb5_login($_POST['form_loginname'], $_POST['form_pw']);
00124       if($krb5ret == -1)
00125         { # KRB5_NOTOK
00126           fb(_("phpkrb5 module failure"),1);
00127           return 0;
00128         }
00129       elseif($krb5ret == 1)
00130         { # KRB5_BAD_PASSWORD
00131             fb(sprintf(_("User is a kerberos principal but password do not match. Please use your kerberos password for the first login and then change your %s password. This is necessary to prevent someone from stealing your account name."),$GLOBALS['sys_name']),1);
00132 
00133           return 0;
00134         }
00135       elseif ($krb5ret == "2")
00136         {
00137           # KRB5_BAD_USER
00138 
00139           /*
00140 
00141 FIXME : this is broken and seems to be due to the kerberos module.
00142         we did not changed anything about that and we get 2 as return
00143         for any name.
00144 
00145           if($_POST['form_loginname']."@".$GLOBALS['sys_lists_domain'])
00146             {
00147               $GLOBALS['register_error'] = sprintf(_("User %s is a known mail alias and cannot be used. If you own this alias (%s@%s) please create a another user (for instance xx%s) and ask %s@%s to rename it to %s."),
00148                                                    $_POST['form_loginname'],
00149                                                    $_POST['form_loginname'],
00150 
00151                                                    $GLOBALS['sys_lists_domain'],
00152                                                    $_POST['form_loginname'],
00153                                                    $GLOBALS['sys_admin_list'],
00154                                                    $GLOBALS['sys_lists_domain'],
00155                                                    $_POST['form_loginname']);
00156               return 0;
00157             }
00158           */
00159         }
00160     }
00161 
00162   # if we got this far, it must be good
00163 
00164   if ($GLOBALS['sys_use_pamauth'] == "yes" && $_POST['form_usepam']==1)
00165     {
00166       # if user chose PAM based authentication, set his encrypted
00167       # password to the specified string
00168       $passwd='PAM';
00169     }
00170   else
00171     {
00172       $passwd=md5($_POST[form_pw]);
00173     }
00174 
00175   $confirm_hash = substr(md5($session_hash . $passwd . time()),0,16);
00176 
00177   $result=db_query("INSERT INTO user (user_name,user_pw,realname,email,add_date,"
00178                    . "status,confirm_hash) "
00179                    . "VALUES ('"
00180                    . addslashes(strtolower($_POST[form_loginname]))."','"
00181                    . addslashes($passwd)."','"
00182                    . addslashes($GLOBALS[form_realname])."','"
00183                    . addslashes($GLOBALS[form_email])."',"
00184                    . time().","
00185                    . "'P','" # status
00186                    . $confirm_hash."')");
00187 
00188   if (!$result)
00189     {
00190       exit_error('error',db_error());
00191     }
00192   else
00193     {
00194 
00195       $GLOBALS['newuserid'] = db_insertid($result);
00196 
00197       # clean id
00198       form_clean($form_id);
00199 
00200       # send mail
00201       $message = sprintf(_("Thank you for registering on the %s web site."),$GLOBALS['sys_name'])."\n"
00202         .sprintf(_("Your login is: %s"), addslashes(strtolower($_POST[form_loginname])))."\n\n"
00203         ._("In order to complete your registration, visit the following URL:\n\n")
00204         . $GLOBALS['sys_https_url']
00205         . $GLOBALS['sys_home']
00206         . "account/verify.php?confirm_hash=$confirm_hash\n\n"
00207         ._("Enjoy the site").".\n\n"
00208         . sprintf(_("-- the %s team.")."\n",$GLOBALS['sys_name']);
00209 
00210       if ($krb5ret == KRB5_OK)
00211         {
00212           $message .= sprintf(_("P.S. Your kerberos password is now stored in encrypted form\nin the %s database."),$GLOBALS['sys_name']);
00213           $message .= sprintf(_("For better security we advise you\nto change your %s password as soon as possible.\n"),$GLOBALS['sys_name']);
00214         }
00215 
00216 
00217       sendmail_mail($GLOBALS['sys_replyto']."@".$GLOBALS['sys_lists_domain'],
00218                     $GLOBALS['form_email'],
00219                     $GLOBALS['sys_name']." "._("Account Registration"),
00220                     $message);
00221 
00222       return 1;
00223     }
00224 }


Variable Documentation

& nbsp
 

Definition at line 250 of file register.php.

Referenced by conf_form(), format_item_attached_files(), graphs_build(), html_select_typedir_box(), maintab_separator(), my_incoming_assigned_item_list(), my_incoming_unassigned_item_list(), my_item_list(), news_show_latest(), people_show_category_list(), search_box(), sendmail_form_message(), show_item_history(), show_item_list(), show_item_list_sober(), show_newest_projects(), show_sitestats(), show_submessages(), show_thread(), show_votes(), specific_showinput(), specific_showinput_inverted(), subtab_separator(), subtab_start(), trackers_data_show_notification_settings(), and utils_unconvert_htmlspecialchars().


Generated on Sun Feb 26 13:23:05 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4