Install of 2.0.21 completed successfully but error anyway?

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Locked
aelunii
Registered User
Posts: 29
Joined: Tue Dec 07, 2004 7:10 pm

Install of 2.0.21 completed successfully but error anyway?

Post by aelunii »

The error is:
Fatal error: Call to undefined function: phpbb_ltrim() in /home2/kamil/public_html/forum/includes/functions.php on line 310

I used the files to update a modded forum from 2.0.20 to 2.0.21 using EasyMod, and the install went fine and update to latest seemed to work- but now the error comes up on every page of the forum.

Can anyone help?
User avatar
karlsemple
Former Team Member
Posts: 39802
Joined: Mon Nov 01, 2004 8:54 am
Location: Hereford, UK
Contact:

Post by karlsemple »

open includes/functions.php


Find:

Code: Select all

// added at phpBB 2.0.11 to properly format the username
function phpbb_clean_username($username)
{
	$username = substr(htmlspecialchars(str_replace("\'", "'", trim($username))), 0, 25);
	$username = phpbb_rtrim($username, "\\");
	$username = str_replace("'", "\'", $username);

	return $username;
}

After Add;

Code: Select all

/**
* This function is a wrapper for ltrim, as charlist is only supported in php >= 4.1.0
* Added in phpBB 2.0.18
*/
function phpbb_ltrim($str, $charlist = false)
{
	if ($charlist === false)
	{
		return ltrim($str);
	}
	
	$php_version = explode('.', PHP_VERSION);

	// php version < 4.1.0
	if ((int) $php_version[0] < 4 || ((int) $php_version[0] == 4 && (int) $php_version[1] < 1))
	{
		while ($str{0} == $charlist)
		{
			$str = substr($str, 1);
		}
	}
	else
	{
		$str = ltrim($str, $charlist);
	}

	return $str;
}
Image
aelunii
Registered User
Posts: 29
Joined: Tue Dec 07, 2004 7:10 pm

Post by aelunii »

Thank you! That worked perfectly.
User avatar
shirleycaat
Registered User
Posts: 186
Joined: Mon Apr 07, 2003 1:11 am

Post by shirleycaat »

Hello karlsemple,

I have similiar problem of
Call to undefined function: phpbb_ltrim() in /includes/functions.php

I modified includes/functions.php as you post above, the problem is gone. Thanks!

Now a question: is this an official fix? will it included in next release?
espicom
Registered User
Posts: 17905
Joined: Wed Dec 22, 2004 1:14 am
Location: Woodstock, IL

Post by espicom »

If you don't have these functions, you didn't do the update when they came out, 10 versions ago. They ARE the "official fix", because they're what is supposed to be there, if your version was truly what you thought it was.

Since these functions were missing, how many other security-related fixes are you missing? You can't know, because you don't know what version of the file "functions.php" you have anymore.
Jeff
Fixing 1016/1030/1034 Errors | (obsolete link) | MySQL 4.1/5.x Client Error | phpBBv2 Logo in ACP
Support requests via PM are ignored!
"To be fully alive is to feel that everything is possible." - Eric Hoffer
User avatar
shirleycaat
Registered User
Posts: 186
Joined: Mon Apr 07, 2003 1:11 am

Post by shirleycaat »

After I post the question I noticed it's added in 2.0.18.
The first version I use is 2.0.4, I did every update, including 2.0.18. But I have no idea how could I missed that part :oops: Yeah now it's really difficult to track such thing for my heavily-modded board. :?
Locked

Return to “2.0.x Support Forum”