<? require('checkcookie.php');
if(isset($_POST[add]))
{
	$url=$_POST[url];
	$desc=$_POST[description];
	$texto=$_POST[texto];
	mysql_query("INSERT INTO tb_psevdolinks (url,description,texto) values ('$url','$desc','$texto')") or die(mysql_error());
	
	if(isset($_POST[saveid]))
	{
		mysql_query("DELETE FROM tb_psevdolinks WHERE id='$_POST[saveid]'") or die(mysql_error());
		echo "<b><center>Ссылка сохранена</center></b>";
		}else{
		echo "<b><center>Ссылка добавлена</b></center>";
		}
}
if(isset($_POST[edit]))
{
	$ident=intval($_POST[edit]);
	$res=mysql_fetch_assoc(mysql_query("SELECT * FROM tb_psevdolinks WHERE id='$ident'"));
	?>
	<form action='' method='post' id='MainForm'>
	<table class='adn'>
	<tr class='lineb'>
	<td align=center>Поле </td>
	<td align="left"><table class="adn"><tr><td align="left" style="border: none; padding: 0">Описание</td><td align="right" style="border: none; padding: 0"><a href="#" onclick="document.getElementById('MainForm').submit(); return false" class="liv">Сохранить</a></td></tr></table></td>
	</tr>
	<tr class='liney ell'>
	<td align=left><input type='text' name='url' value='<?=$res[url]; ?>'></td>
	<td align=left>URL сайта</td>
	</tr><tr class='liney ell'>
	<td align=left><input type='text' name='description' value='<?=$res[description]; ?>'></td>
	<td align=left>Текст ссылки</td>
	</tr>
	<tr class='liney ell'>
	<td align=left>
	<input type='text' name='texto' value='<?=$res[texto]; ?>'></td>
	<td align=left>Краткое описание</td>
	</tr>
<input type='hidden' name='add' value='Сохранить'><input type='hidden' name='saveid' value='<?=$res[id]; ?>'>
	</table></form><?
	exit;
}
if(isset($_POST[del]))
{
mysql_query("DELETE FROM tb_psevdolinks WHERE id='$_POST[del]'") or die(mysql_error());
echo "<b><center>Ссылка удалена!</b></center>";
}
$sql=mysql_query("SELECT * FROM tb_psevdolinks") or die(mysql_error());

?><table class='adn'>
<tr class='lineb'>
<td align=center>URL & DESC</td>
<td></td><td></td>
</tr>
<?
while($res=mysql_fetch_assoc($sql))
{
	?>
	<tr class='liney ell'>
	<td align=center><a href='<?=$res[url]; ?>' target='_blank'><?=$res[description]?></a><br><small><?=$res[texto]; ?></small>
	</td>
	<td align=center>
	<form action='' method='post'><input type='hidden' name='edit' value='<?=$res[id]; ?>'>
	<input type='submit' value='Редактирвоать'></form></td>
		<td align=center>
	<form action='' method='post'><input type='hidden' name='del' value='<?=$res[id]; ?>'>
	<input type='submit' value='Удалить'></form></td>
	</tr>
	<?
}
?>
</table>
<br><b><center>Добавление ссылки</center></b><br>
<form action='' method='post' id='MainForm'>
	<table class='adn'>
	<tr class='lineb'>
	<td align=center>Поле </td>
<td align="left"><table class="adn"><tr><td align="left" style="border: none; padding: 0">Описание</td><td align="right" style="border: none; padding: 0"><a href="#" onclick="document.getElementById('MainForm').submit(); return false" class="liv">Добавить</a></td></tr></table></td>
	</tr>
	<tr class='liney ell'>
	<td align=left><input type='text' name='url' value=''></td>
	<td align=left>URL сайта</td>
	</tr><tr class='liney ell'>
	<td align=left><input type='text' name='description' value=''></td>
	<td align=left>Текст ссылки</td>
	</tr>
	<tr class='liney ell'>
	<td align=left>
	<input type='text' name='texto' value=''></td>
	<input type='hidden' name='add'>
	<td align=left>Краткое описание</td>
	</tr>
</table></form>
	

	
	