Location: PHPKode > projects > Aratix > inc/session.inc.php
<?php
/*
** Aratix
** Version 0.1.0beta8 (Anubis)
**
** Autor: Manuel Burghammer
** E-Mail: hide@address.com
** Homepage: http://www.xitara.net
**
** File: session.inc.php - Version 0.1.0 build
** Position: /inc/
** Last Modified: 02.01.2006 - 20:37:59
*/

function login($db, $config){
	$session = generate_session($config, get('login'));

// 	$user_data = $db->read(TB_USER, "groups, id", "login='" . get('login') . "' AND password=MD5('" . get('passwd') . "')");
	if(!($user_data = $db->read(TB_USER, "groups, id", "login='" . get('login') . "' AND password=MD5('" . get('passwd') . "')")))
		return FALSE;

// 	echo "User_Data: " . $user_data . "<br />";

	$db->delete(TB_SESSION, "user='" . get('login') . "'");
	$db->write(TB_SESSION, "session;;user;;user_md5;;groups;;user_id;;timestamp", $session . ";;" . get('login') . ";;" . MD5(get('login')) . ";;" . $user_data['groups'] . ";;" . $user_data['id'] . ";;CURRENT_TIMESTAMP()+0");

	return $session;
}

function update_session($db, $session, $ident){
	if(!($status = $db->read(TB_SESSION, "groups", "session='" . $session . "' AND user_md5='" . $ident . "'")))
		return FALSE;
	else
		return $status[0];
}

function logout($db, $session, $ident){
	$db->delete(TB_SESSION, "session='" . $session . "' AND user_md5='" . $ident . "'");
}

/********** Session erzeugen **********/
function generate_session($config, $user_name){
	srand(time());
	$user = ereg_replace(" ", "", $user_name);
	$signs = $user_name . "1234567890";
	$session = "";

	while (strlen($session) < $config->get('session_length'))
		$session .= substr($signs, (rand() % (strlen($signs))), 1);

	$session = ereg_replace(" ", "X", $session);

	return $session;
}

?>
Return current item: Aratix