Jump to content


Photo

Rednews V1.0


  • Faça o login para participar
2 replies to this topic

#1 Red FeniX

Red FeniX

    Novato no fórum

  • Usuários
  • 24 posts
  • Sexo:Não informado

Posted 17/12/2008, 21:21

redNews v1.0
Sistema de Notícias com Upload de Foto

Autor: Red FeniX

Demo On-line: CLIQUE AQUI

Arquivos:
  • conexao.php
  • install.php
  • index.php
  • vernew.php
  • admin.php
Altere antes de instalar..

conexao.php
<?php

		 

		 $db_servidor  = "";  // Servidor MySQL, normalmente localhost.

		 $db_user  =  "";  // Usuário da base de dados, altere para o seu

		 $db_pass =  "";  // Senha da base de dados, altere para a sua

		 $db_nome = ""; // Nome da base de dados que usaremos

		 

		 

		 $conexao = mysql_connect ($db_servidor, $db_user, $db_pass);  

					mysql_select_db($db_nome, $conexao);  

		 ?>

install.php
<?

require("conexao.php");





$conecta = mysql_query("CREATE TABLE IF NOT EXISTS `noticias` (

  `nid` int(25) NOT NULL auto_increment,

  `titulo` varchar(255) NOT NULL,

  `noticia` text NOT NULL,

  `foto` varchar(300) default NULL,

  `data` varchar(50) NOT NULL,

  `hora` varchar(50) NOT NULL,

  PRIMARY KEY  (`nid`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;") or die(mysql_error());



if ($conecta){

echo "<div style=\"width: 600px; color: #00CC00; height: 25px; padding: 10px; border: 1px solid #00CC00; font-family: Verdana, Arial, Helvetica, sans-serif;\">A instalação da tabela 
<b>noticias</b> foi completada com sucesso!</div>";

}



$dir_imgs = mkdir("./imagens", 0777);



if ($dir_imgs) {

	echo "<div style=\"width: 600px; color: #00CC00; height: 25px; padding: 10px; border: 1px solid #00CC00; font-family: Verdana, Arial, Helvetica, sans-serif;\">O diretório <b>imagens</b> foi criado com sucesso!</div>";

}

?>

index.php
<html>
<head>
<title>Demo - redNews v1.0</title>
</head>
<body>

<?php 

include "conexao.php";

$achanew = "SELECT * FROM noticias ORDER BY nid DESC LIMIT 10";
$query = mysql_query ($achanew);
$rs = mysql_num_rows($query);
 if($rs > 0) 
	 {
	while ($dados = mysql_fetch_array($query)) 
				   {
		echo $dados["data"]." - <a href='vernew.php?nid=".$dados["nid"]."'>".$dados["titulo"]."</a><br />";
		}
	}
else
 {
	echo "Nenhuma notícia cadastrada até o momento!";
}

?>
</body>
</html>

vernew.php
<html>
<head>
<?php 

include "conexao.php";
include "visitas.php";

$id = $_GET["nid"];

$achanew = "SELECT * FROM noticias WHERE nid=$id";
$query = mysql_query($achanew);
$rs = mysql_num_rows($query);

if($rs > 0) {
	
	while($dados = mysql_fetch_object($query)) {
		
		$titulo = $dados->titulo;
		$noticia = $dados->noticia;
		$data = $dados->data;
		$hora = $dados->hora;
		$foto = $dados->foto;
		
?>
<title><?php echo $titulo; ?> - redNews v1.0</title>
<style type="text/css">
body {
	text-align: justify;
	width: 92%;
}
img { /* Faz o texto futuar em torno da imagem */
	float:left;
	padding: 5px 15px 5px 0px;
}
</style>
</head>

<body>
<?php
		echo "<h1>".$titulo."</h1>";
		echo nl2br("<img src=".$foto." /><p>".$noticia."</p>");
		echo "<div style=\"clear: both;\"><b>Postada em ".$data." às ".$hora."</b></div>";
	}
}
?>
</body>
</html>

admin.php
<?php 

include "conexao.php";
$senha = "123456"; // SENHA ADMIN

$data = date ("d/m/Y",time());
$hora = strftime ("%H:%M");

?>

<html>
<head>
<title>Painel Admin - redNews v1.0</title>
</head>
<body>

<h2>Incluir nova notícia</h2>

<form action="<? $PHP_SELF ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <table width="780" border="0" cellspacing="0" cellpadding="5">
	<tr>
	  <td width="71">Título</td>
	  <td width="689"><input name="titulo" type="text" size="40" /></td>
	</tr>
	<tr>
	  <td>Notícia</td>
	  <td><textarea name="noticia" cols="40" rows="5"></textarea></td>
	</tr>
	<tr>
	  <td>Foto:</td>
	  <td><input name="foto" type="file" size="40" /></td>
	</tr>
	<tr>
	  <td>&nbsp;</td>
	  <td><input type="hidden" name="data" value="<?php echo $data ?>"></td>
	</tr>
	<tr>
	  <td>&nbsp;</td>
	  <td><input type="hidden" name="hora" value="<?php echo $hora ?>">
	  <input type='hidden' name="pass" value="<?php echo $senha ?>"></td>
	</tr>
  </table>
  <table width="780" border="0" cellspacing="0" cellpadding="5">
	  <tr>
	<td><input type="submit" name="enviar" value="Incluir"></td>
	</tr>
</form>
<?
if(isset($_POST["enviar"])) {
	
$titulo = $_POST["titulo"];
$noticia = $_POST["noticia"];
$data = $_POST["data"];
$hora = $_POST["hora"];
$foto = $_FILES['foto']['name'];
$foto_tmp = $_FILES['foto']['tmp_name'];

$t_sem_esp = str_replace(" ", "_", $titulo);
$_acentos = array("ç", "á", "à", "ã", "ó", "õ", "ô", "é", "ê", "í", "ú", "Ç", "Á", "À", "Ã", "Ó", "Õ", "Ô", "É", "Ê", "Í", "Ú");
$_sem_acentos = array("c", "a", "a", "a", "o", "o", "o", "e", "e", "i", "u", "C", "A", "A", "A", "O", "O", "O", "E", "E", "I", "U");
$titulodir = str_replace($_acentos, $_sem_acentos, $t_sem_esp);
$cdir = mkdir("imagens/$titulodir", 0777);
$path = "imagens/$titulodir/";
$caminho = "imagens/$titulodir/";
$arquivo = $foto;
$path_foto = $path.$arquivo;

/* move o arquivo pra pasta imagens */
move_uploaded_file($foto_tmp,$caminho.$foto);

/* insere no banco de dados */
$sql = mysql_query("INSERT INTO noticias (nid, titulo, noticia, foto, data, hora) VALUES('','$titulo','$noticia', '$path_foto','$data','$hora')");
if($sql){
  echo "<b>Notícia cadastrada com sucesso!</b";
}else{
   echo "<h2><font color='#FF0000'>Erro</font>
</h2>
   Infelizmente, não foi possível cadastrar a notícia. O erro retornado pelo sistema foi:<br />
   <blockquote>".mysql_error()."</blockquote>";
}
}
?>



</body>
</html>

DOWNLOAD:

Para quem quiser ae estão os arquivos do meu sistema de notícias:

Attached File  redNews_v1.0.rar   3.76KB   90 downloads

Abraços

Edição feita por: Red FeniX, 17/12/2008, 21:22.


#2 Sh1n0

Sh1n0

    Turista

  • Usuários
  • 58 posts
  • Sexo:Masculino
  • Localidade:Castanheiras, Rondonia

Posted 22/04/2009, 17:12

falta o scrip de deletar as noticias
posta ai!!
Paulo Ricardo
Skype: sh1n0.styl3
Castanheiras, RO

#3 ramonez

ramonez

    Novato no fórum

  • Usuários
  • 4 posts
  • Sexo:Não informado

Posted 17/06/2009, 21:48

falta o scrip de deletar as noticias
posta ai!!

enfase




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq