<?php
include '../inc/functions.inc.php';
$datafile = '../inc/pn_userdata.php';
if (!file_exists($datafile)) fclose(fopen($datafile,"w+"));
$zeile = file($datafile);
$zeilen = sizeof($zeile);
if(!$_GET['go'])
{
echo '
<html><head> <link type="text/css" rel="stylesheet" href="style/site.css" />
<title></title>
</head>
<body>
<div>
<form method="POST" action="'.$_SERVER['PHP_SELF'].'?go=login">
<table cellpadding="0" cellspacing="1" border="0" class="rahmen">
<div >Um diesen Bereich zu betreten, musst Du Dich einloggen!</div> <br/>
<tr class="tr1">
<td width="100">Loginname</td>
<td width="300"><input type="text" name="Name" size="30" maxlength="150"></td>
</tr>
<tr class="tr1">
<td width="110"> Passwort</td>
<td width="300">
<input type="password" name="pw" size="30" maxlength="150">
</td>
</tr>
<tr class="tr1">
<td width="100"></td>
<td width="300">
<input type="submit" value="Einloggen" name="submit">
</td>
</tr>
</table>
</form>
</html>';
}
if($_GET['go'] == 'login')
{
@session_start();
if (empty($_POST['Name']) OR empty($_POST['pw'])) {
exit('<link type="text/css" rel="stylesheet" href="style/site.css" /><a>Komm schon, Name und Passwort - so schwer ist das nicht!? ...versuchs einfach nochmal =)</a> <meta http-equiv="refresh" content="4; URL=pn_login.php">');
}
$_POST['pw'] = crypt($_POST['pw'], 'lala');
for ($i=2; $i<$zeilen-2; $i++) {
$eintrag = explode('§', $zeile[$i]);
if ($eintrag[0] == $_POST['Name']) {
$_SESSION['loginuser'] = $eintrag[0];
$_SESSION['loginlevel'] = $eintrag[1];
$_SESSION['loginpwd'] = $eintrag[2];
$_SESSION['loginid'] = $eintrag[3];
}
}
if($_SESSION['loginpwd'] != $_POST['pw']) {
echo '<link type="text/css" rel="stylesheet" href="style/site.css" /><a>Falsches Passwort!</a>'.$goback;
session_destroy();
exit;
}
header("Location: test.php?$session");
}
?>