View file catalogdeep/adminpanel/rekla.php

File size: 4.3Kb
<?php
include_once "../system/config.php";

$item = isset($_GET['item']) ? (string) $_GET['item'] : 'index';
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;

if(($_SESSION['alogin'] == ALOGIN) AND ($_SESSION['apasswd'] == APASSWORD)){
	$verhall = mysql_num_rows(mysql_query("SELECT * FROM `top_rekla` WHERE `fh` = '0';"));
	$nizall = mysql_num_rows(mysql_query("SELECT * FROM `top_rekla` WHERE `fh` = '1';"));

switch($item)
{
default:

echo "<a href='index.php?mod=rekla&item=verh'>В верху</a>[<font color ='red'>".$verhall."</font>]<br/>
<a href='index.php?mod=rekla&item=niz'>В низу</a>[<font color ='red'>".$nizall."</font>]<br/>
<a href='index.php?mod=rekla&item=add'>Добавить рекламу</a><br/>";
break;

case 'verh':
$sql = mysql_query("SELECT * FROM `top_rekla` WHERE `fh`=0 ORDER BY `position`;");
if(mysql_num_rows($sql) > 0){
	while($rekla = mysql_fetch_assoc($sql)){
		echo "<a href='".$rekla['url']."'>".$rekla['url_name']."</a>";
		echo "[<a href='index.php?mod=rekla&item=del&id=".$rekla['id']."'>X</a>]";
		echo "[<a href='index.php?mod=rekla&item=edit&id=".$rekla['id']."'>edit</a>]<br/>";
		}
	}else{echo "Рекламных ссылок нет<br/>";}
break;

case 'niz':
$sql = mysql_query("SELECT * FROM `top_rekla` WHERE `fh`=1 ORDER BY `position`;");
if(mysql_num_rows($sql) > 0){
	while($rekla = mysql_fetch_assoc($sql)){
		echo "<a href='".$rekla['url']."'>".$rekla['url_name']."</a>";
		echo "[<a href='index.php?mod=rekla&item=del&id=".$rekla['id']."'>X</a>]";
		echo "[<a href='index.php?mod=rekla&item=edit&id=".$rekla['id']."'>edit</a>]<br/>";
		}
	}else{echo "Рекламных ссылок нет<br/>";}
break;
case 'edit':
if(!isset($_POST['go'])){
	$sql = mysql_query("SELECT * FROM `top_rekla` WHERE `id`=".intval(abs($_GET['id'])).";");
	$rekla = mysql_fetch_assoc($sql);
	echo "<form action='index.php?mod=rekla&item=edit' method='post'>
			URL:<br />
			<input type='text' class='input' name='url' maxlength='20' value='".$rekla['url']."' /><br />
			URL_NAME:<br />
			<input type='text' class='input' name='url_name' maxlength='20' value='".$rekla['url_name']."' /><br />
			POSITION:<br />
			<input type='text' class='input' name='position' maxlength='20' value='".$rekla['position']."' /><br />
			<input type='hidden' class='input' name='id' maxlength='20' value='".$rekla['id']."' />
			Где ставим?<br/>
			<select name='fh' class='input'><br/>
			<option value='0'>В верху</option>
			<option value='1'>В низу</option>
			</select><br />
			<input type='submit' class='go' name='go' value='Изменить' />
			</form>";
}else{
	$sql = mysql_query("UPDATE `top_rekla` SET `url` = '".$_POST['url']."', `url_name` = '".$_POST['url_name']."', `position` = '".$_POST['position']."' WHERE `id` = ".intval(abs($_POST['id'])).";");
	if($sql){
		echo "Сохранено<br/><a href='index.php?mod=rekla'>Назад</a>";
		}else{
			echo "ОШИБКА!<br/><a href='index.php?mod=rekla'>Назад</a>";
	}		
}	


break;
case 'del':
$sql = mysql_query("DELETE FROM `top_rekla` WHERE `id` = ".intval(abs($_GET['id'])).";");
if($sql){
	echo "Реклама успешно удалена!<br/><a href='index.php?mod=rekla'>Назад</a>";
		}else{
			echo "ОШИБКА!<br/><a href='index.php?mod=rekla'>Назад</a>";
	}

break;

case 'add':

if(!isset($_POST['go'])){
		echo "<form action='index.php?mod=rekla&item=add' method='post'><br/>
			URL:<br />
			<input type='text' class='input' name='url' maxlength='20' value='http://'/><br />
			URL_NAME:<br />
			<input type='text' class='input' name='url_name' maxlength='20' value='' /><br />
			POSITION:<br />
			<input type='text' class='input' name='position' maxlength='20' value='' /><br />
			Где ставим?<br/>
			<select name='fh' class='input'><br/>
			<option value='0'>В верху</option>
			<option value='1'>В низу</option>
			</select><br />
			<input type='submit' class='go' name='go' value='Добавить' />
			</form>";
}else{
	$sql = mysql_query("INSERT INTO `top_rekla` SET `url` = '".$_POST['url']."', `url_name` = '".$_POST['url_name']."', `position` = '".$_POST['position']."';");
	if($sql){
		echo "Реламная ссылка добавлена<br/><a href='index.php?mod=rekla'>Назад</a>";
		}else{
			echo "ОШИБКА!<br/><a href='index.php?mod=rekla'>Назад</a>";
	}		
}	

}
}else{
echo "0_o";
}


?>