View file foot_set.php

File size: 6.36Kb
<?
include_once 'sys/inc/start.php';
include_once 'sys/inc/compress.php';
include_once 'sys/inc/sess.php';
include_once 'sys/inc/home.php';
include_once 'sys/inc/settings.php';
include_once 'sys/inc/db_connect.php';
include_once 'sys/inc/ipua.php';
include_once 'sys/inc/fnc.php';
include_once 'sys/inc/user.php';

only_reg();
$set['title']='Настройка навигации';
include_once 'sys/inc/thead.php';
title();
err();
aut();

if ((!isset($_SESSION['refer']) || $_SESSION['refer']==NULL)
&& isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']!=NULL &&
!preg_match('#foot_set.php#',$_SERVER['HTTP_REFERER']))
$_SESSION['refer']=str_replace('&','&amp;',preg_replace('#^http://[^/]*/#','/', $_SERVER['HTTP_REFERER']));


function my_int($var){$var = abs((int)$var);return $var;} //функция фильтра цифр

$do = (isset($_GET['do'])) ? $_GET['do'] : NULL;
switch($do) {
default:

		/* УПРАВЛЕНИЕ ССЫЛКАМИ */

			// удаление ссылки
	if (isset($_GET['x'])) {
		$x = my_int($_GET['x']);
		$EmptyLink = mysql_query("SELECT `id` FROM `foot_links` WHERE `user` = '$user[id]' AND `id` = '$x' LIMIT 1");
	if (mysql_num_rows($EmptyLink) != FALSE) {
			mysql_query("DELETE FROM `foot_links` WHERE `user` = '$user[id]' AND `id` = '$x' LIMIT 1");
			header('Location: foot_set.php?');
		} else {
			header('Location: foot_set.php?');
		}
	}

	// Предвижение ссылки вверх
	if (isset($_GET['up'])) {
		$up = my_int($_GET['up']);
		$SqlMyLink = mysql_query("SELECT `id`, `sort` FROM `foot_links` WHERE `id` = '$up' AND `user` = '$user[id]' LIMIT 1");
		$IsSqlMyLink2 = mysql_fetch_array($SqlMyLink);
		if (mysql_num_rows($SqlMyLink) == FALSE) {
			header('Location: foot_set.php?');
		} else {
			$InSqlMyLink = mysql_query("SELECT `id`, `sort` FROM `foot_links` WHERE `sort` = '" . ($IsSqlMyLink2[1] - 1) . "' AND `user` = '$user[id]' LIMIT 1");
		if (mysql_num_rows($InSqlMyLink) == FALSE) {
			header('Location: foot_set.php?');
		} else {
			$IsSqlMyLink1 = mysql_fetch_array($InSqlMyLink);
			mysql_query("UPDATE `foot_links` SET `sort` = '$IsSqlMyLink1[1]' WHERE `id` = '$up' AND `user` = '$user[id]' LIMIT 1");
			mysql_query("UPDATE `foot_links` SET `sort` = '$IsSqlMyLink2[1]' WHERE `id` = '$IsSqlMyLink1[0]' AND `user` = '$user[id]' LIMIT 1");
			header('Location: foot_set.php?');
		}
		}
	}

	// Передвижение ссылки вниз
	if (isset($_GET['down'])) {
		$down = my_int($_GET['down']);
		$SqlMyLink = mysql_query("SELECT `id`, `sort` FROM `foot_links` WHERE `id` = '$down' AND `user` = '$user[id]' LIMIT 1");
		$IsSqlMyLink2 = mysql_fetch_array($SqlMyLink);
		if (mysql_num_rows($SqlMyLink) == FALSE) {
			header('Location: foot_set.php?');
		} else {
			$InSqlMyLink = mysql_query("SELECT `id`, `sort` FROM `foot_links` WHERE `sort` = '" . ($IsSqlMyLink2[1] + 1) . "' AND `user` = '$user[id]' LIMIT 1");
		if (mysql_num_rows($InSqlMyLink) == FALSE) {
			header('Location: foot_set.php?');
		} else {
			$IsSqlMyLink1 = mysql_fetch_array($InSqlMyLink);
			mysql_query("UPDATE `foot_links` SET `sort` = '$IsSqlMyLink1[1]' WHERE `id` = '$down' AND `user` = '$user[id]' LIMIT 1");
			mysql_query("UPDATE `foot_links` SET `sort` = '$IsSqlMyLink2[1]' WHERE `id` = '$IsSqlMyLink1[0]' AND `user` = '$user[id]' LIMIT 1");
			header('Location: foot_set.php?');
		}
		}
	}

	echo '<a href="foot_set.php?do=link"><img src="/style/nav/lj.gif" alt="+"/> Добавить ссылку</a>';

	// вывод моих ссылок
	$FootLinks = mysql_query("SELECT * FROM `foot_links` WHERE `user` = '$user[id]' ORDER BY `sort` ASC");
	while($FootLink = mysql_fetch_assoc($FootLinks)) {
		$down = '<a href="foot_set.php?down='.$FootLink['id'].'"><img src="/style/nav/down.gif" alt="D"/></a> ';
		$up = '<a href="foot_set.php?up='.$FootLink['id'].'"><img src="/style/nav/up.gif" alt="U"/></a> ';

		echo '<div class="main_menu">' . $down . $up . $FootLink['name'] . ' <a style="float:right" href="foot_set.php?x='.$FootLink['id'].'"><img src="/style/nav/del.gif" alt="X"/></a></div>';
	}

break;

case 'link':

		/* ДОБАВЛЕНИЕ ССЫЛКИ */

	if (isset($_GET['a'])) {
		$a = my_int($_GET['a']);

		$MyLink = mysql_query("SELECT * FROM `foot_links` WHERE `user` = '$user[id]' AND `uid` = '$a' LIMIT 1");

		if ($a < 1 || $a > 11) {
			header('Location: foot_set.php?do=link');
			die();
		}

		if ($a == 1) {
			$SetLink = '/index.php?';
			$SetName = 'Гл';
		}
		if ($a == 2) {
			$SetLink = '/user/bookmark/index.php?id=' . $user['id'];
			$SetName = 'Закл';
		}
		if ($a == 3) {
			$SetLink = '/info.php?id=' . $user['id'];
			$SetName = 'Я';
		}
		if ($a == 4) {
			$SetLink = '/mail.php?';
			$SetName = 'Поч';
		}
		if ($a == 5) {
			$SetLink = '/user/frends/?id=' . $user['id'];
			$SetName = 'Др';
		}
		if ($a == 6) {
$SetLink = '/love/index.php?';
			$SetName = 'Знак';
		}
		if ($a == 7) {
			$SetLink = '/chat/index.php?';
			$SetName = 'Чат';
		}
		if ($a == 8) {
			$SetLink = '/forum/index.php?';
			$SetName = 'Фор';
		}

		if ($a == 9) {
			$SetLink = '/obmen/index.php?';
			$SetName = 'ЗО';
		}

		if ($a == 10) {
			$SetLink = '/plugins/rules/index.php?';
			$SetName = 'Пом';
		}
		if ($a == 11) {
			$SetLink = '/exit.php?';
			$SetName = 'Вых';
		}

		if (mysql_num_rows($MyLink) == FALSE) {
			$lst = mysql_fetch_array(mysql_query("SELECT `sort` FROM `foot_links` ORDER BY `sort` DESC LIMIT 1"));
			$Rnd = mt_rand(10000, 9999999);
			mysql_query("INSERT INTO `foot_links` SET `id` = '$Rnd', `user` = '$user[id]', `link` = '$SetLink', `name` = '$SetName', `uid` = '$a', `sort` = '" . ($lst[0] + 1) . "'");
			header('Location: foot_set.php?');
		} else {
			header('Location: foot_set.php?');
		}
	}

	$FootFile = file('foot_str.dat');
	$FootStr = file_get_contents('foot_str.dat');
	$FootEx = explode('|', $FootStr);


	for($strs = 0, $FootFile = count($FootFile); $strs < $FootFile; ++$strs)
	{
		$Sql = mysql_fetch_assoc(mysql_query("SELECT `uid` FROM `foot_links` WHERE `user` = '$user[id]' AND `uid` = '" . ($strs + 1) . "'"));
		if ($Sql['uid'] != $strs + 1) {

			echo '<div class="main_menu">' . $FootEx[$strs] . '</div>';

		}
	}

echo '<div class="main_menu"><a href="/foot_set.php">&laquo; Назад</a></div>';
break;


}

include_once 'sys/inc/tfoot.php';
?>