XF 1.4 Login page - Year field

flowerpot132

Active member
Does it matter how the year is formatted when registering for xenforo? The year field seems to except anything right?
 
I assume you mean 2 digits versus 4 and we do try to make a reasonable assumption as to what they mean, but it's still ambiguous.
 
I mean if you put in letters then it won't work right? Just numbers. But then it passes ok with just one number in. What are requirements of the field please? Can you put in 5 numbers?
 
Non numbers will be treated as 0 (or "coerced" to an integer if possible). Otherwise, you need to enter something that could be a valid (in terms of reasonable) date of birth for someone would could reasonably be registering on the forum.
 
So are you saying by "reason" that me as the admin could interpret that as a year? Basically, what are the field requirements? Can i enter %£&"dfdf and it is still pass.
 
I covered that initially when I commented about 2 digit years (where 1 would be 01). Internally, here's the validation code:
Code:
                $year = $this->get('dob_year');
                if (!$year)
                {
                    $year = 2008; // pick a leap year to be sure
                }
                else if ($year < 100)
                {
                    $year += ($year < 30 ? 2000 : 1900);
                    $this->set('dob_year', $year);
                }

                if ($year > intval(date('Y'))
                    || $year < 1900
                    || !checkdate($this->get('dob_month'), $this->get('dob_day'), $year)
                    || gmmktime(0, 0, 0, $this->get('dob_month'), $this->get('dob_day'), $year) > XenForo_Application::$time + 86400 // +1 day to be careful with TZs ahead of GMT
                )
                {
                    if ($this->_importMode)
                    {
                        // don't error, wipe it out
                        $this->set('dob_day', 0);
                        $this->set('dob_month', 0);
                        $this->set('dob_year', 0);
                    }
                    else
                    {
                        $this->error(new XenForo_Phrase('please_enter_valid_date_of_birth'), 'dob');
                    }

                    return false;
                }
 
Ok so you can use one digit eg 1 and that equates to 01. You can use 2 digits and that equates correctly to 12. You can three digits, and that won't work. Four digits and that equates correctly to 1986. You can use 5 digits and that won't work. You can use text, that won't work.
 
Top Bottom