Fout met geboortedatum

Voor discussies rondom phpBB2. phpBB2 wordt niet meer ondersteund en deze berichten kunnen wellicht gedateerd zijn.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
Gebruikersavatar
Inky
Berichten: 45
Lid geworden op: 07 aug 2004, 14:17
Locatie: Delft
Contacteer:

Fout met geboortedatum

Bericht door Inky » 15 mar 2005, 20:36

Ik heb mijn forum geupdate van 2.0.11 naar 2.0.13. Eerst heb ik de gewijzigde bestanden gedownload en aangepast aan de BirthdayMod hierna heb ik handmatig de files geupload naar de server. De update_to_latest.php gedraaid.

So far so good, en alles leek te werken. Ik ging even testen of mensen zich konden registreren maar als je de geboortedatum wilt invullen en je klikt ok dan krijg ik volgende foutmelding:

Code: Selecteer alles

Fatal error: Call to undefined function: mkrealdate() in /usr/home/ws/drukkerijonline/www.grafischforum.nl/www/includes/usercp_register.php on line 152
Ik heb tich keer usercp_register.php doorgelopen en vergeleken met de backup van 2.0.11 maar niks kunnen vinden wat deze fout veroorzaakt.

Weet iemand hoe ik dit kan oplossen?

Het forum is te vinden op http://www.grafischforum.nl
Forum voor de Grafimedia
http://www.grafischforum.nl

abcde
Berichten: 1494
Lid geworden op: 19 feb 2004, 16:02

Re: Fout met geboortedatum

Bericht door abcde » 15 mar 2005, 20:47

Inky schreef:

Code: Selecteer alles

Fatal error: Call to undefined function: mkrealdate() in /usr/home/ws/drukkerijonline/www.grafischforum.nl/www/includes/usercp_register.php on line 152
Plaats eens de tekst rond line 150.
Bijna 1500 posts!

Gebruikersavatar
Inky
Berichten: 45
Lid geworden op: 07 aug 2004, 14:17
Locatie: Delft
Contacteer:

Bericht door Inky » 15 mar 2005, 20:54

Dit is de code van regel 133 tot 158 van de BirthdayMod:

Code: Selecteer alles

// Start add - Birthday MOD
	if (isset($HTTP_POST_VARS['birthday']) )
	{
		$birthday = intval ($HTTP_POST_VARS['birthday']);
		if ($birthday!=999999)
		{
			$b_day = realdate('j',$birthday); 
			$b_md = realdate('n',$birthday); 
			$b_year = realdate('Y',$birthday);
		}
	} else
	{
		$b_day = ( isset($HTTP_POST_VARS['b_day']) ) ? intval ($HTTP_POST_VARS['b_day']) : 0;
		$b_md = ( isset($HTTP_POST_VARS['b_md']) ) ? intval ($HTTP_POST_VARS['b_md']) : 0;
		$b_year = ( isset($HTTP_POST_VARS['b_year']) ) ? intval ($HTTP_POST_VARS['b_year']) : 0;
		if ($b_day && $b_md && $b_year)
		{
			$birthday = mkrealdate($b_day,$b_md,$b_year);
		} else
		{
			$birthday = 999999;
		}
	}
// End add - Birthday MOD
Regel 152 is:

Code: Selecteer alles

$birthday = mkrealdate($b_day,$b_md,$b_year);
Forum voor de Grafimedia
http://www.grafischforum.nl

Gebruikersavatar
Bee
Berichten: 13403
Lid geworden op: 29 aug 2004, 10:30

Bericht door Bee » 15 mar 2005, 20:56

en functions.php ? Daar wordt die functie gedefineerd, klopt daar alles wel?
... Maar ik modereer (nog) niet.

Gebruikersavatar
Inky
Berichten: 45
Lid geworden op: 07 aug 2004, 14:17
Locatie: Delft
Contacteer:

Bericht door Inky » 15 mar 2005, 21:04

Ja, dit heb ik ook een aantal keer gecontroleerd en het enige wat erin staat wat te maken heeft met de BirthdayMod is:

Code: Selecteer alles

// 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)
{
	// 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_syntax="Ymd",$date=0) 
//{ return create_date($date_syntax,$date*86400+1,0); }

function realdate($date_syntax="Ymd",$date=0)
{
	global $lang;
	$i=2;
	if ($date>=0)
	{
	 	return create_date($date_syntax,$date*86400+1,0);
	} else
	{
		$year= -(date%1461);
		$days = $date + $year*1461;
		while ($days<0)
		{
			$year--;
			$days+=365;
			if ($i++==3)
			{
				$i=0;
				$days++;
			}
		}
	}
	$leap_year = ($i==0) ? TRUE : FALSE;
	$months_array = ($i==0) ?
		array (0,31,60,91,121,152,182,213,244,274,305,335,366) :
		array (0,31,59,90,120,151,181,212,243,273,304,334,365);
	for ($month=1;$month<12;$month++)
	{
		if ($days<$months_array[$month]) break;
	}

	$day=$days-$months_array[$month-1]+1;
	//you may gain speed performance by remove som of the below entry's if they are not needed/used
	return strtr ($date_syntax, array(
		'a' => '',
		'A' => '',
		'\\d' => 'd',
		'd' => ($day>9) ? $day : '0'.$day,
		'\\D' => 'D',
		'D' => $lang['day_short'][($date-3)%7],
		'\\F' => 'F',
		'F' => $lang['month_long'][$month-1],
		'g' => '',
		'G' => '',
		'H' => '',
		'h' => '',
		'i' => '',
		'I' => '',
		'\\j' => 'j',
		'j' => $day,
		'\\l' => 'l',
		'l' => $lang['day_long'][($date-3)%7],
		'\\L' => 'L',
		'L' => $leap_year,
		'\\m' => 'm',
		'm' => ($month>9) ? $month : '0'.$month,
		'\\M' => 'M',
		'M' => $lang['month_short'][$month-1],
		'\\n' => 'n',
		'n' => $month,
		'O' => '',
		's' => '',
		'S' => '',
		'\\t' => 't',
		't' => $months_array[$month]-$months_array[$month-1],
		'w' => '',
		'\\y' => 'y',
		'y' => ($year>29) ? $year-30 : $year+70,
		'\\Y' => 'Y',
		'Y' => $year+1970,
		'\\z' => 'z',
		'z' => $days,
		'\\W' => '',
		'W' => '') );
}
// End add - Birthday MOD

?>
Forum voor de Grafimedia
http://www.grafischforum.nl

Gesloten