Zakaz wstępu dla użytkowników poniżej XX roku życia

Zaczęty przez LukaszP, 2 Grudzień 2005, 21:42

0 użytkowników i 1 Gość przegląda ten wątek.

LukaszP

Modyfikacja działa oczywiście w oparciu o wiek w profilu użytkownika.

Plik: Sources/Load.php

Znajdź:
'time_offset' => empty($user_settings['timeOffset']) ? 0 : $user_settings['timeOffset'],

Poniżej dodaj:
'birthdate' => empty($user_settings['birthdate']) ? 0 : $user_settings['birthdate'],


Plik: Sources/MessageIndex.php

Znajdź:
if (WIRELESS)
$context['sub_template'] = WIRELESS_PROTOCOL . '_messageindex';
else
loadTemplate('MessageIndex')


Poniżej dodaj:


    if ($board == '20')
    {
        if (!empty($user_info['birthdate']))
{
            if ($user_info['birthdate'] != '0000-00-00')
            {
list ($birth_year, $birth_month, $birth_day) = sscanf($user_info['birthdate'], '%d-%d-%d');
$datearray = getdate(forum_time());
$user_info += array(
'age' => empty($birth_year) ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
                'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
            }
            else
{
                $user_info['age'] = '0';
            }
}
       
        if ((@$user_info['age'] < '18') && (!$user_info['is_admin']))
            fatal_error('Przepraszamy, ale musisz mieć powyżej 18 lat!', false);
    }

Plik: Sources/Display.php

Znajdź:
// Load the proper template and/or sub template.
if (WIRELESS)
$context['sub_template'] = WIRELESS_PROTOCOL . '_display';
else
loadTemplate('Display');


Ponizej dodaj:

    if ($board == '20')
    {
        if (!empty($user_info['birthdate']))
{
            if ($user_info['birthdate'] != '0000-00-00')
            {
list ($birth_year, $birth_month, $birth_day) = sscanf($user_info['birthdate'], '%d-%d-%d');
$datearray = getdate(forum_time());
$user_info += array(
'age' => empty($birth_year) ? $txt[470] : $datearray['year'] - $birth_year - (($datearray['mon'] > $birth_month || ($datearray['mon'] == $birth_month && $datearray['mday'] >= $birth_day)) ? 0 : 1),
                'today_is_birthday' => $datearray['mon'] == $birth_month && $datearray['mday'] == $birth_day
);
            }
     else
            {
                $user_info['age'] = '0';
            }
}
       
        if ((@$user_info['age'] < '18') && (!$user_info['is_admin']))
            fatal_error('Przepraszamy, ale musisz mieć powyżej 18 lat!', false);
    }


Wiek można ustalić dowolnie, 3 linijki wyżej tu (18), zaś dział w pierwszej lini modyfikacji.. (tu 20) dla obu plików!