View Single Post
Old 11-30-2012, 07:26 PM   PM User | #3
Junsee
New Coder

 
Join Date: Jun 2012
Posts: 42
Thanks: 4
Thanked 5 Times in 5 Posts
Junsee is an unknown quantity at this point
Yeah totally agree, but its one of those basic packages with a lot of the neat features disabled. I use cronjobs myself, and I have started noticing that webhosts are clamping down on system, exec, and the other one.

this way it to make it simple for the user, for all cases and webhosts, push the big button and the work is done for you.

I hope they don't clamp down on mail()


if anyone wants the new code here is: (in this case I have used a sleep, and seems to correct the issue)
PHP Code:
    
    $sendfrom 
"";
    
$sendto "";
    
$sendsubject "-Keep this Safe- DB Backup " .date("D d-M-Y g:ia");
    
$attachmentname "DB backup [" .date("D d-M-Y gia"). "].txt";

    
$conn mysql_connect($dbhost$dbuser$dbpass) or die("Could not Connect");
    
$rs mysql_select_db($dbname$conn) or die("Couldn't Find Database");
    
    
$insertline " -- \n -- Plain Text Backup of MySQL Database [Generated: " .date("D d-M-Y g:ia"). "] \n -- \n\n -- \n -- Backup of Database: $dbname \n -- On Host: $dbhost \n -- \n\n";
    
    
#Finds the Tables in Database
    
$sqlshowtables "SHOW TABLES; ";
    
$rsshowtables mysql_query($sqlshowtables$conn);
    
#$NumberofTables = mysql_num_rows($rsshowtables);
    
    
while ($row mysql_fetch_array ($rsshowtables)){
        
$TableName $row[0];
        
#echo $TableName. '<br />';
        
        
$insertline .= " -- \n -- Table: $TableName \n -- \n\n";
        
        
$sqlcreatetable "SHOW CREATE TABLE `$TableName`; ";
        
$rscreatetable mysql_query($sqlcreatetable$conn);
        
$CreateTable mysql_result($rscreatetable,0,'Create Table');

        
#Replace "CREATE TABLE" with "IF NOT EXISTS" statements
        
$insertline .= preg_replace('#CREATE TABLE#''CREATE TABLE IF NOT EXISTS'$CreateTable);
        
$insertline .= "\n\n";
        
        
$sqlfindnumberofcolumns "SHOW COLUMNS FROM `$TableName`; ";
        
$rsfindnumberofcolumns mysql_query($sqlfindnumberofcolumns$conn);
        
$NumberofColumnsinTable countmysql_fetch_row($rsfindnumberofcolumns) ) - 1;
        
#echo 'Number of cols:' .$NumberofColumnsinTable;

        
$insertline .= " -- \n -- Values for: $TableName \n -- \n\n";

        
$sqlfindcolumns "SELECT * FROM `$TableName`; ";
        
$rsfindcolumns mysql_query($sqlfindcolumns$conn);
        while (
$row mysql_fetch_array ($rsfindcolumns)){
            
$insertline .= "INSERT INTO `$TableName` VALUES('";
            
            for (
$j=0$j<$NumberofColumnsinTable$j++){
                
$insertline .= $row[$j]. "', '";
            }
            
$insertline substr($insertline0, -4);
            
$insertline .= "');\n";
            
        }
        
$insertline .= "\n\n";
    }

    
#$Display = preg_replace('#\\r\\n#', '<br />', $MyPlainText);
    #echo $Display;

    
$message "Automated Backup and Store of MySQL Database, for $sendfrom.com\nDatabase Backup File: $attachmentname attached.";
    
$mime_boundary "< <<:" md5(time());
    
#$data = chunk_split(base64_encode(implode("", file($writefile))));
    
$data chunk_split(base64_encode($insertline));
    
sleep(4);

    
$headers "From: $sendfrom <>\r\n";
    
$headers .= "MIME-Version: 1.0\r\n";
    
$headers .= "Content-type: multipart/mixed;\r\n";
    
$headers .= " boundary=\"".$mime_boundary."\"\r\n";
    
    
$content "This is a multi-part message in MIME format.\r\n\r\n";
    
$content.= "--".$mime_boundary."\r\n";
    
$content.= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
    
$content.= "Content-Transfer-Encoding: 7bit\r\n\r\n";
    
$content.= $message."\r\n";
    
$content.= "--".$mime_boundary."\r\n";
    
$content.= "Content-Disposition: attachment;\r\n";
    
$content.= "Content-Type: Application/Octet-Stream; name=\"$attachmentname\"\r\n";
    
$content.= "Content-Transfer-Encoding: base64\r\n\r\n";
    
$content.= $data."\r\n";
    
$content.= "--" $mime_boundary "\r\n";
    
    if (
mail($sendto$sendsubject$content$headers)){
        
header("location:stokerslounge1a.php?D=Email");
    } else {
        
header("location:stokerslounge1a.php?D=NotSent");
    }
    exit; 

Last edited by Junsee; 11-30-2012 at 07:27 PM.. Reason: grammar
Junsee is offline   Reply With Quote