<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: site_desktop_share.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 = $bar = $desktop = $siteid = array();
$cdtat_start = '****----****';
$cdtat_end = '####----####';
$arrow = '$';
$desktopId = 0;
if ( !empty($_SGLOBAL['supe_uid']) )
{
	if ( isset( $_POST['action'] ) && $_POST['action'] == 'create' )
	{
		$md5 = md5($_SGLOBAL['timestamp']);
		$query = $_SGLOBAL['db']->query("SELECT uid FROM ".tname('site_desktop')." WHERE desktop_id=".intval($_POST['desktop_id'])." limit 1");
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$check_user[] = $value;
		}
		if ( $_SGLOBAL['supe_uid'] == $check_user[0]['uid'] )
		{
			$setarr = array(
				'md5' => $md5,
				'pash' => $_SC['site_key'] ,
				'desktop_id' => intval($_POST['desktop_id']),
				'uid' => $_SGLOBAL['supe_uid']
			);
			$aid = inserttable('site_share', $setarr, 1);
		}
//		$setarr = array(
//			'share' => 1
//		);
//		updatetable('site_bar', $setarr, array('desktop_id'=>intval($_POST['desktop_id']),'uid'=>$_SGLOBAL['supe_uid']));
	}
	elseif ( isset( $_POST['action'] ) && $_POST['action'] == 'delete' )
	{
		$_SGLOBAL['db']->query("DELETE FROM ".tname('site_share')." WHERE uid=".$_SGLOBAL['supe_uid']." and desktop_id=".intval($_POST['desktop_id']));
//		$setarr = array(
//			'share' => 0
//		);
//		updatetable('site_bar', $setarr, array('desktop_id'=>intval($_POST['desktop_id']),'uid'=>$_SGLOBAL['supe_uid']));
	}
}
else
{
	header("location: /window/login.php");
	exit;
}
?>