<?php
include("mailler/class.phpmailer.php");
//-------> Logo Colors
function hexToRGBA($hex) {
    list($r, $g, $b) = sscanf("#" . $hex, "#%02x%02x%02x");
    return "rgba($r, $g, $b, 0.9)";
}
$clr1_rgba = hexToRGBA($colors[1]);
$clr1_hex = "#" . $colors[1];
$clr2_rgba = hexToRGBA($colors[2]);
$clr2_hex = "#" . $colors[2];
$clr3_rgba = hexToRGBA($colors[3]);
$clr3_hex = "#" . $colors[3];
// Logo belirleme
$hmail = $_SESSION["logo"] ?? ($t45 ? $weburl . "/deppo/image/" . $t45 : $logo);
//$imagePath = tempnam(sys_get_temp_dir(), 'mail_logo');
//file_put_contents($imagePath, file_get_contents($hmail));
//$_SESSION['mail_logo'] = $imagePath;
// Header ve Footer şablonları
$temp_header = "
    <img src=\"".$hmail."\" style=\"max-height: 65px; max-width: 50%; float: left;\" referrerpolicy=\"no-referrer\">
    <hr style=\"width: 50%; float: right;\">
";
$temp_footer = "
    <hr>
    " . uri("domain") . "<br>" . tanim('email', 'n1', 0) . "<br><br>
    " . $design_bottom_icons . "
";
// Veritabanı kontrolü
$tsql = ($_SESSION["tID"] == "") ? " and s7=1" : " and id=" . mysqli_real_escape_string($conn, $_SESSION["tID"]);
if ($tsql) {
    $sql_temp = mysqli_query($conn, "SELECT * FROM genel WHERE t2='tmail' $tsql");
    $rs_temp = mysqli_fetch_assoc($sql_temp);
    if (mysqli_num_rows($sql_temp) > 0) {
        $temp_header = $rs_temp["n7"] ?: $temp_header;
        $temp_footer = $rs_temp["n6"] ?: $temp_footer;
        $mgonderen = $rs_temp["t10"];
        $gonderen = $rs_temp["t11"];
    }
}
// Header ve Footer ile İçerik Düzenleme
$temp_header_with_content = $temp_header ? "<div align=\"center\" style=\"margin-left: auto; margin-right: auto; width:95%; min-height: 65px; padding:10px; border-top-left-radius: 8px; border-top-right-radius: 8px;\">$temp_header</div>" : "";
$temp_footer_with_content = $temp_footer ? "<div style=\"text-align:center; margin-left: auto; margin-right: auto; width:95%; min-height: 65px; padding:10px; border-top-left-radius: 8px; border-top-right-radius: 8px;\">$temp_footer</div>" : "";
// Tasarım HTML başlangıcı
$design_top = "
    <div style=\"width: 100%; font-family: helvetica, 'helvetica neue', arial, verdana, sans-serif; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; padding: 0; margin: 0; background:#".$colors[1]."; width:95%; border-radius: 15px; padding-top: 15px; padding-bottom: 15px; filter: drop-shadow(2px 4px 6px black);\">
    <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:800px; padding:10px; border:0px;font-family:Calibri,'sans-serif'; background:white;\">
        <tr>
            <td>
                $temp_header_with_content
                <table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width:95%;\">
                    <tr>
                        <td>
";
// Tasarım HTML bitişi
$design_bottom = "
                        </td>
                    </tr>
                </table>
                $temp_footer_with_content
                <div style=\"text-align:center;\">".translate("+#Bu Mail Bilgilendirme Amacı ile Gönderilmiştir")."<br><a href=\"".$pweb."\" target=\"_blank\">".translate("+#By CrmPlus+")."</a></div>
                <center><a href=\"".$weburl."/unsubscribe/{malici}\">Listeden Çık</a></center>
            </td>
        </tr>
    </table>
    </div>
";
//echo $design_top . $design_bottom;
?>