OpenVPN_Management_GUI/Site/login.php

51 lines
1.5 KiB
PHP
Executable File

<?php
// Session starten
session_start();
// Datenbankverbindung aufbauen
include($_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php");
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
die ("Could not connect to database!");
}
$loginname = mysql_real_escape_string($_REQUEST["name"]);
$loginpass = mysql_real_escape_string(md5 ($_REQUEST["pwd"]));
$sql = "SELECT ".
"Id, VPNId, IsAdmin, Nickname, Nachname, Vorname, Email, Avatar, NovLogin, NovPass ".
"FROM ".
"userdata ".
"WHERE ".
"(Nickname = '".$loginname."') AND ".
"(Kennwort = '".$loginpass."')";
//echo $sql;
$result = mysql_query ($sql);
if (mysql_num_rows ($result) > 0)
{
// Benutzerdaten in ein Array auslesen.
$data = mysql_fetch_array ($result);
mysql_close();
// Sessionvariablen erstellen und registrieren
$_SESSION["user_id"] = $data["Id"];
$_SESSION["user_vpnid"] = $data["VPNId"];
$_SESSION["user_admin"] = $data["IsAdmin"];
$_SESSION["user_nickname"] = $data["Nickname"];
$_SESSION["user_nachname"] = $data["Nachname"];
$_SESSION["user_vorname"] = $data["Vorname"];
$_SESSION["user_email"] = $data["Email"];
$_SESSION["user_avatar"] = $data["Avatar"];
$_SESSION["user_novlogin"] = $data["NovLogin"];
$_SESSION["user_novpass"] = $data["NovPass"];
header ("Location: ".$_REQUEST["path"]."&uebergabe=0&uebergabe2=0&uebergabe3=0&uebergabe4=0");
}
else
{
mysql_close();
header ("Location: /index.php?site=lf");
}
?>