<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: site_desktop_publish.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'] == 'delete' )
	{
		$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site_publish')." WHERE uid=".$_SGLOBAL['supe_uid']." and id=".intval($_POST['desktop_id'])." limit 1");
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$desktop[] = $value;
		}
		$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(
				'uid' => $_SGLOBAL['supe_uid'],
				'desktop_id' => intval($_POST['desktop_id']),
				'category' => intval($_POST['publish_category']),
				'publish_title' => strip_tags(addslashes($_POST['publish_title'])),
				'publish_tags' => strip_tags(addslashes($_POST['publish_tags'])),
				'publish_description' => strip_tags(addslashes($_POST['publish_description'])),
				'publish_disclaimer' => intval($_POST['publish_disclaimer']),
				'createtime' => $_SGLOBAL['timestamp']
			);
			if( $desktop )
			{
				$id = $desktop[0]['id'];
				updatetable('site_publish', $setarr, array('id'=>$id));
			}
			else
			{
				$aid = inserttable('site_publish', $setarr, 1);
				$id = $aid;
			}
			$msg = 'publishSuccesfull';
		}
	}
}
?>