<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: index.php 10954 2009-01-12 05:26:27Z liguode $
*/

include_once('../common.php');

if ( isset( $_SERVER['QUERY_STRING'] ) && $_SERVER['QUERY_STRING'] != '' )
{
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('site_share')." where md5='".addslashes($_SERVER['QUERY_STRING'])."'");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$share[] = $value;
	}
	$query = $_SGLOBAL['db']->query("SELECT share FROM ".tname('site_visitor')." where cookie='".$_SC['site_key']."'");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		$visitor[] = $value;
	}
	$visitor = unserialize($visitor[0]['share']);
	if ( $visitor )
	{
		if ( !in_array( $share[0]['desktop_id'], $visitor ) )
		{
			$str = array_push( $visitor, $share[0]['desktop_id'] );
			$setarr = array(
				'share' => serialize($str)
			);
			updatetable('site_visitor', $setarr, array('cookie'=>$_SC['site_key']));
		}
	}
	else
	{
		$str = array($share[0]['desktop_id']);
		$setarr = array(
			'share' => serialize($str)
		);
		updatetable('site_visitor', $setarr, array('cookie'=>$_SC['site_key']));
	}
	header("location: /index.php");
	exit;
}
?>