Hi guys,
I'm trying vHostAdmin (vhostadmin-cvs-1114527418) with PHP 5.0.3 getting a fatal error accessing the mail module.

Fatal error: Only variables can be passed by reference in [fullpath]/modules/mail/domains.php on line 193

Line 193 is:
$str = str_replace("v|", "", trim($data), 1);
but the prototype of str_replace, from PHP 5.0 is
mixed str_replace ( mixed search, mixed replace, mixed subject [, int &count] )

This function replaces all occurrences of search in subject with replace storing the total number of replacement made in the count variable passed by reference. Latest versions of PHP triggers a fatal error if you pass a costant (1) by reference.

The same problem occurs in:
/modules/mail/users.php on line 650
/modules/mail/forwards.php on line 333
/modules/mail/autoresponders.php on line 163

My suggestion for fixing the bug is to replace the above lines with

$str = str_replace("v|", "", trim($data));

Or, if the latest '1' is intended as a parameter to limit the number of substitutions, I suggest using preg_replace() instead, which can have a limit parameter; this way you have:

$str = preg_replace('/v\|/', '', trim($data), 1);

or, if "v|" is always at the beginning of the string, you can even use:

$str = preg_replace('/^v\|/', '', trim($data));

I patched the source code as described and it's working perfectly.

Hope it helps

Congratulations !


Edoardo Serra
WeBRainstorm S.r.l.
IT, Internet services & consulting
Via Pio FoĆ  83/C
10126 Torino
Tel: +39 011 6966881

Reply via email to