mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 06:13:58 -07:00
r106
День рождения git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@106 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
parent
bd2d7a17be
commit
8aa6a5c9c4
11 changed files with 260 additions and 18 deletions
|
@ -39,11 +39,58 @@ switch ($field)
|
|||
break;
|
||||
|
||||
case 'user_website':
|
||||
if ($value == '' || preg_match('#^https?://[a-z0-9_:;?&=/.%~\-]+$#i', $value))
|
||||
if ($value == '' || preg_match('#^https?://[\w\#!$%&~/.\-;:=,?@а-яА-Я\[\]+]+$#iu', $value))
|
||||
{
|
||||
$this->response['new_value'] = htmlCHR($value);
|
||||
}
|
||||
else $this->ajax_die('Ïîëå "Ñàéò" ìîæåò ñîäåðæàòü òîëüêî http:// ññûëêó');
|
||||
else $this->ajax_die('Поле "Сайт" может содержать только http:// ссылку');
|
||||
break;
|
||||
|
||||
case 'user_gender':
|
||||
if (!isset($lang['GENDER_SELECT'][$value]))
|
||||
{
|
||||
$this->ajax_die('error');
|
||||
}
|
||||
else
|
||||
{
$this->response['new_value'] = $lang['GENDER_SELECT'][$value];
}
|
||||
break;
|
||||
|
||||
case 'user_birthday':
|
||||
if(!$bb_cfg['birthday']['enabled']) $this->ajax_die('off');
|
||||
$data = explode('-', $value);
|
||||
$b_day = (isset($data[2])) ? (int) $data[2] : 0;
|
||||
$b_md = (isset($data[1])) ? (int) $data[1] : 0;
|
||||
$b_year = (isset($data[0])) ? (int) $data[0] : 0;
|
||||
|
||||
if($b_day || $b_md || $b_year)
|
||||
{
|
||||
if((bb_date(TIMENOW, 'Y') - $b_year) > $bb_cfg['birthday']['max_user_age'])
|
||||
{
$this->ajax_die(sprintf($lang['BIRTHDAY_TO_HIGH'], $bb_cfg['birthday']['max_user_age']));
}
|
||||
else if((bb_date(TIMENOW, 'Y') - $b_year) < $bb_cfg['birthday']['min_user_age'])
|
||||
{
|
||||
$this->ajax_die(sprintf($lang['BIRTHDAY_TO_LOW'], $bb_cfg['birthday']['min_user_age']));
|
||||
}
|
||||
if (!checkdate($b_md, $b_day, $b_year))
|
||||
{
|
||||
$this->ajax_die($lang['WRONG_BIRTHDAY_FORMAT']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = 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
|
||||
{
|
||||
$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'];
|
||||
break;
|
||||
|
||||
case 'user_from':
|
||||
case 'user_occ':
|
||||
$value = htmlCHR($value);
|
||||
$this->response['new_value'] = $value;
|
||||
break;
|
||||
|
||||
case 'user_regdate':
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
- Magnet links
|
||||
- No avatar
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
|
||||
// Advanced Report Hack
|
||||
|
@ -29,4 +29,9 @@ $bb_cfg['auto_delete_posted_pics'] = true; // Delete pictures while delete post?
|
|||
$bb_cfg['magnet_links_enabled'] = true;
|
||||
|
||||
// No avatar
|
||||
$bb_cfg['no_avatar'] = 'images/avatars/gallery/noavatar.png';
|
||||
$bb_cfg['no_avatar'] = 'images/avatars/gallery/noavatar.png';
|
||||
|
||||
// Birthday
|
||||
$bb_cfg['birthday']['enabled'] = true;
|
||||
$bb_cfg['birthday']['max_user_age'] = 100;
|
||||
$bb_cfg['birthday']['min_user_age'] = 10;
|
|
@ -1982,6 +1982,85 @@ function bb_date ($gmepoch, $format = false, $tz = null)
|
|||
return ($bb_cfg['translate_dates']) ? strtr(strtoupper($date), $lang['DATETIME']) : $date;
|
||||
}
|
||||
|
||||
// Birthday
|
||||
// Add function mkrealdate for Birthday MOD
|
||||
// the originate php "mktime()", does not work proberly on all OS, especially when going back in time
|
||||
// before year 1970 (year 0), this function "mkrealtime()", has a mutch larger valid date range,
|
||||
// from 1901 - 2099. it returns a "like" UNIX timestamp divided by 86400, so
|
||||
// calculation from the originate php date and mktime is easy.
|
||||
// mkrealdate, returns the number of day (with sign) from 1.1.1970.
|
||||
|
||||
function mkrealdate($day, $month, $birth_year)
|
||||
{
|
||||
// define epoch
|
||||
$epoch = 0;
|
||||
// range check months
|
||||
if ($month < 1 || $month > 12) return "error";
|
||||
// range check days
|
||||
switch ($month)
|
||||
{
|
||||
case 1: if ($day > 31) return "error"; break;
|
||||
case 2: if ($day > 29) return "error";
|
||||
$epoch = $epoch+31; break;
|
||||
case 3: if ($day > 31) return "error";
|
||||
$epoch = $epoch+59; break;
|
||||
case 4: if ($day > 30) return "error" ;
|
||||
$epoch = $epoch+90; break;
|
||||
case 5: if ($day > 31) return "error";
|
||||
$epoch = $epoch+120; break;
|
||||
case 6: if ($day > 30) return "error";
|
||||
$epoch = $epoch+151; break;
|
||||
case 7: if ($day > 31) return "error";
|
||||
$epoch = $epoch+181; break;
|
||||
case 8: if ($day > 31) return "error";
|
||||
$epoch = $epoch+212; break;
|
||||
case 9: if ($day > 30) return "error";
|
||||
$epoch = $epoch+243; break;
|
||||
case 10: if ($day > 31) return "error";
|
||||
$epoch = $epoch+273; break;
|
||||
case 11: if ($day > 30) return "error";
|
||||
$epoch = $epoch+304; break;
|
||||
case 12: if ($day > 31) return "error";
|
||||
$epoch = $epoch+334; break;
|
||||
}
|
||||
$epoch = $epoch+$day;
|
||||
$epoch_Y = sqrt(($birth_year-1970)*($birth_year-1970));
|
||||
$leapyear = round((($epoch_Y+2) / 4)-.5);
|
||||
if (($epoch_Y+2)%4 == 0)
|
||||
{// curent year is leapyear
|
||||
$leapyear--;
|
||||
if ($birth_year > 1970 && $month >= 3) $epoch = $epoch+1;
|
||||
if ($birth_year < 1970 && $month < 3) $epoch = $epoch-1;
|
||||
}
|
||||
else if ($month == 2 && $day > 28) return "error";//only 28 days in feb.
|
||||
//year
|
||||
if ($birth_year > 1970)
|
||||
{
|
||||
$epoch = $epoch + $epoch_Y*365-1 + $leapyear;
|
||||
}
|
||||
else
|
||||
{
|
||||
$epoch = $epoch - $epoch_Y*365-1 - $leapyear;
|
||||
}
|
||||
return $epoch;
|
||||
}
|
||||
|
||||
// Add function realdate for Birthday MOD
|
||||
// the originate php "date()", does not work proberly on all OS, especially when going back in time
|
||||
// before year 1970 (year 0), this function "realdate()", has a mutch larger valid date range,
|
||||
// from 1901 - 2099. it returns a "like" UNIX date format (only date, related letters may be used, due to the fact that
|
||||
// the given date value should already be divided by 86400 - leaving no time information left)
|
||||
// a input like a UNIX timestamp divided by 86400 is expected, so
|
||||
// calculation from the originate php date and mktime is easy.
|
||||
// e.g. realdate ("m d Y", 3) returns the string "1 3 1970"
|
||||
|
||||
// UNIX users should replace this function with the below code, since this should be faster
|
||||
//
|
||||
|
||||
function realdate($date, $format = "Ymd")
|
||||
{
|
||||
return bb_date($date*86400+1, $format, 0);
|
||||
}
|
||||
//
|
||||
// Pagination routine, generates
|
||||
// page number sequence
|
||||
|
@ -2875,7 +2954,7 @@ function clean_text_match ($text, $ltrim_star = true, $remove_stopwords = false,
|
|||
|
||||
if (!$text_match_sql && $die_if_empty)
|
||||
{
|
||||
bb_die($lang['No_search_match']);
|
||||
bb_die($lang['NO_SEARCH_MATCH']);
|
||||
}
|
||||
return $text_match_sql;
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ switch ($mode)
|
|||
'user_email' => true, // должен быть после user_password
|
||||
'user_lang' => true,
|
||||
'user_gender' => true,
|
||||
'user_birthday' => true,
|
||||
'user_timezone' => true,
|
||||
'user_opt' => true,
|
||||
'user_icq' => true,
|
||||
|
@ -321,7 +322,7 @@ foreach ($profile_fields as $field => $can_edit)
|
|||
break;
|
||||
|
||||
/**
|
||||
* Язык (edit, reg)
|
||||
* Пол (edit, reg)
|
||||
*/
|
||||
case 'user_gender':
|
||||
$gender = isset($_POST['user_gender']) ? (int) $_POST['user_gender'] : $pr_data['user_gender'];
|
||||
|
@ -330,7 +331,42 @@ foreach ($profile_fields as $field => $can_edit)
|
|||
$pr_data['user_gender'] = $gender;
|
||||
$db_data['user_gender'] = $gender;
|
||||
}
|
||||
$tp_data['USER_GENDER'] = build_select('user_gender', $lang['GENDER_SELECT'], $pr_data['user_gender']);
|
||||
$tp_data['USER_GENDER'] = build_select('user_gender', array_flip($lang['GENDER_SELECT']), $pr_data['user_gender']);
|
||||
break;
|
||||
|
||||
/**
|
||||
* Возраст (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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$birthday = 0;
|
||||
$next_birthday_greeting = 0;
|
||||
}
|
||||
}
|
||||
if ($submit && $birthday != $pr_data['user_birthday'])
|
||||
{
|
||||
$pr_data['user_birthday'] = $birthday;
|
||||
$db_data['user_birthday'] = (int) $birthday;
|
||||
$db_data['user_next_birthday_greeting'] = $next_birthday_greeting;
|
||||
}
|
||||
break;
|
||||
|
||||
/**
|
||||
|
@ -662,6 +698,33 @@ foreach ($profile_fields as $field => $can_edit)
|
|||
}
|
||||
}
|
||||
|
||||
if($bb_cfg['birthday']['enabled'] && $mode != 'register')
|
||||
{
|
||||
$days = array($lang['DELTA_TIME']['INTERVALS']['mon'][0] => 0);
|
||||
for($i=1; $i<=31; $i++)
|
||||
{
|
||||
$days[$i] = $i;
|
||||
}
|
||||
$s_birthday = build_select('b_day', $days, $b_day);
|
||||
|
||||
$months = array($lang['DELTA_TIME']['INTERVALS']['mon'][0] => 0);
|
||||
for($i=1; $i<=12; $i++)
|
||||
{
|
||||
$month = bb_date(mktime(0, 0, 0, ($i+1), 0, 0), 'F');
|
||||
$months[$month] = $i;
|
||||
}
|
||||
$s_birthday .= build_select('b_md', $months, $b_md);
|
||||
|
||||
$year = bb_date(TIMENOW, 'Y');
|
||||
$years = array($lang['DELTA_TIME']['INTERVALS']['year'][0] => 0);
|
||||
for($i=$year-$bb_cfg['birthday']['max_user_age']; $i<=$year-$bb_cfg['birthday']['min_user_age']; $i++)
|
||||
{
|
||||
$years[$i] = $i;
|
||||
}
|
||||
$s_birthday .= build_select('b_year', $years, $b_year);
|
||||
$tp_data['BIRTHDAY'] = $s_birthday;
|
||||
}
|
||||
|
||||
// submit
|
||||
if ($submit && !$errors)
|
||||
{
|
||||
|
|
|
@ -198,6 +198,9 @@ $template->assign_vars(array(
|
|||
|
||||
'OCCUPATION' => ( $profiledata['user_occ'] ) ? $profiledata['user_occ'] : '',
|
||||
'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') : '',
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
|
||||
'L_VIEWING_PROFILE' => sprintf($lang['VIEWING_USER_PROFILE'], $profiledata['username']),
|
||||
|
|
|
@ -559,10 +559,15 @@ $lang['BOARD_STYLE'] = 'Board Style';
|
|||
$lang['BOARD_LANG'] = 'Board Language';
|
||||
$lang['GENDER'] = 'Ïîë';
|
||||
$lang['GENDER_SELECT'] = array(
|
||||
'Unselect' => 0,
|
||||
'Male' => 1,
|
||||
'Female' => 2
|
||||
0 => 'Unselect',
|
||||
1 => 'Male',
|
||||
2 => 'Female'
|
||||
);
|
||||
$lang['BIRTHDAY'] = 'Birthday';
|
||||
$lang['WRONG_BIRTHDAY_FORMAT'] = 'The birthday format was entered incorrectly.';
|
||||
$lang['AGE'] = 'Age';
|
||||
$lang['BIRTHDAY_TO_HIGH'] = 'Sorry, this site, does not accept user older than %d years old';
|
||||
$lang['BIRTHDAY_TO_LOW'] = 'Sorry, this site, does not accept user yonger than %d years old';
|
||||
$lang['NO_THEMES'] = 'No Themes In database';
|
||||
$lang['TIMEZONE'] = 'Timezone';
|
||||
$lang['DATE_FORMAT_PROFILE'] = 'Date format';
|
||||
|
|
|
@ -564,10 +564,15 @@ $lang['BOARD_STYLE'] = 'Внешний вид форумов';
|
|||
$lang['BOARD_LANG'] = 'Язык';
|
||||
$lang['GENDER'] = 'Пол';
|
||||
$lang['GENDER_SELECT'] = array(
|
||||
'Не определилось' => 0,
|
||||
'Мужской' => 1,
|
||||
'Женский' => 2
|
||||
0 => 'Не определилось',
|
||||
1 => 'Мужской',
|
||||
2 => 'Женский'
|
||||
);
|
||||
$lang['BIRTHDAY'] = 'День рождения';
|
||||
$lang['WRONG_BIRTHDAY_FORMAT'] = 'Дата рождения указан не верно.';
|
||||
$lang['AGE'] = 'Возраст';
|
||||
$lang['BIRTHDAY_TO_HIGH'] = 'Извините, сайт запрещено посещать людям старше %d лет';
|
||||
$lang['BIRTHDAY_TO_LOW'] = 'Извините, сайт запрещено посещать детям младше %d лет';
|
||||
$lang['NO_THEMES'] = 'В базе нет цветовых схем';
|
||||
$lang['TIMEZONE'] = 'Часовой пояс';
|
||||
$lang['DATE_FORMAT_PROFILE'] = 'Формат даты';
|
||||
|
|
|
@ -337,6 +337,7 @@ if (!$items_found)
|
|||
}
|
||||
|
||||
// Forum
|
||||
$forum_selected = '';
|
||||
if ($var =& $_REQUEST[$forum_key])
|
||||
{
|
||||
$forum_selected = get_id_ary($var);
|
||||
|
|
|
@ -254,6 +254,15 @@ function OpenInEditor ($file, $line)
|
|||
<input type="button" class="editable-cancel" value="x" style="width: 30px;" />
|
||||
</span>
|
||||
</div>
|
||||
<div id="editable-tpl-yesno-gender" style="display: none;">
|
||||
<span class="editable-inputs nowrap" style="display: none;">
|
||||
<label><input class="editable-value" type="radio" name="editable-value" value="1">{$lang['GENDER_SELECT'][1]}</label>
|
||||
<label><input class="editable-value" type="radio" name="editable-value" value="2">{$lang['GENDER_SELECT'][2]}</label>
|
||||
<label><input class="editable-value" type="radio" name="editable-value" value="0">{$lang['GENDER_SELECT'][0]}</label>
|
||||
<input type="button" class="editable-submit" value="»" style="width: 30px; font-weight: bold;">
|
||||
<input type="button" class="editable-cancel" value="x" style="width: 30px;">
|
||||
</span>
|
||||
</div>
|
||||
<!-- ENDIF / EDITABLE_TPLS -->
|
||||
|
||||
<table id="ajax-loading" cellpadding="0" cellspacing="0"><tr><td class="icon"></td><td>Loading...</td></tr></table>
|
||||
|
|
|
@ -89,6 +89,12 @@ ajax.callback.gen_passkey = function(data){
|
|||
<td>{L_GENDER}:</td>
|
||||
<td>{USER_GENDER}</td>
|
||||
</tr>
|
||||
<!-- IF BIRTHDAY -->
|
||||
<tr>
|
||||
<td>{L_BIRTHDAY}:</td>
|
||||
<td>{BIRTHDAY}</td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<tr>
|
||||
<td>ICQ:</td>
|
||||
<td><input type="text" name="user_icq" size="30" maxlength="15" value="{USER_ICQ}" /></td>
|
||||
|
|
|
@ -74,6 +74,13 @@ $(document).ready(function(){
|
|||
<var class="ajax-params">{action: "edit_user_profile", id: "username"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "user_regdate"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "user_lastvisit"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "user_from"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "user_website"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "user_occ"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "user_interests"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "user_gender", editableType: "yesno-gender"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "user_birthday"}</var>
|
||||
|
||||
<!-- IF IGNORE_SRV_LOAD_EDIT -->
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "ignore_srv_load", editableType: "yesno-radio"}</var>
|
||||
<!-- ENDIF -->
|
||||
|
@ -206,25 +213,37 @@ $(document).ready(function(){
|
|||
<!-- IF LOCATION -->
|
||||
<tr>
|
||||
<th class="vBottom">{L_LOCATION}:</th>
|
||||
<td><b>{LOCATION}</b></td>
|
||||
<td id="user_from"><b class="editable">{LOCATION}</b></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- IF WWW -->
|
||||
<tr>
|
||||
<th>{L_WEBSITE}:</th>
|
||||
<td><b>{WWW}</b></td>
|
||||
<td id="user_website"><b class="editable">{WWW}</b></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- IF OCCUPATION -->
|
||||
<tr>
|
||||
<th>{L_OCCUPATION}:</th>
|
||||
<td><b>{OCCUPATION}</b></td>
|
||||
<td id="user_occ"><b class="editable">{OCCUPATION}</b></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- IF INTERESTS -->
|
||||
<tr>
|
||||
<th>{L_INTERESTS}:</th>
|
||||
<td><b>{INTERESTS}</b></td>
|
||||
<td id="user_interests"><b class="editable">{INTERESTS}</b></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- IF GENDER -->
|
||||
<tr>
|
||||
<th>{L_GENDER}:</th>
|
||||
<td id="user_gender"><b class="editable">{GENDER}</b></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- IF BIRTHDAY -->
|
||||
<tr>
|
||||
<th>{L_BIRTHDAY}:</th>
|
||||
<td id="user_birthday"><b class="editable">{BIRTHDAY}</b></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- BEGIN switch_upload_limits -->
|
||||
|
@ -239,7 +258,7 @@ $(document).ready(function(){
|
|||
<!-- IF SHOW_ACCESS_PRIVILEGE -->
|
||||
<tr>
|
||||
<th>{L_ACCESS}:</th>
|
||||
<td id="ignore_srv_load">{L_ACCESS_SRV_LOAD}: <span class="editable bold">{IGNORE_SRV_LOAD}</span></td>
|
||||
<td id="ignore_srv_load">{L_ACCESS_SRV_LOAD}: <b class="editable">{IGNORE_SRV_LOAD}</b></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- IF IS_AM -->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue