Validate welcome fusion

Modifications for phpBB3.
Try the Mods here and share Your own Mods
Forum rules
You dont have to use ModX or make your mod AutoMod compatible. A simple textfile is fine
But if you post Mods here You also have to give support

Validate welcome fusion

Post by Tigerman75 »

Hello Stoker

take this opportunity to wish you a happy new year, I have a problem with the validation Customise the welcome mod-fusion
viewtopic.php?f=52&t=2325
I have reported this problem

root/welcome_fusion.php:

Code: Select all

switch (true)
{
        case ($date < 1):
            // if the hour is 11am-12am (18-23)
            $s_welcome = sprintf($user->lang['GOOD_NIGHT'], $u_user_name);
        break;
      
         case ($date < 4):
            // if the hour is 1-3 am
            $s_welcome = sprintf($user->lang['UP_LATE'], $u_user_name);
        break;
       
        case ($date < 8):
            // if the hour is 4-7 am
            $s_welcome = sprintf($user->lang['UP_EARLY'], $u_user_name);
        break;
       
        case ($date < 12):
            // if the hour is 8-11 am
            $s_welcome = sprintf($user->lang['GOOD_MORNING'], $u_user_name);
        break;
       
        case ($date < 18):
            // if the hour is 12-5pm
            $s_welcome = sprintf($user->lang['GOOD_AFTERNOON'], $u_user_name);
        break;
       
        case ($date < 24):
            // if the hour is 6pm-11pm
            $s_welcome = sprintf($user->lang['GOOD_EVENING'], $u_user_name);
        break;
} 

// how long a member for
$member_for = '';
if ($user->data['is_registered'] && !$user->data['is_bot'])
{
    $member_length = time() - $user->data['user_regdate'];
    $years = $months = $days = 0;
    $member_for = '';
    if ($member_length)
    {   
        if ($member_length >= 31536000)
        {
            $years = floor($member_length / 31536000);
            $member_length = $member_length - ($years * 31536000);
            $member_for .= $years > 1 ? ($years . ' ' . $user->lang['WELCOME_YEARS'] . ', ') : ($years . ' ' . $user->lang['WELCOME_YEAR'] . ', ');
        }
        $months = floor($member_length / 2628000);
        if ($months)
        {
            $months = $months > 1 ? ($months . ' ' . $user->lang['WELCOME_MONTHS'] . ', ') : ($months . ' ' . $user->lang['WELCOME_MONTHS'] . ', ');
            $member_length = $member_length - ($months * 2628000);
            $member_for .= $months;
        }
        $days = floor($member_length / 86400);
        if ($days)
        {
            $days = $days > 1 ? ($days . ' ' . $user->lang['WELCOME_DAYS']) : ($days . ' ' . $user->lang['WELCOME_DAY']);
            $member_for .= $days;
        }       
    }
}
Mark wrote:
Please use constants instead of magic numbers.
how can I solve it, I have no idea on how to fix?

Thanks very much and happy new year. :)

Validate welcome fusion

Post by RMcGirr83 »

So you are submitting a mod and don't know how to fix what they are telling you to fix? How do you plan on supporting your mod if you don't know how to fix what is wrong with it?

PS magic numbers are like this one
$date < 1

Validate welcome fusion

Post by Tigerman75 »

RMcGirr83 wrote:So you are submitting a mod and don't know how to fix what they are telling you to fix? How do you plan on supporting your mod if you don't know how to fix what is wrong with it?




You're right, I apologize, but I'm learning php recently, and in my indecision, I ask you more 'experts in this language

Best reguards. :)

PS magic numbers are like this one
$date < 1
Thanks you very much RMcGirr83.