foreach ($tables as $table) {
        $sqldump .= dataBak(DB_PREFIX . $table);
    }
    $dumpfile = '#version:emlog ' . Option::EMLOG_VERSION . "\n";
    $dumpfile .= '#date:' . gmdate('Y-m-d H:i', time() + $timezone * 3600) . "\n";
    $dumpfile .= '#tableprefix:' . DB_PREFIX . "\n";
    $dumpfile .= $sqldump;
    $dumpfile .= "\n#the end of backup";
    @($fp = fopen($filename, 'w+'));
    if ($fp) {
        @flock($fp, 3);
        if (@(!fwrite($fp, $dumpfile))) {
            @fclose($fp);
        } else {
            @fclose($fp);
            kl_auto_backup_and_mail_mail_to(KL_AUTO_BACKUP_AND_MAIL_SMTP, KL_AUTO_BACKUP_AND_MAIL_PORT, KL_AUTO_BACKUP_AND_MAIL_SENDEMAIL, KL_AUTO_BACKUP_AND_MAIL_PASSWORD, KL_AUTO_BACKUP_AND_MAIL_TOEMAIL, '您的博客自动备份数据', '附件中为您的博客' . $blogname . '的自动备份数据 :)', $blogname, $filename);
        }
    }
}
function dataBak($table)
{
    $DB = Database::getInstance();
    $sql = "DROP TABLE IF EXISTS {$table};\n";
    $createtable = $DB->query("SHOW CREATE TABLE {$table}");
    $create = $DB->fetch_row($createtable);
    $sql .= $create[1] . ";\n\n";
    $rows = $DB->query("SELECT * FROM {$table}");
    $numfields = $DB->num_fields($rows);
    $numrows = $DB->num_rows($rows);
    while ($row = $DB->fetch_row($rows)) {
        $comma = "";
<?php

/**
 * kl_auto_backup_and_mail_test_do.php
 * design by KLLER
 */
require_once '../../../init.php';
!(ISLOGIN === true && $value['author'] == UID || ROLE == 'admin') && exit('access deined!');
include_once 'kl_auto_backup_and_mail_config.php';
require_once EMLOG_ROOT . '/content/plugins/kl_auto_backup_and_mail/class/class.smtp.php';
require_once EMLOG_ROOT . '/content/plugins/kl_auto_backup_and_mail/class/class.phpmailer.php';
$blogname = Option::get('blogname');
$subject = $content = '这是一封测试邮件';
if (kl_auto_backup_and_mail_mail_to(KL_AUTO_BACKUP_AND_MAIL_SMTP, KL_AUTO_BACKUP_AND_MAIL_PORT, KL_AUTO_BACKUP_AND_MAIL_SENDEMAIL, KL_AUTO_BACKUP_AND_MAIL_PASSWORD, KL_AUTO_BACKUP_AND_MAIL_TOEMAIL, $subject, $blogname, $blogname)) {
    echo '<font color="green">发送成功!请到相应邮箱查收!:)</font>';
}