<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: site_add_icon.php 10953 2009-01-12 02:55:37Z liguode $
*/

if(!defined('IN_UCHOME')) {
	exit('Access Denied');
}
@include_once(S_ROOT.'./data/site_config.php');
$list = $label = array();
$cdtat_start = '****----****';
$cdtat_end = '####----####';
if ( !empty($_SGLOBAL['supe_uid']) )
{
	if ( empty($_POST['icon_id']) )
	{
		if ( $_POST['content_type'] == 'links' )
		{
			$type = 'links';
		}
		elseif ( $_POST['content_type'] == 'search' )
		{
			$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site')." WHERE hot=1");
			while ($value = $_SGLOBAL['db']->fetch_array($query)) {
				$list[] = $value;
			}
			$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site_label'));
			while ($value = $_SGLOBAL['db']->fetch_array($query)) {
				$label[] = $value;
			}
			$type = 'search';
		}
		$color = 0;
		$id = 0;
	}
	else
	{
		$type = 'links';
		$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site')." WHERE id=".intval($_POST['icon_id']));
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$list[] = $value;
		}
		$id = intval($_POST['icon_id']);
		if ( $list[0]['hot'] == 1 )
		{
			$id = 1;
		}
		else
		{
			$id = intval($_POST['icon_id']);
		}
		switch($list[0]['color'])
		{
			case 'white':
				$color = 0;
				break;
			case 'green':
				$color = 2;
				break;
			case 'blue':
				$color = 3;
				break;
			case 'red':
				$color = 4;
				break;
			case 'brown':
				$color = 5;
				break;
			case 'orange':
				$color = 6;
				break;
			case 'purple':
				$color = 7;
				break;
			default:
				$color = 0;
				break;
		}
	}
}
else
{
	header("location: /window/login.php");
}
?>