<?php
ob_start();
session_start();
date_default_timezone_set('Europe/Istanbul');
if (isset($_POST['city'])) {
    $city = $_POST['city'];
    setcookie('city', $city, 60 * 60 * 24 * 365, "/");
    $_COOKIE['city'] = $city;
    $_SESSION['city'] = $city;
} else if (isset($_COOKIE['city'])) {
    $city = $_COOKIE['city'];
} else if (isset($_SESSION['city'])) {
    $city = $_SESSION['city'];
} else {
    $city = "istanbul";
    $_COOKIE['city'] = $city;
    setcookie('city', $city, 60 * 60 * 24 * 365, "/");
}
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
$curl = curl_init();
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array('username' => 'rest_integration', 'password' => 'Verify_06_O*P', 'city' => $city)));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://serverkursu.com/rest/get/getPrayTimes/" . $city,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
));

$response = curl_exec($curl);

$err = curl_error($curl);

curl_close($curl);
$decode = json_decode($response);
$prayTimes = $decode->times;
?>
<!DOCTYPE html>
<html lang="tr">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Server Life</title>
    <link rel="icon" type="image/png" href="fav-icon.png">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
    <script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
    <style>
        .pray-box {
            padding: 5px 0px;
            border-bottom: 1px solid;
        }

        .active-box {
            background-color: #1d5fad;
            color: white;
            border-color: black;
        }
    </style>
</head>

<body style="background-color:#fcf8ed;text-align:center">
    <div class="row m-3 md-5">
        <div class="col-12 col-md-6 my-3">
            <a href="/"><img src="main-logo.png" style="width:200px"></a>
        </div>
        <div class="col-12 col-md-6 my-3">
            <div class="header-namaz-vakitleri float-end m-0">
                <?php
                setlocale(LC_TIME, "tr_TR");
                $date = iconv('latin5', 'utf-8', strftime("%d %B %Y"));
                ?>
                <div class="row" style="border-bottom:3px solid;font-size: 14px;margin-bottom: 5px;padding-bottom: 5px;">
                    <div class="col-4 p-0">
                        <a href="#" title="Şehir Seçimi" id="changeCity" data-bs-toggle="modal" data-bs-target="#modalCity"><b><?= strtoupper($city); ?></b></a>
                    </div>
                    <div class="col-4 text-center fw-bold p-0"><?= $decode->hijri->string_format; ?></div>
                    <div class="col-4"><?= $date; ?></div>
                </div>
                <?php if ($prayTimes != null) { ?>
                    <div class="row">
                        <div class="col-4 pray-box <?= date('H:i:s') > $prayTimes->yatsi ? "fw-bold active-box" : ""; ?>">İmsak <span><?= date("H:i", strtotime($prayTimes->imsak)); ?></span></div>
                        <div class="col-4 pray-box <?= date('H:i:s') > $prayTimes->imsak && date('H:i:s') < $prayTimes->gunes ? "fw-bold active-box" : ""; ?>">Güneş <span><?= date("H:i", strtotime($prayTimes->gunes)); ?></span></div>
                        <div class="col-4 pray-box <?= date('H:i:s') > $prayTimes->gunes && date('H:i:s') < $prayTimes->ogle ? "fw-bold active-box" : ""; ?>">Öğle <span><?= date("H:i", strtotime($prayTimes->ogle)); ?></span></div>
                        <div class="col-4 pray-box <?= date('H:i:s') > $prayTimes->ogle && date('H:i:s') < $prayTimes->ikindi ? "fw-bold active-box" : ""; ?>">İkindi <span><?= date("H:i", strtotime($prayTimes->ikindi)); ?></span></div>
                        <div class="col-4 pray-box <?= date('H:i:s') > $prayTimes->ikindi && date('H:i:s') < $prayTimes->aksam ? "fw-bold active-box" : ""; ?>">Akşam <span><?= date("H:i", strtotime($prayTimes->aksam)); ?></span></div>
                        <div class="col-4 pray-box <?= date('H:i:s') > $prayTimes->aksam ? "fw-bold active-box" : ""; ?>">Yatsı <span><?= date("H:i", strtotime($prayTimes->yatsi)); ?></span></div>
                    </div>
                <?php } ?>
            </div>
        </div>
    </div>
    <div class="row" style="max-width: 800px;margin:0px auto">

        <div class="col-4 col-md-2 mb-5" style="border-right:1px dashed #e6dcc3">
            <img src="ff.png" style="max-width:80px;width:100%" alt=""><br>
            <small style="font-size: 10px;color: #af4646;font-weight: bold;">Kur’ân-ı Kerîm</small>
            <p style="font-size: 10px;margin-top: 15px;">Web Sitesi<br><a href="http://feyzulfurkan.com/">feyzulfurkan.com</a><br><br>Mobil Uygulama</p>
            <a href="https://apps.apple.com/tr/app/feyzul-furkan/id378448713?l=tr">
                <img class="w-100" style="max-width: 100px;" src="m1.png" alt="App Store">
            </a><br>
            <a href="https://play.google.com/store/apps/details?id=com.serveriletisim.ffandroid&pcampaignid=web_share">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m2.png" alt="Play Store">
            </a><br>
            <a href="https://appgallery.huawei.com/app/C118328519">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m3.png" alt="Huawei Store">
            </a><br>
            <a href="feyzulfurkan.apk">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m4.png" alt="APK">
            </a>
            <p style="font-size: 10px;margin-top: 15px;"><a href="ff_gecmis.html">Sürüm Geçmişi</a><br></p>
        </div>

        <div class="col-4 col-md-2 mb-5" style="border-right:1px dashed #e6dcc3">
            <img src="logo2.png" style="max-width:80px;width:100%" alt=""><br>
            <small style="font-size: 10px;color: #10b9d2;font-weight: bold;">DUA</small>
            <p style="font-size: 10px;margin-top: 15px;">Web Sitesi<br><a href="http://serverdua.com/">serverdua.com</a><br><br>Mobil Uygulama</p>
            <a href="https://apps.apple.com/tr/app/dua-evrad-%C4%B1-%C5%9Ferife/id1133866841?l=tr">
                <img class="w-100" style="max-width: 100px;" src="m1.png" alt="App Store">
            </a><br>
            <a href="https://play.google.com/store/apps/details?id=com.serveriletisim.duaapp&pcampaignid=web_share">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m2.png" alt="Play Store">
            </a><br>
            <a href="https://appgallery.huawei.com/app/C109482867?sharePrepath=ag&locale=tr_TR&source=appshare&subsource=C109482867">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m3.png" alt="Huawei Store">
            </a><br>
            <a href="gunlukduaokumalari.apk">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m4.png" alt="APK">
            </a>
            <p style="font-size: 10px;margin-top: 15px;"><a href="dua_gecmis.html">Sürüm Geçmişi</a><br></p>
        </div>

        <div class="col-4 col-md-2 mb-5" style="border-right:1px dashed #e6dcc3">
            <img src="logo-sk.png" style="max-width:80px;width:100%" alt=""><br>
            <small style="font-size: 10px;color: #B8611A;font-weight: bold;">Server Kürsü</small>
            <p style="font-size: 10px;margin-top: 15px;">Web Sitesi<br><a href="http://serverkursu.com/">serverkursu.com</a><br><br>Mobil Uygulama</p>
        </div>

        <div class="col-4 col-md-2 mb-5" style="border-right:1px dashed #e6dcc3">
            <img src="logo5.png" style="max-width:80px;width:100%" alt=""><br>
            <small style="font-size: 10px;color: #10b9d2;font-weight: bold;">Gıda Katkı Maddeleri</small>
            <p style="font-size: 10px;margin-top: 15px;"><br><a href="#"></a><br><br>Mobil Uygulama</p>
            <a href="https://apps.apple.com/tr/app/g%C4%B1da-katk%C4%B1-maddeleri/id1000558182?l=tr">
                <img class="w-100" style="max-width: 100px;" src="m1.png" alt="App Store">
            </a><br>
            <a href="https://play.google.com/store/apps/details?id=com.serveriletisim.gidakatkimaddeleripro&hl=tr&gl=US">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m2.png" alt="Play Store">
            </a><br>
            <a href="https://appgallery.huawei.com/#/app/C118312935">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m3.png" alt="Huawei Store">
            </a><br>
            <a href="https://drive.google.com/file/d/1HzwIFp3GcxAdfoQhOPJht_tG_OLRmt7W/view?usp=sharing">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m4.png" alt="APK">
            </a>
        </div>

        <div class="col-4 col-md-2 mb-5" style="border-right:1px dashed #e6dcc3">
            <img src="akra.png" style="max-width:80px;width:100%" alt=""><br>
            <small style="font-size: 10px;color: #0e3d5b;font-weight: bold;">AKRA.media</small>
            <p style="font-size: 10px;margin-top: 15px;">Web Sitesi<br><a href="http://akra.media/">akra.media</a><br><br>Mobil Uygulama</p>
            <a href="https://apps.apple.com/tr/app/akra-media/id1507921044?l=tr">
                <img class="w-100" style="max-width: 100px;" src="m1.png" alt="App Store">
            </a><br>
            <a href="https://play.google.com/store/apps/details?id=com.halas.akramedia&pcampaignid=web_share">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m2.png" alt="Play Store">
            </a>
        </div>

        <div class="col-4 col-md-2 mb-5">
            <img src="logo7.png" style="max-width:80px;width:100%" alt=""><br>
            <small style="font-size: 10px;color: #10b9d2;font-weight: bold;">Ufka Yolculuk</small>
            <p style="font-size: 10px;margin-top: 15px;">Web Sitesi<br><a href="https://ufkayolculuk.com/">ufkayolculuk.com</a><br><br>Mobil Uygulama</p>
            <a href="https://apps.apple.com/tr/app/ufka-yolculuk-app/id6756546563?l=tr">
                <img class="w-100" style="max-width: 100px;" src="m1.png" alt="App Store">
            </a><br>
            <a href="https://play.google.com/store/apps/details?id=com.serveriletisim.ufkayolculuk&hl=tr">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m2.png" alt="Play Store">
            </a><br>
            <a href="https://appgallery.huawei.com/app/C118445737">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m3.png" alt="Huawei Store">
            </a><br>
            <a href="ufkayolculuk.apk">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m4.png" alt="APK">
            </a>
        </div>

        <div class="col-4 col-md-2 mb-5" style="border-right:1px dashed #e6dcc3">
            <img src="duha.png" style="max-width:80px;width:100%" alt=""><br>
            <small style="font-size: 10px;color: #0e3d5b;font-weight: bold;">Duha</small>
            <p style="font-size: 10px;margin-top: 15px;">Web Sitesi<br><a href="https://duha.global">duha.global</a><br><br>Mobil Uygulama</p>
            <a href="https://apps.apple.com/tr/app/duha-kurban-y%C3%B6netim/id1633055892?l=tr">
                <img class="w-100" style="max-width: 100px;" src="m1.png" alt="App Store">
            </a><br>
            <a href="https://play.google.com/store/apps/details?id=com.halasteknoloji.meckurbanyonetim&pcampaignid=web_share">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m2.png" alt="Play Store">
            </a>
        </div>

        <div class="col-4 col-md-2 mb-5" style="border-right:1px dashed #e6dcc3">
            <img src="buhari.png" style="max-width:80px;width:100%" alt=""><br>
            <small style="font-size: 10px;color: #0e3d5b;font-weight: bold;">Buhari</small>
            <p style="font-size: 10px;margin-top: 15px;"><br><a href=""></a><br><br>Mobil Uygulama</p>
            <a href="https://apps.apple.com/tr/app/buhari/id6742466583?l=tr">
                <img class="w-100" style="max-width: 100px;" src="m1.png" alt="App Store">
            </a><br>
            <a href="https://play.google.com/store/apps/details?id=com.server.buhari&pcampaignid=web_share">
                <img class="w-100 mt-3" style="max-width: 100px;" src="m2.png" alt="Play Store">
            </a>
        </div>
        
    </div>
</body>
<div class="modal fade" tabindex="-1" role="dialog" id="modalCity">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h1 class="modal-title fs-5">Şehir Seç </h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body p-5 pt-0">
                <form method="post">
                    <div class="form-floating m-3">
                        <select type="text" name="city" class="form-select">
                            <option value="adana">Adana</option>
                            <option value="adiyaman">Adıyaman</option>
                            <option value="afyonkarahisar">Afyonkarahisar</option>
                            <option value="agri">Ağrı</option>
                            <option value="amasya">Amasya</option>
                            <option value="ankara">Ankara</option>
                            <option value="antalya">Antalya</option>
                            <option value="artvin">Artvin</option>
                            <option value="aydin">Aydın</option>
                            <option value="balikesir">Balıkesir</option>
                            <option value="bilecik">Bilecik</option>
                            <option value="bingol">Bingöl</option>
                            <option value="bitlis">Bitlis</option>
                            <option value="bolu">Bolu</option>
                            <option value="burdur">Burdur</option>
                            <option value="bursa">Bursa</option>
                            <option value="canakkale">Çanakkale</option>
                            <option value="cankiri">Çankırı</option>
                            <option value="corum">Çorum</option>
                            <option value="denizli">Denizli</option>
                            <option value="diyarbakir">Diyarbakır</option>
                            <option value="edirne">Edirne</option>
                            <option value="elazig">Elazığ</option>
                            <option value="erzincan">Erzincan</option>
                            <option value="erzurum">Erzurum</option>
                            <option value="eskisehir">Eskişehir</option>
                            <option value="gaziantep">Gaziantep</option>
                            <option value="giresun">Giresun</option>
                            <option value="gumushane">Gümüşhane</option>
                            <option value="hakkari">Hakkâri</option>
                            <option value="hatay">Hatay</option>
                            <option value="isparta">Isparta</option>
                            <option value="mersin">Mersin</option>
                            <option value="istanbul">İstanbul</option>
                            <option value="izmir">izmir</option>
                            <option value="kars">Kars</option>
                            <option value="kastamonu">Kastamonu</option>
                            <option value="kayseri">Kayseri</option>
                            <option value="kirklareli">Kırklareli</option>
                            <option value="kirsehir">Kırşehir</option>
                            <option value="kocaeli">Kocaeli</option>
                            <option value="konya">Konya</option>
                            <option value="kutahya">Kütahya</option>
                            <option value="malatya">Malatya</option>
                            <option value="manisa">Manisa</option>
                            <option value="kahramanmaras">Kahramanmaraş</option>
                            <option value="mardin">Mardin</option>
                            <option value="mugla">Muğla</option>
                            <option value="mus">Muş</option>
                            <option value="nevsehir">Nevşehir</option>
                            <option value="nigde">Niğde</option>
                            <option value="ordu">Ordu</option>
                            <option value="rize">Rize</option>
                            <option value="sakarya">Sakarya</option>
                            <option value="samsun">Samsun</option>
                            <option value="siirt">Siirt</option>
                            <option value="sinop">Sinop</option>
                            <option value="sivas">Sivas</option>
                            <option value="tekirdag">Tekirdağ</option>
                            <option value="tokat">Tokat</option>
                            <option value="trabzon">Trabzon</option>
                            <option value="tunceli">Tunceli</option>
                            <option value="sanliurfa">Şanlıurfa</option>
                            <option value="usak">Uşak</option>
                            <option value="van">Van</option>
                            <option value="yozgat">Yozgat</option>
                            <option value="zonguldak">Zonguldak</option>
                            <option value="aksaray">Aksaray</option>
                            <option value="bayburt">Bayburt</option>
                            <option value="karaman">Karaman</option>
                            <option value="kirikkale">Kırıkkale</option>
                            <option value="batman">Batman</option>
                            <option value="sirnak">Şırnak</option>
                            <option value="bartin">Bartın</option>
                            <option value="ardahan">Ardahan</option>
                            <option value="igdir">Iğdır</option>
                            <option value="yalova">Yalova</option>
                            <option value="karabuk">Karabük</option>
                            <option value="kilis">Kilis</option>
                            <option value="osmaniye">Osmaniye</option>
                            <option value="duzce">Düzce</option>
                        </select>
                        <label for="city_id">Şehir Seçiniz</label>
                    </div>
                    <button class="w-100 mb-2 btn btn-lg rounded-3 btn-primary" type="submit">Kaydet</button>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    $('#changeCity').on("click", function() {
        $('#modalCity').modal('show');
    })
</script>

</html>