<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: site_icon_add_window_browse.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 = $search = $desktop = $label = array();
$cdtat_start = '****----****';
$cdtat_end = '####----####';
$style = 'style="border: 1px solid #CCC; background: #e5e5e5;"';
if ( $_POST['content'] == 'search' )
{
	if ( isset( $_POST['categories'] ) )
	{
		if ( $_POST['categories'] == '' )
		{
			$categories = 1;
		}
		elseif ( $_POST['categories'] == 1 )
		{
			$categories = 1;
		}
		elseif ( $_POST['categories'] == 2 )
		{
			$categories = 2;
		}
		elseif ( $_POST['categories'] == 3 )
		{
			$categories = 3;
		}
		elseif ( $_POST['categories'] == 4 )
		{
			$categories = 4;
		}
		elseif ( $_POST['categories'] == 5 )
		{
			$categories = 5;
		}
		elseif ( $_POST['categories'] == 6 )
		{
			$categories = 6;
		}
		$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site_categories'));
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$list[] = $value;
		}
		if ( $categories )
		{
			$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site')." WHERE cid=".$categories." and hot=1 and type='".addslashes($_POST['content'])."'");
			while ($value = $_SGLOBAL['db']->fetch_array($query)) {
				$search[] = $value;
			}
		}
		if ( $_POST['desktop_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']);
		}
	}
}
elseif ( $_POST['content'] == 'links' )
{
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site_label'));
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$label[] = $value;
	}
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site')." WHERE hot=1 and type='".addslashes($_POST['content'])."'");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$list[] = $value;
	}
	if ( $_POST['desktop_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']);
	}
}
elseif ( $_POST['content'] == 'radio' )
{
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site_radio'));
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$label[] = $value;
	}
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site')." WHERE hot=1 and type='".addslashes($_POST['content'])."'");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$list[] = $value;
	}
	if ( $_POST['desktop_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']);
	}
}
elseif ( $_POST['content'] == 'widget' )
{
	if ( $_POST['categories'] == '' )
	{
		$categories = 1;
	}
	elseif ( $_POST['categories'] == 1 )
	{
		$categories = 1;
	}
	elseif ( $_POST['categories'] == 2 )
	{
		$categories = 2;
	}
	elseif ( $_POST['categories'] == 3 )
	{
		$categories = 3;
	}
	elseif ( $_POST['categories'] == 4 )
	{
		$categories = 4;
	}
	elseif ( $_POST['categories'] == 5 )
	{
		$categories = 5;
	}
	elseif ( $_POST['categories'] == 6 )
	{
		$categories = 6;
	}
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site_widget'));
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$list[] = $value;
	}
	if ( $categories )
	{
		$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site')." WHERE wid=".$categories." and hot=1 and type='".addslashes($_POST['content'])."'");
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$search[] = $value;
		}
	}
	if ( $_POST['desktop_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']);
	}
}
elseif ( $_POST['content'] == 'feeds' )
{
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site_feeds'));
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$label[] = $value;
	}
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site')." WHERE hot=1 and type='".addslashes($_POST['content'])."'");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$list[] = $value;
	}
	if ( $_POST['desktop_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(",", str_replace('|',',',$desktop['0']['content']));
	}
}
?>