diff --git a/upload/ajax/edit_user_profile.php b/upload/ajax/edit_user_profile.php index ed15289dd..c6d19ff32 100644 --- a/upload/ajax/edit_user_profile.php +++ b/upload/ajax/edit_user_profile.php @@ -81,10 +81,11 @@ switch ($field) } } else { + $value = 0; $next_birthday_greeting = 0; } DB()->query("UPDATE $table SET user_next_birthday_greeting = $next_birthday_greeting WHERE user_id = $user_id LIMIT 1"); - $this->response['new_value'] = $this->request['value']; + $this->response['new_value'] = $this->request['value']; break; case 'user_from': diff --git a/upload/config.php b/upload/config.php index 41497353b..ee213ec8e 100644 --- a/upload/config.php +++ b/upload/config.php @@ -57,8 +57,8 @@ $bb_cfg['css_ver'] = 1; // Increase number of revision after update $bb_cfg['tp_version'] = '2.0.2'; -$bb_cfg['tp_release_state'] = 'TP II r107'; -$bb_cfg['tp_release_date'] = '14-07-2011'; +$bb_cfg['tp_release_state'] = 'TP II r109'; +$bb_cfg['tp_release_date'] = '15-07-2011'; $bb_cfg['board_disabled_msg'] = 'форум временно отключен'; // 'forums temporarily disabled'; // show this msg if board has been disabled via ON/OFF trigger $bb_cfg['srv_overloaded_msg'] = "Извините, в данный момент сервер перегружен\nПопробуйте повторить запрос через несколько минут"; diff --git a/upload/includes/functions.php b/upload/includes/functions.php index 88c90480d..7460a68e6 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -2059,8 +2059,16 @@ function mkrealdate($day, $month, $birth_year) function realdate($date, $format = "Ymd") { + if(!$date) return; return bb_date($date*86400+1, $format, 0); } + +function birthday_age($date) +{ + if(!$date) return; + return delta_time(mktime(0, 0, 0, 0, 0, realdate($date, 'Y'))); +} + // // Pagination routine, generates // page number sequence diff --git a/upload/includes/ucp/usercp_register.php b/upload/includes/ucp/usercp_register.php index d635e4caf..955e28b3a 100644 --- a/upload/includes/ucp/usercp_register.php +++ b/upload/includes/ucp/usercp_register.php @@ -338,29 +338,28 @@ foreach ($profile_fields as $field => $can_edit) * Возраст (edit, reg) */ case 'user_birthday': - if($birthday = $pr_data['user_birthday']) + $b_day = (isset($_POST['b_day'])) ? (int) $_POST['b_day'] : realdate($pr_data['user_birthday'], 'j'); + $b_md = (isset($_POST['b_md'])) ? (int) $_POST['b_md'] : realdate($pr_data['user_birthday'], 'n'); + $b_year = (isset($_POST['b_year'])) ? (int) $_POST['b_year'] : realdate($pr_data['user_birthday'], 'Y'); + + if ($b_day || $b_md || $b_year) { - $b_day = (isset($_POST['b_day'])) ? (int) $_POST['b_day'] : realdate($pr_data['user_birthday'], 'j'); - $b_md = (isset($_POST['b_md'])) ? (int) $_POST['b_md'] : realdate($pr_data['user_birthday'], 'n'); - $b_year = (isset($_POST['b_year'])) ? (int) $_POST['b_year'] : realdate($pr_data['user_birthday'], 'Y'); - if ($b_day || $b_md || $b_year) + if (!checkdate($b_md, $b_day, $b_year)) { - if (!checkdate($b_md, $b_day, $b_year)) - { - $errors[] = $lang['WRONG_BIRTHDAY_FORMAT']; - } - else - { - $birthday = mkrealdate($b_day, $b_md, $b_year); - $next_birthday_greeting = (date('md') < $b_md . (($b_day <= 9) ? '0' : '') . $b_day) ? date('Y') : date('Y')+1; - } + $errors[] = $lang['WRONG_BIRTHDAY_FORMAT']; + $birthday = $next_birthday_greeting = 0; } else { - $birthday = 0; - $next_birthday_greeting = 0; + $birthday = mkrealdate($b_day, $b_md, $b_year); + $next_birthday_greeting = (date('md') < $b_md . (($b_day <= 9) ? '0' : '') . $b_day) ? date('Y') : date('Y')+1; } - } + } + else + { + $birthday = $next_birthday_greeting = 0; + } + if ($submit && $birthday != $pr_data['user_birthday']) { $pr_data['user_birthday'] = $birthday; diff --git a/upload/includes/ucp/usercp_viewprofile.php b/upload/includes/ucp/usercp_viewprofile.php index 65ddd774a..1a2142926 100644 --- a/upload/includes/ucp/usercp_viewprofile.php +++ b/upload/includes/ucp/usercp_viewprofile.php @@ -200,7 +200,7 @@ $template->assign_vars(array( 'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : '', 'GENDER' => ( $profiledata['user_gender'] ) ? $lang['GENDER_SELECT'][$profiledata['user_gender']] : '', 'BIRTHDAY' => ( $profiledata['user_birthday'] ) ? realdate($profiledata['user_birthday'], 'Y-m-d') : '', - 'AGE' => ( $profiledata['user_birthday'] ) ? bb_date(TIMENOW, 'Y') - realdate($profiledata['user_birthday'], 'Y') : '', + 'AGE' => ( $profiledata['user_birthday'] ) ? birthday_age($profiledata['user_birthday']) : '', 'AVATAR_IMG' => $avatar_img, 'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']), diff --git a/upload/templates/default/usercp_viewprofile.tpl b/upload/templates/default/usercp_viewprofile.tpl index 1e44e0b02..6ad09e6c5 100644 --- a/upload/templates/default/usercp_viewprofile.tpl +++ b/upload/templates/default/usercp_viewprofile.tpl @@ -247,9 +247,8 @@ $(document).ready(function(){