equipalsa/news.php
2021-09-12 22:52:08 +02:00

223 lines
8.8 KiB
PHP
Raw Permalink Blame History

<?
session_name( "EQUIPALSA" );
$v1="user_id";
$v2="user_name";
$v3="user_auth";
session_register($v1,$v2,$v3);
session_start();
require ("common/config.inc.php");
require ("common/dbnav_bar.php");
$limit = 8;
if ( !isset( $offset ) ) $offset = 0;
// Segun TIPO selecionamos las pelis
$conexion = mysql_connect( 'localhost', 'equipalsa_users', '06mar2002' ) OR die("No puedo conectar");
$id = mysql_select_db( 'EQUIPALSA', $conexion ) OR die("No puedo abrir Base de Datos");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>-= SYNCRO news =- </title>
<link href="images/syncro.ico" rel="SHORTCUT ICON">
<link rel="stylesheet" type="text/css" href="eq.css" body="eq.css">
</head>
<body bgcolor="#057CD8">
<?
if ( !isset( $accion ) )
{
$qFROM = "news";
$consulta = "SELECT * FROM $qFROM ORDER BY id DESC LIMIT $offset, $limit";
CreateDBnav( $qFROM );
$res = mysql_query( $consulta, $conexion ) OR die("No puedo realizar la consulta<br>$consulta<br>".mysql_error($conexion));
?>
<div align="center"><center>
<table border="1" cellpadding="0" cellspacing="0" width="600" bgcolor="#52ABF0" bordercolor="#000000" bordercolordark="#000000" bordercolorlight="#000000">
<tr>
<td><table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td valign="top" width="225">
<p style='text-align:center'><font size="4">Coordinador -news-</font><br>
<?
if ( $user_id == 1 )
echo "-=[ <a href=\"$PHP_SELF?accion=sins\">Insertar nueva noticia</a> ]=-";
?></p></td>
<td valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>&nbsp;</td>
<td width="20">
<a href="<? echo $PHP_SELF ?>" target="_blank">
<img src="images/exp.gif" alt="Hacer zoom (Iniciar en una ventana nueva)" align="absmiddle" border="0" width="20" height="18">
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
<hr>
<table border="0" width="100%">
<?
// Bucle de NOTICIAS
while ( $datos = mysql_fetch_array($res) )
{
echo "<tr>" .
"<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">".
"<tr><td><strong>$datos[3] - $datos[5]</strong></td>".
"<td width=\"100\">[-<font color=\"#FFFFBB\">$datos[2]</font>-]</td>".
"<td width=\"26\">";
if ( $user_auth && ( $user_id == $datos[1] || $user_id == 1 ) )
echo "<a href=\"$PHP_SELF?accion=sedit&new=$datos[0]\"><img src=\"images/edit.gif\" width=\"26\" height=\"34\" border=\"0\"></a>";
echo "</td><td valign=\"bottom\" width=\"26\">";
if ( $user_auth && ( $user_id == $datos[1] || $user_id == 1 ) )
echo "'<a href=\"$PHP_SELF?accion=del&new=$datos[0]\"><img src=\"images/del.gif\" alt=\"Eliminar esta noticia\" width=\"17\" height=\"15\" border=\"0\"></a>";
echo "</td>".
"</tr>".
"</table></td></tr>".
"<tr><td><blockquote><p>".nl2br($datos[6])."</p></blockquote></td></tr>";
}
// Fin del bucle de noticias
?>
</table>
</td>
</tr>
</table>
</center></div><br>
<?
$navBarBox = MakeBox( GetDBnav() );
echo $navBarBox;
} else {
// Muestra la pantalla de insertar...
if ( strcmp( $accion, "sins" )==0 ||
strcmp( $accion, "sedit" )==0 )
{
if ( strcmp( $accion, "sins" ) == 0 )
{
$next_action = "ins";
$fecha = date("Y-m-d");
$n_user_name = $user_name;
} else {
$next_action = "edit&new=$new";
// Leemos los datos actuales...
$sql = "SELECT fecha, Apodo, Asunto, Comentario FROM news WHERE id = $new";
$res = mysql_query( $sql, $conexion );
$datos = mysql_fetch_array($res);
$fecha = $datos[0];
$n_user_name = $datos[1];
$p_asunto = $datos[2];
$p_comentario = $datos[3];
}
?>
<form action="<? echo "$PHP_SELF?accion=$next_action" ?>" method="POST">
<div align="center"><center>
<table border="1" cellpadding="0" cellspacing="0" width="600"
bgcolor="#52ABF0" bordercolor="#000000" bordercolordark="#000000"
bordercolorlight="#000000">
<tr>
<td><table border="0" cellpadding="2" cellspacing="0"
width="100%">
<tr>
<td valign="top" width="225"><!--webbot
bot="HTMLMarkup" startspan --><p style='text-align:center'><!--webbot
bot="HTMLMarkup" endspan --><font size="6">SyNcro
-news-</font><br>
-=[ <font color="#FFFF80">Insertando nueva
Noticia</font>]=-<!--webbot bot="HTMLMarkup"
startspan --></p><!--webbot bot="HTMLMarkup"
endspan --></td>
<td valign="top"><table border="0"
cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>&nbsp;</td>
<td width="20"><a href="<? echo $PHP_SELF ?>"><img src="images/del.gif"
alt="Cancelar la operaci<63>n actual"
align="absmiddle" border="0" width="20"
height="18"></a></td>
</tr>
</table>
</td>
</tr>
</table>
<hr>
<table border="0" cellpadding="0" cellspacing="0"
width="100%">
<tr>
<td><strong><? echo $fecha; ?></strong></td>
<td><input type="text" size="40"
name="p_asunto" value="<? echo $p_asunto ?>"></td>
<td width="100">[<? echo $n_user_name ?>]</td>
</tr>
<tr>
<td align="center"><!--webbot
bot="HTMLMarkup" startspan --><p style='text-align:center'><!--webbot
bot="HTMLMarkup" endspan --><input
type="image" name="I1"
src="images/enviar.gif" align="bottom"
border="0" width="20" height="71"><!--webbot
bot="HTMLMarkup" startspan --></p><!--webbot
bot="HTMLMarkup" endspan --></td>
<td colspan="2"><textarea name="p_comentario"
rows="6" cols="60"><? echo $p_comentario ?></textarea></td>
</tr>
</table>
</td>
</tr>
</table>
</center></div>
</form>
<?
}
// Inserta los datos...
if ( strcmp( $accion, "ins" )==0 )
{
if ( isset( $p_asunto ) && !empty( $p_asunto ) &&
isset( $p_comentario ) && !empty( $p_comentario ) )
{
$sql_ins = "INSERT INTO news (owner, Apodo, fecha, hora, Asunto, Comentario)".
"VALUES ('$user_id', '$user_name', '".date("Y-m-d")."', '".date("H:i:s")."', '$p_asunto', '$p_comentario')";
$res = mysql_query( $sql_ins, $conexion ) OR die("No puedo realizar la Insersi<73>n de NEWS<br>$sql_ins<br>".mysql_error($conexion));
$dev = MakeBox( "<br><p style=\"text-align:center\">Tu \"Noticia\" ha sido insertada<br>-[<a href=\"$PHP_SELF\">ver noticias</a>]-</p><br>" );
} else {
$dev = MakeBox( "<br><p style=\"text-align:center\">No puedo insertar una noticia VACIA.<br>-[<a href=\"$PHP_SELF\">ver noticias</a>]-</p><br>" );
}
echo $dev;
}
// Actualizamos los datos
if ( strcmp( $accion, "edit" )==0 )
{
if ( isset( $p_asunto ) && !empty( $p_asunto ) &&
isset( $p_comentario ) && !empty( $p_comentario ) )
{
$sql_upd = "UPDATE news SET Asunto='$p_asunto', Comentario='$p_comentario' WHERE id=$new";
$res = mysql_query( $sql_upd, $conexion ) OR die("No puedo realizar la Actualizacion de la Noticia<br>$sql_upd<br>".mysql_error($conexion));
$dev = MakeBox( "<br><p style=\"text-align:center\">Tu \"Noticia\" ha sido actualizada<br>-[<a href=\"$PHP_SELF\">ver noticias</a>]-</p><br>" );
} else {
$dev = MakeBox( "<br><p style=\"text-align:center\">No puedo modificar una noticia a VACIA.<br>-[<a href=\"$PHP_SELF\">ver noticias</a>]-</p><br>" );
}
echo $dev;
}
// Eliminamos la noticia
if ( strcmp( $accion, "del" )==0 )
{
if ( isset( $new ) )
{
$sql_upd = "DELETE FROM news WHERE id=$new";
$res = mysql_query( $sql_upd, $conexion ) OR die("No puedo eliminar la Noticia<br>$sql_upd<br>".mysql_error($conexion));
$dev = MakeBox( "<br><p style=\"text-align:center\">La \"Noticia\" ha sido eliminada<br>-[<a href=\"$PHP_SELF\">ver noticias</a>]-</p><br>" );
} else {
$dev = MakeBox( "<br><p style=\"text-align:center\">No estas autorizado a eliminar esa Noticia<br>-[<a href=\"$PHP_SELF\">ver noticias</a>]-</p><br>" );
}
echo $dev;
}
}
mysql_close($conexion);
?>
</body>
</html>