Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
16 kB
2
Indexable
Never
<style>
  input[type=text],
  input[type=number],
  input[type=password],
  input[type=date],
  input[type=email],
  select {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    display: inline-block;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
  }

  input[type="submit"],
  button {
    width: 100%;
    background-color: #4CAF50;
    color: white;
    padding: 14px 20px;
    margin: 8px 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }

  button:hover {
    background-color: #45a049;
  }
</style> <?php

        $msg = $msg1 = "";

        $linguaForm ="PT";
      
        $titulo = $descricao = $content = "";
        
            if(isset($_POST["idCancao"])) {
   
                $_SESSION["idCancao"] = $_POST["idCancao"];
                $titulo = $content = "";
                
           
        
                $ms = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
                if ($ms->connect_error) {
            
                echo '
<h3 style="color:red;">Erro: ('. $ms->connect_errno .') '. $ms->connect_error . '</h3>';
                }
                mysqli_set_charset($ms, 'utf8');
                $qr = "select titulo,descricao,conteudo from news where id=?";		
                $ordem = $ms->prepare($qr);				
                $ordem->bind_param('s', $_POST["idCancao"]);
                $ordem->execute();
                $ordem->bind_result($titulo, $descricao, $content);
                $ordem->fetch();
                $ordem->close();
                $titulo = trim($titulo,"
<p class='apNoticia'>
	<b>");
                $titulo = trim($titulo,"</b>
</p>");
                $ms->close();

            }
 
        if(isset($_POST["alterar"])){

             $ms = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
             if ($ms->connect_error) {
        
             echo '
<h3 style="color:red;">Erro: ('. $ms->connect_errno .') '. $ms->connect_error . '</h3>';
             }
             mysqli_set_charset($ms, 'utf8');
             $titulo = $_POST["tit"];
             $content = $_POST["editor1"];
             $qr = "update news set conteudo=?, descricao=?, titulo=? where id=?";		
             $ordem = $ms->prepare($qr);				
             $ordem->bind_param('sssi',$_POST["editor1"],$_POST["desc"],$_POST["tit"],$_SESSION["idCancao"]);

             if($ordem->execute() && $ordem->affected_rows >0){
        
                 if ($_SESSION["sessaoLang"] == "PT")
                     $msg = ('
                         
<div class="alert success">
	<span class="closebtn">&times;</span>
	<strong>Sucesso!</strong> Dados Alterados Corretamente.
                         
</div>
                     ');
                 else if ($_SESSION["sessaoLang"] == "ES") 
                 $msg = ('
                         
<div class="alert success">
	<span class="closebtn">&times;</span>
	<strong>Éxito!</strong> Los datos cambiaron correctamente.
                         
</div>
                     ');
                 else if ($_SESSION["sessaoLang"] == "EN") 
                
                     $msg = ('
                         
<div class="alert success">
	<span class="closebtn">&times;</span>
	<strong>Success!</strong> Data Changed Correctly.
                         
</div>
                     ');
                    
             }
             else{
        
                 if ($_SESSION["sessaoLang"] == "PT")
                     $msg = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Erro!</strong> Probemas Na Alteração Dos Dados.
                     
</div>');
                 else if ($_SESSION["sessaoLang"] == "ES") 
                     $msg = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Error!</strong> Problemas al cambiar datos.
                     
</div>');
                 else if ($_SESSION["sessaoLang"] == "EN") 
                                        
                     $msg = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Error!</strong> Problems Changing Data.
                     
</div>');
             }
             $ordem->close();
             $ms->close();
             $content = $descricao = $titulo = '';
             $_SESSION["idCancao"] = 0;
        }
         
        if(isset($_POST["inserir"])){
            $x = 0;
            if($_FILES["thumb"]["type"]=="image/jpeg"){
                $destino =  "fotos_2thumbnails/a" . uniqid() . ".jpg" ;
                $x = 1;
            }
            else if($_FILES["thumb"]["type"]=="image/png"){
                $destino =  "fotos_thumbnails/a" . uniqid() . ".png" ;
                $x = 1;
            }
            if($_FILES['thumb']['size'] == 0){
                $destino =  "fotos_thumbnails/a63637a593543a.png";
                $x = 1;
            }
            else{
            if(move_uploaded_file($_FILES['thumb']['tmp_name'], '../'.$destino)){}
            else{
                if ($_SESSION["sessaoLang"] == "PT")
                    $msg = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Erro!</strong> Probemas na Publicação da Noticia.
                    
</div>');
                else if ($_SESSION["sessaoLang"] == "ES") 
                    $msg = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Error!</strong> Problemas en la Publicación de las Noticias.
                    
</div>');
                else if ($_SESSION["sessaoLang"] == "EN") 
                            
                    $msg = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Error!</strong> Problems in the Publication of the News.
                    
</div>');
            }
            }
            if($x == 1){
                
                    
                    $ms = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
                    if ($ms->connect_error) {
                                
                        echo '
<h3 style="color:red;">Erro: ('. $ms->connect_errno .') '. $ms->connect_error . '</h3>';
                    }
                    mysqli_set_charset($ms, 'utf8');

                    $qr = "INSERT INTO news(titulo,descricao,conteudo,thumbnail,langCod) VALUES(?,?,?,?,?)";		
                
                
                
                    $ordem = $ms->prepare($qr);
                    
                    $ordem->bind_param('sssss', $_POST["tit"], $_POST["desc"], $_POST["editor1"], $destino, $_SESSION["sessaoLangForm"]);
                    
                    if($ordem->execute() && $ordem->affected_rows >0){

                        if ($_SESSION["sessaoLang"] == "PT")
                            $msg = ('
                                
<div class="alert success">
	<span class="closebtn">&times;</span>
	<strong>Sucesso!</strong> Notícia Publicada.
                                
</div>
                            ');
                        else if ($_SESSION["sessaoLang"] == "ES") 
                        $msg = ('
                                
<div class="alert success">
	<span class="closebtn">&times;</span>
	<strong>Éxito!</strong> Noticias Publicadas.
                                
</div>
                            ');
                        else if ($_SESSION["sessaoLang"] == "EN") 
                        
                            $msg = ('
                                
<div class="alert success">
	<span class="closebtn">&times;</span>
	<strong>Success!</strong> Published News.
                                
</div>
                            ');
                            
                        }
                    $ordem->close();
                    $ms->close();
                    
                
            
        }
        else{

            if ($_SESSION["sessaoLang"] == "PT")
                $msg = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Erro!</strong> Tipo de Imagem de Perfil Não Aceite.
                
</div>');
            else if ($_SESSION["sessaoLang"] == "ES") 
                $msg = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Error!</strong> Tipo de imagen de perfil no aceptado.
                
</div>');
            else if ($_SESSION["sessaoLang"] == "EN") 
                                
                 $msg = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Error!</strong> Profile Image Type Not Accepted.
                
</div>');
        }
        }
        $ms = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
        if ($ms->connect_error) {
                            
            echo '
<h3 style="color:red;">Erro: ('. $ms->connect_errno .') '. $ms->connect_error . '</h3>';
        }
        mysqli_set_charset($ms, 'utf8');
        
        $_SESSION["sessaoLangForm"] = $linguaForm;
        
        $qr = "select fotoLang from  footer where langCod=?";		
        $ordem = $ms->prepare($qr);				
        $ordem->bind_param('s', $_SESSION["sessaoLangForm"]);
        $ordem->execute();
        $ordem->bind_result($band);
        $ordem->fetch();
        $ordem->close();  

        $ms->close();
        
?> <?php

    if(isset($_POST["idCancaoApagar"])){
        
        $ms = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
    
        if ($ms->connect_error) {

            $msg= '
<h3 style="color:red;">Erro: ('. $ms->connect_errno .') '. $ms->connect_error . '</h3>';
        }

        $qr = "DELETE FROM  news WHERE id=?";
		$ordem = $ms->prepare($qr);				
		$ordem->bind_param('i',$_POST["idCancaoApagar"]);
		if($ordem->execute() && $ordem->affected_rows >0){

            if ($_SESSION["sessaoLang"] == "PT")
                $msg1 = ('
                    
<div class="alert success">
	<span class="closebtn">&times;</span>
	<strong>Sucesso!</strong> Notícia Eliminada.
                    
</div>
                ');
            else if ($_SESSION["sessaoLang"] == "ES") 
            $msg1 = ('
                    
<div class="alert success">
	<span class="closebtn">&times;</span>
	<strong>Éxito!</strong> Noticias borrado.
                    
</div>
                ');
            else if ($_SESSION["sessaoLang"] == "EN") 
            
                $msg1 = ('
                    
<div class="alert success">
	<span class="closebtn">&times;</span>
	<strong>Success!</strong> News Deleted.
                    
</div>
                ');
                
        }
        else{
  
            if ($_SESSION["sessaoLang"] == "PT")
                $msg1 = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Erro!</strong> Problemas na Eliminação da Notícia.
                
</div>');
            else if ($_SESSION["sessaoLang"] == "ES") 
                $msg1 = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Error!</strong> Problemas de eliminación de Noticias.
                
</div>');
            else if ($_SESSION["sessaoLang"] == "EN") 
                                    
                $msg1 = ('
<div class="alert">
	<span class="closebtn">&times;</span>
	<strong>Error!</strong> News elimination problems.
                
</div>');
        }
        $ordem->close();
        $ms->close();
    }
?> <h1 style="font-family:mavenPro;margin-top:50px"> <?php echo "Gestor de Noticias" ?> </h1>
<div id="lista"> <?php

    $ms = new mysqli($bd_host,$bd_user,$bd_password,$bd_database);
    if ($ms->connect_error) {

    echo '
	<h3 style="color:red;">Erro: ('. $ms->connect_errno .') '. $ms->connect_error . '</h3>';
    }
    mysqli_set_charset($ms, 'utf8');
    $sq="select * from news";
    $results = $ms->query($sq);

            
            $x  = 0; 

            while($row = $results->fetch_array()) {
                $x++;
                    echo '
	<table width="100%">';
                    echo '
		<tr width="100%">';
                    

                    
                    echo '
			<form name="editCancao" method="POST" action="" style="font-family:mavenPro;">';
                    
                    echo '
				<td width="200px" >';
                            echo '
					<div id="listaCancoes" style="  padding: 14px 20px;width:90%;padding-left:50px;border:1px solid black;background-color:grey;color:white;">'.$row["titulo"].'</div>';
                            echo '
				</td>';
                            echo '
				<input type="hidden" name="editCancao" value="1">';
                            echo '
					<td width="3%">
						<button onclick="document.editCancao.submit()" width="100%">Editar</button>
					</td>';
                            
                            echo '
					<input type="hidden" name="idCancao" id="idCancao" value="'.$row["id"].'"">';
                            
                    echo '
					</form>';
                    echo '
					<form name="idCancaoApagarForm" method="POST" action="" style="font-family:mavenPro;">';

                            echo '
						<input type="hidden" name="idCancaoApagar" id="idCancaoApagar" value="'.$row["id"].'"">';
                            echo '
							<td width="3%">
								<button  style="background-color:red;width:100%" onclick="document.idCancaoApagarForm.submit()">Apagar</button>
							</td>';
                            echo '
						</tr>';
                    echo '
					</form>';
                    echo '
				</table>';

               
                    
              
                
            }

            $results->free();

    $ms->close(); 

?> <form name="inserirCancao" method="POST" action="" style="font-family:mavenPro;">
    <input type="hidden" name="editCancao" value="0">
  </form> <?php
        
    echo '
					<table>
						<hr>
							<tr>
								<td width="86%">
									<h1 style="font-family:mavenPro;">Editar notícia</h1>
								</td>
							</tr>
						</table>';
    
?> <form enctype="multipart/form-data" name="ex" method="post" action="" style="font-family:mavenPro;">
    <label>
      <b>Título</b>
    </label>
    <input type="text" name="tit" style="margin-bottom:30px" maxlength="36" placeholder="Max Size:36" value="
								<?php echo $titulo; ?>">
    <label>
      <b>Descrição</b>
    </label>
    <input type="text" name="desc" style="margin-bottom:30px" maxlength="108" placeholder="Max Size:108" value="
									<?php echo $descricao; ?>">
    <label>
      <b>Conteúdo</b>
    </label>
    <textarea name="editor1" id="editor1" rows="1000000" cols="80">
										<?php echo $content; ?>
									</textarea>
    <script>
      CKEDITOR.replace('editor1');
    </script>
    <label style="margin-top:30px;">
      <b>Thumbnail</b>
    </label>
    <br>
    <input type="file" name="thumb" />
    <br> <?php
            echo '
											<input style="margin-top:30px;" type="submit" name="alterar" value="Editar">';
        
  
    ?>
  </form>
  <script>
    initSample();
  </script> <?php echo $msg; ?> <?php echo $msg1; ?> <script>
    var close = document.getElementsByClassName("closebtn");
    var i;
    for (i = 0; i < close.length; i++) {
      close[i].onclick = function() {
        var div = this.parentElement;
        div.style.opacity = "0";
        setTimeout(function() {
          div.style.display = "none";
        }, 600);
      }
    }
  </script>