<?php
$user_admin=$_COOKIE["user_admin"];
include("kurs/datenbankanbindung.php");     // f&uuml;gt die Datenbankanbindung ein: \php\includes\kurs\datenbankanbindung.php

// Rechte&uuml;berpr&uuml;fung
$db = dbconnect();
if ($user_admin == ""){ require("index.php"); exit;} //Wenn man nicht angemeldet ist, darf man nicht auf die Seite
$result = $db->query("SELECT 1 FROM pros_admin_rechte, pros_admin_rechte_zuord , pros_admin where pros_admin_rechte.pros_admin_rolle = pros_admin_rechte_zuord.pros_admin_rolle AND pros_admin_rechte_zuord.faid = pros_admin.faid AND pros_admin.user = '$user_admin' AND pros_admin_rechte_zuord.pros_admin_rolle = 'a_dozanl'");
$row = $result->fetch_array();
if ($row[0] != 1){ include("kurs/rechte.php"); exit;}
// Rechte&uuml;berpr&uuml;fung ende

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

switch($action){
default:
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>Dozent anlegen</title>
</head>
<body onload=\"if(document.doz_anleg)document.doz_anleg.titel.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\">Dozent anlegen</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=doz"; echo" method=\"POST\" name=\"doz_anleg\">
					  <table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" style=\"border-collapse: collapse; border-width: 0\" bordercolor=\"#111111\" width=\"100%\" id=\"AutoNumber1\" height=\"194\">
						<tr>
						  <td width=\"40%\">
						  <b>Titel/Anrede*:</b>
						  </td>
						  <td width=\"60%\">
						  <input type=\"text\" name=\"titel\" size=\"10\">
						  </td>
						</tr>
						<tr>
						  <td width=\"40%\">
						  <b>Vorname*:</b>
						  </td>
						  <td width=\"60%\">
						  <input type=\"text\" name=\"vorname\" size=\"40\">
						  </td>
						</tr>
						<tr>
						  <td width=\"40%\">
						  <b>Nachname*:</b>
						  </td>
						  <td width=\"60%\">
						  <input type=\"text\" name=\"nachname\" size=\"40\">
						  </td>
						</tr>
						<tr>
						  <td width=\"40%\">
						  <b>Stra&szlig;e:</b>
						  </td>
						  <td width=\"60%\">
						  <input type=\"text\" name=\"doz_strasse\" size=\"40\">
						  </td>
						</tr>
							<tr>
						  <td width=\"40%\">
						  <b>PLZ:</b>
						  </td>
						  <td width=\"60%\">
						  <input type=\"text\" name=\"doz_plz\" size=\"5\">
						  </td>
						</tr>
						  <tr>
						  <td width=\"40%\">
						  <b>Ort:</b>
						  </td>
						  <td width=\"60%\">
						  <input type=\"text\" name=\"doz_ort\" size=\"40\">
						  </td>
						<tr>
						</tr>
						  <tr>
						  <td width=\"40%\">
						  <b>Tel.:</b>
						  </td>
						  <td width=\"60%\">
						  <input type=\"text\" name=\"doz_tel\" size=\"40\">
						  </td>
						<tr>
						  <td width=\"40%\">
						  <b>Benutzerkennung:</b><br><font size='1'>(keine Umlaute)</font>
						  </td>
						  <td width=\"60%\">
						  <input type=\"text\" name=\"doz_uid\" size=\"40\">
						  </td>
						</tr>
						  <tr>
							<td>
							<b>E-Mail Adresse*:</b>
							</td>
							<td>
							<input type=\"text\" name=\"doz_mail\" size=\"40\">
							
							</td>
						  </tr>
						<tr>
						  <td width=\"40%\">
						  &nbsp;
						  </td>
						  <td width=\"60%\">
						  &nbsp;
						  </td>
						</tr
						<tr>
						  <td width=\"40%\">
						  * = Pflichtfelder
						  </td>
						  <td width=\"60%\">
						  &nbsp;
						  </td>
						</tr>
					  </table>
					  <br>
					  <br>
						<input type=\"submit\" value=\"Abschicken\" name=\"B1\">
						<input type=\"reset\" value=\"Zur&uuml;cksetzen\" name=\"B2\">
					</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 "doz":
$db = dbconnect();

if ($_POST[titel] == "" or $_POST[vorname] == "" or $_POST[nachname] == "" or $_POST[doz_mail] == ""){    // Fehler, falls Pflichtfelder unausgef&uuml;llt
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 mindestens die Pflichtfelder ausgef&uuml;llt werden!</b>
                    </p>
                    <p align=\"center\"><a href=\"javascript:history.back()\">
                    <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>";
exit;
}

$doz_uid = strtolower($_POST[doz_uid]);
if ($doz_uid != ""){
$result = $db->query("SELECT lower(doz_uid) doz_uid FROM doz where doz_uid='$doz_uid'");
$row = $result->fetch_array();
     if ($doz_uid == $row[doz_uid] ){

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>Doppelerfassung</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\">Doppelerfassung</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>Die Benutzerkennung ist im System bereits vorhanden!</b>
                    </p>
                    <p align=\"center\"><a href=\"javascript:history.back()\">
                    <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>";

exit;
} // Ende If zwei benutzerkennungen

} // Ende If $_POST['doz_uid']=""

$doz_mail = $_POST['doz_mail'];
$passwd = md5($doz_uid);
//$passwd= mysqli_escape_string($db,$passwd);

$sql = $db->query("INSERT INTO doz ( doz_nr
                                    , doz_uid
                                    , doz_name
                                    , doz_vorname
                                    , doz_titel
                                    , doz_mail
                                    , doz_strasse
                                    , doz_plz
                                    , doz_ort
                                    , doz_tel
                                    , doz_pwd
                                    )
                    VALUES
                                    ( ''
                                    , \"$doz_uid\"
                                    , \"". $_POST['nachname']."\"
                                    , \"". $_POST['vorname']."\"
                                    , \"". $_POST['titel']."\"
                                    , \"$doz_mail\"
                                    , \"". $_POST['doz_strasse']."\"
                                    , \"". $_POST['doz_plz']."\"
                                    , \"". $_POST['doz_ort']."\"
                                    , \"". $_POST['doz_tel']."\"
                                    , \"$passwd\"
                                    )
                  ");



if($sql)
{

// Nachricht an Dozent &uuml;ber Registrierung und Passwort: Hinzugef&uuml;gt 19.09.2006

  $empfaenger = "$_POST[doz_mail]";
  $betreff = "Registrierung Dozent im Kurssystem";
  $text = "
    <html>
    <head>
    <title>Registrierung</title>
    </head>
    <body>
    <font face='Arial' size='2'>
    Guten Tag $_POST[titel] $_POST[vorname] $_POST[nachname]!<br><br>
    Sie wurden als Dozent im Kurssystem der Hochschule Ludwigsburg registriert.<br>
    Nachfolgend finden Sie Ihre registrierten Daten:
    <br>
    <br>
    <table>
    <tr>
       <td valign='top'>
         <font face='Arial' size='2'>
           Titel:
         </font>
       </td>
       <td valign='top'>
         <font face='Arial' size='2'>
           <b>$_POST[titel]</b>
         </font>
       </td>
    </tr>
    <tr>
       <td valign='top'>
         <font face='Arial' size='2'>
           Vorname:
         </font>
       </td>
       <td valign='top'>
         <font face='Arial' size='2'>
           <b>$_POST[vorname]</b>
         </font>
       </td>
    </tr>
    <tr>
       <td valign='top'>
         <font face='Arial' size='2'>
           Nachname:
         </font>
       </td>
       <td valign='top'>
         <font face='Arial' size='2'>
           <b>$_POST[nachname]</b>
         </font>
       </td>
    </tr>
    <tr>
       <td valign='top'>
         <font face='Arial' size='2'>
           Stra&szlig;e:
         </font>
       </td>
       <td valign='top'>
         <font face='Arial' size='2'>
           <b>$_POST[doz_strasse]</b>
         </font>
       </td>
    </tr>
    <tr>
       <td valign='top'>
         <font face='Arial' size='2'>
           PLZ / Ort:
         </font>
       </td>
       <td valign='top'>
         <font face='Arial' size='2'>
           <b>$_POST[doz_plz] $_POST[doz_ort]</b>
         </font>
       </td>
    </tr>
    <tr>
       <td valign='top'>
         <font face='Arial' size='2'>
           &nbsp;
         </font>
       </td>
       <td valign='top'>
         <font face='Arial' size='2'>
           &nbsp;
         </font>
       </td>
    </tr>
    <tr>
       <td valign='top'>
         <font face='Arial' size='2'>
           Benutzerkennung:
         </font>
       </td>
       <td valign='top'>
         <font face='Arial' size='2'>
           <b>$doz_uid</b>
         </font>
       </td>
    </tr>
    <tr>
       <td valign='top'>
         <font face='Arial' size='2'>
           Passwort:
         </font>
       </td>
       <td valign='top'>
         <font face='Arial' size='2'>
           <b>$doz_uid</b>
         </font>
       </td>
    </tr>
    </table>
    <br>
    Bitte beachten Sie, dass zwischen Gro&szlig;- und<br>
    Kleinschreibung unterschieden wird.
    <p>
    &Auml;ndern Sie bitte zu Ihrer eigenen Sicherheit das<br>
    Passwort nach dem ersten Login.
    <p>
    Diese Mail wurde automatisch generiert!<br>
    Antworten Sie daher nicht auf diese Mail<br>
    <br>
    Vielen Dank
    </body>
    </html>";
    
    
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=utf-8\r\n";
    
    $return = @mail($empfaenger, $betreff, $text,  $headers);

// ENDE Nachricht an Dozent &uuml;ber Registrierung und Passwort

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>Einbindung</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\">Einbindung</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>Der Dozent wurde eingebunden! Das Passwort ist gleich der Benutzerkennung</b>
                    </p>
                    <p align=\"center\"><a href=\"doz_anleg.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{
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>Einbindung fehlgeschlagen</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\">Einbindung fehlgeschlagen</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>Der Dozent wurde nicht eingebunden!<br>Es trat ein interner Fehler auf!</b>
                    </p>
                    <p align=\"center\"><a href=\"doz_anleg.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>";
}

}
?>
