Installed SPForm 1.0.5 on my local WAMP system with PHP 5.3.8 (MODX Evolution 1.06) and got this message:
PHP error debug
Error: Function eregi() is deprecated
Error type/ Nr.: - 8192
File: C:\wamp\www\kennisis.ca\assets\snippets\spform\spformproc.inc.php
Line: 144
Line 144 source: if(eregi($referers[$x], $referer)) {
Does anyone know how to convert this eregi statement to preg_match?
if(eregi($referers[$x], $referer))
Apparently we need to add a /i delimiter with preg_match but that doesn't seem to work when the argument is a variable and not a string. I tried this but it didn't work:
$pattern = $referers[$x] . '/i';
if(eregi($pattern, $referer))
preg_match needs delimiters. Try this:
$pattern = '@' . $referers[$x] . '@i';
if(preg_match($pattern, $referer))
Thank you. That worked but now I'm getting another error:
PHP error debug
Error: Function ereg_replace() is deprecated
Error type/ Nr.: - 8192
File: C:\wamp\www\kennisis.ca\assets\snippets\spform\spformproc.inc.php
Line: 225
Line 225 source: $banFix = trim(strtolower(ereg_replace('\.', '\\.', $banned)));
I believe ereg_replace should be replaced by preg_replace. Can you give me the syntax for this one too, please?
I resolved the ereg_replace issue, but the ereg() function is also deprecated. Is there an updated version of SPForm somewhere, that works on PHP 5.3?
I'm afraid not. The Evolution version is no longer being developed.
You should be able to fix any ereg calls by replacing them with preg_match (adding delimiters at each end).
So
becomes:
$delimiter = '#';
preg_match($delimiter . $pattern . $delimiter, $string);
You can use any character for the delimiter. Just make sure it's a character that will never appear in the pattern.
Trying to replace them all ... stuck on this one which has a variable and a caret in the pattern:
$addrMatch = ereg("^$chkAgainst", $chkAddr);
$addrMatch = preg_match('#^' . $chkAgainst . '#', $chkAddr);
BTW, you can look at the code of the Revolution version. All the deprecated functions are fixed there.
Can you tell me what file I should be looking at in the Revo version? I downloaded spform 3.2.0 and there is no corresponding spformproc.inc.php file.
I think it's the spform.class.php file, but I'm away from the computer now and can't check for sure.