<?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 = $desktop = array();
$cdtat_start = '****----****';
$cdtat_end = '####----####';
@include_once(S_ROOT.'./source/site_position.php');
if ( !empty($_SGLOBAL['supe_uid']) )
{
	$tmp_id = str_replace('c','',$_POST['icon_id']);
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site')." WHERE id=".intval($tmp_id));
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$list[] = $value;
	}
	if ( $_POST['old_site_id'] )
	{
		$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site_desktop')." WHERE desktop_id=".intval($_POST['desktop_id']));
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$desktop[] = $value;
		}
		$str = explode("|", $desktop[0]['content']);
		$row = 0;
		$col = 0;
		$listkey = 0;
		foreach( $_SITE as $key ){
			foreach( $key as $val ){
				if ( $str[$listkey] == intval($_POST['old_site_id']) ){
					$pos = ($col*90).'_'.($row*90);
				}
				$row++;
				$listkey++;
				if( $row == 10 ){
					$row = 0;
				}
			}
			$col++;
		}
		$style = explode("_", $pos);
		$order = $target_position[$pos];
	}
	else
	{
		$style = explode("_", $_POST['target_position']);
		$order = $target_position[$_POST['target_position']];
	}
}
else
{
	header("location: /window/login.php");
}
?>