<?
if (!defined('webid')) {
    exit();
}

if ($user_status != 'admin') {
    exit();
}
if(isset($_POST['del'])) {
	mysql_query("DELETE FROM seo_blacklist WHERE id='$_POST[del]'");
}
if(isset($_POST['add'])) {
	$reason=$_POST['add'];
	$site=$_POST['urlsite'];
	function getHost($Address) {
   $parseUrl = parse_url(trim($Address));
   return trim($parseUrl['host'] ? $parseUrl['host'] : array_shift(explode('/', $parseUrl['path'], 2)));
}
$site=getHost($site);
$site=str_ireplace("www.","",$site);
mysql_query("INSERT INTO seo_blacklist (site,reason) values ('$site','$reason')") or die(mysql_error());
}
$sql=mysql_query("SELECT * FROM seo_blacklist");
?>
<table width="60%" border="0" cellpadding="0" cellspacing="1" class="tab">
<tr>
<td style="background: #ebebeb; padding: 5px;" width="40%">URL</td>
<td style="background: #ebebeb; padding: 5px;" width="50%">Причина</td>
<td style="background: #ebebeb; padding: 5px;" width="100">Действие</td>
</tr>
<?
while($row=mysql_fetch_array($sql)) {
	?><tr>
	<td align="left" class="lt"><a href='http://<?=$row['site']; ?>/' target='_blank'><?=$row['site']; ?></a>
	</td>
	<td align="left" class="rt"><?=$row['reason']; ?></td>
	<td align="center" class="lt"><form action='' method='post'><input type='hidden' name='del' value='<?=$row['id']; ?>'>
	<input type='submit' value='Удалить' id="save" />
	</form></td></tr><?
}
?></table><br />
<form method="post" action="" id="MainForm">
<table width="60%" border="0" cellpadding="0" cellspacing="1" class="tab">
<tr>
<td align="left" width="200" style="background: #ebebeb; padding-left: 5px;"><strong>Значение</strong></td>
<td align="left" style="background: #ebebeb;"><table width="100%"><tr><td align="left" style="background: #ebebeb; padding-left: 5px;"><strong>Описание</strong></td><td align="center" width="100px" style="background: #ebebeb; padding-left: 5px;"><input type="submit" id="save" value="Добавить" /></td></tr></table></td>
</tr>
<tr>
 <td class="lt"><input type="text" value='' name='urlsite' style="width: 99%;" /></td>
 <td class="rt"><b>URL сайта</b></td>
</tr>
<tr>
 <td class="lt"><input type="text" value='' name='add' style="width: 99%;" /></td>
 <td class="rt"><b>Причина</b><br>Причина блокировки</td>
</tr></table></form>