ok
Direktori : /home/pequenacapitolio/www/administrador/ |
Current File : /home/pequenacapitolio/www/administrador/videos_admin.php |
<?php include '../conexao.php'; // ############# INSERE DEPOIMENTOS ################### if (isset($_GET["act"]) && $_GET["act"] == "inserir" && isset($_POST["submit"])) { $pag_titulo = $_POST["titulo"]; $pag_link = $_POST["link"]; $pag_corpo = $_POST["editor1"]; $pag_categoria = $_POST["categoria"]; $dados_not = array( 'titulo' => $pag_titulo, 'link' => $pag_link, 'descricao' => $pag_corpo, 'categoria' => $pag_categoria, ); $conn->prepare("INSERT INTO videos (titulo, descricao, id_categoria, link) VALUES (:titulo, :descricao, :categoria, :link)")->execute($dados_not); $redirect = "/administrador/videos_admin.php"; //$redirect = "http://www.tchaudor.com.br/administrador/videos_admin.php"; header("location:$redirect"); } // ############# DELETA DEPOIMENTO ################### if (isset($_GET["act"]) && $_GET["act"] == "excluir") { $pag_exclui = $_GET["id"]; $dados_cat = array( 'id' => $pag_exclui, ); $conn->prepare("DELETE FROM videos WHERE idvideos = :id")->execute($dados_cat); $redirect = "/administrador/videos_admin.php"; // $redirect = "http://www.tchaudor.com.br/administrador/videos_admin.php"; header("location:$redirect"); } // ############# UPDATE DEPOIMENTO ################### if (isset($_GET["act"]) && $_GET["act"] == "editar") { $pag_id = $_GET["id"]; $idinsertfck = $_GET["id"]+1; $name_ckeditor = $_POST["editor".$idinsertfck]; $pag_titulo = $_POST["titulo"]; $pag_link = $_POST["link"]; $categoria_edita = $_POST["categoria"]; $pag_corpo = $name_ckeditor; $dados_titulo = array( 'id' => $pag_id, 'titulo' => $pag_titulo, 'link' => $pag_link, 'descricao' => $pag_corpo, 'categoria' => $categoria_edita, ); $conn->prepare("UPDATE videos SET titulo = :titulo, descricao = :descricao, id_categoria = :categoria, link = :link WHERE idvideos = :id")->execute($dados_titulo); $redirect = "/administrador/videos_admin.php"; //$redirect = "http://www.tchaudor.com.br/administrador/videos_admin.php"; header("location:$redirect"); } ?> <!DOCTYPE html> <html> <head> <?php include 'include_head.php';?> </head> <body class="hold-transition skin-blue sidebar-mini"> <!-- Site wrapper --> <div class="wrapper"> <?php include 'estrutura_menu.php';?> <!-- =============================================== --> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <!-- Content Header (Page header) --> <div class="col-md-12" style="background: #fff;border-bottom: 1px solid #bbbbbb"> <div class="col-md-12" style="text-align: left;padding-left: 0px"> <p style="color: #040404;font-weight: 700;font-size: 32px;margin-top: 1%;margin-bottom: 0px">Gerenciamento de Vídeos</p> </div> <div class="col-md-8" style="height: 34px;padding-left: 0px"> <p style="color: #3a3a3a;font-size: 14px;">Tela Inicial/Gerenciamento de Vídeos</p> </div> <div class="col-md-4" style="text-align: right;margin-bottom: 1%"> <a href="categorias_videos_admin.php" class="btn btn-primary btn-flat" style="margin-right: 4%">Gerenciar Categorias</a> <a href="#" data-toggle="modal" data-target="#modal-inserir" class="btn btn-primary btn-flat">Inserir Vídeo</a> </div> </div> <div class="col-md-12" style="height: 22px"> </div> <!-- Main content --> <section class="content"> <?php $depoimento = $conn->query("SELECT videos.link, videos.titulo as titulovideo, videos.idvideos, categorias_videos.titulo as titulocat FROM videos inner join categorias_videos on videos.id_categoria = categorias_videos.idcategorias order by idvideos desc"); ?> <div class="row"> <div class="col-xs-12"> <div class="box" style="border-top:5px solid #408db9"> <div class="box-body table-responsive no-padding"> <!-- <a href="#" data-toggle="modal" data-target="#modal-inserir" class="btn btn-primary btn-flat" style="float:right; margin:20px;">Inserir Vídeos</a> --> </div> <?php if ($depoimento->rowCount()) {?> <!-- /.box-header --> <div class="box-body table-responsive no-padding"> <table class="table table-hover"> <?php while ($depo = $depoimento->fetch(PDO::FETCH_OBJ)) {?> <tr> <td width="25%"> <iframe class="video" src="https://www.youtube.com/embed/<?php echo $depo->link ?>" allowfullscreen="" width="100%" height="auto" style="border:none;"></iframe> </td> <td width="40%"> <p style="font-size: 18px;font-weight: 900"><?php echo $depo->titulovideo ?></p> <p><?php echo $depo->titulocat ?></p> </td> <td width="15%"></td> <td width="20%"> <p></p> <a href="#" data-toggle="modal" data-target="#modal-atualizar<?php echo $depo->idvideos ?>"><i style="margin-right:20px;" class="fas fa-pencil-alt"></i></a> <a href="videos_admin.php?act=excluir&id=<?php echo $depo->idvideos ?>"><i class="fas fa-trash-alt"></i></a> </td> </tr> <?php }?> </table> </div> <?php }?> <!-- /.box-body --> </div> <!-- /.box --> </div> </div> </section> <!-- /.content --> </div> <!-- /.content-wrapper --> <?php include 'estrutura_rodape.php';?> <!-- ########## MODAL INSERIR ########## --> <div class="modal fade" id="modal-inserir"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span></button> <h4 class="modal-title">Inserir Vídeo</h4> </div> <div class="modal-body"> <div class="row"> <form action="videos_admin.php?act=inserir" method="POST" enctype="multipart/form-data"> <div class="col-xs-12 pad"> <input type="text" name="titulo" class="form-control" placeholder="Título*" required> </div> <div class="col-xs-12 pad"> <input type="text" name="link" class="form-control" placeholder="Link*" required> </div> <?php $cat = $conn->query("SELECT * FROM categorias_videos order by idcategorias desc"); ?> <div class="col-xs-12 pad"> <select name="categoria" class="form-control" required> <option value="">Selecione uma Categoria*</option> <?php while ($categoria = $cat->fetch(PDO::FETCH_OBJ)) {?> <option value="<?php echo $categoria->idcategorias ?>"><?php echo $categoria->titulo ?></option> <?php } ?> </select> </div> <div class="col-xs-12 pad"> <textarea id="editor1" name="editor1" rows="10" cols="80"></textarea> </div> <div class="col-xs-12 pad"> <button type="submit" value="Upload Image" name="submit" class="btn btn-primary" style="margin-top:20px;">Cadastrar</button> </div> </form> </div> </div> <!-- <div class="modal-footer"> <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Fechar</button> </div> --> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.modal --> <?php $pagparamodal = $conn->query("SELECT * FROM videos order by idvideos desc"); // ##### SELECT IGUAL O DA LISTA COM MESMA ORDENAÇÃO PARA QUE TENHA O MESMO RESULTADO ####### while ($pagmodal = $pagparamodal->fetch(PDO::FETCH_OBJ)) { // ######### LAÇO DE REPETIÇÃO MODAL CONFORME SELECT ANTERIOR ?> <!-- ########## MODAL ATUALIZAR ########## --> <div class="modal fade" id="modal-atualizar<?php echo $pagmodal->idvideos ?>"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span></button> <h4 class="modal-title">Editar Vídeo</h4> </div> <div class="modal-body"> <div class="row"> <form enctype="multipart/form-data" action="videos_admin.php?act=editar&id=<?php echo $pagmodal->idvideos ?>" method="POST"> <div class="col-xs-12 pad"> <input type="text" name="titulo" class="form-control" placeholder="Título*" value="<?php echo $pagmodal->titulo ?>" required> </div> <div class="col-xs-12 pad"> <input type="text" name="link" class="form-control" placeholder="Link*" value="<?php echo $pagmodal->link ?>" required> </div> <?php $cat = $conn->query("SELECT * FROM categorias_videos order by idcategorias desc"); $idcatselect = $pagmodal->id_categoria; ?> <div class="col-xs-12 pad"> <select name="categoria" class="form-control" required> <?php while ($categoria = $cat->fetch(PDO::FETCH_OBJ)) {?> <option value="<?php echo $categoria->idcategorias ?>" <?php if($idcatselect == $categoria->idcategorias) { echo "selected"; }?>><?php echo $categoria->titulo ?></option> <?php } ?> </select> </div> <div class="col-xs-12 pad"> <textarea id="editor<?php echo $pagmodal->idvideos+1 ?>" name="editor<?php echo $pagmodal->idvideos+1 ?>" rows="10" cols="80"><?php echo $pagmodal->corpo ?></textarea> </div> <div class="col-xs-12 pad"> <button type="submit" value="Upload Image" name="submit" class="btn btn-primary" style="margin-top:20px;">Editar</button> </div> </form> </div> </div> <!-- <div class="modal-footer"> <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Fechar</button> </div> --> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div> <!-- /.modal --> <?php }?> <!-- Add the sidebar's background. This div must be placed immediately after the control sidebar --> <div class="control-sidebar-bg"></div> </div> <!-- ./wrapper --> <!-- jQuery 3 --> <script src="bower_components/jquery/dist/jquery.min.js"></script> <!-- Bootstrap 3.3.7 --> <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> <!-- SlimScroll --> <script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script> <!-- FastClick --> <script src="bower_components/fastclick/lib/fastclick.js"></script> <!-- CK Editor --> <script src="bower_components/ckeditor/ckeditor.js"></script> <!-- AdminLTE App --> <script src="dist/js/adminlte.min.js"></script> <!-- AdminLTE for demo purposes --> <script src="dist/js/demo.js"></script> <script> $(document).ready(function () { $('.sidebar-menu').tree() }) </script> <script> $(function () { // Replace the <textarea id="editor1"> with a CKEditor // instance, using default configuration. CKEDITOR.replace('editor1') //bootstrap WYSIHTML5 - text editor $('.textarea').wysihtml5() }) </script> <?php $scriptmodal = $conn->query("SELECT * FROM videos order by idvideos desc"); // ##### SELECT IGUAL O DA LISTA COM MESMA ORDENAÇÃO PARA QUE TENHA O MESMO RESULTADO ####### while ($pagscript = $scriptmodal->fetch(PDO::FETCH_OBJ)) { // ######### LAÇO DE REPETIÇÃO SCRIPT CKEDITOR - MODAL CONFORME SELECT ANTERIOR ?> <script> $(function () { // Replace the <textarea id="editor1"> with a CKEditor // instance, using default configuration. CKEDITOR.replace('editor<?php echo $pagscript->idvideos+1 ?>') //bootstrap WYSIHTML5 - text editor $('.textarea').wysihtml5() }) </script> <?php }?> </body> </html>