4images Modifications / Modifikationen > Mods & Plugins (Releases & Support)

[MOD] Birthday Mod v1.0

<< < (29/29)

FairyCosmo:

--- Quote from: thunderstrike on July 30, 2007, 07:13:20 PM ---My bad.


--- Quote ---$user_birthday = $lang['months'] . REPLACE_EMPTY . $birthday[2].", "[sprintf(REPLACE_EMPTY, $birthday[1])];

--- End quote ---

Change to:


--- Quote ---$user_birthday = $lang['months'] . REPLACE_EMPTY . $birthday[2].", [" . sprintf(REPLACE_EMPTY, $birthday[1]) . "]";

--- End quote ---

Should work now. 8)

--- End quote ---

Doesnt work. Gives out:


--- Quote ---Array 25, [ ] 1987
--- End quote ---

Aleksey:
Fixes for the [MOD] Birthday Mod v1.0 to work in gallery 1.8 on php 7

Open includes/functions.php
find:

--- Code: ---if ($valid == 1 && ($error || (!ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $birthday)))) return false;
--- End code ---
and replace with:

--- Code: ---if ($valid == 1 && ($error || (!preg_match("/([0-9]{4})-([0-9]{2})-([0-9]{2})/", $birthday)))) return false;
--- End code ---

The (ereg) function was removed from php 7, and we use (preg_match) instead.

Aleksey:
Improving the [MOD] Birthday Mod v1.0

If the user doesn't want to show the year of birth, they no longer need to enter the year 0000.
Just leave this field empty and the system will automatically enter the year 0000.

Open includes/functions.php

find:

--- Code: ---function check_birthday($birthday_day = "", $birthday_month = "", $birthday_year = "", $valid = 0) {
  $error = 0;

--- End code ---

below insert:

--- Code: ---  if (empty($birthday_year)) {
  $birthday_year = "0000";
  }

--- End code ---

The user must not enter a date of birth more than 100 years old.
The user must not enter a date of birth greater than the current year.
The check must take into account 0000 when the user hides their year of birth.

find:

--- Code: ---   else {
       $birthday = "0000-00-00";
       $error = 1;
   }

--- End code ---

below insert:

--- Code: ---//check if age is bigger than 100 or bigger current year
$today = getdate (time());
if ($birthday_year == "0000") { }
elseif (($today['year'] > (intval($birthday_year)+100)) || (intval($birthday_year) > $today['year'])) return false;

--- End code ---

By default, if the user enters the last two digits of the year, the function automatically inserts the year 19XX at the beginning.
This is wrong because there are people born in 2001.

find:

--- Code: ---      case 2:
          $birthday_year = "19$birthday_year";
          break;

--- End code ---

and replace:

--- Code: ---\\      case 2:
\\          $birthday_year = "19$birthday_year";
\\          break;

--- End code ---

Or delete it is not the correct solution.

You can make it intuitive for the user that the year can be left empty.

Open lang/<your language>/main.php
Find

--- Code: ---$lang['year'] = "year";
--- End code ---
Replace:

--- Code: ---$lang['year'] = "year (optional)";
--- End code ---

This will be displayed when registering and editing the user (control panel)

Navigation

[0] Message Index

[*] Previous page

Go to full version