also wenn ich mich nicht irre funktioniert der mod nur für die v1.7
sollte es jemand bei der v1.7.1 zum laubfen bringen bitte bescheid sagen
Hallo,
also ich habe alles soweit nochmals eingebaut und es funkt. auch unter v1.7.1
Hier das MOD:
User Age Mod Readme, Version 1.0 by NicNac for 4Images 4Images/lang/<yourlanguage>/main.php
Place at the end of the file, just before the closing tag (?>):
//-----------------------------------------------------
//--- User age ----------------------------------------
//-----------------------------------------------------
$lang['user_age'] = "[Age]";
$lang['user_birthday'] = "Birthday";
$lang['user_age_missing'] = "Not available";
$lang['months'] = array(
"01" => "January",
"02" => "February",
"03" => "March",
"04" => "April",
"05" => "May",
"06" => "June",
"07" => "July",
"08" => "August",
"09" => "September",
"10" => "October",
"11" => "November",
"12" => "December",
);
4Images/includes/db_field.definitions.php
Place at the end of the file, just before the closing tag (?>):
//-----------------------------------------------------
//--- Additional fields for the user age --------------
//-----------------------------------------------------
$additional_user_fields['user_age_birthday'] = array($lang['user_age_birthday'], "text", 1);
4Images/includes/functions.php
Place at the end of the file, just before the closing tag (?>):
//-----------------------------------------------------
//--- User Age Mod ------------------------------------
//-----------------------------------------------------
function get_birthday($sql_date_string)
{
$birthday_array = array();
$birthday_array[0] = substr($sql_date_string, 0, 4);
$birthday_array[1] = substr($sql_date_string, 5, 2);
$birthday_array[2] = substr($sql_date_string, 8, 2);
return $birthday_array;
}
function get_age($year, $month, $day)
{
$age = 0;
$act_timestamp = getdate();
$age = $act_timestamp['year'] - $year;
if($month == $act_timestamp['mon'])
{
if($day > $act_timestamp['mday'])
{
--$age;
}
}
elseif($month > $act_timestamp['mon'])
{
--$age;
}
return $age;
}
function get_year()
{
$act_timestamp = getdate();
return $act_timestamp['year'];
}
4Images/member.php
Search for:
"lang_comments" => $lang['comments'],
"lang_email" => $lang['email'],
"lang_homepage" => $lang['homepage'],
"lang_icq" => $lang['icq']
Add after that:
//--- User Age Mod ------------------------------------
"lang_user_age" => $lang['user_age'],
"lang_user_birthday" => $lang['user_birthday']
//--- End of User Age Mod -----------------------------
Right after that, look for:
if (!empty($additional_user_fields)) {
$additional_field_array = array();
foreach ($additional_user_fields as $key => $val) {
$additional_field_array[$key] = (!empty($user_row[$key])) ? format_text($user_row[$key], 1) : REPLACE_EMPTY;
$additional_field_array['lang_'.$key] = $val[0];
}
if (!empty($additional_field_array)) {
$site_template->register_vars($additional_field_array);
and add directly after that:
//--- User Age Mod ------------------------------------
$birthday_array = array();
$birthday_array = get_birthday($additional_field_array['user_age_birthday']);
$birthday_array[3] = get_age($birthday_array[0], $birthday_array[1], $birthday_array[2]);
if($birthday_array[0] == "0000")
{
$site_template->register_vars(array(
"user_age_missing" => $lang['user_age_missing']
));
}
else
{
if($birthday_array[0] != "0000" && $birthday_array[1] != "00" && $birthday_array[2] != "00")
{
$birthday_timestamp = format_date($config['date_format'], strtotime($birthday_array[0] . "-" . $birthday_array[1] . "-" . $birthday_array[2]));
}
else
{
$birthday_timestamp = (($birthday_array[1] != "00") ? $lang['months'][$birthday_array[1]] . " " : "") . $birthday_array[0];
}
$site_template->register_vars(array(
"user_birthday" => $birthday_timestamp,
"user_age" => "[" . $birthday_array[3] . "]"
));
}
//--- End of User Age Mod -----------------------------
Search for:
$user_showemail = (isset($HTTP_POST_VARS['user_showemail'])) ? intval($HTTP_POST_VARS['user_showemail']) : 0;
$user_allowemails = (isset($HTTP_POST_VARS['user_allowemails'])) ? intval($HTTP_POST_VARS['user_allowemails']) : 0;
$user_invisible = (isset($HTTP_POST_VARS['user_invisible'])) ? intval($HTTP_POST_VARS['user_invisible']) : 0;
and add after that:
//--- User Age Mod ------------------------------------
$birthday = "";
($HTTP_POST_VARS['birthday_year'] != "00") ? $birthday .= $HTTP_POST_VARS['birthday_year'] : $birthday .= "0000";
($HTTP_POST_VARS['birthday_month'] != "00") ? $birthday .= "-" . $HTTP_POST_VARS['birthday_month'] : $birthday .= "-00";
($HTTP_POST_VARS['birthday_day'] != "00") ? $birthday .= "-" . $HTTP_POST_VARS['birthday_day'] : $birthday .= "-00";
//--- End of User Age Mod ------------------------------
Search for:
if (!$error) {
$additional_sql = "";
if (!empty($additional_user_fields)) {
$table_fields = $site_db->get_table_fields(USERS_TABLE);
foreach ($additional_user_fields as $key => $val) {
and add after that:
//--- User Age Mod ------------------------------------
if($key == "user_age_birthday")
{
$additional_sql .= ", $key = '" .$birthday . "'";
}
//--- End of User Age Mod -----------------------------
Right there, replace the following:
if(isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key]))
{
$additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
with this:
elseif(isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key]))
{
$additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
}
Search for:
"lang_new_password_confirm" => $lang['new_password_confirm'],
"lang_edit_profile_msg" => $edit_profile_msg,
"lang_yes" => $lang['yes'],
"lang_no" => $lang['no'],
and add after that:
//--- User Age Mod ------------------------------------
"lang_user_birthday" => $lang['user_birthday']
//--- End of User Age Mod -----------------------------
Search for:
else {
$value = (isset($HTTP_POST_VARS[$key])) ? htmlspecialchars(trim($HTTP_POST_VARS[$key])) : $user_info[$key];
}
$additional_field_array[$key] = $value;
$additional_field_array['lang_'.$key] = $val[0];
}
if (!empty($additional_field_array)) {
$site_template->register_vars($additional_field_array);
and add after that:
//--- User Age Mod ------------------------------------
$birthday_array = array();
$year_offset = 1900;
$birthday_array = get_birthday($additional_field_array['user_age_birthday']);
$birthday_dropdowns = array();
$act_year = get_year();
//The years dropdownbox
$birthday_dropdowns[0] .= "<option value=\"00\"" . (($birthday_array[0] == "00") ? " selected=\"selected\"" : "") . ">Year</option>\r\n";
$birthday_dropdowns[0] .= "<option value=\"00\">----------</option>\r\n";
for($year = $act_year; $year >= $year_offset; $year--)
{
if($year == $birthday_array[0])
{
$birthday_dropdowns[0] .= "<option value=\"" . $year . "\" selected=\"selected\">" . $year . "</option>\r\n";
}
else
{
$birthday_dropdowns[0] .= "<option value=\"" . $year . "\">" . $year . "</option>\r\n";
}
}
//The months
$birthday_dropdowns[1] .= "<option value=\"00\"" . (($birthday_array[1] == "00") ? " selected=\"selected\"" : "") . ">Month</option>\r\n";
$birthday_dropdowns[1] .= "<option value=\"00\">----------</option>\r\n";
for($month = 1; $month <= 12; $month++)
{
if($month == $birthday_array[1])
{
$birthday_dropdowns[1] .= "<option value=\"" . sprintf("%02d",$month) . "\" selected=\"selected\">" . $lang['months'][sprintf("%02d",$month)] . "</option>\r\n";
}
else
{
$birthday_dropdowns[1] .= "<option value=\"" . sprintf("%02d",$month) . "\">" . $lang['months'][sprintf("%02d",$month)] . "</option>\r\n";
}
}
//The days
$birthday_dropdowns[2] .= "<option value=\"00\"" . (($birthday_array[2] == "00") ? " selected=\"selected\"" : "") . ">Day</option>\r\n";
$birthday_dropdowns[2] .= "<option value=\"00\">----------</option>\r\n";
for($day = 1; $day <= 31; $day++)
{
if($day == $birthday_array[2])
{
$birthday_dropdowns[2] .= "<option value=\"" . sprintf("%02d",$day) . "\" selected=\"selected\">" . $day . "</option>\r\n";
}
else
{
$birthday_dropdowns[2] .= "<option value=\"" . sprintf("%02d",$day) . "\">" . $day . "</option>\r\n";
}
}
$site_template->register_vars(array(
"dropdown_year" => $birthday_dropdowns[0],
"dropdown_month" => $birthday_dropdowns[1],
"dropdown_day" => $birthday_dropdowns[2],
));
//--- End of User Age Mod -----------------------------
4Images/templates/<yourtemplate>/member_profile.html
Use this code to display each user's birthday:
<tr>
<td class="row1"><b>{lang_user_birthday}{lang_user_age}</b></td>
<td class="row1">{user_age_missing}{user_birthday} {user_age}</td>
</tr>
4Images/templates/<yourtemplate>/member_editprofile.html
Use these three boxes to allow user's to edit their birthdate:
<tr>
<td class="row1"><b>{lang_user_birthday}</b></td>
<td class="row1">
<select name="birthday_day" style="width:50px;">
{dropdown_day}
</select>
<select name="birthday_month" style="width:70px;">
{dropdown_month}
</select>
<select name="birthday_year" style="width:75px;">
{dropdown_year}
</select>
</td>
</tr>
user_age_install.php
And now please use the user_age_install.php file, after adding it to your root directory, to add the additional field to your MySQL Database.
Have Fun!
NicNac