View Thread
Who is here? 1 guest(s)
|
"Auto DB Backup panel with email" email changes
|
|
| quiki |
Posted on 10-07-2009 05:42
|
|
Frequent poster ![]() Posts: 143 Joined: 25/11/2008 09:28 |
Hi, Is it possible to make the backup infusion send an email to a specific mail address instead of the site owner's address? Great infusion btw, works very good with sites I use the site mail on. Maybe it's possible to change something here: $email_to = $settings['siteemail']; // ??? Hoping anyone have looked into this before. Regards <?php
/*---------------------------------------------------+ | PHP-Fusion 6 Content Management System +----------------------------------------------------+ | Copyright (c) 2003-2008 Nick Jones | http://www.php-fu... +----------------------------------------------------+ | Released under the terms & conditions of v2 of the | GNU General Public License. For details refer to | the included gpl.txt file or visit http://gnu.org +----------------------------------------------------+ | Database Backup developed by CrappoMan | email: +----------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------- Backup Yapma Ve Gönderme Kodu 1.2: Kodlayan: SoulSmasher - www.soulsmasher.net phpfusion-tr.com - PHP Fusion Türkiye Resmi Destek Sitesi Kodlarda örnek olarak Auto Db Backup ve Christoph2k nın attachmentlı mail sistemi kodları kullanılmıştır \-----------------------------------------------------------------------------------------------------------------------------------*/ if(file_exists(INFUSIONS."auto_mail_backup_panel/locale/".$settings['locale'].".php")) { include INFUSIONS."auto_mail_backup_panel/locale/".$settings['locale'].".php"; } else { include INFUSIONS."auto_mail_backup_panel/locale/English.php"; } /*******************BURALARI KENDİNİZE GÖRE DÜZENLEYEBİLİRSİNİZ***********************/ $silmek = true; //backup gönderdikten sonra ftpden silmek için true, ftpden silmemek için false yazın // Değişkenler - bilmediklerinize dokanmayın define('A_WAIT_TIME', 60*60*24); // bekleme süresi, 1 gün için 60*60*24 define('A_DB_DIR', ADMIN.'db_backups/'); // backup klasörü (777 chmodlu olmalıdır) define('A_TOUCH_FILE', A_DB_DIR.'aw_last_update'); define('A_GZ_BACKUP', true); // gzip desteği açıksa true, değilse false define('A_ENDOL', "\n"); // default: "\n" define('DBNAME', $db_name); //database adını define ettik daha hızlı çalışır - buna dokanmayın /*********************************************************************************************/ //email yapma kodu - bu da benim eserim :) - www.soulsmasher.net if (substr($_SERVER['HTTP_HOST'], 0, 4) == "www.") { $domainadi = substr($_SERVER['HTTP_HOST'], 4); } else { $domainadi = $_SERVER['HTTP_HOST']; } $email_from = "mailbackup@".$domainadi; // email kimdenmiş $email_subject = $locale['konuadi']; // Email Konu Adı $email_message = $locale['yedekmesaji']; // Message that the email has in it $email_to = $settings['siteemail']; // Who the email is too - EMAİL GİDECEK ADRES, YÖNETİCİ MAİLİNE GİDİYOR STANDART OLARAK $headers = "From: ".$email_from; $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= $locale['backupburada']."\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"".$locale['charset']."\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n"; /************BURADAN AŞAĞISINA BİLMİYORSANIZ DOKANMAYIN*****************/ if(!defined("IN_FUSION")) { die(); } //hash oluşturma mt_srand((double)microtime()*1000000); //memoryde random için yer ayarlıyor $backup_rand = rand(1000000, 9999999); $backup_hash = substr(md5($backup_rand), 8, 8); //önce globaldi şimdi fonsiyon geliştirildi :) //hash bitti // FUNCS function need_backup($file) { if(file_exists($file)) { $mtime = filemtime($file); return((time()-$mtime) > A_WAIT_TIME); } return true; } //from administration/db_backup.php function gzcompressfile($source,$level=false){ $dest = $source.'.gz'; $mode = 'wb'.$level; $error = false; if($fp_out = gzopen($dest,$mode)) { if($fp_in=fopen($source,'rb')) { while(!feof($fp_in)) { gzputs($fp_out,fread($fp_in,1024*512)); } fclose($fp_in); } else { $error=true; } gzclose($fp_out); } else { $error=true; } if($error) { return false; } else { return $dest; } } // partly from administration/db_backup.php function do_backup($thehash) { //global $db_name; $query_id = dbquery("SHOW TABLES FROM `".DBNAME."`"); if(!$query_id || !dbrows($query_id)) { return false; } while($row = dbarray($query_id)) { foreach($row as $key => $val) { $db_tables[$val] = $val; } } ob_start(); @ob_implicit_flush(0); echo "#----------------------------------------------------------".A_ENDOL; echo "# PHP-Fusion SQL Data Dump".A_ENDOL; echo "# Database Name: `".DBNAME."`".A_ENDOL; echo "# Table Prefix: `".DB_PREFIX."`".A_ENDOL; echo "# Date: `".date("d/m/Y H:i")."`".A_ENDOL; echo "# Auto sendmail Mod Made From awAutoDBBackup".A_ENDOL; echo "#----------------------------------------------------------".A_ENDOL; dbquery('SET SQL_QUOTE_SHOW_CREATE=1'); foreach($db_tables as $table){ $column_list = array(); $num_fields = 0; @set_time_limit(1200); dbquery("OPTIMIZE TABLE `".$table."`"); echo A_ENDOL."#".A_ENDOL."# Structure for Table `".$table."`".A_ENDOL."#".A_ENDOL; echo "DROP TABLE IF EXISTS `$table`;".A_ENDOL; $row = dbarraynum(dbquery("SHOW CREATE TABLE `".$table."`")); echo $row[1].";".A_ENDOL; $result = dbquery("SELECT * FROM ".$table); if($result && dbrows($result)) { echo A_ENDOL."#".A_ENDOL."# Table Data for `".$table."`".A_ENDOL."#".A_ENDOL; $num_fields = mysql_num_fields($result); for($i=0; $i<$num_fields; $i++) { $column_list[] = "`".mysql_field_name($result, $i)."`"; } } while($row = dbarraynum($result)){ $data_list = array(); for($i=0; $i<$num_fields; $i++) { if(!isset($row[$i])){ $data_list[] = "NULL"; } elseif($row[$i]=="0" || $row[$i]!="") { $type = mysql_field_type($result, $i); if($type=="tinyint"||$type=="smallint"||$type=="mediumint"||$type=="int"||$type=="bigint"||$type=="timestamp") { $data_list[] = $row[$i]; } else { $search_array=array('\\','\'',"\x00","\x0a","\x0d","\x1a"); $replace_array=array('\\\\','\\\'','\0','\n','\r','\Z'); $row[$i]=str_replace($search_array,$replace_array,$row[$i]); $data_list[] = "'$row[$i]'"; } } else { $data_list[] ="''"; } } echo "INSERT INTO `$table` (".implode(", ", $column_list).") VALUES (".implode(", ", $data_list).");".A_ENDOL; } } $contents = ob_get_contents(); ob_end_clean(); /* mt_srand((double)microtime()*1000000); $backup_rand = rand(1000000, 9999999); $backup_hash = substr(md5($backup_rand), 8, 8); */ $file = "backup_".$thehash."_".date('Y-m-d_Hi').".sql"; $fp = @fopen(A_DB_DIR.$file,"w"); if(!$fp) { return false; } $ok = fwrite($fp,$contents); fclose($fp); if(A_GZ_BACKUP) { if(gzcompressfile(A_DB_DIR.$file, 9)!=false) { unlink(A_DB_DIR.$file); } } return true; } // ACTION $err_txt = ""; if((iSUPERADMIN && isset($_GET['force_backup'])) || need_backup(A_TOUCH_FILE)) { if(is_dir(A_DB_DIR) && is_writeable(A_DB_DIR)) { @umask(0111); if(@touch(A_TOUCH_FILE)) { if(!do_backup($backup_hash)) { $err_txt = $locale['aw_err_db']; } } else { $err_txt = str_replace("%s", A_TOUCH_FILE, $locale['aw_err_touch']); } } else { $err_txt = str_replace("%s", "<b>".A_DB_DIR."</b>", $locale['aw_err_write']); } /********************************************** Dosyamız ********************************************/ $backupfilegz = A_DB_DIR."backup_".$backup_hash."_".date('Y-m-d_Hi').".sql.gz"; $backupfilenormal = A_DB_DIR."backup_".$backup_hash."_".date('Y-m-d_Hi').".sql"; if(A_GZ_BACKUP) { $fileatt = $backupfilegz; // dosya adresi $fileatt_type = "application/zip"; // dosya türü - dokanmayın $fileatt_name = "backup_".$backup_hash."_".date('Y-m-d_Hi').".sql.gz"; // gidecek dosyanın adı } else { $fileatt = $backupfilenormal; // dosya adresi $fileatt_type = "application/zip"; // dosya türü - dokanmayın $fileatt_name = "backup_".$backup_hash."_".date('Y-m-d_Hi').".sql"; // gidecek dosyanın adı } $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}\n"; unset($data); unset($file); unset($fileatt); unset($fileatt_type); unset($fileatt_name); /******************************************ikinci dosya göndermek isytersek (şimdilik gereksiz)*******************************/ /* $fileatt = ""; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $fileatt_name = ""; // Filename that will be used for the file as the attachment $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $data = chunk_split(base64_encode($data)); $email_message .= "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; unset($data); unset($file); unset($fileatt); unset($fileatt_type); unset($fileatt_name); */ /********************************************** ayar bitişi ********************************************/ if (file_exists($backupfilenormal) || file_exists($backupfilegz)) { //backup yapmadan maili atmasın değil mi :) $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { openside(" "); echo $locale['aw_mailgitti']; closeside(); } else { openside(" "); echo $locale['aw_mailgitmedi']; closeside(); } if ($silmek == true) //eğer true ya yarlanırsa mail gönderdikten sonra ftp den yedeği siliyor { opendir(A_DB_DIR); if (file_exists($backupfilenormal)) { unlink($backupfilenormal); echo $locale['silmek']; } if (file_exists($backupfilegz)) { unlink($backupfilegz); echo $locale['silmek']; } //closedir(A_DB_DIR); } } //file exists in sonu } //actionun bitişi // GUI if(iSUPERADMIN) { openside($p_data['panel_name']); echo "<div style='text-align:center;'>"; if(empty($err_txt)) { echo $locale['aw_last'] . "<br />" . showdate("shortdate", filemtime(A_TOUCH_FILE)); if(iSUPERADMIN) { echo "<p><a href='".FUSION_SELF."?force_backup=1'>" .$locale['AWAU010']."</a>\n"; } } else { echo $err_txt; } echo "</div>"; echo "<table cellpadding='0' cellspacing='0' border='0' align='right'><tr><td align='right'>"; echo "<a href='http://www.soulsmasher.net' target='_blank' title='Auto Mail Backup Panel 1.2 By SoulSmasher'>©</a>"; echo "</td></tr></table>"; closeside(); } //arkamızı temizleyelim unset ($backup_rand); //güvenlik için unset($backup_hash); //güvenlik için ?> Edited by quiki on 10-07-2009 05:43 |
|
|
|
| Smokeman |
Posted on 10-07-2009 09:19
|
|
Site Robotic Spammer Slave ![]() Posts: 879 Joined: 08/09/2008 06:53 |
Hi. We should find the following line: - and change it to: Edited by Smokeman on 10-07-2009 09:20 |
|
|
|
| quiki |
Posted on 10-07-2009 17:37
|
|
Frequent poster ![]() Posts: 143 Joined: 25/11/2008 09:28 |
ok, thx ![]() |
|
|
|
| quiki |
Posted on 12-07-2009 22:16
|
|
Frequent poster ![]() Posts: 143 Joined: 25/11/2008 09:28 |
Hm, that did'nt work with just placing the e-mail address there. Any other suggestions? |
|
|
|
| quiki |
Posted on 18-07-2009 05:57
|
|
Frequent poster ![]() Posts: 143 Joined: 25/11/2008 09:28 |
*bump* Anyone else know how to do this? |
|
|
|
| Smokeman |
Posted on 18-07-2009 07:04
|
|
Site Robotic Spammer Slave ![]() Posts: 879 Joined: 08/09/2008 06:53 |
I don't understand it not work that way.. Hmm, where can i DL that exactly version you have ?? Tell me and I will take a look at it for myself.
|
|
|
|
| quiki |
Posted on 19-07-2009 22:58
|
|
Frequent poster ![]() Posts: 143 Joined: 25/11/2008 09:28 |
Hi Smokeman, thx for looking into it: http://www.phpfus...amp;id=171 |
|
|
|
| foc_in_gaura |
Posted on 05-08-2010 11:54
|
|
Newbie ![]() Posts: 11 Joined: 10/09/2008 06:23 |
Just CHMOD with 777 the "administration/db_backups/aw_last_update" file. Easy. This error appear mostly when you move to another host. You forget to chmod that file back !Good luck! P.S. After postin I realised that this thread is inactive for more than 1 year !
Edited by foc_in_gaura on 05-08-2010 11:55 |
|
|
|
| Jump to Forum: |


Information
Resources
Submit











