Problems since upgrading to php v5.3.0 - PHP ereg_replace

Post your support requests/solutions for phpMySQLAutoBackup [website]
MacOfTheEast
Working towards guru status...
Working towards guru status...
Posts: 7
Joined: Fri Aug 05, 2005 11:01 pm
Contact:

Problems since upgrading to php v5.3.0 - PHP ereg_replace

Postby MacOfTheEast » Sun Nov 01, 2009 7:57 pm

Dave,

Sorry to have to report this but since upgrading to php v5.3.0 from v5.2.11 phpMySQLAutoBackup no longer works. From apache2's error log:

[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:25 2009] [error] [client 192.168.1.11] PHP Deprecated: Function ereg_replace() is deprecated in /Library/WebServer/Documents/demval/phpmysqlautobackup/files/schema_for_export.php
[Sun Nov 01 07:46:28 2009] [notice] child pid 28856 exit signal Segmentation fault (11)

I've tried a few versions of phpMySQLAutoBackup including the very latest.

Appreciate you having a look at it.

P.S. Also troubles with phpAutoMembersArea which I'll report in the appropriate forum.

Thank you,
B. Bodger

davidgwalker
MODS thats what I do that is! But definately NO mod music! It has to be ROCK!
Posts: 1809
Joined: Mon Oct 25, 2004 8:20 pm
Location: Huddersfield, UK
Contact:

Re: Problems since upgrading to php v5.3.0

Postby davidgwalker » Mon Nov 02, 2009 7:13 am

Hi, Many thanks for taking the time to post the issue :-)

Deprecation! Dont you just love it! NO THANK YOU :x
For those that dont know what this means - the error message means the integrated PHP function "ereg_replace" is nolonger supported and has been removed:
http://php.net/manual/en/function.ereg-replace.php

I will have a look today and issue an update.

Cheers

Dave

davidgwalker
MODS thats what I do that is! But definately NO mod music! It has to be ROCK!
Posts: 1809
Joined: Mon Oct 25, 2004 8:20 pm
Location: Huddersfield, UK
Contact:

Re: Problems since upgrading to php v5.3.0

Postby davidgwalker » Mon Nov 02, 2009 8:48 am

Patch below - replace the existing file:
\phpmysqlautobackup\files\schema_for_export.php

PLEASE ensure you test this by exporting a backup and importing to a test database to confirm it is working correctly.

Should be fine, however, if you have any issues please let me know.

Code: Select all

<?php
/*******************************************************************************************
    phpMySQLAutoBackup  -  Author:  http://www.DWalker.co.uk - released under GPL License
           For support and help please try the forum at: http://www.dwalker.co.uk/forum/
********************************************************************************************
Version    Date              Comment
0.2.0      7th July 2005     GPL release
0.3.0      June 2006  Upgrade - added ability to backup separate tables
0.4.0      Dec 2006   removed bugs/improved code
1.4.0      Dec 2007   improved faster version
1.5.0      Dec 2008   improved and added FTP backup to remote site
1.5.1      Feb 2009   improved export data - added quotes around field names
1.5.2      April 2009   improved "create table" export and added backup time start & end
1.5.3      Nov 2009     replaced PHP function "ereg_replace" with "str_replace"
********************************************************************************************/
$phpMySQLAutoBackup_version="1.5.3";
// ---------------------------------------------------------
$link = mysql_connect($db_server,$mysql_username,$mysql_password);
if ($link) mysql_select_db($db);
if (mysql_error()) exit(mysql_error($link));
//add new phpmysqlautobackup table if not there...
if(mysql_num_rows(mysql_query("SHOW TABLES LIKE 'phpmysqlautobackup' "))==0)
{
   $query = "
    CREATE TABLE phpmysqlautobackup (
    id int(11) NOT NULL,
    version varchar(6) default NULL,
    time_last_run int(11) NOT NULL,
    PRIMARY KEY (id)
    ) TYPE=MyISAM;";
   $result=mysql_query($query);
   $query="INSERT INTO phpmysqlautobackup (id, version, time_last_run)
             VALUES ('1', '$phpMySQLAutoBackup_version', '0');";
   $result=mysql_query($query);
}
//check time last run - to prevent malicious over-load attempts
$query="SELECT * from phpmysqlautobackup WHERE id=1 LIMIT 1 ;";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
if (time() < ($row['time_last_run']+$time_internal)) exit();// exit if already run within last time_interval
//update version number if not already done so
if ($row['version']!=$phpMySQLAutoBackup_version) mysql_query("update phpmysqlautobackup set version='$phpMySQLAutoBackup_version'");
////////////////////////////////////////////////////////////////////////////////////

$query="UPDATE phpmysqlautobackup SET time_last_run = '".time()."' WHERE id=1 LIMIT 1 ;";
$result=mysql_query($query);

if (!isset($table_select))
{
  $t_query = mysql_query('show tables');
  $i=0;
  $table="";
  while ($tables = mysql_fetch_array($t_query, MYSQL_ASSOC) )
        {
         list(,$table) = each($tables);
         $exclude_this_table = isset($table_exclude)? in_array($table, $table_exclude) : false;
         if(!$exclude_this_table) $table_select[$i]=$table;
         $i++;
        }
}

$thedomain = $_SERVER['HTTP_HOST'];
if (substr($thedomain,0,4)=="www.") $thedomain=substr($thedomain,4,strlen($thedomain));

$buffer = '# MySQL backup created by phpMySQLAutoBackup' . "\n" .
          '#' . "\n" .
          '# http://www.dwalker.co.uk/phpmysqlautobackup/' . "\n" .
          '#' . "\n" .
          '# Database: '. $db . "\n" .
          '# Domain name: ' . $thedomain . "\n" .
          '# (c)' . date('Y') . ' ' . $thedomain . "\n" .
          '#' . "\n" .
          '# Backup START time: ' . strftime("%H:%M:%S",time()) . "\n".
          '# Backup END time: 20:21:00' . "\n".
          '# Backup Date: ' . strftime("%d %b %Y",time()) . "\n";$i=0;
foreach ($table_select as $table)
        {
          $i++;
          $export = "\n" .'drop table if exists `' . $table . '`;' . "\n";

          //export the structure
          $query='SHOW CREATE TABLE `' . $table . '`';
          $rows_query = mysql_query($query);
          $tables = mysql_fetch_array($rows_query);
          $export.= $tables[1] ."; \n";

          $table_list = array();
          $fields_query = mysql_query('show fields from  `' . $table . '`');
          while ($fields = mysql_fetch_array($fields_query))
           {
            $table_list[] = $fields['Field'];
           }

          $buffer.=$export;
          // dump the data
          $query='select * from `' . $table . '` LIMIT '. $limit_from .', '. $limit_to.' ';
          $rows_query = mysql_query($query);
          while ($rows = mysql_fetch_array($rows_query)) {
            $export = 'insert into `' . $table . '` (`' . implode('`, `', $table_list) . '`) values (';
            reset($table_list);
            while (list(,$i) = each($table_list)) {
              if (!isset($rows[$i])) {
                $export .= 'NULL, ';
              } elseif (has_data($rows[$i])) {
                $row = addslashes($rows[$i]);
                $row = str_replace("\n#", "\n".'\#', $row);

                $export .= '\'' . $row . '\', ';
              } else {
                $export .= '\'\', ';
              }
            }
            $export = str_replace(', $', '', $export) . ');' . "\n";
            $buffer.= $export;
          }
        }
mysql_close();
$buffer = str_replace('20:21:00', strftime("%H:%M:%S",time()), $buffer);
?>

davidgwalker
MODS thats what I do that is! But definately NO mod music! It has to be ROCK!
Posts: 1809
Joined: Mon Oct 25, 2004 8:20 pm
Location: Huddersfield, UK
Contact:

Re: Problems since upgrading to php v5.3.0 - PHP ereg_replace

Postby davidgwalker » Mon Nov 02, 2009 3:11 pm

New version which corrects the above issue has now been released:
http://www.dwalker.co.uk/phpmysqlautobackup/

Any problems please let me know...

Cheers

Dave


Return to “phpMySQLAutoBackup [forum]”

Who is online

Users browsing this forum: No registered users and 2 guests