<?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 ( $_POST['add_recommend_icon_desktop_id'] )
	{
		$query = $_SGLOBAL['db']->query("SELECT content FROM ".tname('site_desktop')." WHERE desktop_id=".intval($_POST['add_recommend_icon_desktop_id']));
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$list[] = $value;
		}
		$str = explode("|", $list[0]['content']);
		if ( in_array($_POST['add_recommend_icon_links_id'],$str) )
		{
			$msg = 'fail';
			$id = 0;
		}
		else
		{
			$msg = 'success';
			$id = $_POST['add_recommend_icon_desktop_id'];
		}
	}
	else
	{
		switch(intval($_POST['add_custom_icon_bg_color']))
		{
			case 0:
				$color = 'white';
				break;
			case 1:
				$color = 'white';
				break;
			case 2:
				$color = 'green';
				break;
			case 3:
				$color = 'blue';
				break;
			case 4:
				$color = 'red';
				break;
			case 5:
				$color = 'brown';
				break;
			case 6:
				$color = 'orange';
				break;
			case 7:
				$color = 'purple';
				break;
			default:
				$color = 'white';
				break;
		}
		if ( is_numeric($_POST['add_custom_icon_links_image_default']) )
		{
			$icon = '/images/a/icon/def/'.intval($_POST['add_custom_icon_links_image_default']).'.gif';
		}
		else
		{
			$icon = intval($_POST['add_custom_icon_links_image_default']);
		}
		$setarr = array(
			'title' => addslashes($_POST['add_custom_icon_links_label']),
			'url' => addslashes($_POST['add_custom_icon_links_url']),
			'icon' => $icon,
			'color' => $color,
			'titlecolor' => addslashes($_POST['add_custom_icon_text_color']),
			'createtime' => $_SGLOBAL['timestamp']
		);
		if ( isset($_POST['add_custom_icon_links_id']) && intval($_POST['add_custom_icon_links_id']) <= 1 )
		{
			$id = inserttable('site', $setarr, 1);
		}
		else
		{
			$id = intval($_POST['add_custom_icon_links_id']);
			updatetable('site', $setarr, array('id'=>intval($_POST['add_custom_icon_links_id'])));
		}
	}
}
else
{
	header("location: /window/login.php");
}
?>