<?php
/***
* Prüfen, ob der User berechtigt ist, einen Login durchzuführen.
*/
function CheckUserLogin ($un, $pw, $session) {
$result = mysql_query("SELECT UserId,Name,Vorname,UserName,UserPasswd FROM AdminUser
WHERE UserName='$un' AND UserPasswd=MD5('$pw')") or mysql_error();
$zeile = mysql_fetch_array($result);
if ( $zeile['UserId'] == "" )
{
header ("Location: index.php");
}
else
{
$result = mysql_query("UPDATE AdminUser SET UserSession = '".$session."',UserLogin = NOW()
WHERE UserId = '".$zeile['UserId']."'") or mysql_error();
header ("Location: admin.php");
}
}
/***
* LOGOUT
*/
function UserLogout ($session) {
$result = mysql_query("UPDATE AdminUser SET UserSession = NULL
WHERE UserSession = '".$session."'") or mysql_error();
header ("Location: index.php");
}
/***
* Prüfen, ob die Session in Ordnung ist.
*/
function CheckUserSession ($session) {
$result = mysql_query("SELECT UserId,Name,Vorname,UserName,UserLogin FROM AdminUser
WHERE UserSession = '".$session."'") or mysql_error();
if ( mysql_num_rows($result) == 1 ) {
$zeile = mysql_fetch_array($result);
$sessarr[UserId] = $zeile['UserId'];
$sessarr[Name] = $zeile['Name'];
$sessarr[Vorname] = $zeile['Vorname'];
$sessarr[UserPaket] = $zeile['UserPaket'];
$sessarr[UserLogin] = $zeile['UserLogin'];
return $sessarr;
}
else {
header ("Location: index.php");
return false;
}
}
?>