<?
  if ( !empty( $db_asunto ) && !empty( $db_noticia ) )
  {
	  if ( isset( $add ) && $user_auth && $user_level == -2)
		    $res = mysql_query( "INSERT INTO news (fecha, uid, asunto, noticia) VALUES (CURDATE(), '$user_id', '".addslashes($db_asunto)."','".addslashes($db_noticia)."')", $conexion ) OR die("No puedo insertar la noticia");

	  if ( isset( $mod ) && ( $user_auth ) && $user_level == -2 )
	    $res = mysql_query( "UPDATE news SET uid='$user_id', asunto='".addslashes($db_asunto)."', noticia='".addslashes($db_noticia)."' WHERE id=$mod", $conexion ) OR die("No puedo modificar la noticia");
  }

  if ( !isset( $go ) )
	$go = 1;
  $go--;

  if ( isset( $smod ) )
    $res = mysql_query( "SELECT fecha, asunto, noticia, id FROM news WHERE id=$smod", $conexion ) OR die("No puedo realizar la consulta<br>$sql_upd<br>".mysql_error($conexion)); 
  else
    $res = mysql_query( "SELECT fecha, asunto, noticia, id FROM news ORDER BY fecha+id DESC LIMIT $go, 5", $conexion ) OR die("No puedo realizar la consulta<br>$sql_upd<br>".mysql_error($conexion)); 
?>


<? if ( isset( $sadd ) || isset( $smod ) ) { ?>
<br><br>
<form method="post" action="<? if ( isset( $sadd ) ) echo "./?dgo=noticias.php&add=this"; else echo "./?dgo=noticias.php&mod=$smod"; ?>"><p>
<input type=text maxlength=60 name="db_asunto" 
<? 
  if ( isset( $smod ) )
  {
	$datos = mysql_fetch_array($res);
	echo "value=\"$datos[1]\" "; 
  }
?>
style="width: 100%; font-family: arial, serif;font-size: 12pt;background-color:#CFFFCF;color: #000000;border: 1px solid #000000;">
<textarea name="db_noticia" style="overflow: auto;
background-color:#CFFFCF;
LAYER-BACKGROUND-COLOR:#CFFFCF;
color: #000000;
font-family: arial, serif;
font-size: 12pt;
line-height: 105%;
left: 0px;
font-weight: medium;
scrollbar-base-color: #000000; 
scrollbar-arrow-color: #FFFFFF;
scrollbar-face-color: #gray; 
scrollbar-shadow-color: #444444;
border: 1px solid black; height: 100px; width: 100%;
CLIP: rect(0,100%,100,0)"><? if ( isset( $smod ) ) echo "$datos[2]"; ?></textarea>
<input type="image" name src="images/enviar.gif" border="0" width="71" height="14"></p>
</form>
<?} else {

 echo '<br><br>';
//<p style="font-family: verdana, arial, serif; font-size: 8pt;">';
  $numrows = mysql_num_rows( $res ); 
  if (  $numrows > 0 ) 
  { 
   while( ($datos = mysql_fetch_array($res)) )
   {
     echo '<div align="center"><center><table border="0"  bordercolor="#000000"  cellpadding="0" cellspacing="0" width="90%" >';
     echo "<tr><td width=24>";

     echo "<img src=\"images/td_divv.gif\" align=\"absmiddle\"></td><td bgcolor=\"#000000\" style=\"color:#FFFFFF\">";
     if ( $user_auth && $user_level == -2 )
	echo "<a href=\"./?dgo=noticias.php&smod=$datos[3]\">[ E ]</a> ";

     echo"<b>$datos[0] &gt;&gt &gt; ".stripslashes($datos[1])."</b></td></tr>";
     echo '</table><table border="1" bordercolor="#000000"  cellpadding="0" cellspacing="0" width="90%" >';

     echo "<tr><td bgcolor=\"#FFFFFF\">".nl2br(stripslashes($datos[2]))."</td></tr>";
     echo "</table><br><br></center></div>";
   }

  } else { 
    echo "No hay noticias en el sistema"; 
  }
  mysql_free_result($res);
// echo "</p>";
}
?>
