<?php
include 'config.php';

$user_onesignal = $_COOKIE['user_onesignal'];
$user_token = $_COOKIE['user_token'];


$url = $_SERVER['PHP_SELF']; // OR $_SERVER['REQUEST_URI']
$ip = $_SERVER["REMOTE_ADDR"];





if(empty($user_token) OR empty($user_onesignal)) {
$ortam = parse_url($url, PHP_URL_PATH);
if($ortam != "/login.php" AND $ortam != "/register.php"){
header("Location: exit.php");
}

}





$user_token = $_COOKIE['user_token'];

$myUser = $db->query("SELECT * FROM kullanicilar WHERE user_token = '$user_token'")->fetch(PDO::FETCH_ASSOC);

$user_id = $myUser['user_id'];
$suan = time();

$query = $db->prepare("UPDATE kullanicilar SET
user_songiris = :bir
WHERE user_token = :iki");
$update = $query->execute(array(
     "bir" => $suan,
     "iki" => $user_token
));

if($myUser['user_ban']!=0){
    echo '<title>Yasaklandınız!</title>
    <meta name="viewport"
        content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" />';
    echo "<style>
    b.bir {
        font-family:sans-serif;
    }
 
    b.iki {
        font-family:monospace;
    }
</style>";

    echo "<br><br><br><center><b class='bir'>HESABINIZ ALDIĞINIZ ŞİKAYETLER <br />NEDENİYLE YASAKLANDI!</b><br><br><img src='assets/img/yasak.jpg' style='max-width: 100%'><br /><br /><br /><b class='bir'>İletişim: heysen@yandex.com</b></center>";
        die();
}


if($myUser['user_deaktif']!=0){
    echo '<meta name="viewport"
        content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" />';
    echo "";

    echo "<br><br><br><center><b>BU HESAP SİLİNMİŞ</b><br><br><img src='assets/img/yasak.jpg' style='max-width: 100%'></center>";

$query = $db->prepare("UPDATE kullanicilar SET
user_onesignal = :bir
WHERE user_token = :iki");
$update = $query->execute(array(
     "bir" => NULL,
     "iki" => $user_token
));

    header("Refresh:5; url=exit.php");
        die();
}

?>
<!doctype html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, viewport-fit=cover" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="theme-color" content="#000000">
    <title>HeySen v1.0</title>
    <meta name="description" content="Mobilekit HTML Mobile UI Kit">
    <meta name="keywords" content="bootstrap 4, mobile template, cordova, phonegap, mobile, html" />
    <link rel="icon" type="image/png" href="assets/img/favicon.png" sizes="32x32">
    <link rel="apple-touch-icon" sizes="180x180" href="assets/img/icon/192x192.png">
    <link rel="stylesheet" href="assets/css/style.css">

        <script src="assets/js/lib/jquery-3.4.1.min.js"></script>
            <script type="text/javascript">
    
$(document).ready(function() {


<?php 

$ortam = parse_url($url, PHP_URL_PATH);
if($ortam != "/bilgi_doldur.php" AND $ortam != "/login.php" AND $ortam != "/register.php"){


if($myUser['user_cinsiyet']===NULL OR $myUser['user_sehir']===NULL OR $myUser['user_yas']===NULL){ ?>

window.location.href = "bilgi_doldur.php";

<?php }} ?>

});
</script>
</head>

<body>

    <!-- loader -->
    <div id="loader">
        <div class="spinner-border text-primary" role="status"></div>
    </div>
    <!-- * loader -->

    <!-- App Header --> 


	<div class="appHeader" id="normalheader">
		<div class="left">
            <a href="index.html#" class="headerButton" data-toggle="modal" data-target="#sidebarPanel">
                <i class="fa-solid fa-bars fa-lg"></i>
            </a>
        </div>
                <div class="pageTitle">
                    <a href="./"><img src="assets/img/logo.png" alt="logo" class="logo"></a>
                </div>
                <div class="right">
                    <!-- <a href="javascript:void(0)" data-toggle="modal" data-target="#belesJetonid" class="headerButton"> -->
                        <a href="javascript:void(0)" data-toggle="modal" data-target="#ModalBasic" class="headerButton">
                
                <i class="fa-regular fa-eye text-warning fa-xl"></i>
                <span class="badge badge-danger">1+</span>
            </a>

            <a href="javascript:void(0)" data-toggle="modal" data-target="#ModalListviewx" class="headerButton">
                <i class="fa-regular fa-bell text-warning fa-xl"></i>
                <span class="badge badge-success">1+</span>
            </a>

                </div>
    </div>


    <!-- * App Header -->

<style type="text/css">
    
    .blurla{
        filter: blur(4px);
        -webkit-filter: blur(4px);
    }

    .noselect {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    pointer-events:none;
    }

</style>
<script type="text/javascript">
    
    function uyariVer(){

$("#ModalBasic").modal("toggle");
$("#ziyaret_kilit").modal("show");

    }

    function uyariVer2(){

$("#aramaListview").modal("hide");
$("#arama_kilit").modal("show");

    }

    function yogunUyari(){
        $("#aramaListview").modal("toggle");
        $('#DialogIconedSuccess2').modal('show');  
    }



    function buyVisit(){



    }

</script>

<?php 

if($myUser['user_visit']==0){
    $blurla = " blurla noselect";
    $oncl = 'onclick="uyariVer();" ';
}


if($myUser['user_call']==0){
    $blurla2 = " blurla noselect";
    $oncl2 = 'onclick="uyariVer2();" ';
}

?>


        <!-- Dialog Iconed Inline -->
        <div class="modal fade dialogbox" id="ziyaret_kilit" data-backdrop="static" tabindex="-1"
            role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                     <div class="modal-icon text-danger">
                       <i class="fa-solid fa-lock fa-xs"></i>
                    </div>
                    <div class="modal-header">
                        <h5 class="modal-title">Ziyaretçiler Kilitli!</h5>
                    </div>
                    <div class="modal-body">
                        Profilinizi ziyaret eden kullanıcıları sınırsız olarak görebilmek için kilidi açmanız gerekmektedir!
                    </div>
                    <div class="modal-footer">
                        <div class="btn-inline">
                            <a onclick="buyJeton2('visitorunlock');" href="javascript:void(0)" class="btn btn-text-success" data-dismiss="modal">
                               <i class="fa-solid fa-unlock-keyhole mr-1"></i>
                                Kilidi Aç
                            </a>
                            <a href="component-dialog.html#" class="btn btn-text-secondary" data-dismiss="modal">
                               <i class="fa-solid fa-hourglass mr-1"></i>
                                Sonra
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- * Dialog Iconed Inline -->


        <!-- Modal Basic -->
        <div class="modal fade modalbox" id="ModalBasic" data-backdrop="static" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title"> <i class="fa-regular fa-eye text-warning fa-xl"></i> Profilini Ziyaret Edenler</h5>
                        <a href="javascript:;" data-dismiss="modal">Kapat</a>
                    </div>
                    <div class="modal-body">
                  
<div class="alert alert-primary" role="alert">
                    <h4 class="alert-title">Profilini Ziyaret Eden Kullanıcıları Buradan Görebilir ve Onlarla Tanışmak için Mesaj Gönderebilirsin!</h4>
                </div>
                <br />

                    <div <?=$oncl?>class="mt-2 pr-2 pl-2">
                        <div class="row">
                           

<?php 
if(isset($user_id)){

$query = $db->query("SELECT * FROM ziyaretler WHERE u_to = {$user_id} ORDER BY id DESC LIMIT 15", PDO::FETCH_ASSOC);
if ($query->rowCount()>0){


foreach ($query as $veri) {
    // code...
$kBilgisi = $db->query("SELECT * FROM kullanicilar WHERE user_id = '{$veri['u_from']}'")->fetch(PDO::FETCH_ASSOC);


echo '<div class="col-4 mb-2'.$blurla.'" onclick="window.location.href=\'profil.php?id='.$veri['u_from'].'\'">
                                <img src="/'.$kBilgisi['user_picture'].'" alt="image" class="imaged w-100">
                            </div>';

}

}else{
    echo '<div class="error-page">
            <div class="icon-box text-danger">
                <i class="fa-solid fa-circle-exclamation"></i>
            </div>
            <h1 class="title">Bilgilendirme</h1>
            <div class="text mb-5">
                Henüz Profilinizi Ziyaret Eden Yok!
            </div>
        </div>';
}
}

?>




                            
                        </div>
                    </div>

                    </div>
                </div>
            </div>
        </div>
        <!-- * Modal Basic -->









    <!-- Modal Listview -->
<div class="modal fade modalbox" id="ModalListviewx" data-backdrop="static" tabindex="-1" role="dialog">
   <div class="modal-dialog" role="document">
      <div class="modal-content">
         <div class="modal-header">
            <h5 class="modal-title">Bildirimleriniz</h5>
            <a href="javascript:;" data-dismiss="modal">Kapat</a>
         </div>
         <div class="modal-body p-0">
            <ul class="listview image-listview flush mb-2">

<!--                 <li>
<div class="error-page">
            <div class="mb-2">
                <img src="https://kadikoyehliyet.org/wp-content/uploads/2018/11/icon.png" alt="alt" class="imaged square w200">
            </div>
            <h1 class="title">Bildiriminiz Yok!</h1>
            <div class="text mb-3">
                Henüz bir bildiriminiz yok.
            </div>

      
        </div>
               </li> -->


<?php



if(isset($user_id)){

$query = $db->query("SELECT * FROM begeniler WHERE begenilen_id = {$user_id} ORDER BY id DESC LIMIT 30", PDO::FETCH_ASSOC);
if ($query->rowCount()>0){


foreach ($query as $veri) {
    // code...
$kBilgisi = $db->query("SELECT * FROM kullanicilar WHERE user_id = '{$veri['begenen_id']}'")->fetch(PDO::FETCH_ASSOC);
$zamanim = date('Y-m-d H:i:s', $veri['zaman']);

echo '<li>
                  <div class="item" onclick="window.location.href=\'profil.php?id='.$veri['begenen_id'].'\'">
                     <img src="/'.$kBilgisi['user_picture'].'" alt="image" class="image">
                     <div class="in">
                        <div>
                           <b>'.$kBilgisi['user_fullname'].'</b>
                           sizi beğendi❤️
                           <footer><i class="fa-solid fa-clock" style="margin-right: 2px;"></i>'.time_ago($zamanim).'</footer>
                        </div>
                     </div>
                  </div>
               </li>';

}

}else{

echo '<li>
<div class="error-page">
            <div class="mb-2">
                <img src="assets/img/check.png" alt="alt" class="imaged square w200">
            </div>
            <h1 class="title">Bildiriminiz Yok!</h1>
            <div class="text mb-3">
                Henüz bir bildiriminiz yok.
            </div>

      
        </div>
               </li>';

}

}

?>

            </ul>
         </div>
      </div>
   </div>
</div>
    <!-- Modal Listview -->





                
















<script type="text/javascript">

    function buyJeton(value){

        var butonici = $("#"+value).html();
        $("#"+value).prop('disabled', true);
        $("#"+value).html('<span class="spinner-border spinner-border-sm mr-05" role="status" aria-hidden="true"></span> Bekleyin!');

setTimeout(function(){ 
Android.javaFuncs(value+"-"+"<?=$user_id?>")
        }, 1000);
       
       setTimeout(function(){ 
                $("#"+value).prop('disabled', false);
        $("#"+value).html(butonici);
        }, 2000);


    }

function belesJeton() {
    

$('#belesJetonid').modal('show');


}


function playAc(value){

Android.playAc(value);

}

</script>



        



        <!-- Modal Listview -->
<div class="modal fade modalbox" id="jetonPaketleri" data-backdrop="static" tabindex="-1" role="dialog">
   <div class="modal-dialog" role="document">
      <div class="modal-content">
         <div class="modal-header">
            <h5 class="modal-title">Jeton Paketleri</h5>
            <a href="javascript:;" data-dismiss="modal">Kapat</a>
         </div>
         <div class="modal-body p-0">
<div class="section mt-2">

<div class="alert alert-primary mb-2" role="alert">
                    Bir kere ödeme yaparsınız. Otomatik yenilenmez.
                </div>

            <div class="card">
                <ul class="listview flush transparent image-listview">

<!--                   <li>
                    <div class="item">
                      <div class="icon-box bg-warning">
                        <i class="fa-solid fa-coins"></i>
                      </div>
                      <div class="in">
                        5 Jeton
                        <button type="button" id="paket1" data-dismiss="modal" onclick="belesJeton();" class="btn paketbtn btn-danger">
                    <ion-icon name="star-outline" role="img" class="md hydrated" aria-label="document text outline"></ion-icon>
                    Ücretsiz
                </button>
                      </div>
                    </div>
                  </li> -->

<?php

$query = $db->query("SELECT * FROM odemeler WHERE user_email = '{$myUser['user_email']}' AND urun='1paket' ORDER BY id DESC", PDO::FETCH_ASSOC);
$query2 = $db->query("SELECT * FROM odemeler WHERE user_email = '{$myUser['user_email']}' AND urun='2paket' ORDER BY id DESC", PDO::FETCH_ASSOC);
if ($query->rowCount()==0 AND $query2->rowCount()==0){

    ?>

<!--                   <li>
                    <div class="item">
                      <div class="icon-box bg-warning">
                        <i class="fa-solid fa-coins"></i>
                      </div>
                      <div class="in">
                        50 Jeton
                        <button type="button" id="1paket" onclick="buyJeton('1paket');" class="btn paketbtn btn-success">
                   <i class="fa-solid fa-tags mr-1 fa-xl"></i>
                    49,99 TL
                </button>
                      </div>
                    </div>
                  </li> -->

<?php
 } ?>
<?php 
if ($query2->rowCount()<1){
    ?>
                  <li>
                    <div class="item">
                      <div class="icon-box bg-warning">
                        <i class="fa-solid fa-coins"></i>
                      </div>
                      <div class="in">
                        100 Jeton
                        <button type="button" id="2paket" onclick="buyJeton('2paket');" class="btn paketbtn btn-primary">
                   <i class="fa-solid fa-tags mr-1 fa-xl"></i>
                    99,99 TL
                </button>
                      </div>
                    </div>
                  </li>

                  <?php
              }
              ?>


                  <li>
                    <div class="item">
                      <div class="icon-box bg-warning">
                        <i class="fa-solid fa-coins"></i>
                      </div>
                      <div class="in">
                        250 Jeton
                        <button type="button" id="3paket" onclick="buyJeton('3paket');" class="btn paketbtn btn-success">
                   <i class="fa-solid fa-tags mr-1 fa-xl"></i>
                    199,99 TL
                </button>
                      </div>
                    </div>
                  </li>
                  <li>
                    <div class="item">
                      <div class="icon-box bg-warning">
                        <i class="fa-solid fa-coins"></i>
                      </div>
                      <div class="in">
                        500 Jeton
                       <button type="button" id="4paket" onclick="buyJeton('4paket');" class="btn paketbtn btn-primary">
                   <i class="fa-solid fa-tags mr-1 fa-xl"></i>
                    299,99 TL
                </button>
                      </div>
                    </div>
                  </li>
                 <li>
                    <div class="item">
                      <div class="icon-box bg-warning">
                        <i class="fa-solid fa-coins"></i>
                      </div>
                      <div class="in">
                        1000 Jeton
                        <button type="button" id="5paket" onclick="buyJeton('5paket');" class="btn paketbtn btn-success">
                   <i class="fa-solid fa-tags mr-1 fa-xl"></i>
                    399,99 TL
                </button>
                      </div>
                    </div>
                  </li>

                  <li>
                    <div class="item">
                      <div class="icon-box bg-warning">
                        <i class="fa-solid fa-coins"></i>
                      </div>
                      <div class="in">
                        Sınırsız Jeton
                        <button type="button" id="6paket" onclick="buyJeton('6paket');" class="btn paketbtn btn-primary">
                   <i class="fa-solid fa-tags mr-1 fa-xl"></i>
                    699,99 TL
                </button>
                      </div>
                    </div>
                  </li>
                </ul>
            </div>
          </div>
<div class="divider bg-danger mt-4 mb-2">
                <div class="icon-box bg-danger">
                  <i class="fa-solid fa-arrow-down"></i>
                </div>
            </div>
  <center><div class="mt-3 mb-2 toast-center">Jeton Ne İşe Yarar?</div></center>









            <div class="section">
                <!-- timeline -->
                <div class="timeline">
                    <div class="item">
                        <div class="dot"></div>
                        <div class="content">
                            <h4 class="title">Mesajlaşmak için Jeton gereklidir, atacağınız her mesaj 1 Jeton değerindedir.</h4>
                        </div>
                    </div>
                    <!-- <div class="item">
                        <div class="dot bg-danger"></div>
                        <div class="content">
                            <h4 class="title">Konuştuğunuz kişiye hediye göndermek isterseniz Jeton karşılığında gönderebilirsiniz.</h4>
                        </div>
                    </div> -->
                    <div class="item">
                        <div class="dot bg-warning"></div>
                        <div class="content">
                            <h4 class="title">Normal üyelerde Günlük beğeni hakkı 10 iken Jeton satın aldığınızda 50'ye yükseltilir.</h4>
                        </div>
                    </div>
                    <div class="item">
                        <div class="dot bg-info"></div>
                        <div class="content">
                            <h4 class="title">Jeton Paketi satın aldıktan sonra Yapacağınız beğeniler Jetonlarınızdan düşmez. Günlük 50 beğeni yapabilirsiniz.</h4>
                        </div>
                    </div>
                </div>
                <!-- * timeline -->
            </div>










<!-- <ul class="listview image-listview">
            <li>
                <div class="item">
                    <div class="icon-box bg-primary">
                        <ion-icon name="help-circle-outline" role="img" class="md hydrated" aria-label="image outline"></ion-icon>
                    </div>
                    <div class="in">
                        <div>Mesajlaşmak için Jeton gereklidir, atacağınız her mesaj 1 Jeton değerindedir.</div>
                    </div>
                </div>
            </li>
            <li>
                <div class="item">
                    <div class="icon-box bg-secondary">
                        <ion-icon name="help-circle-outline" role="img" class="md hydrated" aria-label="videocam outline"></ion-icon>
                    </div>
                    <div class="in">
                        <div>Konuştuğunuz kişiye hediye göndermek isterseniz Jeton karşılığında gönderebilirsiniz.</div>
                    </div>
                </div>
            </li>
            <li>
                <div class="item">
                    <div class="icon-box bg-danger">
                        <ion-icon name="help-circle-outline" role="img" class="md hydrated" aria-label="musical notes outline"></ion-icon>
                    </div>
                    <div class="in">
                        <div>Normal üyelerde Günlük beğeni hakkı 10 iken Jeton satın aldığınızda 50'ye yükseltilir.</div>
                    </div>
                </div>
            </li>
        </ul> -->




        </div>



      </div>
   </div>
</div>
    <!-- Modal Listview -->