<?php include 'inc/header.php';?>
<?php include 'inc/sidebar.php';?>
<?php include 'inc/navbar.php';?>
<?php

  if(!empty($_POST)){ 

      $title = $_POST['title'];

      /* hakkımızda */

    if ($_FILES['fotobir']['tmp_name'] != "") {
      $boyutbir = $_FILES['fotobir']['size'];
    if ($boyutbir > (1024 * 1024 * 10)) {
       echo 'Dosya 10MB den büyük olamaz.';
       } else {
      $tipbir = $_FILES['fotobir']['type'];
      $isimbir = $_FILES['fotobir']['name'];
      $uzantibir = explode('.', $isimbir);
      $uzantibir = $uzantibir[count($uzantibir) - 1];
    $randombir = rand();
    $dosyabir = $_FILES['fotobir']['tmp_name'];
      $foto_urlbir = $randombir . "." . $uzantibir;
        copy($dosyabir, '../img/' . $foto_urlbir);
        echo "
        <script>
         const Toast = Swal.mixin({
          toast: true,
          position: 'top-end',
          showConfirmButton: false,
          timer: 6000,
          timerProgressBar: true,
          didOpen: (toast) => {
            toast.addEventListener('mouseenter', Swal.stopTimer)
            toast.addEventListener('mouseleave', Swal.resumeTimer)
          }
          })

          Toast.fire({
            icon: 'success',
            title: 'Başarı ile kayıt edildi.'
            })
            </script>";
      $settings = $dbh->prepare("UPDATE page_pictures SET about_pictures = '".$foto_urlbir."' WHERE id=1 ");
      $settings->execute();
        }
        }

        /* hakkımızda bitiş */

        /* referans */

    if ($_FILES['fotoiki']['tmp_name'] != "") {
      $boyutiki = $_FILES['fotoiki']['sizeiki'];
    if ($boyutiki > (1024 * 1024 * 10)) {
       echo 'Dosya 10MB den büyük olamaz.';
       } else {
      $tipiki = $_FILES['fotoiki']['type'];
      $isimiki = $_FILES['fotoiki']['name'];
      $uzantiiki = explode('.', $isimiki);
      $uzantiiki = $uzantiiki[count($uzantiiki) - 1];
    $randomiki = rand();
    $dosyaiki = $_FILES['fotoiki']['tmp_name'];
      $foto_urliki = $randomiki . "." . $uzantiiki;
        copy($dosyaiki, '../img/' . $foto_urliki);
        echo "<script>
         const Toast = Swal.mixin({
          toast: true,
          position: 'top-end',
          showConfirmButton: false,
          timer: 6000,
          timerProgressBar: true,
          didOpen: (toast) => {
            toast.addEventListener('mouseenter', Swal.stopTimer)
            toast.addEventListener('mouseleave', Swal.resumeTimer)
          }
          })

          Toast.fire({
            icon: 'success',
            title: 'Başarı ile kayıt edildi.'
            })
            </script>";
      $settings = $dbh->prepare("UPDATE page_pictures SET gallery_pictures = '".$foto_urliki."' WHERE id=1 ");
      $settings->execute();
        }
        }

        /* referns bitiş */

       
         /* fiyat */

    if ($_FILES['fotodort']['tmp_name'] != "") {
      $boyutdort = $_FILES['fotodort']['sizedort'];
    if ($boyutdort > (1024 * 1024 * 10)) {
       echo 'Dosya 10MB den büyük olamaz.';
       } else {
      $tipdort = $_FILES['fotodort']['type'];
      $isimdort = $_FILES['fotodort']['name'];
      $uzantidort = explode('.', $isimdort);
      $uzantidort = $uzantidort[count($uzantidort) - 1];
    $randomdort = rand();
    $dosyadort = $_FILES['fotodort']['tmp_name'];
      $foto_urldort = $randomdort . "." . $uzantidort;
        copy($dosyadort, '../img/' . $foto_urldort);
        echo "<script>
         const Toast = Swal.mixin({
          toast: true,
          position: 'top-end',
          showConfirmButton: false,
          timer: 6000,
          timerProgressBar: true,
          didOpen: (toast) => {
            toast.addEventListener('mouseenter', Swal.stopTimer)
            toast.addEventListener('mouseleave', Swal.resumeTimer)
          }
          })

          Toast.fire({
            icon: 'success',
            title: 'Başarı ile kayıt edildi.'
            })
            </script>";
      $settings = $dbh->prepare("UPDATE page_pictures SET contact_pictures = '".$foto_urldort."' WHERE id=1 ");
      $settings->execute();
        }
        }

        /* fiyat bitiş */

         /* banka */

    if ($_FILES['fotobes']['tmp_name'] != "") {
      $boyutbes = $_FILES['fotobes']['sizebes'];
    if ($boyutbes > (1024 * 1024 * 10)) {
       echo 'Dosya 10MB den büyük olamaz.';
       } else {
      $tipbes = $_FILES['fotobes']['type'];
      $isimbes = $_FILES['fotobes']['name'];
      $uzantibes = explode('.', $isimbes);
      $uzantibes = $uzantibes[count($uzantibes) - 1];
    $randombes = rand();
    $dosyabes = $_FILES['fotobes']['tmp_name'];
      $foto_urlbes = $randombes . "." . $uzantibes;
        copy($dosyabes, '../img/' . $foto_urlbes);
        echo "<script>
         const Toast = Swal.mixin({
          toast: true,
          position: 'top-end',
          showConfirmButton: false,
          timer: 6000,
          timerProgressBar: true,
          didOpen: (toast) => {
            toast.addEventListener('mouseenter', Swal.stopTimer)
            toast.addEventListener('mouseleave', Swal.resumeTimer)
          }
          })

          Toast.fire({
            icon: 'success',
            title: 'Başarı ile kayıt edildi.'
            })
            </script>";
      $settings = $dbh->prepare("UPDATE page_pictures SET product_pictures = '".$foto_urlbes."' WHERE id=1 ");
      $settings->execute();
        }
        }

        /* banka bitiş */
 
    $update = $dbh->prepare("UPDATE page_pictures SET title = '".$title."' WHERE id = 1 " );
      $update->execute();
      }
?>

<?php
$ayar = $dbh->query("SELECT * FROM page_pictures WHERE id = 1 ", PDO::FETCH_ASSOC);
if ($ayar->rowCount()) {
    foreach ($ayar as $ayar) {
    }
}
?> 
        <!-- Page Content-->
        <div class="page-content">
          <div class="container-fluid">
            <!-- Page-Title -->

            <form method="post" action="" enctype="multipart/form-data">

              <div class="row">
                <div class="col-sm-12">
                  <div class="page-title-box">
                    <div class="row">
                      <div class="col">
                        <h4 class="page-title">Genel Site Ayarları</h4>
                        <ol class="breadcrumb">
                          <li class="breadcrumb-item"><a href="index.php">Anasayfa</a></li> 
                          <li class="breadcrumb-item active">Genel Ayarlar</li>
                        </ol>
                      </div><!--end col-->
                      <div class="col-auto align-self-center">
                        <button class="btn btn-primary" type="submit">
                          <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                          GÜNCELLE
                        </button> 
                      </div><!--end col-->  
                    </div><!--end row-->                                                              
                  </div><!--end page-title-box-->
                </div><!--end col-->
              </div><!--end row-->
              <!-- end page title end breadcrumb -->


              <div class="row">
                <div class="col-lg-12">
                  <div class="card">
                    <div class="card-header">
                      <h4 class="card-title">Sayfa Görsel Ayarları</h4>
                      <p class="text-muted mb-0">Değerli kullanıcı, bu alan sayesinde sayfalarınızın görsel alanlarını düzenleyebilirsiniz.</p> 
                    </div><!--end card-header-->
                    <div class="card-body">
                      <div class="row">

                        <div class="col-xl-12"> 
                          <div class="form-group"> 
                            <input class="form-control" type="hidden" value="<?=$ayar['title'];?>" name="title">
                          </div>
                        </div> 

                      </div>
                      
                      <div class="row">
                        <div class="col-xl-6">   
                          <div class="card-body">
                            <input type="file" id="input-file-now-custom-1" name="fotobir" accept="image/x-png,image/gif,image/png,image/jpeg,application/pdf" class="dropify" data-default-file="../img/<?=$ayar['about_pictures'];?>" />    
                            <center>Hakkımızda Sayfası</center>
                          </div><!--end col--> 
                        </div> 

                        <div class="col-xl-6">   
                          <div class="card-body">
                            <input type="file" id="input-file-now-custom-2" name="fotoiki" accept="image/x-png,image/gif,image/png,image/jpeg,application/pdf" class="dropify" data-default-file="../img/<?=$ayar['gallery_pictures'];?>" />    
                            <center>Galeri Sayfası</center>
                          </div><!--end col--> 
                        </div>
                        

                        <div class="col-xl-6">   
                          <div class="card-body">
                            <input type="file" id="input-file-now-custom-3" name="fotodort" accept="image/x-png,image/gif,image/png,image/jpeg,application/pdf" class="dropify" data-default-file="../img/<?=$ayar['contact_pictures'];?>" />    
                            <center>İletişim Sayfası</center>
                          </div><!--end col--> 
                        </div>
                        

                        <div class="col-xl-6">   
                          <div class="card-body">
                            <input type="file" id="input-file-now-custom-4" name="fotobes" accept="image/x-png,image/gif,image/png,image/jpeg,application/pdf" class="dropify" data-default-file="../img/<?=$ayar['product_pictures'];?>" /> 
                            <center>Ürün Sayfası</center>   
                          </div><!--end col--> 
                        </div> 
                      </div>
                       

                <br>    
                <button class="btn btn-primary btn-block" type="submit">
                  <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                  GÜNCELLE
                </button>
              </form>                                           
            </div><!--end card-body-->
          </div><!--end card-->
        </div><!--end col-->


      </div><!--end row-->



    </div><!-- container -->

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

