Location: PHPKode > projects > Phparchive > phparchive.0.1.86.beta/includes/initenv.inc.php
<?php
/**
 *
 * @version @version $Id: initenv.inc.php,v 1.5 2003/12/27 12:09:14 freedev Exp $
 * @author Vincenzo D'Amore <hide@address.com>
 * @package wa_includes
 */

/**
 *
 */

function WAInitialize()
{
//	ini_set("session.use_cookies", "0");
	WAStartSession(true);
/*	
	session_register("gsUser_Name");
	session_register("gsUser_Surname");
	session_register("gsUser_GroupName");

	session_register("giIdUser");
	session_register("giIdGroup");
	session_register("giAdmin");
	session_register("gbLoggedIn");
	session_register("giIdMenu");
	session_register("giIdContext");
	session_register("gaMenuStatus");
	session_register("gIdForm");
	session_register("gIdCurrentForm");

	session_register("gaMenuConfiguration");
	session_register("gaForms");
	session_register("gsOldAction");
	session_register("gsStyleName");
*/
	
	$_SESSION["gIdForm"] = "";
	$_SESSION["gIdCurrentForm"] = "";
	$_SESSION["gsOldAction"] = "";
	$_SESSION["gaMenuConfiguration"] = array();
	$_SESSION["gaForms"] = array();
	$_SESSION["giIdMenu"] = 0;
	$_SESSION["giIdContext"] = 0;
	$_SESSION["gaMenuStatus"] = array();
	$_SESSION["gaMenuStatus"][] = 1;
	$_SESSION["gaMenuStatus"][] = 0;
	$_SESSION["gsStyleName"] = WA_CURRENT_CSS_FILE;
	
//	$_SESSION["gsUserFingerprint"] = md5($_SERVER['HTTP_USER_AGENT'].$_SERVER['HTTP_ACCEPT'].$_SERVER['HTTP_ACCEPT_ENCODING']);	
	
}

/**
 *
 */

function Login($User, $Pass)
{
	$bRC = False;
	$rec = new WARecordset();
//	$rec->WAOpenConnection($GLOBALS['WA_CONF_DBHOST'], $GLOBALS['WA_CONF_DBNAME'], $GLOBALS['WA_CONF_DBUSER'], $GLOBALS['WA_CONF_DBPASS'], GetDBTypeId($GLOBALS['WA_CONF_DBTYPE']));
	$rec->SetupFromGlobalCnn() or die(WA_MSG_ERROR_OPEN_DATABASE);

	$query = "SELECT * FROM tbusers, tbgroups WHERE tbusers.WAIdGroup = tbgroups.WAIdGroup AND ";
	$query .= "tbusers.WAUser = '" . $User . "' AND ";
	$query .= "tbusers.WAPassword = '".md5($Pass)."'";

	$rec->WAOpenRecordset($query);

	if ($rec->WAFetchRow())
	{
		WAInitialize();
		
		$_SESSION["gsUser_Name"] = $rec->WAResult("WAName");
		$_SESSION["gsUser_Surname"] = $rec->WAResult("WASurname");
		$_SESSION["gsUser_GroupName"] = $rec->WAResult("WAGroupName");
		$_SESSION["giIdUser"] = $rec->WAResult("WAIdUser");
		$_SESSION["giIdGroup"] = $rec->WAResult("WAIdGroup");
		$_SESSION["giAdmin"] = $rec->WAResult("WAAdmin");
		$_SESSION["gsOtherGroups"] = "";
		
		if (($_SESSION["giIdUser"] > 0) && ($_SESSION["giIdGroup"] > 0))
		{
			$_SESSION["gbLoggedIn"] = True;
			$bRC = True;
		}
		$rec2 = new WARecordset();
		$rec2->SetupFromGlobalCnn() or die(WA_MSG_ERROR_OPEN_DATABASE);
		$query = "SELECT WAIdGroup FROM tbusersgroups WHERE WAIdUser = ".$_SESSION["giIdUser"];

		$rec2->WAOpenRecordset($query);
		if ($rec2->WAFetchRow())
		{
			do 
			{
				if (!empty($_SESSION["gsOtherGroups"]))
					$_SESSION["gsOtherGroups"] .= ",";
				$_SESSION["gsOtherGroups"] .= $rec2->WAResult("WAIdGroup");
			} while ($rec2->WAFetchRow());
		}
		$rec2->WACloseRecordset();
	}
	$rec->WACloseRecordset();
	return $bRC;	
}

?>
Return current item: Phparchive