<?php
	/***********************************************************\
	* Edit the values in the following array to configure       *
	* the site generator.                                       *
	\***********************************************************/
	$sitemgr_info = array(
		// add trailing slash
		'phpgw_path'           => '/var/www/html/phpgroupware/',
		'htaccess_404'         => 'disabled'
	);

	/***********************************************************\
	* Leave the rest of this file alone.                        *
	\***********************************************************/
	if (!file_exists($sitemgr_info['phpgw_path'].'header.inc.php'))
	{
		die("Header file not found.  Either your path to phpGroupWare in the config.inc.php file is bad, or you have not setup phpGroupWare.");
	}

	if (
		($GLOBALS['phpgw_info']['flags']['currentapp'] != 'sitemgr-link') 
		&& 
		($GLOBALS['phpgw_info']['flags']['currentapp'] != 'sitemgr')
	   )
	{
		include($sitemgr_info['phpgw_path'] . 'header.inc.php');

		$GLOBALS['phpgw_info']['flags']['currentapp'] = 'login';
		include(PHPGW_SERVER_ROOT . '/phpgwapi/inc/functions.inc.php');
		$GLOBALS['phpgw_info']['flags']['currentapp'] = 'sitemgr-site';

		$pref = CreateObject('sitemgr.sitePreference_SO');
		$sitemgr_info = array(
			'phpgw_path'           => $sitemgr_info['phpgw_path'],
			'htaccess_404'         => $sitemgr_info['htaccess_404'],
			'usethemes'            => (int) $pref->getPreference('interface'),
			'sitemgr-site_path'    => $pref->getPreference('sitemgr-site-dir'),
			'sitemgr-site_url'     => $pref->getPreference('sitemgr-site-url'),
			'domain'               => $pref->getPreference('login-domain'),
			'login' 		       => $pref->getPreference('anonymous-user'),
			'passwd'		       => $pref->getPreference('anonymous-passwd'),
			'themesel'	     	   => $pref->getPreference('themesel'),
			'sitelanguages'            => explode(',',$pref->getPreference('sitelanguages'))             
		);

		if (! $GLOBALS['phpgw']->session->verify())
		{
			$GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($sitemgr_info['login'],$sitemgr_info['passwd'], 'text');
			if (!$GLOBALS['sessionid'])
			{
				die(lang('NO ANONYMOUS USER ACCOUNTS INSTALLED.  NOTIFY THE ADMINISTRATOR.'));
				//exit;
			}
			//$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link($sitemgr_url . 'index.php'));
		}
	}
	else
	{
		$pref = CreateObject('sitemgr.sitePreference_SO');
		$sitemgr_info = array(
			'phpgw_path'           => $sitemgr_info['phpgw_path'],
			'interface'            => $sitemgr_info['interface'],
			'sitemgr-site_path'    => $pref->getPreference('sitemgr-site-dir'),
			'sitemgr-site_url'     => $pref->getPreference('sitemgr-site-url'),
			'domain'               => $pref->getPreference('login-domain'),
			'login' 		       => $pref->getPreference('anonymous-user'),
			'passwd'		       => $pref->getPreference('anonymous-passwd'),
			'themesel'	     	   => $pref->getPreference('themesel'),
			'sitelanguages'            => explode(',',$pref->getPreference('sitelanguages'))
		);
	}
	unset($pref);
?>
