<?
	/*
	** File: globals
	** Description: Sets a bunch of global variables
	** Version: 1.0
	** Created: 11/09/98
	** Author: Leon Atkinson
	** Email: leon@clearink.com
	** 
	** Copyright 1998,99 Clear Ink Corporation
	*/

	define("FREEASSOC_VERSION", "1.0-development");

	/*
	** Database variables
	*/
	$DatabaseMachine = "localhost";
	$DatabaseUser = "httpd";
	$DatabasePasswd = "";
	$Database = "fa";

	$Location_Script = "location.php";
	
	// set path of icons for pathways, relative to the index document
	$Icon_URL = "images/icons/"; 

	if($pathway <= 0)
	{
		$pathway = 1;
	}
	
	/*
	** Pathway constants
	*/
	
	//Set the maximum number of columns for the pathway Layout (must be at least 1)
	define("MAX_PATHWAY_COLS", 4);
	
	//Set the width between columns in multi-column layout (in pixels, width of clear.gif)
	define("PATHWAY_GUTTER", 10);
	
	
	/*
	** Vote constants
	*/
	
	//Set the maximum number of options in a vote
	define("MAX_VOTE_OPTIONS", 10);
	
	/*
	** Story constants
	*/
	
	//Set the tags that can be included in a story by the user 
	//(when a story is added)
	define("OK_STORY_TAGS", "<BR>,<P>,<I>,<B>");
	
	
	/*
	** Email consstants
	*/
	
	//Set the email address for comment submission
	define("COMMENT_EMAIL_ADDRESS", "root@localhost");
	
	
	/*
	** Discussion (threaded and bulletin board) constants
	*/
	
	// Set this to TRUE if you want users to be able to post to existing discussion
	// nodes without logging in.
	define("MESSAGES_ENABLE_PUBLIC", TRUE);
	
	// Set this to TRUE if you want logged-in users to be able to post anonymous
	// messages to existing discussion nodes.
	define("MESSAGES_ENABLE_ANONYMOUS", TRUE);
	
	// Set this to TRUE if you want users' email addresses to be shown on messages.
	define("MESSAGES_SHOW_EMAIL", TRUE);
	
	
	/*
	** File upload constants
	*/
	
	// Set the maximum file size to accept
	define("MAX_FILE_SIZE_CONSTANT", "409600");
	
	// Set the directory for file storage
	define("FILE_PATH", "uploads/");
	
	
	/*
	** Cookie constants
	*/
	
	//Set this to TRUE if you want to use cookies for session IDs
	//Users without cookies will still get $sid from a form variable 
	define("USE_COOKIES", TRUE);

	//the following constants have no meaning if cookies aren't used
	if(USE_COOKIES)
	{
		//Set this to TRUE if you want to use cookies to implement autologin.
		//Turning this on exposes your users to some security risk because
		//their password must be saved in the cookie file and then sent between
		//the browser and the server for every page load.  This allows a sniffer
		//to a greater chance at grabbing the password.  Even though the password
		//is encoded with MD5(), it's still enough by itself to allow a login
		//from anyone who has it.  Since this is such a security risk, this
		//feature is left off by default.
		define("USE_AUTOLOGIN", FALSE);
	
		if(USE_AUTOLOGIN)
		{
			//This constant controls the lifetime of a cookie used to store
			//the login and password of a user.  When the user returns to
			//the site, the cookie will allow them to be logged in automatically.
			define("AUTOLOGIN_LIFETIME", 60*60*24*365);
		}

		//Automatically check if user supports cookies
		//If we got $sid as a cookie, then the user is
		//obviously using cookies.
		if(isset($HTTP_COOKIE_VARS['sid']))
		{
			define("COOKIE_FOUND", TRUE);
		}
		else
		{
			define("COOKIE_FOUND", FALSE);
		}

	}
	
	
	/*
	** Generate browser information
	*/
	
	$Browser_Name = strtok($HTTP_USER_AGENT, "/");
	$Browser_Version = strtok(" ");
	
	if(ereg("MSIE", $HTTP_USER_AGENT))
	{
		$Browser_Name = "MSIE";
		
		$Browser_Version = strtok("MSIE"); /*get junk*/
		$Browser_Version = strtok(" ");
		$Browser_Version = strtok(";");
	}

	$Browser_Platform = "unknown";
	if(ereg("Windows",$HTTP_USER_AGENT) || 
		ereg("WinNT",$HTTP_USER_AGENT) ||
		ereg("Win98",$HTTP_USER_AGENT) ||
		ereg("Win95",$HTTP_USER_AGENT))
	{
		$Browser_Platform = "Windows";
	}
	if(ereg("Mac", $HTTP_USER_AGENT))
	{
		$Browser_Platform = "Macintosh";
	}

	$Browser_JavaScriptOK = FALSE;
	$Browser_FileUpload = FALSE;
	$Browser_CSSOK = FALSE;

	if($Browser_Platform == "Windows")
	{
		if($Browser_Name == "Mozilla")
		{
			if($Browser_Version >= 3.0)
			{
				$Browser_JavaScriptOK = TRUE;
				$Browser_FileUpload = TRUE;
			}		
			if($Browser_Version >= 4.0)
			{
				$Browser_CSSOK = TRUE;
			}
		}
		else /* must be MSIE */
		{
			if($Browser_Version >= 4.0)
			{
				$Browser_JavaScriptOK = TRUE;
				$Browser_FileUpload = TRUE;
				$Browser_CSSOK = TRUE;
			}		
		}
	}
	elseif($Browser_Platform == "Macintosh")
	{
		if($Browser_Name == "Mozilla")
		{
			if($Browser_Version >= 3.0)
			{
				$Browser_JavaScriptOK = TRUE;
				$Browser_FileUpload = TRUE;
			}		
			if($Browser_Version >= 4.0)
			{
				$Browser_CSSOK = TRUE;
			}
		}
		else /* must be MSIE */
		{
			if($Browser_Version >= 4.0)
			{
				$Browser_JavaScriptOK = TRUE;
				$Browser_CSSOK = TRUE;
				$Browser_FileUpload = TRUE;
			}		
		}
	}
	else
	{
		$Browser_TextOnly = TRUE;
	}

	
	function ScreenURL($screen, $secure=FALSE)
	{
		//SERVER_NAME and SCRIPT_NAME are defined by the PHP engine
		global $SERVER_NAME, $SCRIPT_NAME, $sid;
		
		if(USE_SSL AND $secure)
		{
			$URL = "https://";
		}
		else
		{
			$URL = "http://";
		}
		
		$URL .= $SERVER_NAME . $SCRIPT_NAME . "?SCREEN=$screen";
		if(!COOKIE_FOUND)
		{
			$URL .= "&amp;sid=$sid";
		}
		
		return($URL);
	}

	function GetUserInfo($userID)
	{
		global $DatabaseLink;
		$Query = "SELECT FirstName, LastName, Email FROM user WHERE ID = $userID";
		$DatabaseResult = mysql_query($Query, $DatabaseLink);
		$DatabaseRow = mysql_fetch_row($DatabaseResult);

		$ReturnValue["ID"] = $userID;
		$ReturnValue["FirstName"] = $DatabaseRow[0];
		$ReturnValue["LastName"] = $DatabaseRow[1];
		$ReturnValue["Email"] = $DatabaseRow[2];
		
		//get permissions
		$Query = "SELECT p.Name ";
		$Query .= "FROM user_permission up, permission p ";
		$Query .= "WHERE up.User=$userID ";
		$Query .= "AND up.Permission = p.ID ";
		$DatabaseResult = mysql_query($Query, $DatabaseLink);
		while($DatabaseRow = mysql_fetch_row($DatabaseResult))
		{
			$ReturnValue[($DatabaseRow[0])] = TRUE;
		}		
				
		return($ReturnValue);

	}

?>
