<?php
include("kurs/datenbankanbindung.php");     // f&uuml;gt die Datenbankanbindung ein: Sys:\php\includes\kurs\datenbankanbindung.php

if ($_COOKIE["uid1"] == ""){ include("kurs/anmeldefehler.php"); exit;} //Wenn man nicht angemeldet ist soll man nichts ausw&auml;hlen k&ouml;nnen
$uid1=$_COOKIE["uid1"];

if (isset($_GET['action']))
   $action = $_GET['action'];
else
   $action = "";

switch($action){
default:

$db = dbconnect();
include("kurs/pros/pros_useronline_write.php");     // F&uuml;r Statistik, wieviele User online sind

$result = $db->query("SELECT nachname, vorname, ag, Jahrgang FROM stud where uid=\"$uid1\"");
$row = $result->fetch_array();

echo "
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"styles_pc.css\" type=\"text/css\">
<title>Daten vervollst&auml;ndigen</title>
</head>
<body onload=\"if(document.pers_daten)document.pers_daten.pw_alt.focus();return false;\">
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"images/box_e1.gif\">
                    <img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"images/box_top.gif\" valign=\"top\">
                    <img height=\"10\" src=\"images/blank.gif\" width=\"1\"><br>
                    <font class=\"hd\">Kennwort &auml;ndern</font><br>
                    <img height=\"5\" src=\"images/blank.gif\" width=\"1\"></font></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e2.gif\">
                    <img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"images/box_l.gif\">
                    <img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td>
                    <form action="; echo $_SERVER['PHP_SELF'] . "?action=wechsel"; echo" method=\"POST\" name=\"pers_daten\">
                        <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-width:0; border-collapse: collapse\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" height=\"142\">
                            <tr>
                                <td style=\"border-style: none; border-width: medium\" height=\"25\">
                                <b>Name:</b> </td>
                                <td align=\"left\" style=\"border-style: none; border-width: medium\" height=\"25\">
                                <p>$row[vorname] $row[nachname]</p>
                                </td>
                            </tr>
                            <tr>
                                <td style=\"border-style: none; border-width: medium\" height=\"25\">
                                <b>AG:</b> </td>
                                <td align=\"left\" style=\"border-style: none; border-width: medium\" height=\"25\">
                                <p>$row[ag] / $row[Jahrgang]</p>
                                </td>
                            </tr>
                            <tr>
                                <td style=\"border-style: none; border-width: medium\" height=\"32\">
                                <b>altes Kennwort:</b> </td>
                                <td align=\"left\" style=\"border-style: none; border-width: medium\" height=\"32\">
                                <p>
                                <input type=\"password\" name=\"pw_alt\" size=\"30\"></p>
                                </td>
                            </tr>
                            <tr>
                                <td style=\"border-style: none; border-width: medium\" height=\"32\">
                                <b>neues Kennwort:</b> </td>
                                <td align=\"left\" style=\"border-style: none; border-width: medium\" height=\"32\">
                                <p>
                                <input type=\"password\" name=\"pw_neu\" size=\"30\"></p>
                                </td>
                            </tr>
                            <tr>
                                <td style=\"border-style: none; border-width: medium\" height=\"32\">
                                <b>neues Kennwort wiederholen:</b> </td>
                                <td align=\"left\" style=\"border-style: none; border-width: medium\" height=\"32\">
                                <p>
                                <input type=\"password\" name=\"pw_wied\" size=\"30\"></p>
                                </td>
                            </tr>
                            <tr>
                                <td width=\"45%\" style=\"border-style: none; border-width: medium\" height=\"25\">
                                <p>&nbsp;</p>
                                </td>
                                <td width=\"55%\" align=\"left\" style=\"border-style: none; border-width: medium\" height=\"25\">
                                <p>&nbsp;</p>
                                </td>
                            </tr>
                        </table>
                        <input type=\"submit\" value=\"Abschicken\" name=\"B1\" size=\"20\"></form>
                    </td>
                    <td width=\"1%\" background=\"images/box_r.gif\">
                    <img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"images/box_e3.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"images/box_bottom.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e4.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";

break;
case "wechsel":

$db = dbconnect();
$result = $db->query("SELECT pwd FROM stud where uid=\"$uid1\"");
$row = $result->fetch_array();

If ($_POST['pw_alt'] == "" or $_POST['pw_neu'] == "" or $_POST['pw_wied'] == "")
{
echo "
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"styles_pc.css\" type=\"text/css\">
<title>Eingabefehler</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"images/box_e1.gif\">
                    <img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"images/box_top.gif\">
                    <img height=\"10\" src=\"images/blank.gif\" width=\"1\"><br>
                    <span class=\"sh\">Eingabefehler</span><br>
                    <img height=\"5\" src=\"images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e2.gif\">
                    <img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"images/box_l.gif\">
                    <img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <p align=\"center\"><b>Es m&uuml;ssen alle Felder ausgef&uuml;llt werden!</b>
                    </p>
                    <p align=\"center\"><a href=\"Kennwortwechsel.php\">
                    <img border=\"0\" src=\"images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                    </p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </td>
                    <td width=\"1%\" background=\"images/box_r.gif\">
                    <img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"images/box_e3.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e4.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";

} else {
$pwd_alt = md5($_POST['pw_alt']);

if ($pwd_alt != $row[pwd])
{
echo "
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"styles_pc.css\" type=\"text/css\">
<title>Eingabefehler</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"images/box_e1.gif\">
                    <img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"images/box_top.gif\">
                    <img height=\"10\" src=\"images/blank.gif\" width=\"1\"><br>
                    <span class=\"sh\">Eingabefehler</span><br>
                    <img height=\"5\" src=\"images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e2.gif\">
                    <img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"images/box_l.gif\">
                    <img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <p align=\"center\"><b>Ihr altes Kennwort stimmt nicht<br>mit dem aus dem System &uuml;berein!</b>
                    </p>
                    <p align=\"center\"><a href=\"Kennwortwechsel.php\">
                    <img border=\"0\" src=\"images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                    </p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </td>
                    <td width=\"1%\" background=\"images/box_r.gif\">
                    <img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"images/box_e3.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e4.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";

} else {
$pwd_neu = md5($_POST['pw_neu']);
$pwd_wied = md5($_POST['pw_wied']);

if ($pwd_neu != $pwd_wied)
{

echo"
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"styles_pc.css\" type=\"text/css\">
<title>Eingabefehler</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"images/box_e1.gif\">
                    <img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"images/box_top.gif\">
                    <img height=\"10\" src=\"images/blank.gif\" width=\"1\"><br>
                    <span class=\"sh\">Eingabefehler</span><br>
                    <img height=\"5\" src=\"images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e2.gif\">
                    <img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"images/box_l.gif\">
                    <img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <p align=\"center\"><b>Das neue Kennwort stimmt nicht<br>mit der Kennwortwiederholung &uuml;berein!</b>
                    </p>
                    <p align=\"center\"><a href=\"Kennwortwechsel.php\">
                    <img border=\"0\" src=\"images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                    </p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </td>
                    <td width=\"1%\" background=\"images/box_r.gif\">
                    <img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"images/box_e3.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e4.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";

} else {
dbconnect ();
$passwd = md5($_POST['pw_neu']);
//$passwd= mysqli_escape_string($db,$passwd);
$sql = $db->query ("UPDATE stud SET Pwd=\"$passwd\" WHERE uid=\"$uid1\"");

echo "
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<link rel=\"stylesheet\" href=\"styles_pc.css\" type=\"text/css\">
<title>Kennwort ge&auml;ndert</title>
</head>
<body>
<table border=\"0\" style=\"border-collapse: collapse\" width=\"100%\" cellpadding=\"0\" height=\"100%\" id=\"table1\">
    <tr>
        <td>
        <div align=\"center\">
            <table cellspacing=\"0\" cellpadding=\"0\" width=\"550\" border=\"0\">
                <tr>
                    <td width=\"10\" background=\"images/box_e1.gif\">
                    <img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"3%\" background=\"images/box_top.gif\" valign=\"top\"></td>
                    <td width=\"95%\" background=\"images/box_top.gif\">
                    <img height=\"10\" src=\"images/blank.gif\" width=\"1\"><br>
                    <span class=\"sh\">Kennwort ge&auml;ndert</span><br>
                    <img height=\"5\" src=\"images/blank.gif\" width=\"1\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e2.gif\">
                    <img height=\"40\" src=\"images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td width=\"1%\" background=\"images/box_l.gif\">
                    <img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td colspan=\"2\"><br>
                    <p align=\"center\"><b>Das Kennwort wurde aktualisiert!</b>
                    </p>
                    <p align=\"center\"><a href=\"hauptframe.php\">
                    <img border=\"0\" src=\"images/zurueck.gif\" width=\"77\" height=\"22\"></a><br>
                    </p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p></p>
                    <p><br>
                    </p>
                    </td>
                    <td width=\"1%\" background=\"images/box_r.gif\">
                    <img height=\"1\" src=\"images/blank.gif\" width=\"22\"></td>
                </tr>
                <tr>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"1%\" background=\"images/box_e3.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"22\"></td>
                    <td nowrap=\"nowrap\" align=\"left\" width=\"98%\" background=\"images/box_bottom.gif\" colspan=\"2\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"8\"></td>
                    <td nowrap=\"nowrap\" align=\"right\" width=\"1%\" background=\"images/box_e4.gif\">
                    <img height=\"16\" src=\"images/blank.gif\" width=\"22\"> </td>
                </tr>
            </table>
        </div>
        </td>
    </tr>
</table>
</body>
</html>";
                }
    }
}



} // Ende IF von Action Abfrage
?>