<?php 
// heysen
include 'header.php';

$profil_id = $_GET['id'];


$profilRow = $db->query("SELECT * FROM kullanicilar WHERE user_id = '{$profil_id}'")->fetch(PDO::FETCH_ASSOC);

$profilBegeni = $db->query("SELECT COUNT(*) FROM begeniler where begenilen_id = '{$profil_id}'")->fetchColumn();

$seniBegenmisMi = $db->query("SELECT COUNT(*) FROM begeniler WHERE begenilen_id = '{$myUser['user_id']}' AND begenen_id = '{$profilRow['user_id']}'")->fetchColumn();

function username($string) {


$pattern = " ";

$turkish = array("ı", "ğ", "ü", "ş", "ö", "ç", "İ", "Ğ", "Ü", "Ş", "Ö", "Ç");//turkish letters
$english   = array("i", "g", "u", "s", "o", "c", "i", "g", "u", "s", "o", "c");//english cooridinators letters


$firstPart = strstr(strtolower($string), $pattern, true);
$secondPart = strstr(strtolower($string), $pattern, false);

$firstPart = str_replace($turkish, $english, $firstPart);
$secondPart = str_replace($turkish, $english, $secondPart);

$nrRand = rand(0, 100);

$username = trim($firstPart).trim($secondPart).trim($nrRand);
return $username;
}

$isimsoyisimCek = explode(" ", $profilRow['user_fullname']);


?>   
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'>

        <style type="text/css">
        	

.heart {
  -webkit-animation: animateHeart 2.5s infinite;
  animation: animateHeart 2.5s infinite;
}
@-webkit-keyframes animateHeart {
  0% {
    -webkit-transform: scale(1.1);
  }
  5% {
    -webkit-transform: scale(1.2);
  }
  10% {
    -webkit-transform: scale(1.1);
  }
  15% {
    -webkit-transform: scale(1.3);
  }
  50% {
    -webkit-transform: scale(1.1);
  }
  100% {
    -webkit-transform: scale(1.1);
  }
}
@keyframes animateHeart {
  0% {
    transform: scale(1.1);
  }
  5% {
    transform: scale(1.2);
  }
  10% {
    transform: scale(1.1);
  }
  15% {
    transform: scale(1.3);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1.1);
  }
}

.scale-image2 {
  object-fit: cover;
    width: 60%;
    height: 250px;
}

.w-100x {
	object-fit: cover;
  width: 100%;
  height: 50px;
}



.discard {
  position: absolute;
  bottom: 20px;
  padding: 10px 15px;
  color: #FFF;
  font-weight: bold;
  background-color: rgb(255 0 0 / 70%);
  border-radius: 0 5px 5px 0;
  pointer-events: none;
}

@keyframes wiggle {
    0% { transform: rotate(0deg); }
   80% { transform: rotate(0deg); }
   85% { transform: rotate(5deg); }
   95% { transform: rotate(-5deg); }
  100% { transform: rotate(0deg); }
}

.wiggle {
  animation: wiggle 2.5s infinite;
}

.wiggle:hover {
  animation: none;
}


        </style>

<script type="text/javascript">

function engelle1(user_id){


        var url = "assets/api.php";
        var bilgi = {
            userid: user_id,
            type: 'engelle'
        }

        $.post(url,bilgi,function(response) {

$("#engelbuton").html('<i class="fa-solid fa-user-large-slash mr-1"></i>Engellendi')

toastbox('toast-5', 5000)

setTimeout(function() {

location.reload();

}, 5000);

    


        })



}

function engelKaldir(value){

    var url = "assets/api.php";
    var bilgi = {
      type: 'engel_kaldir',
      userid: value
    }
    $.post(url,bilgi,function(response) {
    $("#engelbuton").html('<i class="fa-solid fa-clock mr-1"></i>Bekleyin');  

$("#engelkaldiri").remove();
toastbox('toast-6', 5000)
            setTimeout(function() {

location.reload();

      }, 3000);



   })

  }


  function sikayetEt(value){

    var sikayet_tipi = $('input[name="customRadioList"]:checked').val();
    var aciklamasi = $('#sikayetsebebi').val();

    var url = "assets/api.php";
    var bilgi = {
      type: 'sikayetet',
      userid: value,
      sikayet_tipi: sikayet_tipi,
      aciklama: aciklamasi
    }
    $.post(url,bilgi,function(response) {
      

toastbox('toast-4', 5000)
      setTimeout(function() {

location.reload();

      }, 5000);


   })

  }
  
  function begeniGonder2(value){



    var url = "assets/api.php";
    var bilgi = {
      type: 'begeni',
      begenilen_id: value
    }
    $.post(url,bilgi,function(response) {
      var json = JSON.parse(response);

      if(json.result==1){
        $("#user_"+value).html('<i class="fa-solid fa-check fa-lg mr-1"></i>Beğendin');
        $("#user_"+value).prop("onclick", null);
        console.log('begenildi');
      }else if(json.result==100){
  
  $('#bjetonAl').modal('show'); 

  }
      


   })

  }


<?php 

if($seniBegenmisMi>0){ ?>

$(document ).ready(function() {
    //console.log( "ready!" );

setTimeout(function(){ 

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

 }, 1500);



});
<?php 
}
?>

</script>



    <!-- App Capsule -->
<div id="appCapsule">
        <div class="section-full mb-4">
           
        <div class="fab-button animate bottom-right" style="margin-bottom: 60px;">
<!--                                 <button type="button" class="btn btn-icon btn-success mr-1">
                        <ion-icon name="mail-outline" role="img" class="md hydrated" aria-label="logo linkedin"></ion-icon>
                    </button>


                    <button type="button" class="btn btn-icon btn-danger mr-1">
                        <ion-icon name="heart-outline" role="img" class="md hydrated" aria-label="logo linkedin"></ion-icon>
                    </button> -->
                    <!-- <button type="button" class="btn btn-icon btn-warning heart mr-1" data-toggle="modal" data-target="#ModalListviewxz">
                        <ion-icon name="gift-outline" role="img" class="md hydrated" aria-label="logo linkedin"></ion-icon>
                    </button> -->


</div>

<?php

if($profilRow['user_picture']=="assets/img/no-avatar.png"){

            if($profilRow['user_cinsiyet']=="kadin"){
                $profilRow['user_picture'] = "assets/img/k.png";
            }else if($profilRow['user_cinsiyet']=="erkek"){
                $profilRow['user_picture'] = "assets/img/e.png";
            }else{
                $profilRow['user_picture'] = $profilRow['user_picture'];
            }

        }

?>

        <div class="section mt-2 mb-2">

<?php 
$engelVarmi = $db->query("SELECT COUNT(*) FROM engellemeler where u_from = '{$myUser['user_id']}' AND u_to = '{$profil_id}'")->fetchColumn();
if($engelVarmi==1){
  echo '<button id="engelkaldiri" onclick="engelKaldir('.$profil_id.')" type="button" class="btn mb-3 btn-danger btn-block">KİŞİNİN ENGELİNİ KALDIRMAK İÇİN DOKUN!</button>';
}
?>

            <div class="card bg-primary comment-box">
                <img data-toggle="modal" data-target="#DialogImage" src="<?=$profilRow['user_picture']?>" alt="avatar" class="imaged w200" style="border-radius: 5% !important;">
				<h4 class="card-title"><?=$profilRow['user_fullname']?> <?php if ($profilRow['user_onay'] > 0): ?><i class="fa-solid fa-check-circle text-success"></i><?php endif; ?></h4>
                <div class="card-text"><?=$myUser['user_sehir']?>, <?=$profilRow['user_yas']?></div>
                <div class="text">

<?php 
$query = $db->query("SELECT * FROM begeniler WHERE begenen_id = '{$user_id}' AND begenilen_id = '{$profilRow['user_id']}'")->fetch(PDO::FETCH_ASSOC);
if($query){
?>

                <button id="user_<?=$profilRow['user_id']?>" type="button" class="btn btn-danger mr-1 mb-1">
                    <i class="fa-solid fa-check fa-lg mr-1"></i>
                    Beğendin
                </button>
            <?php }else{ ?>

                <button id="user_<?=$profilRow['user_id']?>" onclick="begeniGonder2(<?=$profilRow['user_id']?>);" type="button" class="btn btn-danger mr-1 mb-1">
                   <i class="fa-solid fa-heart fa-xl mr-1"></i>
                    Beğen
                </button>

            <?php } ?>
                <a href="./mesajlar.php?id=<?=$profilRow['user_id']?>" type="button" class="btn btn-warning mr-1 mb-1 wiggle">
                    <i class="fa-regular fa-envelope fa-xl mr-1"></i>
                    Mesaj
                </a>

<?php
if($user_id != 663793) { // 663793 ID'li kullanıcı değilse göster
    if($myUser['user_call']==0){
    ?>
        <a onclick="accept1();" href="javascript:void(0);" type="button" class="btn btn-icon btn-success mr-1 mb-1">
            <i class="fa-solid fa-phone fa-xl"></i>
        </a>
    <?php 
    }else{ 
    ?>
        <a onclick="$('#DialogIconedSuccess2').modal('show');" href="javascript:void(0);" type="button" class="btn btn-icon btn-success mr-1 mb-1">
            <i class="fa-solid fa-phone fa-xl"></i>
        </a>
    <?php 
    }
}
?>


<?php

if($myUser['user_id']==707615 && $profilRow['user_id']==842355){

?>

<br />
                <a onclick="buyJeton('3paket');" href="javascript:void(0)" type="button" class="btn btn-block btn-warning mr-1 mb-1">
                    <ion-icon name="aperture-outline"></ion-icon>
                   Hediye Jeton Gönder
                </a>

                <?php 
            } 
            ?>


<?php 
if($profilRow['user_id']==942197){

//echo '<button type="button" class="btn btn-secondary btn-block">Bu Profile Atılan Mesajlarda Jeton Eksilmez!</button>';

}
?>


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



<div class="listview-title mt-2">Kişisel Bilgiler 

<?php 
$engelVarmi = $db->query("SELECT COUNT(*) FROM engellemeler where u_from = '{$myUser['user_id']}' AND u_to = '{$profil_id}'")->fetchColumn();
if($engelVarmi==0){
  echo '<a href="javascript:void(0)" onclick="engelle1('.$profil_id.')" type="button" class="btn btn-sm btn-danger mr-1 mb-1" id="engelbuton">
                    <i class="fa-solid fa-user-large-slash mr-1"></i>
                    Engelle
                </a>';
}else{
    echo '<a href="javascript:void(0)" onclick="engelKaldir('.$profil_id.')" type="button" class="btn btn-sm btn-danger mr-1 mb-1" id="engelbuton">
                    <i class="fa-solid fa-user-large-slash mr-1"></i>
                    Engellendi
                </a>'; 
}
?>





<?php 
$sikayetVarmi = $db->query("SELECT COUNT(*) FROM sikayetler where u_from = '{$myUser['user_id']}' AND u_to = '{$profil_id}'")->fetchColumn();

if($sikayetVarmi==0){

?>


  <a href="javascript:void(0)" data-toggle="modal" data-target="#DialogForm" type="button" class="btn btn-sm btn-warning mr-1 mb-1">
                    <i class="fa-solid fa-circle-xmark fa-lg mr-1"></i>
                    Şikayet Et
                </a>


         <div id="toast-4" class="toast-box toast-center">
            <div class="in">
               <i class="fa-solid fa-circle-exclamation fa-3x text-danger"></i>
                <div class="text">
                  Profil şikayet edildi. <br><br> Mümkün olan en kısa sürede inceleme yapılacaktır.
                </div>
            </div>
        </div>

<?php 
}else{ 
echo '<a href="javascript:void(0)" type="button" class="btn btn-sm btn-secondary mr-1 mb-1"><i class="fa-solid fa-circle-exclamation fa-lg mr-1"></i>
                    Şikayet Edildi!
                </a>';
}
  ?>



</div>

<ul class="listview image-listview">

<?php if($user_id != 663793): ?> <!-- 663793 ID'li kullanıcı değilse göster -->
    <li>
        <div class="item">
            <div class="icon-box bg-success">
                <i class="fa-solid fa-phone"></i>
            </div>
            <div class="in">
                <div>Telefon Numarası</div>
                <?php if ($myUser['user_iletisim'] > 0 || $myUser['user_onay'] > 0): ?>
                    <span class="badge badge-danger">İzin Vermemiş</span>
                <?php else: ?>
                    <span onclick="uyariVer3();" class="badge badge-success">DOKUN ➡️ (05*********)</span>
                <?php endif; ?>
            </div>
        </div>
    </li>

    <li>
        <div class="item">
            <div class="icon-box bg-primary" style="background-color: #F56040 !important;">
                <i class="fab fa-instagram"></i>
            </div>
            <div class="in">
                <div>Instagram Profili</div>
                <?php if ($myUser['user_iletisim'] > 0 || $myUser['user_onay'] > 0): ?>
                    <span class="badge badge-danger">İzin Vermemiş</span>
                <?php else: ?>
                    <span onclick="uyariVer3();" class="badge badge-success">DOKUN ➡️ (********)</span>
                <?php endif; ?>
            </div>
        </div>
    </li>

    <li>
        <div class="item">
            <div class="icon-box bg-primary" style="background-color: #4267B2 !important;">
                <i class="fab fa-facebook"></i>
            </div>
            <div class="in">
                <div>Facebook Hesabı</div>
                <?php if ($myUser['user_iletisim'] > 0 || $myUser['user_onay'] > 0): ?>
                    <span class="badge badge-danger">İzin Vermemiş</span>
                <?php else: ?>
                    <span onclick="uyariVer3();" class="badge badge-success">DOKUN ➡️ (<?=$profilRow['user_fullname']?>)</span>
                <?php endif; ?>
            </div>
        </div>
    </li>
<?php endif; ?>



<li>
<div class="item">
<div class="icon-box bg-primary" style="background-color: #25a0ca !important;">
<i class="fa-solid fa-location-dot"></i>
</div>
<div class="in">
<div>Şehir</div>
<span class="badge badge-danger"><?=$myUser['user_sehir']?></span>
</div>
</div>
</li>
<li>
<div class="item">
<div class="icon-box bg-primary">
<i class="fa-solid fa-calendar-days"></i>
</div>
<div class="in">
<div>Yaş</div>
<span class="badge badge-danger"><?=$profilRow['user_yas']?></span>
</div>
</div>
</li>



<?php if(isset($profilRow['user_boy1'])){ ?>

<li>
<div class="item">
<div class="icon-box bg-primary" style="background-color: #ff5a8c !important;">
<i class="fa-solid fa-person-arrow-up-from-line"></i>
</div>
<div class="in">
<div>Boy</div>
<span class="badge badge-danger"><?=$profilRow['user_boy']?> cm</span>
</div>
</div>
</li>

<?php } ?>

<?php if(isset($profilRow['user_kilo1'])){ ?>

<li>
<div class="item">
<div class="icon-box bg-primary" style="background-color: #d555ff !important;">
<i class="fa-solid fa-person-pregnant"></i>
</div>
<div class="in">
<div>Kilo</div>
<span class="badge badge-danger"><?=$profilRow['user_kilo']?> Kg</span>
</div>
</div>
</li>

<?php } ?>

<li>
<div class="item">
<div class="icon-box bg-danger">
<i class="fa-solid fa-face-kiss-wink-heart"></i>
</div>
<div class="in">
<div>Profil Beğenisi</div>
<span class="badge badge-info"><?=$profilBegeni?> Beğeni Aldı</span>
</div>
</div>
</li>

        </ul>




<br /> <br />  


        <!-- DialogIconedSuccess -->
        <div class="modal fade dialogbox" id="DialogIconedSuccess" 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-face-grin-hearts"></i>
                    </div>
                    <div class="modal-header">
                        <h5 class="modal-title"><?=$isimsoyisimCek[0]?> Sizi Beğendi!</h5>
                    </div>
                    <div class="modal-body">
                        <?=$isimsoyisimCek[0]?> sizinle tanışmak istiyor. <br />Hemen ona bir mesaj gönder.
                    </div>
                    <div class="modal-footer">
                        <div class="btn-inline">
                            <a href="component-dialog.html#" class="btn" data-dismiss="modal">Tamam</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- * DialogIconedSuccess -->      


<div id="toast-5" class="toast-box toast-center">
            <div class="in">
               <i class="fa-solid fa-circle-check text-success fa-2x"></i>
                <div class="text">
                Profil Başarıyla Engellendi!
                </div>
            </div>
        </div>

        <div id="toast-6" class="toast-box toast-center">
            <div class="in">
               <i class="fa-solid fa-circle-check text-success fa-2x"></i>
                <div class="text">
                Engel Başarıyla Kaldırıldı!
                </div>
            </div>
        </div>


<!-- SİKAYET MODAL -->

        <div class="modal fade dialogbox" id="DialogForm" 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 btn-text-danger">Şikayet Sebebini Seçiniz</h5>
                    </div>
                    <div class="modal-body">
                        <div class="form-group boxed">

                <div class="input-list">
                    <div class="custom-control custom-radio">
                        <input type="radio" id="customRadio11" name="customRadioList" class="custom-control-input" value="spam" checked>
                        <label class="custom-control-label" for="customRadio11">Şüpheli veya Spam</label>
                    </div>
                    <div class="custom-control custom-radio">
                        <input type="radio" id="customRadio12" name="customRadioList" class="custom-control-input" value="taklit">
                        <label class="custom-control-label" for="customRadio12">Taklit Hesap</label>
                    </div>
                    <div class="custom-control custom-radio">
                        <input type="radio" id="customRadio13" name="customRadioList" class="custom-control-input" value="taciz">
                        <label class="custom-control-label" for="customRadio13">Taciz veya Nefret</label>
                    </div>
                    <div class="custom-control custom-radio">
                        <input type="radio" id="customRadio14" name="customRadioList" class="custom-control-input" value="diger">
                        <label class="custom-control-label" for="customRadio14">Diğer</label>
                    </div>
                </div>
</div>
<div class="form-group boxed">
                        <div class="input-wrapper">
                            <label class="label" for="address5">Şikayet Sebebibizi Yazın</label>
                            <textarea id="sikayetsebebi" rows="2" class="form-control"></textarea>
                            <i class="clear-input">
                                 <i class="fa-solid fa-circle-xmark"></i>
                            </i>
                        </div>
                    </div>
                    </div>
                    <div class="modal-footer">
                        <div class="btn-inline">
                            <a href="component-dialog.html#" class="btn btn-text-secondary" data-dismiss="modal">Vazgeç</a>
                            <a onclick="sikayetEt(<?=$profil_id?>)" href="component-dialog.html#" class="btn btn-text-danger" data-dismiss="modal">Şikayet Gönder</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
<!-- SİKAYET MODAL -->


        <!-- Dialog Image -->
        <div class="modal fade dialogbox" id="DialogImage" data-backdrop="static" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content" style="max-width: 350px !important;">
                    <img src="<?=$profilRow['user_picture']?>" alt="image" class="img-fluid">
                    <div class="modal-footer">
                        <div class="btn-inline">
                           <a href="javascript:void(0)" class="btn btn-text-primary" data-dismiss="modal">
                                <i class="fa-solid fa-circle-xmark fa-lg mr-1"></i>
                                Kapat
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- * Dialog Image -->



        </div>






        <script src="assets/js/hammer.min.js"></script>
        <script src="assets/js/finder.js"></script>


<?php include 'footer.php'; ?>