<?php
    foreach($_GET    as $k => $v) $_GET[$k]    = strip_tags($v);
    foreach($_POST   as $k => $v) $_POST[$k]   = strip_tags($v);

    include 'panel/baglan.php';


    if(isset($_GET['sayfa'])) {
      $sayfa = cleanAZ($_GET['sayfa']);
      if($sayfa == 'cikis-yap'){
        unset($_SESSION['kullanici']['login']);
        unset($_SESSION['kullanici']['id']);
      }
      if (!is_file('inc/'.$sayfa.'.php')) {
            $sayfa = 'anasayfa';
      }
    }else{
      $sayfa = 'anasayfa';
    }

    $cek = $db->query("SELECT * FROM ayarlar LIMIT 1")->fetch(PDO::FETCH_ASSOC);

    function meta_degistir($icerik) {
      global  $_title, $_description;
      $icerik = str_replace('[$_title]', $_title, $icerik);
      $icerik = str_replace('[$_description]', $_description, $icerik);
      return $icerik;
    }

    ob_start('meta_degistir');

    $_title         =  $cek['title'];
    $_description   =  $cek['description'];
?>
<!doctype html>
<html lang="tr">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all">
    <title>[$_title]</title>
    <meta name="description" content="[$_description]" />
    <base href="<?php echo $site; ?>">
    <meta property="og:title" content="[$_title]">
    <meta property="og:description" content="[$_description]">
    <meta property="og:locale" content="tr_TR">
    <meta property="og:type" content="website">
    <meta name="author" content="https://www.webyazilimajansi.com">
    <meta name="robots" content="index follow">
    <meta name="googlebot" content="index follow">
    <meta name="theme-color" content="#08C" />
    <link rel="shortcut icon" href="upload/<?php echo $cek['fav']; ?>" type="image/x-icon">
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript">
      $(window).on("load",function(){
        $('#yukleniyor').fadeOut(500);
      });
    </script>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="slick/slick.css">
    <link rel="stylesheet" href="slick/slick-theme.css">
    <link rel="stylesheet" href="css/owl.carousel.css">
    <link rel="stylesheet" href="css/owl.theme.css">
    <link rel="stylesheet" href="css/menu.css?v=1">
    <script src="js/bootstrap.min.js"></script>
    <script src="js/main.js?v=3"></script>
    <script src="js/owl.carousel.js"></script>
    <script src="slick/slick.js"></script>
  </head>
  <body class="theme-default">

    <div id="yukleniyor"><center><img src="images/yukleniyor.gif"></center></div>

    <?php echo $cek['site_ust_img'] !='' ? '<div class="container-fluid"><div class="row"><a href="'.$cek['site_ust_link'].'" id="ust-reklam"><img src="upload/'.$cek['site_ust_img'].'" style="width: 100%;"></a></div></div>' : ''; ?>

    <div class="container">
      <div class="row mt-10 mb-10">
        <div class="col-md-3 pt-10">
          <a href="index.php" id="logo" title="<?php echo $cek['title']; ?>"><img src="upload/<?php echo $cek['logo']; ?>" alt="<?php echo $cek['title']; ?>" class="img-responsive" style="width: 135px"></a>
        </div>
        <div class="col-md-9">
          <div class="row hidden-xs">
            <div class="col-md-9">
              <ul class="menu1 mb-10 ">
                <?php
                $query = $db->query("SELECT * FROM sayfa WHERE ust_menu = 1", PDO::FETCH_ASSOC);
                if($query->rowCount()){
                  foreach($query as $row){
                    echo '<li><a href="sayfa/'.$row['sef'].'" title="'.$row['baslik'].'">'.$row['baslik'].'</a></li>';
                  }
                }
                ?>
                <li><a href="blog" title="Blog">Blog</a></li>
                <li><a href="iletisim" title="İletişim">İletişim</a></li>
              </ul>
            </div>
            <div class="col-md-3">
              <ul class="menu2 mb-10 pull-right">
                <?php echo $cek['whatsapp'] !='' ? '<li><a href="https://api.whatsapp.com/send?phone=9'.$cek['whatsapp'].'&text=Merhaba, yardım almak istiyorum." title="whatsapp"><i class="fa fa-whatsapp"></i></a></li>' : ''; ?>
                <?php echo $cek['facebook'] !='' ? '<li><a href="'.$cek['facebook'].'" title="facebook"><i class="fa fa-facebook"></i></a></li>' : ''; ?>
                <?php echo $cek['youtube'] !='' ? '<li><a href="'.$cek['facebook'].'" title="youtube"><i class="fa fa-youtube"></i></a></li>' : ''; ?>
                <?php echo $cek['twitter'] !='' ? '<li><a href="'.$cek['twitter'].'" title="twitter"><i class="fa fa-twitter"></i></a></li>' : ''; ?>
                <?php echo $cek['instagram'] !='' ? '<li><a href="'.$cek['instagram'].'" title="instagram"><i class="fa fa-instagram"></i></a></li>' : ''; ?>
              </ul>
            </div>
          </div>
          <div class="row">
            <div class="col-md-8">
              <form action="ara" method="post" id="ara">
                <input type="text" class="form-control" placeholder="Ürün adı ile arama yapabilirsiniz..." autocomplete="off" name="ara" required="">
                <i class="fa fa-search"></i>
                <button type="submit">ARA</button>
              </form>
            </div>
            <div class="col-md-4">
              <div class="row">
                <div class="col-md-6 col-xs-6">

                  <?php if(isset($_SESSION['kullanici']['login'])){ ?>
                    <a href="hesabim" title="Hesabım" class="kayit-giris">
                      <i class="fa fa-user-o"></i>
                      <div><span style="padding: 8px 0px;">Hesabım <b class="glyphicon glyphicon-chevron-down pull-right" style="margin-top: 2px"></b></span></div>
                    </a>
                  <?php }else{ ?>
                    <a href="kayit-giris" title="Kayıt Ol - Giriş Yap" class="kayit-giris">
                      <i class="fa fa-user-o"></i>
                      <div><span>Giriş Yap</span><span>veya üye ol</span></div>
                    </a>
                  <?php } ?>

                </div>
                <div class="col-md-6 col-xs-6">
                  <div class="sepetim">
                    <i class="fa fa-shopping-basket"></i>
                    <span><?php echo @count($_SESSION['sepet']['key']); ?></span>
                    <div>Sepetim</div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="row" id="menu_bar">
            <div class="col-md-12">
                <a class="toggle" href="#">
                  <i class="fa fa-bars"></i>
                  Menü
                </a>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="container-fluid">
      <div class="row" id="cizgi-dis">
          <?php 
            for ($i=1; $i <= 6; $i++) { 
              echo '<div class="cizgi'.$i.'"></div>';
            }
          ?>
      </div>
    </div>

    

    <div class="container-fluid" id="ana_menu_dis">
      <div class="container">
          <div class="col-md-12">
            <section class="ana_menu slider">
              <?php
                $query = $db->query("SELECT * FROM kategori WHERE ust_menu = 1 ORDER BY sira ASC", PDO::FETCH_ASSOC);
                if($query->rowCount()){
                  foreach($query as $row){
                    echo '<div><a href="kategori/'.$row['sef'].'" title="'.$row['baslik'].'">'.$row['baslik'].'</a></div>';
                  }
                }
              ?>
            </section>
          </div>
      </div>
    </div>

    
    <?php
      include 'inc/'.$sayfa.'.php';
    ?>


     <div class="container-fluid">
      <div class="row" id="cizgi-dis">
          <?php 
            for ($i=1; $i <= 6; $i++) { 
              echo '<div class="cizgi'.$i.'"></div>';
            }
          ?>
      </div>
    </div>

    <footer>
      <div class="container-fluid" id="etiket_dis">
        <div class="row">
          <div class="container">
              <div class="row">
                  <div class="col-md-12 mt-15 mb-15"><h4>En Çok Arananlar</h4></div>
                  <div class="col-md-12">
                    <ul class="ozel">
                      <?php
                      $query = $db->query("SELECT * FROM etiket ORDER BY id DESC", PDO::FETCH_ASSOC);
                      if($query->rowCount()){
                        foreach($query as $row){
                          echo '<li><a href="'.$row['link'].'" title="'.$row['baslik'].'">'.$row['baslik'].'</a></li>';
                        }
                      }
                      ?>
                    </ul>
                  </div>
              </div>
          </div>
        </div>
        <div class="container mb-20">
            <div class="row">
              <div class="col-md-3">
                <div class="telefon pt-10">
                  <img src="images/telefon.png">
                  <div><span>Destek Hattı</span><a href="tel:<?php echo $cek['telefon']; ?>"><?php echo $cek['telefon']; ?></a></div>
                </div>
                <div class="adres-email">
                  <div><span>Adres: </span><span><?php echo $cek['adres']; ?></span></div>
                  <div><span>Email: </span><span><?php echo $cek['email']; ?></span></div>
                </div>
                <ul class="menu2 mt-10 ozel">
                  <?php echo $cek['whatsapp'] !='' ? '<li><a href="https://api.whatsapp.com/send?phone=9'.$cek['whatsapp'].'&text=Merhaba, yardım almak istiyorum." title="whatsapp"><i class="fa fa-whatsapp"></i></a></li>' : ''; ?>
                  <?php echo $cek['facebook'] !='' ? '<li><a href="'.$cek['facebook'].'" title="facebook"><i class="fa fa-facebook"></i></a></li>' : ''; ?>
                  <?php echo $cek['youtube'] !='' ? '<li><a href="'.$cek['facebook'].'" title="youtube"><i class="fa fa-youtube"></i></a></li>' : ''; ?>
                  <?php echo $cek['twitter'] !='' ? '<li><a href="'.$cek['twitter'].'" title="twitter"><i class="fa fa-twitter"></i></a></li>' : ''; ?>
                  <?php echo $cek['instagram'] !='' ? '<li><a href="'.$cek['instagram'].'" title="instagram"><i class="fa fa-instagram"></i></a></li>' : ''; ?>
                </ul>
              </div>
              <div class="col-md-3">
                <ul class="kategori-sayfa">
                    <li>Kategoriler</li>
                    <?php
                      $query = $db->query("SELECT * FROM kategori WHERE alt_menu = 1", PDO::FETCH_ASSOC);
                      if($query->rowCount()){
                        foreach($query as $row){
                          echo '<li><a href="kategori/'.$row['sef'].'" title="'.$row['baslik'].'">'.$row['baslik'].'</a></li>';
                        }
                      }
                    ?>
                </ul>
              </div>
              <div class="col-md-3">
                <ul class="kategori-sayfa">
                    <li>Sayfalar</li>
                    <?php
                      $query = $db->query("SELECT * FROM sayfa WHERE alt_menu = 1", PDO::FETCH_ASSOC);
                      if($query->rowCount()){
                        foreach($query as $row){
                          echo '<li><a href="sayfa/'.$row['sef'].'" title="'.$row['baslik'].'">'.$row['baslik'].'</a></li>';
                        }
                      }
                    ?>
                </ul>
              </div>
              <div class="col-md-3">
                <ul class="kategori-sayfa">
                    <li>Blog Haberleri</li>
                    <?php
                      $query = $db->query("SELECT * FROM blog ORDER BY id DESC LIMIT 8", PDO::FETCH_ASSOC);
                      if($query->rowCount()){
                        foreach($query as $row){
                          echo '<li><a href="blog/'.$row['sef'].'" title="'.$row['baslik'].'">'.$row['baslik'].'</a></li>';
                        }
                      }
                    ?>
                </ul>
              </div>
            </div>
        </div>
      </div>
        <div class="container-fluid" id="en_alt">
          <div class="row">
            <div class="container">
              <div class="row">
                <div class="col-md-4">
                  © <?php echo $cek['title']; ?> - 2021 Tüm Hakları Saklıdır
                </div>
                <div class="col-md-4">
                  <center>Bu web sitesi <a href="https://www.demoadresim.com">Demo Adresim</a> tarafından kurulmuştur</center>
                </div>
                <div class="col-md-4">
                  <div class="pull-right"><img src="images/odeme-yontemleri.png" alt="ödeme yöntemleri" class="img-responsive"></div>
                </div>
              </div>
            </div>
          </div>
        </div>
    </footer>


    <div id="sepet"></div>
    <div id="saydam_bg"></div>
    

    <header>
      <div class="wrapper cf">
        <nav id="main-nav">
          <ul class="first-nav">
            <?php
                $query = $db->query("SELECT * FROM kategori WHERE alt_menu = 1 ORDER BY sira ASC", PDO::FETCH_ASSOC);
                if($query->rowCount()){
                  foreach($query as $row){
                    echo '<li><a href="kategori/'.$row['sef'].'">'.$row['baslik'].'</a></li>';
                  }
                }
            ?>
          </ul>
          <h3 style="float: left;margin-top: 1px;">Sayfalar</h3>
          <ul class="second-nav">
            <?php
                $query = $db->query("SELECT * FROM sayfa", PDO::FETCH_ASSOC);
                if($query->rowCount()){
                  foreach($query as $row){
                    echo '<li><a href="sayfa/'.$row['sef'].'">'.$row['baslik'].'</a></li>';
                  }
                }
            ?>
          </ul>
        </nav>
      </div>
    </header>

    <script src="js/menu.js"></script>
    <script src="js/menu-ek.js"></script>

  </body>
</html>