Error: REMOTE_ADDR not set, PHP Backup Script

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by TechAsh, Mar 5, 2008.

  1. TechAsh

    TechAsh Retired

    Messages:
    5,853
    Likes Received:
    7
    Trophy Points:
    38
    I'm having problems with a PHP backup script I use. It is run daily via a cron job, and it's job is to create a gzip backup of my databases, then save it on the server and also e-mail me a copy.

    The error I'm getting is:
    Here is the contents of 'phpmysqlautobackup_extras.php':
    PHP:
    <?php
    $phpMySQLAutoBackup_version
    ="1.4.0";

    function 
    has_data($value)
    {
     if (
    is_array($value)) return (sizeof($value) > 0)? true false;
     else return ((
    $value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) ? true false;
    }

    function 
    xmail ($to_emailaddress,$from_emailaddress$subject$content$file_name$backup_type)
    {
     
    $mail_attached "";
     
    $boundary "----=_NextPart_000_01FB_010".md5($to_emailaddress);
     
    $mail_attached.="--".$boundary."\n"
                           
    ."Content-Type: application/octet-stream;\n name=\"$file_name\"\n"
                           
    ."Content-Transfer-Encoding: base64\n"
                           
    ."Content-Disposition: attachment; \n filename=\"$file_name\"\n\n"
                           
    .chunk_split(base64_encode($content))."\n";
     
    $mail_attached .= "--".$boundary."--\n";
     
    $add_header ="MIME-Version: 1.0\nContent-Type: multipart/mixed;\n        boundary=\"$boundary\" \n\n";
     
    $mail_content="--".$boundary."\n"."Content-Type: text/plain; \n charset=\"iso-8859-1\"\n"."Content-Transfer-Encoding: 7bit\n\nMySQL BACKUP Successful...\n\nPlease see attached for your zipped Backup file; $backup_type \n".$mail_attached;
     return 
    mail($to_emailaddress$subject$mail_content"From: $from_emailaddress\nReply-To:$from_emailaddress\n".$add_header);
    }

    function 
    write_backup($gzdata$backup_file_name)
    {
     
    $fp fopen(LOCATION."../backups/".$backup_file_name"w");
     
    fwrite($fp$gzdata);
     
    fclose($fp);
    }
    ?>
    Please can someone tell me what to do to make it work.

    P.S. It was working fine up till 3rd March, and I don't think I have changed anything near that line to make it stop working.
     
  2. bonzo meier

    bonzo meier Member

    Messages:
    47
    Likes Received:
    0
    Trophy Points:
    6
    if this script is run on x10, check your php-configuration in the account panel - if you run basic configuration, mail() is disabled.

    the only other thing i could think about (regarding the error you quoted) is that $to_emailaddress is not passed correctly to the xmail-function...

    but maybe you can specify a little more what the problem is. i figure you are getting an error message. but: is the gzip created and stored or not? and is it being sent or not?

    peace, bonzo
     
  3. TechAsh

    TechAsh Retired

    Messages:
    5,853
    Likes Received:
    7
    Trophy Points:
    38
    I've got PHP version 2 (Intermediate).

    The thing is it was working fine a couple of days ago, and I haven't modified it for a while.

    The gzip backup is not being saved or sent (The script gives this error before it saved the file.)

    This line is causing the error:
    PHP:
    return mail($to_emailaddress$subject$mail_content"From: $from_emailaddress\nReply-To:$from_emailaddress\n".$add_header); 
    And this bit saves the file:
    PHP:
    function write_backup($gzdata$backup_file_name)
    {
     
    $fp fopen(LOCATION."../backups/".$backup_file_name"w");
     
    fwrite($fp$gzdata);
     
    fclose($fp);

    So the script encounters a problem before it saves the file.

    I can't really provide much more information about the error (I'm not very good at php)
     
    Last edited: Mar 6, 2008
  4. TechAsh

    TechAsh Retired

    Messages:
    5,853
    Likes Received:
    7
    Trophy Points:
    38
    Can anyone help?

    I've commented out the bit that sends the e-mail and everything else works, but I would like it to e-mail me the backup files.
     
    Last edited: Mar 8, 2008

Share This Page