We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29703
    • 217 Posts
    Hi all,

    I’ve run into a bit of a problem. Seemingly in my test environment any snippet that is dependent on PHPthumb spews out the error:

    Deprecated: Function eregi() is deprecated in C:\xampp\htdocs\hook\assets\snippets\treasure_chest\images\phpthumb\phpThumb.php on line 152


    (this is TreasureChest specific though I have the same problem with the PHPthumb PHx snippet)

    I’ve tried downgrading my PHP version on my XAMPP installation but everything stopped working. So I then downgraded my entire XAMPP installation and still nothing worked.

    Is the function eregi() something that can be easily replaced or is that oversimplifying things?

    Thanks!
      • 22303 MODX Staff
      • 10,725 Posts
      This is part of phpthumb, not MODx, so, I would check with the phpthumb project for updates for PHP 5.3.
        • 29703
        • 217 Posts
        So it is! Thanks for the help smiley
          • 31471
          • 206 Posts
          PHP 5.3 fix for phpThumb
          http://sourceforge.net/tracker/index.php?func=detail&aid=2937928&group_id=106407&atid=643974
            • 29423
            • 2 Posts
            If you upgraded to PHP 5.3, chances are high you’re going to run into a few warnings or deprecated function messages.

            An example is the ereg family of functions, which are gone for good, as they were slower and felt less familiar than the alternative Perl-compatible preg family.

            To migrate ereg():

            ereg(’.([^.]*$)’, $this->file_src_name, $extension);

            becomes

            preg_match(’/.([^.]*$)/’, $this->file_src_name, $extension);


            Notice that I wrapped the pattern (.([^.]*$)) around / /, which are RegExp delimiters. If you find yourself escaping / too much (for an URL for example), you might want to use the # delimiter instead.

            To migrate ereg_replace():

            $this->file_dst_name_body = ereg_replace(’[^A-Za-z0-9_]’, ’’, $this->file_dst_name_body);

            becomes

            $this->file_dst_name_body = preg_replace(’/[^A-Za-z0-9_]/’, ’’, $this->file_dst_name_body);

            Again, I just added delimiters to the pattern.
            If you are using eregi functions (which are the case-insensitive version of ereg), you’ll notice there’re no equivalent pregi functions. This is because this functionality is handled by RegExp modifiers.

            Basically, to make the pattern match characters in a case-insensitive way, append i after the delimiter:

            eregi(’.([^.]*$)’, $this->file_src_name, $extension);

            becomes

            preg_match(’/.([^.]*$)/i’, $this->file_src_name, $extension);
              • 9995
              • 1,613 Posts
              damned, after host updated php to 5.3.8 phpthumb doesnt work anymore..

              Error message:
              PHP error debug
                Error: 	Function ereg() is deprecated	 
                Error type/ Nr.: 	- 8192	 
                File: 	/usr/home/xxx/domains/xxx.nl/public_html/mbl/assets/snippets/phpthumb/phpThumb.config.php	 
                Line: 	30	 
                Line 30 source: 	
              $PHPTHUMB_CONFIG['document_root'] = realpath((getenv('DOCUMENT_ROOT') && ereg('^'.preg_quote(realpath(getenv('DOCUMENT_ROOT'))), realpath(__FILE__))) ? getenv('DOCUMENT_ROOT') : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__)))); 	 


              How do i fix this?

              What do i need to change into my phpthumb config file? (line 30 has above code)

              Seems here the fix is :

              https://forums.modx.com/index.php?topic=43077.0
              [ed. note: fourroses666 last edited this post 14 years, 11 months ago.]
                Evolution user, I like the back-end speed and simplicity smiley