ok

Mini Shell

Direktori : /home/agroviero/www/adm/
Upload File :
Current File : /home/agroviero/www/adm/sliders.php

<?
include('conecta.php');

//------------------------------------------------------------ SESSÃO
   session_start();
   if(!isset($_SESSION['userid']) && !isset($_SESSION['username'])) {
   Header('Location: index.php');
};

//------------------------------------------------------------ ID

  $id = $_GET["id"];
  $codigo = $_GET["codigo"];
  $categ = $_GET["categ"];


//------------------------------------------------------------ CADASTRA SLIDER
  if ($id == "cad") {
      
      $nome = $_REQUEST["nome"];
	  $subtitulo = $_REQUEST["subtitulo"];
	  $botao = $_REQUEST["botao"];
      $url = $_REQUEST["url"];
      $imagem = $_FILES['imagem']['name'];
      
        if ($imagem == "") {
        $query= "insert into slides set nome='$nome',subtitulo='$subtitulo',botao='$botao',url='$url'";
        $retorno = mysql_query($query) or die (mysql_error());
        if($retorno){
            Header("Location: ?id="); }} else {
//--------->
        if (is_uploaded_file($_FILES['imagem']['tmp_name'])){
            $ext = explode(".", $_FILES['imagem']['name']);
            $num = mt_rand(1, 99999);
            $nomeimg = "img/".$ext[0]."$num".".".$ext[1]."";
        if (copy($_FILES['imagem']['tmp_name'],$nomeimg)){
        $query= "insert into slides set nome='$nome',subtitulo='$subtitulo',botao='$botao',url='$url',imagem='$nomeimg'";
        $retorno = mysql_query($query) or die (mysql_error());
        if($retorno){
            Header("Location: ?id="); }
        }}}


//------------------------------------------------------------ EDITAR SLIDER
} else if ($id == "edit") {
       
      $nome = $_REQUEST["nome"];
      $nome = $_REQUEST["nome"];
	  $subtitulo = $_REQUEST["subtitulo"];
	  $botao = $_REQUEST["botao"];
	  $url = $_REQUEST["url"];
      $imagem = $_FILES['imagem']['name'];
      
        if ($imagem == "") {
        $query= "update slides set nome='$nome',subtitulo='$subtitulo',botao='$botao',url='$url' where codigo='$codigo'";
        $retorno = mysql_query($query) or die (mysql_error());
        if($retorno){
            Header("Location: ?id="); }} else {
//--------->
        if (is_uploaded_file($_FILES['imagem']['tmp_name'])){
            $ext = explode(".", $_FILES['imagem']['name']);
            $num = mt_rand(1, 99999);
            $nomeimg = "img/".$ext[0]."$num".".".$ext[1]."";
        if (copy($_FILES['imagem']['tmp_name'],$nomeimg)){
        $query= "update slides set nome='$nome',subtitulo='$subtitulo',botao='$botao',url='$url',imagem='$nomeimg' where codigo='$codigo'";
        $retorno = mysql_query($query) or die (mysql_error());
        if($retorno){
            Header("Location: ?id="); }
        }}}}


//------------------------------------------------------------ EXCLUIR IMAGEM DO SLIDER
    if ($id == "excluirImg") {
     $query = "select imagem from slides where codigo ='$codigo'";
     $linha = @mysql_fetch_array(@mysql_query($query));
       @unlink($linha["imagem"]); 
     $query= "update slides set imagem='' where codigo ='$codigo'";
     $retorno = mysql_query($query) or die (mysql_error());
      if($retorno){
        Header('Location: ?id='); }
}


//------------------------------------------------------------ EXCLUIR SLIDER
    if ($id == "excluir") {
     $query = "select imagem from slides where codigo ='$codigo'";
     $linha = @mysql_fetch_array(@mysql_query($query));
     if ($linha["imagem"] == "img/") {} else {
       @unlink($linha["imagem"]); }
     $query= "delete from slides where codigo ='$codigo'";
     $retorno = mysql_query($query) or die (mysql_error());
      if($retorno){
        Header('Location: ?id='); }
}


//------------------------------------------------------------ MOSTRA EDIÇÃO
if ($id == "edita") {
   $query = "SELECT * from slides where codigo = '$codigo'";
   $ed = mysql_query($query);
   $edVer = mysql_fetch_array($ed);
}
?>

<!DOCTYPE html>
<html lang="pt-br">
    
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>AGROVIERO - Nutrição Animal</title>

    <!-- Todos os codigos CSS -->
   <link href="css/styles.css" rel="stylesheet">
   <script src="js/jquery.js"></script> 
   
    <link href="css/bootstrap.css" rel="stylesheet"> 
  <script src="js/bootstrap.js"></script> 

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    
<script>
function DeleteImg(value) {
  if(confirm('Deseja realmente excluir a imagem desse slider?') ) {
    location.href="?id=excluirImg&&codigo="+value;
  } else {
    location.href="#";
  }
}
</script>
    
<script>
function DeleteP(value) {
  if(confirm('Deseja realmente excluir esse slide?') ) {
    location.href="?id=excluir&&codigo="+value;
  } else {
    location.href="#";
  }
}
</script>
    
</head>

<body>

        <!-- Menu de navegação -->
<nav class="navbar navbar-default">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand">AGROVIERO</a>
    </div>

   <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
         <li><a href="#">Notícias<span class="sr-only"></span></a></li>
		 <li><a href="produtos.php">Produtos<span class="sr-only"></span></a></li>
         <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Tipos <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="linhas.php">Linhas</a></li>
                <li><a href="categorias.php">Categorias</a></li>
              </ul>
            </li>
     <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Ajustes <span class="caret"></span></a>
          <ul class="dropdown-menu">
			 <li><a href="sliders.php">Capas Site</a></li>
            <li><a href="usuarios.php">Usuários</a></li>
          </ul>
        </li>          
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="index.php?id=finaliza">Sair</a></li>
      </ul>
    </div>
  </div>
</nav>

</br>
    
<? //---------------------------------------------------------------------------------------------------------
  if ($id == "") {?>
    
<div class="container">
        		<div class="row col-md-9 col-sm-9 col-xs-12">
				<div class="page-header text-center">
				<h3>Sliders Site</h3>
				<h4>Aqui você pode configurar os slides da página inicial</h4>
				</div>
        
		  <div class="btn-group btn-group-justified" role="group" aria-label="...">
			  <div class="btn-group" role="group">
				<a href="?id=nova" class="btn btn-success">CRIAR SLIDE</a>
			  </div>
		  </div>		
	       </div>
	<div class="row">
		<div class="col-md-9 col-sm-9 col-xs-12 curses" style="min-height: 300px;"> 			<!-- classe responsiva do bootstrap -->
		<table border="0" class="table tabela-post">
		  <thead>
			<tr>
			  <th>Nome</th>
			  <th>Editar</th>
			  <th>Apagar</th>
			</tr>
		  </thead>
        
		  <tbody>

<? //--------------------------------------------------------------------------------------------------------------------TODOS OS SLIDERS
      
        $qu = "SELECT * FROM slides"; 
        $cur = mysql_query($qu);
	    while ($veC = mysql_fetch_array($cur)) {?>
              
			<tr>
              <td><b><? echo($veC["nome"]);?></b></td>
			  <td><a href="?id=edita&codigo=<? echo($veC["codigo"]);?>" type="button" class="btn btn-default">
			  <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
			  </a>
			  </td>
			  <td><a href="<?echo("javascript:DeleteP(".$veC['codigo'].")")?>" type="button" class="btn btn-danger">
			  <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
			  </a>
			  </td> 
			 </tr>
        <?}?>          
              
            </tbody>
		</table>
		
	</div>
	</div>
</div>
<? //---------------------------------------------------------------------------------------------------------
    } if (($id =="nova") || ($id =="edita")) {?>
    
<div class="container"> 

<div class="col-md-offset-1 col-md-10">
<? if ($id == "edita") {?>
<form method="post" action="?id=edit&codigo=<?echo($codigo);?>" enctype="multipart/form-data">
<?} else {?>
<form method="post" action="?id=cad" enctype="multipart/form-data">
<?}?>
<div class="input-group">
  <span class="input-group-addon" id="basic-addon1">Nome:</span>
  <input type="text" class="form-control" aria-describedby="basic-addon1" name="nome" value="<? echo($edVer["nome"]);?>" required>
</div>
<br>
<div class="input-group">
  <span class="input-group-addon" id="basic-addon1">Subtítulo:</span>
  <input type="text" class="form-control" aria-describedby="basic-addon1" name="subtitulo" value="<? echo($edVer["subtitulo"]);?>" required>
</div>
<br>
<div class="input-group">
  <span class="input-group-addon" id="basic-addon1">Texto Botão:</span>
  <input type="text" class="form-control" aria-describedby="basic-addon1" name="botao" value="<? echo($edVer["botao"]);?>" required>
</div>
<br>
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Imagem do slide:</span>
<input type="file" accept="image/*" class="form-control" aria-describedby="basic-addon1" name="imagem">
</div>
<? if ($edVer["imagem"] == "") {?>
<div class="row" style="display: none;">
<?}else{?><div class="row"><?}?>
 <br>
<div class="col-xs-3 col-md-3">
    <a class="thumbnail">
      <img src="<?echo($edVer["imagem"]);?>">
    </a>
    <div class="btn-group" role="group">
    <a type="button" class="btn btn-danger" href="<?echo("javascript:DeleteImg(".$edVer['codigo'].")")?>">Excluir imagem</a>
    </div>
</div>
</div>
<br>
<div class="input-group">
  <span class="input-group-addon" id="basic-addon1">Link do slide:</span>
  <input type="text" class="form-control" aria-describedby="basic-addon1" name="url" value="<? echo($edVer["url"]);?>">
</div>
<br>
		<div class="btn-group" role="group" aria-label="">
            <? if ($id == "edita"){ ?>
		  <button type="submit" class="btn btn-success">Concluir edição</button><?} else {?>
            <button type="submit" class="btn btn-success">Publicar</button><?}?>
		  <a href="javascript:{ window.location.href='?id='}" class="btn btn-danger">Cancelar</a>
		</div>
</form>
</div>
</div>

<?}?>
<br>
<div class="container">
	<div class="row">
		<div class="col-md-offset-3 col-sm-offset-3 col-md-6 col-sm-6 col-xs-12 text-center footer">
			<p>&copy 2019 Agroviero • Feito por Mulis</p>
		</div>
	</div>
</div>	


</body>

</html>

Zerion Mini Shell 1.0