Beispiel #1
0
 /**
  * Prepares the User's Birthday
  *
  */
 function prepare_birthday()
 {
     $userinfo =& $this->userinfo;
     $this->prepared['age'] = '';
     $this->prepared['birthday'] = '';
     if ($userinfo['birthday'] and $userinfo['showbirthday'] > 0) {
         $bday = explode('-', $userinfo['birthday']);
         $year = vbdate('Y', TIMENOW, false, false);
         $month = vbdate('n', TIMENOW, false, false);
         $day = vbdate('j', TIMENOW, false, false);
         if ($year > $bday[2] and $bday[2] != '0000' and $userinfo['showbirthday'] != 3) {
             $this->prepared['age'] = $year - $bday[2];
             if ($month < $bday[0] or $month == $bday[0] and $day < $bday[1]) {
                 $this->prepared['age']--;
             }
         }
         if ($userinfo['showbirthday'] >= 2) {
             if ($year > $bday[2] and $bday[2] > 1901 and $bday[2] != '0000' and $userinfo['showbirthday'] == 2) {
                 require_once DIR . '/includes/functions_misc.php';
                 $this->registry->options['calformat1'] = mktimefix($this->registry->options['calformat1'], $bday[2]);
                 if ($bday[2] >= 1970) {
                     $yearpass = $bday[2];
                 } else {
                     // day of the week patterns repeat every 28 years, so
                     // find the first year >= 1970 that has this pattern
                     $yearpass = $bday[2] + 28 * ceil((1970 - $bday[2]) / 28);
                 }
                 $this->prepared['birthday'] = vbdate($this->registry->options['calformat1'], mktime(0, 0, 0, $bday[0], $bday[1], $yearpass), false, true, false);
             } else {
                 // lets send a valid year as some PHP3 don't like year to be 0
                 $this->prepared['birthday'] = vbdate($this->registry->options['calformat2'], mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
             }
             if ($this->prepared['birthday'] == '') {
                 if ($bday[2] == '0000') {
                     $this->prepared['birthday'] = "{$bday['0']}-{$bday['1']}";
                 } else {
                     $this->prepared['birthday'] = "{$bday['0']}-{$bday['1']}-{$bday['2']}";
                 }
             }
         }
     }
 }
Beispiel #2
0
 if ($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canusecustomtitle']) {
     exec_switch_bg();
     if ($vbulletin->userinfo['customtitle'] == 2) {
         $vbulletin->userinfo['usertitle'] = htmlspecialchars_uni($vbulletin->userinfo['usertitle']);
     }
     $show['customtitleoption'] = true;
 } else {
     $show['customtitleoption'] = false;
 }
 require_once DIR . '/includes/functions_misc.php';
 // Set birthday required or optional
 $show['birthday_readonly'] = false;
 if ($vbulletin->options['reqbirthday']) {
     $show['birthday_required'] = true;
     if ($birthday[2] > 1901 and $birthday[2] <= date('Y') and @checkdate($birthday[0], $birthday[1], $birthday[2])) {
         $vbulletin->options['calformat1'] = mktimefix($vbulletin->options['calformat1'], $birthday[2]);
         if ($birthday[2] >= 1970) {
             $yearpass = $birthday[2];
         } else {
             // day of the week patterns repeat every 28 years, so
             // find the first year >= 1970 that has this pattern
             $yearpass = $birthday[2] + 28 * ceil((1970 - $birthday[2]) / 28);
         }
         $birthdate = vbdate($vbulletin->options['calformat1'], mktime(0, 0, 0, $birthday[0], $birthday[1], $yearpass), false, true, false);
         $show['birthday_readonly'] = true;
     }
 } else {
     $show['birthday_optional'] = true;
 }
 // Get Custom profile fields
 $customfields = array();
Beispiel #3
0
function do_register()
{
    global $vbulletin, $vbphrase, $db;
    if ($vbulletin->userinfo['userid']) {
        json_error(ERR_NO_PERMISSION);
    }
    if (!$vbulletin->options['forumrunner_enable_registration']) {
        json_error(ERR_NO_PERMISSION);
    }
    $vbulletin->input->clean_array_gpc('r', array('username' => TYPE_STR, 'email' => TYPE_STR, 'password' => TYPE_STR, 'password_md5' => TYPE_STR, 'birthday' => TYPE_STR, 'timezoneoffset' => TYPE_NUM));
    // They are registering.  Lets find out what fields are required.
    if (!$vbulletin->options['allowregistration']) {
        standard_error(fetch_error('noregister'));
    }
    $out = array();
    if ($vbulletin->GPC['username']) {
        // Registering.
        $userdata =& datamanager_init('User', $vbulletin, ERRTYPE_ARRAY);
        $vbulletin->GPC['coppauser'] = false;
        $userdata->set_info('coppauser', false);
        $userdata->set_info('coppapassword', $vbulletin->GPC['password']);
        $userdata->set_bitfield('options', 'coppauser', false);
        $userdata->set('parentemail', '');
        if (empty($vbulletin->GPC['username']) || empty($vbulletin->GPC['email']) || empty($vbulletin->GPC['password']) && empty($vbulletin->GPC['password_md5'])) {
            standard_error(fetch_error('fieldmissing'));
        }
        $vbulletin->GPC['password_md5'] = strtolower($vbulletin->GPC['password_md5']);
        $vbulletin->GPC['passwordconfirm_md5'] = strtolower($vbulletin->GPC['password_md5']);
        $userdata->set('email', $vbulletin->GPC['email']);
        $userdata->set('username', $vbulletin->GPC['username']);
        $userdata->set('password', $vbulletin->GPC['password_md5'] ? $vbulletin->GPC['password_md5'] : $vbulletin->GPC['password']);
        $userdata->set_bitfield('options', 'adminemail', 1);
        if ($vbulletin->options['verifyemail']) {
            $newusergroupid = 3;
        } else {
            if ($vbulletin->options['moderatenewmembers'] || $vbulletin->GPC['coppauser']) {
                $newusergroupid = 4;
            } else {
                $newusergroupid = 2;
            }
        }
        $userdata->set('usergroupid', $newusergroupid);
        $userdata->set('languageid', $vbulletin->userinfo['languageid']);
        $userdata->set_usertitle('', false, $vbulletin->usergroupcache["{$newusergroupid}"], false, false);
        $parts = preg_split('#/#', $vbulletin->GPC['birthday']);
        $day = $month = $year = '';
        if ($parts[1]) {
            $day = $parts[1];
        }
        if ($parts[0]) {
            $month = $parts[0];
        }
        if ($parts[2]) {
            $year = $parts[2];
        }
        $userdata->set('showbirthday', 0);
        $userdata->set('birthday', array('day' => $day, 'month' => $month, 'year' => $year));
        $dst = 2;
        $userdata->set_dst($dst);
        $userdata->set('timezoneoffset', $vbulletin->GPC['timezoneoffset']);
        // register IP address
        $userdata->set('ipaddress', IPADDRESS);
        $userdata->pre_save();
        if (count($userdata->errors)) {
            // Just return one error for now.
            json_error(strip_tags($userdata->errors[0]));
        }
        $vbulletin->userinfo['userid'] = $userid = $userdata->save();
        if ($userid) {
            $userinfo = fetch_userinfo($userid);
            $userdata_rank =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
            $userdata_rank->set_existing($userinfo);
            $userdata_rank->set('posts', 0);
            $userdata_rank->save();
            require_once DIR . '/includes/functions_login.php';
            $vbulletin->session->created = false;
            process_new_login('', false, '');
            // send new user email
            if ($vbulletin->options['newuseremail'] != '') {
                $username = $vbulletin->GPC['username'];
                $email = $vbulletin->GPC['email'];
                if ($birthday = $userdata->fetch_field('birthday')) {
                    $bday = explode('-', $birthday);
                    $year = vbdate('Y', TIMENOW, false, false);
                    $month = vbdate('n', TIMENOW, false, false);
                    $day = vbdate('j', TIMENOW, false, false);
                    if ($year > $bday[2] and $bday[2] > 1901 and $bday[2] != '0000') {
                        require_once DIR . '/includes/functions_misc.php';
                        $vbulletin->options['calformat1'] = mktimefix($vbulletin->options['calformat1'], $bday[2]);
                        if ($bday[2] >= 1970) {
                            $yearpass = $bday[2];
                        } else {
                            $yearpass = $bday[2] + 28 * ceil((1970 - $bday[2]) / 28);
                        }
                        $birthday = vbdate($vbulletin->options['calformat1'], mktime(0, 0, 0, $bday[0], $bday[1], $yearpass), false, true, false);
                    } else {
                        $birthday = vbdate($vbulletin->options['calformat2'], mktime(0, 0, 0, $bday[0], $bday[1], 1992), false, true, false);
                    }
                    if ($birthday == '') {
                        if ($bday[2] == '0000') {
                            $birthday = "{$bday['0']}-{$bday['1']}";
                        } else {
                            $birthday = "{$bday['0']}-{$bday['1']}-{$bday['2']}";
                        }
                    }
                }
                if ($userdata->fetch_field('referrerid') and $vbulletin->GPC['referrername']) {
                    $referrer = unhtmlspecialchars($vbulletin->GPC['referrername']);
                } else {
                    $referrer = $vbphrase['n_a'];
                }
                $ipaddress = IPADDRESS;
                eval(fetch_email_phrases('newuser', 0));
                $newemails = explode(' ', $vbulletin->options['newuseremail']);
                foreach ($newemails as $toemail) {
                    if (trim($toemail)) {
                        vbmail($toemail, $subject, $message);
                    }
                }
            }
            $username = htmlspecialchars_uni($vbulletin->GPC['username']);
            $email = htmlspecialchars_uni($vbulletin->GPC['email']);
            // sort out emails and usergroups
            if ($vbulletin->options['verifyemail']) {
                $activateid = build_user_activation_id($userid, ($vbulletin->options['moderatenewmembers'] or $vbulletin->GPC['coppauser']) ? 4 : 2, 0);
                eval(fetch_email_phrases('activateaccount'));
                vbmail($email, $subject, $message, true);
            } else {
                if ($newusergroupid == 2) {
                    if ($vbulletin->options['welcomemail']) {
                        eval(fetch_email_phrases('welcomemail'));
                        vbmail($email, $subject, $message);
                    }
                }
            }
            ($hook = vBulletinHook::fetch_hook('register_addmember_complete')) ? eval($hook) : false;
            // Let them log in again.
            process_logout();
            $out += array('emailverify' => $vbulletin->options['verifyemail'] ? true : false);
        }
    } else {
        $rules = preg_replace('/<a href=\\"(.*?)\\">(.*?)<\\/a>/', "\\2", $vbphrase['fr_register_forum_rules']);
        $out += array('rules' => prepare_utf8_string($rules), 'birthday' => $vbulletin->options['reqbirthday'] ? true : false);
    }
    return $out;
}