<?php
include("include/baglan.php");
include("include/fonksiyonlar.php");
ob_start();
session_start();
oturumkontrolana();

if ($_SESSION["lan"] != '') {

    $dilsec = $db->query("select * from lan where id='{$_SESSION["lan"]}'")->fetch(PDO::FETCH_ASSOC);
}
if ($_GET["lan"]) {

    $_SESSION["lan"] = $_GET["lan"];

    $dilsec = $db->query("select * from lan where id='{$_SESSION["lan"]}'")->fetch(PDO::FETCH_ASSOC);
}
if ($_SESSION["lan"] == '') {
    $dilsec = $db->query("select * from lan where anadil='0'")->fetch(PDO::FETCH_ASSOC);
}
$uyet = $db->query("select * from admin where id='{$_SESSION["id"]}'")->fetch(PDO::FETCH_ASSOC);
$uye = $db->query("select * from admin where id='{$_SESSION["id"]}'")->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title><?= $title ?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta content="<?= $description ?>" name="description" />
    <meta content="<?= $author ?>" name="author" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <link rel="shortcut icon" href="../imgupload/<?= $favicon ?>">

    <link href="assets/plugins/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/plugins/datatables/responsive.bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/plugins/datatables/dataTables.bootstrap.min.css" rel="stylesheet" type="text/css" />


    <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="assets/css/icons.css" rel="stylesheet" type="text/css">
    <link href="assets/css/style.css" rel="stylesheet" type="text/css">

</head>


<body class="fixed-left">

    <div id="wrapper">
        <?php include("inc/menu.php") ?>

        <div class="content-page">
            <div class="content">
                <div class="container">
                    <!-- Page-Title -->
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="page-header-title">
                                <h4 class="pull-left page-title">Admin</h4>
                                <ol class="breadcrumb pull-right">
                                    <li><a href="#"><?= $title ?></a></li>
                                    <li class="active">Admin Panel</li>
                                </ol>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                    </div>


                    <form method="post" action="include/fonksiyonlar.php" enctype="multipart/form-data">
                        <div class="row">
                            <div class="col-sm-6 col-lg-6">

                                <div class="panel panel-primary text-center">

                                    <div class="panel-heading">
                                        <h4 class="panel-title">Panel orta header rəngi</h4>
                                    </div>

                                    <div class="panel-body"><input type="color" name="p_renk1" size="100"
                                            value="<?= $panel["p_renk1"] ?>">

                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6 col-lg-6">

                                <div class="panel panel-primary text-center">

                                    <div class="panel-heading">
                                        <h4 class="panel-title">Panel Sol bar rəngi</h4>
                                    </div>

                                    <div class="panel-body"><input type="color" name="p_renk2"
                                            value="<?= $panel["p_renk2"] ?>">

                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-12 col-lg-12">

                                <div class="panel panel-primary text-center">
                                    <br>

                                    <button type="submit" name="genel-ayarlar1"
                                        class="btn btn-info waves-effect waves-light">Rənglərini yenilə
                                    </button>
                                    <br><br>
                                </div>
                            </div>
                            <div class="col-sm-6 col-lg-6">

                                <div class="panel panel-primary text-center">

                                    <div class="panel-heading">
                                        <h4 class="panel-title">Sayt rəngi yazılar</h4>
                                    </div>

                                    <div class="panel-body"><input type="color" name="renk" size="100" value="<?= $renk ?>">

                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-6 col-lg-6">

                                <div class="panel panel-primary text-center">

                                    <div class="panel-heading">
                                        <h4 class="panel-title">Sayt rəngi düymələr</h4>
                                    </div>

                                    <div class="panel-body"><input type="color" name="renk2" size="100"
                                            value="<?= $renk2 ?>">

                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-12 col-lg-12">

                                <div class="panel panel-primary text-center">
                                    <br>

                                    <button type="submit" name="genel-ayarlar"
                                        class="btn btn-info waves-effect waves-light">Rənglərini yenilə
                                    </button>
                                    <br><br>
                                </div>
                            </div>

                            <!-- <div class="col-sm-6 col-lg-3">

                            <div class="panel panel-primary text-center">

                                <div class="panel-heading">
                                    <h4 class="panel-title">Son giriş vaxtdı</h4>
                                </div>

                                <div class="panel-body">
                                    <h3 class=""><b><?= $uye["son_giris"] ?></b></h3>

                                </div>
                            </div>
                        </div> -->


                            <div class="col-sm-6 col-lg-3">

                                <div class="panel panel-primary text-center">

                                    <div class="panel-heading">
                                        <h4 class="panel-title">Yenilənən 1 USD</h4>
                                    </div>

                                    <div class="panel-body">
                                        <h3 class=""><b><?= $usd ?>AZN</b></h3>

                                    </div>
                                </div>
                            </div>
                            <!-- <div class="col-sm-6 col-lg-3">

                                <div class="panel panel-primary text-center">

                                    <div class="panel-heading">
                                        <h4 class="panel-title">Məzənnə 1 - ₼</h4>
                                    </div>

                                    <div class="panel-body">
                                        <h3 class=""><b><?= $aznToUsd ?> $</b></h3>

                                    </div>
                                </div>
                            </div> -->

                            <div class="col-sm-6 col-lg-3">

                                <div class="panel panel-primary text-center">

                                    <div class="panel-heading">
                                        <h4 class="panel-title">Tarix və Saat</h4>
                                    </div>

                                    <div class="panel-body">
                                        <h3 class=""><b><?= $tarih ?> / <?= $saat ?></b></h3>

                                    </div>
                                </div>
                            </div>

                            <div class="col-sm-6 col-lg-3">
                                <div class="panel panel-primary text-center">
                                    <div class="panel-heading">
                                        <h4 class="panel-title">Bakı havası</h4>
                                    </div>
                                    <div class="panel-body">
                                        <?php if ($havadurumu): ?>
                                            <h3 class="">
                                                <b><?= $havadurumu['sicaklik'] ?>°C</b>
                                                <?php if ($havadurumu['simge_url']): ?>
                                                    <img src="<?= $havadurumu['simge_url'] ?>"
                                                        alt="<?= $havadurumu['aciklama'] ?>"
                                                        style="vertical-align: middle; height: 50px;">
                                                <?php endif; ?>
                                            </h3>
                                            <p><?= $havadurumu['aciklama'] ?></p>
                                        <?php else: ?>
                                            <p>Hava vəziyyəti məlumati yenilənmədi.</p>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>

                            <div class="col-sm-6 col-lg-3">
                                <div class="panel panel-primary text-center">
                                    <div class="panel-heading">
                                        <h4 class="panel-title">Sitemap Yarat</h4>
                                    </div>
                                    <div class="panel-body">
                                        <h3 class="">
                                            <button type="button" class="btn btn-success btn-lg" id="generateSitemapBtn">
                                                <i class="fa fa-refresh"></i>Yarat/Yenilə
                                            </button>
                                        </h3>
                                        <p id="sitemapStatus" class="mt-3"></p>
                                        <p><small>Sitemap ən son: <span id="lastSitemapGenTime">Yüklənir...</span>
                                                yenilənib</small></p>
                                    </div>
                                </div>
                            </div>

                            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
                            <script>
                                $(document).ready(function() {
                                    function getLastModifiedDate(url, elementId) {
                                        $.ajax({
                                            url: url,
                                            type: 'HEAD',
                                            success: function(data, textStatus, jqXHR) {
                                                var lastModified = jqXHR.getResponseHeader('Last-Modified');
                                                if (lastModified) {
                                                    $('#' + elementId).text(new Date(lastModified).toLocaleString('tr-TR'));
                                                } else {
                                                    $('#' + elementId).text('Bilinmir');
                                                }
                                            },
                                            error: function() {
                                                $('#' + elementId).text('Giriş Xətası');
                                            }
                                        });
                                    }

                                    // Sitemap'in son güncellenme tarihini göster
                                    getLastModifiedDate('../sitemap.xml', 'lastSitemapGenTime');

                                    $('#generateSitemapBtn').on('click', function() {
                                        var $btn = $(this);
                                        var originalText = $btn.html();
                                        var statusDiv = $('#sitemapStatus');

                                        $btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> Yaradılır...');
                                        statusDiv.removeClass('text-success text-danger').text('');

                                        // sitemap.php dosyasını çağırırken doğru yol
                                        $.ajax({
                                            url: 'sitemap.php',
                                            type: 'GET',
                                            success: function(response) {
                                                statusDiv.addClass('text-success').text('Sitemap uğurla yaradıldı/yeniləndi!');
                                                getLastModifiedDate('../sitemap.xml', 'lastSitemapGenTime');
                                            },
                                            error: function(xhr, status, error) {
                                                statusDiv.addClass('text-danger').text('Sitemap yaradarkən bir xəta baş verdi: ' + error);
                                                console.error("Sitemap AJAX Xətası: ", xhr.responseText);
                                            },
                                            complete: function() {
                                                $btn.prop('disabled', false).html(originalText);
                                            }
                                        });
                                    });
                                });
                            </script>
                            <div class="col-lg-12">


                                <ul class="nav nav-tabs navtab-bg">


                                    <li class="active">
                                        <a href="#home" data-toggle="tab" aria-expanded="false">
                                            <span class="visible-xs"><i class="fa fa-home"></i></span>
                                            <span class="hidden-xs">Əsas səhifə Haqqımızda</span>
                                        </a>
                                    </li>
                                    <li class="">
                                        <a href="#profile" data-toggle="tab" aria-expanded="true">
                                            <span class="visible-xs"><i class="fa fa-user"></i></span>
                                            <span class="hidden-xs">Banner və İndex şəkilləri</span>
                                        </a>
                                    </li>

                                    <li class="">
                                        <a href="#settings" data-toggle="tab" aria-expanded="false">
                                            <span class="visible-xs"><i class="fa fa-cog"></i></span>
                                            <span class="hidden-xs">Sosial media linkleri</span>
                                        </a>
                                    </li>

                                    <li class="">
                                        <a href="#mail" data-toggle="tab" aria-expanded="false">
                                            <span class="visible-xs"><i class="fa fa-cog"></i></span>
                                            <span class="hidden-xs">SMTP mail tənzimləməsi</span>
                                        </a>
                                    </li>
                                </ul>


                                <div class="tab-content">
                                    <div class="tab-pane active" id="home">





                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Video Linki</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" name="video"
                                                value="<?= $video ?>">
                                        </div>




                                        <div class="form-group">
                                            <label>Haqqımızda şəkili</label>
                                            <input type="file" class="colorpicker-default form-control" name="hresim">
                                        </div>
                                        <div class="form-group">
                                            <img src="../imgupload/<?= $hresim ?>" width="200">
                                        </div>
                                        <div class="form-group">
                                            <label>Haqqımızda şəkili 2</label>
                                            <input type="file" class="colorpicker-default form-control" name="hresim2">
                                        </div>
                                        <div class="form-group">
                                            <img src="../imgupload/<?= $hresim2 ?>" width="200">
                                        </div>

                                        <button type="submit" name="haqqimizda-duzelis"
                                            class="btn btn-info waves-effect waves-light">Təsdiqlə
                                        </button>

                                    </div>
                                    <div class="tab-pane " id="profile">
                                        <div class="form-group">
                                            <label>Banner Şəkili</label>
                                            <input type="file" class="colorpicker-default form-control" name="resim">
                                        </div>
                                        <div class="form-group">
                                            <img src="../imgupload/<?= $bead["resim"] ?>" width="200">
                                        </div>
                                        <input type="hidden" name="link" value="../">
                                        <div class="form-group">
                                            <label>Footer Şəkili</label>
                                            <input type="file" class="colorpicker-default form-control" name="footersekli">
                                        </div>
                                        <div class="form-group">
                                            <img src="../imgupload/<?= $bead["footersekli"] ?>" width="200">
                                        </div>
                                        <div class="form-group">
                                            <label>Rəy bölməsi Şəkili</label>
                                            <input type="file" class="colorpicker-default form-control" name="reybolmesekli">
                                        </div>
                                        <div class="form-group">
                                            <img src="../imgupload/<?= $bead["reybolmesekli"] ?>" width="200">
                                        </div>
                                        <div class="form-group">
                                            <label>Xidmət bölməsi Şəkili</label>
                                            <input type="file" class="colorpicker-default form-control" name="xidmetbolmesekli">
                                        </div>
                                        <div class="form-group">
                                            <img src="../imgupload/<?= $bead["xidmetbolmesekli"] ?>" width="200">
                                        </div>
                                        <div class="form-group">
                                            <label>Sual cavab bölməsi Şəkili</label>
                                            <input type="file" class="colorpicker-default form-control" name="sualcavabbolmesekli">
                                        </div>
                                        <div class="form-group">
                                            <img src="../imgupload/<?= $bead["sualcavabbolmesekli"] ?>" width="200">
                                        </div>
                                        <div class="form-group">
                                            <label>Statistika bölməsi Şəkili</label>
                                            <input type="file" class="colorpicker-default form-control" name="statistikabolmesekli">
                                        </div>
                                        <div class="form-group">
                                            <img src="../imgupload/<?= $bead["statistikabolmesekli"] ?>" width="200">
                                        </div>
                                        <input type="hidden" name="link" value="../">
                                        <button type="submit" name="beadcrumb-duzenle"
                                            class="btn btn-info waves-effect waves-light">Təsdiqlə
                                        </button>
                                    </div>
                                    <div class="tab-pane" id="messages">
                                        <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula
                                            eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient
                                            montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque
                                            eu, pretium quis, sem. Nulla consequat massa quis enim.</p>
                                        <p>Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim
                                            justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu
                                            pede mollis pretium. Integer tincidunt.Cras dapibus. Vivamus elementum semper
                                            nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu,
                                            consequat vitae, eleifend ac, enim.</p>
                                    </div>
                                    <div class="tab-pane" id="settings">

                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Facebook</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" name="facebook"
                                                value="<?= $facebook ?>">
                                        </div>

                                        <div class="form-group">
                                            <label for="exampleInputEmail1">İnstagram</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" name="instagram"
                                                value="<?= $instagram ?>">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Youtube</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" name="youtube"
                                                value="<?= $youtube ?>">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Whatsapp linki</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" name="whatsappp"
                                                value="<?= $whatsappp ?>">
                                        </div>

                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Linkedin</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" name="linkedin"
                                                value="<?= $linkedin ?>">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Pinterest</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" name="pinterest"
                                                value="<?= $pinterest ?>">
                                        </div>

                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Telegram</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" name="telegram"
                                                value="<?= $telegram ?>">
                                        </div>

                                        <button type="submit" name="sosyal-medya"
                                            class="btn btn-info waves-effect waves-light">Sosial media linkləri yenilə
                                        </button>
                                    </div>
                                    <div class="tab-pane" id="mail">

                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Sayt gmailı</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1" name="site_mail"
                                                value="<?= $smtp["site_mail"] ?>">
                                        </div>

                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Sayt gmail Şifre</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1"
                                                name="site_mail_sifre" value="<?= $smtp["site_mail_sifre"] ?>">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Sayt gmail Host</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1"
                                                name="site_mail_host" value="<?= $smtp["site_mail_host"] ?>">
                                        </div>
                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Sayt gmail Port</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1"
                                                name="site_mail_port" value="<?= $smtp["site_mail_port"] ?>">
                                        </div>

                                        <div class="form-group">
                                            <label for="exampleInputEmail1">Göndərən gmail</label>
                                            <input type="text" class="form-control" id="exampleInputEmail1"
                                                name="gonderen_mail" value="<?= $smtp["gonderen_mail"] ?>">
                                        </div>


                                        <button type="submit" name="smtp-ayar"
                                            class="btn btn-info waves-effect waves-light">SMTP yenilə
                                        </button>
                                    </div>
                                </div>

                            </div>

                        </div>
                    </form>


                </div>

            </div>

            <?php include("inc/footer.php"); ?>

        </div>

    </div>


    <script src="assets/js/jquery.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>
    <script src="assets/js/modernizr.min.js"></script>
    <script src="assets/js/detect.js"></script>
    <script src="assets/js/fastclick.js"></script>
    <script src="assets/js/jquery.slimscroll.js"></script>
    <script src="assets/js/jquery.blockUI.js"></script>
    <script src="assets/js/waves.js"></script>
    <script src="assets/js/wow.min.js"></script>
    <script src="assets/js/jquery.nicescroll.js"></script>
    <script src="assets/js/jquery.scrollTo.min.js"></script>

    <script src="assets/plugins/jquery-sparkline/jquery.sparkline.min.js"></script>

    <script src="assets/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="assets/plugins/datatables/dataTables.bootstrap.js"></script>
    <script src="assets/plugins/datatables/dataTables.responsive.min.js"></script>
    <script src="assets/plugins/datatables/responsive.bootstrap.min.js"></script>

    <script src="assets/pages/dashborad.js"></script>

    <script src="assets/js/app.js"></script>

</body>

</html>