<?php 
    require_once("../_ayarlar.php");
    require_once("../_fonksiyonlar.php");
?>
<!DOCTYPE html>
<html lang="tr">

<head>
    <?php include("_head.php") ?>
    <title>Medya Sil</title>
</head>

<body id="page-top">

    <!-- Page Wrapper -->
    <div id="wrapper">

        <?php include("_sidebar.php") ?>

        <!-- Content Wrapper -->
        <div id="content-wrapper" class="d-flex flex-column">

            <!-- Main Content -->
            <div id="content">

                <?php include("_topbar.php") ?>

                <!-- Sayfaya Özel İçerik -->
                <div class="container-fluid">

                    <div class="card shadow mb-4">
                        <div class="card-header py-3">
                            <h6 class="m-0 font-weight-bold text-primary">Medya Sil</h6>
                        </div>
                        <div class="card-body">

                        <?php

                        $id = $_GET["id"];
						$onay = @$_GET["onay"];

						if($onay!=1){
                        	echo "<div class='alert alert-danger' role='alert'>
                                <img height='200' src='../medya/$id' />
                                <h4 class='alert-heading'>$id adlı dosyayı sunucudan tamamen silmeyi onaylıyor musunuz?</h4>
                                <hr>
                                <a class='btn btn-success' href='$_SERVER[REQUEST_URI]&onay=1'>Onayla</a>
                                <br><br>
                                <a class='btn btn-info' href='medya.php'>Geri Dön</a>
                            </div>";
                        }
						else if($onay==1){
							
							$sil = unlink("../medya/$id");
							
							if($sil){		
								echo "<div class='alert alert-success' role='alert'>
                                    <h4 class='alert-heading'>$id adlı dosya sunucudan başarıyla silindi</h4>
                                    <hr>
                                    Yönlendiriliyorsunuz";
                                header("Refresh:2; medya.php");
                            }
							else{
								echo "<div class='alert alert-danger' role='alert'>
                                    <h4 class='alert-heading'>Silme İşlemi Başarısız</h4>
                                    <hr>
                                    Yönlendiriliyorsunuz";								
								header("Refresh:2; medya.php");
							}
						}

                        ?>

                        </div>
                    </div>

                </div>
                <!-- /.container-fluid -->

            </div>
            <!-- End of Main Content -->

            <?php include("_footer.php") ?>

        </div>
        <!-- End of Content Wrapper -->

    </div>
    <!-- End of Page Wrapper -->

    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
        <i class="fas fa-angle-up"></i>
    </a>

    <?php include("_script.php") ?>
</body>

</html>