Пример #1
0
 /**
  * create() - Create a new user.
  *
  * @param	string	The unix username.
  * @param	string	The real firstname.
  * @param	string	The real lastname.
  * @param	string	The first password.
  * @param	string	The confirmation password.
  * @param	string	The users email address.
  * @param	string	The users preferred default language.
  * @param	string	The users preferred default timezone.
  * @param	string	The users preference for receiving site updates by email.
  * @param	string	The users preference for receiving community updates by email.
  * @param	int		The ID of the language preference.
  * @param	string	The users preferred timezone.
  * @param	string	The users Jabber address.
  * @param	int		The users Jabber preference.
  * @param	int		The users theme_id.
  * @param	string	The users unix_box.
  * @param	string	The users address.
  * @param	string	The users address part 2.
  * @param	string	The users phone.
  * @param	string	The users fax.
  * @param	string	The users title.
  * @param	char(2)	The users ISO country_code.
  * @param	bool	Whether to send an email or not
  * @returns The newly created user ID
  *
  */
 function create($unix_name, $firstname, $lastname, $password1, $password2, $email, $mail_site, $mail_va, $language_id, $timezone, $jabber_address, $jabber_only, $theme_id, $unix_box = 'shell', $address = '', $address2 = '', $phone = '', $fax = '', $title = '', $ccode = 'US', $send_mail = true)
 {
     if (!$theme_id) {
         $this->setError(_('You must supply a theme'));
         return false;
     }
     if (!$unix_name) {
         $this->setError(_('You must supply a username'));
         return false;
     }
     if (!$firstname) {
         $this->setError(_('You must supply a first name'));
         return false;
     }
     if (!$lastname) {
         $this->setError(_('You must supply a last name'));
         return false;
     }
     if (!$password1) {
         $this->setError(_('You must supply a password'));
         return false;
     }
     if ($password1 != $password2) {
         $this->setError(_('Passwords do not match'));
         return false;
     }
     if (!account_pwvalid($password1)) {
         $this->setError(_('Invalid Password:'******'Invalid Unix Name.'));
         return false;
     }
     if (!validate_email($email)) {
         $this->setError(_('Invalid Email Address'));
         return false;
     }
     if ($jabber_address && !validate_email($jabber_address)) {
         $this->setError(_('Invalid Jabber Address'));
         return false;
     }
     if (!$jabber_only) {
         $jabber_only = 0;
     } else {
         $jabber_only = 1;
     }
     if (db_numrows(db_query("SELECT user_id FROM users WHERE user_name LIKE '{$unix_name}'")) > 0) {
         $this->setError(_('That username already exists.'));
         return false;
     }
     if ($GLOBALS['sys_require_unique_email']) {
         if (db_numrows(db_query("SELECT user_id FROM users WHERE email='{$email}'")) > 0) {
             $this->setError(_('User with this email already exists - use people search to recover your login.'));
             return false;
         }
     }
     // if we got this far, it must be good
     $confirm_hash = substr(md5($password1 . rand() . microtime()), 0, 16);
     db_begin();
     $sql = "INSERT INTO users (user_name,user_pw,unix_pw,realname,firstname,lastname,email,add_date,\n\t\t\tstatus,confirm_hash,mail_siteupdates,mail_va,language,timezone,jabber_address,jabber_only,\n\t\t\tunix_box,address,address2,phone,fax,title,ccode,theme_id) \n\t\t\tVALUES ('{$unix_name}',\n\t\t\t'" . md5($password1) . "',\n\t\t\t'" . account_genunixpw($password1) . "',\n\t\t\t'" . htmlspecialchars($firstname . ' ' . $lastname) . "',\n\t\t\t'" . htmlspecialchars($firstname) . "',\n\t\t\t'" . htmlspecialchars($lastname) . "',\n\t\t\t'{$email}',\n\t\t\t'" . time() . "',\n\t\t\t'P',\n\t\t\t'{$confirm_hash}',\n\t\t\t'" . ($mail_site ? "1" : "0") . "',\n\t\t\t'" . ($mail_va ? "1" : "0") . "',\n\t\t\t'{$language_id}',\n\t\t\t'{$timezone}',\n\t\t\t'{$jabber_address}',\n\t\t\t'{$jabber_only}',\n\t\t\t'{$unix_box}',\n\t\t\t'" . htmlspecialchars($address) . "',\n\t\t\t'" . htmlspecialchars($address2) . "',\n\t\t\t'" . htmlspecialchars($phone) . "',\n\t\t\t'" . htmlspecialchars($fax) . "',\n\t\t\t'" . htmlspecialchars($title) . "',\n\t\t\t'{$ccode}',\n\t\t\t'{$theme_id}')";
     $result = db_query($sql);
     if (!$result) {
         $this->setError(_('Insert Failed') . db_error() . $sql);
         db_rollback();
         return false;
     } else {
         $id = db_insertid($result, 'users', 'user_id');
         if (!$id) {
             $this->setError('Could Not Get USERID: ' . db_error());
             db_rollback();
             return false;
         }
         // send mail
         if (!$this->fetchData($id)) {
             db_rollback();
             return false;
         }
         $hook_params = array();
         $hook_params['user'] = $this;
         $hook_params['user_id'] = $this->getID();
         $hook_params['user_name'] = $unix_name;
         $hook_params['user_password'] = $password1;
         plugin_hook("user_create", $hook_params);
         if ($send_mail) {
             setup_gettext_from_lang_id($language_id);
             $this->sendRegistrationEmail();
             setup_gettext_from_browser();
         }
         db_commit();
         return $id;
     }
 }
Пример #2
0
//	Include user Theme
//
require_once $sys_themeroot . $sys_theme . '/Theme.class.php';
$HTML = new Theme();
/*

	Timezone must come after logger to prevent messups
*/
if (session_loggedin()) {
    //set up the user's timezone if they are logged in
    putenv('TZ=' . $LUSER->getTimeZone());
} else {
    //just use pacific time as always
}
/*
	Now figure out what language file to instantiate
*/
require_once $gfcommon . 'include/gettext.php';
require_once $gfcommon . 'include/group_section_texts.php';
setup_gettext_from_browser();
/*
RESERVED VARIABLES
$gfconn
$session_hash
$LUSER - Logged in user object
$HTML
*/
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
Пример #3
0
function session_continue($sessionKey)
{
    global $session_ser;
    $session_ser = $sessionKey;
    session_set();
    setup_gettext_from_browser();
    $LUSER =& session_get_user();
    if (!is_object($LUSER) || $LUSER->isError()) {
        return false;
    } else {
        putenv('TZ=' . $LUSER->getTimeZone());
        return true;
    }
}
Пример #4
0
    /**
     *	sendNewProjectNotificationEmail - Send new project notification email.
     *
     *	This function sends out a notification email to the
     *	SourceForge admin user when a new project is
     *	submitted.
     *
     *	@return	boolean	success.
     *	@access public.
     */
    function sendNewProjectNotificationEmail()
    {
        // Get the user who wants to register the project
        $res = db_query("SELECT u.user_id\n\t\t\t\t FROM users u, user_group ug\n\t\t\t\t WHERE ug.group_id='" . $this->getID() . "' AND u.user_id=ug.user_id;");
        if (db_numrows($res) < 1) {
            $this->setError(_("Could not find user who has submitted the project."));
            return false;
        }
        $submitter =& user_get_object(db_result($res, 0, 'user_id'));
        $res = db_query("SELECT users.email, users.language, users.user_id\n\t \t\t\tFROM users,user_group\n\t\t\t\tWHERE group_id=1 \n\t\t\t\tAND user_group.admin_flags='A'\n\t\t\t\tAND users.user_id=user_group.user_id;");
        if (db_numrows($res) < 1) {
            $this->setError(_("There is no administrator to send the mail."));
            return false;
        }
        for ($i = 0; $i < db_numrows($res); $i++) {
            $admin_email = db_result($res, $i, 'email');
            $admin =& user_get_object(db_result($res, $i, 'user_id'));
            setup_gettext_for_user($admin);
            $message = stripcslashes(sprintf(_('New %1$s Project Submitted

Project Full Name:  %2$s
Submitted Description: %3$s
License: %4$s
Submitter: %6$s (%7$s)

Please visit the following URL to approve or reject this project:
%5$s'), $GLOBALS['sys_name'], $this->getPublicName(), util_unconvert_htmlspecialchars($this->getRegistrationPurpose()), $this->getLicenseName(), util_make_url('/admin/approve-pending.php'), $submitter->getRealName(), $submitter->getUnixName()));
            util_send_message($admin_email, sprintf(_('New %1$s Project Submitted'), $GLOBALS['sys_name']), $message);
            setup_gettext_from_browser();
        }
        $email = $submitter->getEmail();
        setup_gettext_for_user($submitter);
        $message = stripcslashes(sprintf(_('New %1$s Project Submitted

Project Full Name:  %2$s
Submitted Description: %3$s
License: %4$s

The %1$s admin team will now examine your project submission.  You will be notified of their decision.'), $GLOBALS['sys_name'], $this->getPublicName(), util_unconvert_htmlspecialchars($this->getRegistrationPurpose()), $this->getLicenseName(), $GLOBALS['sys_default_domain']));
        util_send_message($email, sprintf(_('New %1$s Project Submitted'), $GLOBALS['sys_name']), $message);
        setup_gettext_from_browser();
        return true;
    }
 /**
  *	send_accept_mail()
  *
  */
 function send_accept_mail()
 {
     $user =& user_get_object($this->getUserId());
     setup_gettext_for_user($user);
     $subject = sprintf(_('Request to Join Project %1$s'), $this->Group->getPublicName());
     $body = sprintf(_('Your request to join the %1$s project was granted by an administrator.'), $this->Group->getPublicName());
     util_send_message($user->getEmail(), $subject, $body);
     setup_gettext_from_browser();
 }