147 lines
4.2 KiB
PHP
147 lines
4.2 KiB
PHP
<?
|
||
$myName = "./?dgo=pages/sat/links.php&";
|
||
|
||
$showLinks = true;
|
||
|
||
if ( !isset( $flinks ) )
|
||
$flinks = "pages/sat/drivers";
|
||
|
||
if ( isset( $sins ) )
|
||
{
|
||
$showLinks = false;
|
||
displayFORM( $myName."ins=link", "Titulo", "http://", "tu comentario" );
|
||
}
|
||
|
||
if ( isset( $ins ) )
|
||
{
|
||
$fp = fopen( $flinks.".txt", "a" );
|
||
if ( $fp )
|
||
{
|
||
fputs( $fp, $db_descr ."|" );
|
||
fputs( $fp, $db_url ."|");
|
||
fputs( $fp, urlencode($db_comment)."\n");
|
||
fclose( $fp );
|
||
echo "<p align=center class=remark>Enlace insertado<p>";
|
||
} else {
|
||
echo "<p align=center class=remark>Se produjo un error intentando insertar el enlace</p>";
|
||
}
|
||
|
||
}
|
||
|
||
if ( $user_auth && $user_level <= -1 && $showLinks )
|
||
{
|
||
if ( isset( $mod ) ) $linea = $mod;
|
||
if ( isset( $del ) ) $linea = $del;
|
||
|
||
if ( isset( $linea ) )
|
||
{
|
||
$llink = file( $flinks.".txt" );
|
||
$nlink = count($llink);
|
||
|
||
if ( ($fp = fopen( $flinks.".txt", "w" )) )
|
||
{
|
||
for ($i=0;$i<$nlink;$i++)
|
||
{
|
||
if ( $i == $linea )
|
||
{
|
||
if ( isset( $mod ) )
|
||
{
|
||
fputs( $fp, $db_descr ."|" );
|
||
fputs( $fp, $db_url ."|");
|
||
fputs( $fp, urlencode($db_comment)."\n");
|
||
}
|
||
} else
|
||
fputs( $fp, $llink[$i] );
|
||
}
|
||
fclose( $fp );
|
||
}
|
||
}
|
||
|
||
// include( "inicio.htm" );
|
||
|
||
// Muestra los enlaces actuales del fichero
|
||
if ( ( $fp = fopen( $flinks.".txt", "r" ) ) )
|
||
{
|
||
echo "<h1>Listado de enlaces</h1><p class=remark>Fichero: $flinks.txt</p>";
|
||
echo "<br><br><br>";
|
||
echo "<table witdh=100%><tr><td>ID</td><td width=300>Link</td><td>[X]</td></tr>";
|
||
$id = 0;
|
||
while( $linfo=fscanf($fp, "%[a-zA-Z0-9@&;:,. /!?-]|%[a-zA-Z0-9@&;:,. /!?-]|%[a-zA-Z0-9@&;:,. %/!?+-]\n" ) )
|
||
{
|
||
list( $descLink, $urlLink, $comment ) = $linfo;
|
||
|
||
if ( isset( $smod ) && $smod == $id )
|
||
{
|
||
echo "</table>";
|
||
displayFORM( $myName."mod=$id", $descLink, $urlLink, urldecode($comment) );
|
||
echo "<table witdh=100%><tr><td>ID</td><td width=300>Link</td><td>[X]</td></tr>";
|
||
} else {
|
||
echo "<tr><td><a href=\"$myName"."smod=$id\">$id</a></td>";
|
||
echo "<td><a href=\"$urlLink\" target=\"_blank\">$descLink</a></td>";
|
||
echo "<td><a href=\"$myName"."del=$id\">Borrar</a></td>";
|
||
echo "</tr>";
|
||
}
|
||
$id++;
|
||
}
|
||
echo "</table>";
|
||
fclose( $fp );
|
||
} else
|
||
echo "<p align=center>No he podido abrir el fichero $flinks.txt</p>";
|
||
echo "<br><br><br><hr noshade color=\"#800000\">";
|
||
echo "<p align=center><a href=\"$myName"."sins=new\">Insertar nuevo enlace</a>";
|
||
echo "<hr noshade color=\"#800000\">";
|
||
}
|
||
|
||
//include("fin.htm");
|
||
|
||
|
||
function displayFORM( $dest, $db_descr, $db_url, $db_comment )
|
||
{
|
||
echo "<form name=\"enlaces\" method=\"POST\" action=\"$dest\" onsubmit=\"return validateform( this.form )\">";
|
||
echo '<table border="0">';
|
||
echo '<tr><td width="30%">Enlace:</td>
|
||
<td width="20%"><input type="text" size="20"
|
||
name="db_descr" value="'.$db_descr.'"</td>
|
||
<td valign="top" rowspan="3" width="50%"
|
||
bgcolor="#B4CCE9" class="tdSuave"><strong>Informaci<63>n
|
||
del enlace</strong> <p>Indica un nombre para el
|
||
enlace, la direcci<63>n de este y opcionalmente el
|
||
comentario que debemos mostrar para el mismo.</p>
|
||
<p>El enlace se ver<65> reflejado, en cuanto sea
|
||
aprovado por alguno de nuestros administradores";
|
||
</p>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td width="30%">url:</td>
|
||
<td width="20%"><input type="text" size="20"
|
||
name="db_url" value="'.$db_url.'"></td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="2" width="30%">Comentario: <p><textarea name="db_comment"
|
||
rows="5" cols="40">'.$db_comment.'</textarea></p>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
<p align="center"><input type="submit" name="B1" value="Enviar"></p>
|
||
</form>';
|
||
echo '<script language="JavaScript"><!--
|
||
function validateform()
|
||
{
|
||
|
||
if (document.enlaces.db_descr.value=="")
|
||
{
|
||
window.alert ("Por favor, introduce la descripcion")
|
||
return false;
|
||
}
|
||
if (document.enlaces.db_url.value=="")
|
||
{
|
||
window.alert ("Por favor, introduce la direcci<63>n")
|
||
return false;
|
||
}
|
||
if (document.enlaces.db_comment.value=="" )
|
||
{
|
||
window.alert ("Introduce algun comentario sobre la web")
|
||
return false; \
|
||
} }// --></script>';
|
||
} |