We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38689
    • 14 Posts
    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))


      • 3749
      • 24,544 Posts
      preg_match needs delimiters. Try this:


      $pattern = '@' . $referers[$x] . '@i'; 
      
      if(preg_match($pattern, $referer))
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 38689
        • 14 Posts
        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?
          • 38689
          • 14 Posts
          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?
            • 3749
            • 24,544 Posts
            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

            ereg($pattern, $string);


            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.

              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 38689
              • 14 Posts
              Trying to replace them all ... stuck on this one which has a variable and a caret in the pattern:

              $addrMatch = ereg("^$chkAgainst", $chkAddr);

                • 3749
                • 24,544 Posts


                $addrMatch = preg_match('#^' . $chkAgainst . '#', $chkAddr);


                BTW, you can look at the code of the Revolution version. All the deprecated functions are fixed there.

                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 38689
                  • 14 Posts
                  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.
                    • 3749
                    • 24,544 Posts
                    I think it's the spform.class.php file, but I'm away from the computer now and can't check for sure.
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting